Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

#define PRIME_TABLE_SIZE 1000000
#define P_MAX 100
#define UNKNOWN -1

char is_prime[PRIME_TABLE_SIZE];
int next_prime[PRIME_TABLE_SIZE];

int comp_ints(const void* a, const void*b) { return *(int*)a - *(int*)b; }

void prime_table_init()
{
    int i, j;

    /* sieve */

    is_prime[0] = is_prime[1] = 0;
    for(i = 2; i < PRIME_TABLE_SIZE; i++)
        is_prime[i] = 1;

    i = 2;
    while(i < PRIME_TABLE_SIZE)
    {
        for(j = i * 2; j < PRIME_TABLE_SIZE; j += i)
            is_prime[j] = 0;

        /* search for the next prime */
        for(i++; !is_prime[i] && PRIME_TABLE_SIZE < i; i++);
    }

    for(i = UNKNOWN, j = PRIME_TABLE_SIZE - 1; j >= 0; j--)
    {
        next_prime[j] = i;
        if(is_prime[j]) i = j;
    }
}

int main(void)
{
    int n, p, i, j, k, primes[P_MAX], sums[P_MAX * P_MAX];

    prime_table_init();

    while(scanf("%d %d", &n, &p), n != -1)
    {
        for(i = 0, j = next_prime[n]; i < p; i++, j = next_prime[j])
            primes[i] = j;
        for(i = k = 0; i < p; i++)
            for(j = 0; j <= i; j++, k++)
                sums[k] = primes[i] + primes[j];
        qsort(sums, k, sizeof(int), comp_ints);
        printf("%d\n", sums[p - 1]);
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	is_prime
	.bss
	.align 32
	.type	is_prime, @object
	.size	is_prime, 1000000
is_prime:
	.zero	1000000
	.globl	next_prime
	.align 32
	.type	next_prime, @object
	.size	next_prime, 4000000
next_prime:
	.zero	4000000
	.text
	.globl	comp_ints
	.type	comp_ints, @function
comp_ints:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	comp_ints, .-comp_ints
	.globl	prime_table_init
	.type	prime_table_init, @function
prime_table_init:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movb	$0, 1+is_prime(%rip)
	movzbl	1+is_prime(%rip), %eax
	movb	%al, is_prime(%rip)
	movl	$2, -8(%rbp)
	jmp	.L4
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movb	$1, (%rax,%rdx)
	addl	$1, -8(%rbp)
.L4:
	cmpl	$999999, -8(%rbp)
	jle	.L5
	movl	$2, -8(%rbp)
	jmp	.L6
.L11:
	movl	-8(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -4(%rbp)
	jmp	.L7
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
.L7:
	cmpl	$999999, -4(%rbp)
	jle	.L8
	addl	$1, -8(%rbp)
	jmp	.L9
.L10:
	addl	$1, -8(%rbp)
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	jne	.L6
	cmpl	$1000000, -8(%rbp)
	jg	.L10
.L6:
	cmpl	$999999, -8(%rbp)
	jle	.L11
	movl	$-1, -8(%rbp)
	movl	$999999, -4(%rbp)
	jmp	.L12
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	next_prime(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L13
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L13:
	subl	$1, -4(%rbp)
.L12:
	cmpl	$0, -4(%rbp)
	jns	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	prime_table_init, .-prime_table_init
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3584, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	prime_table_init
	jmp	.L16
.L23:
	movl	$0, -40428(%rbp)
	movl	-40436(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_prime(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40424(%rbp)
	jmp	.L17
.L18:
	movl	-40428(%rbp), %eax
	cltq
	movl	-40424(%rbp), %edx
	movl	%edx, -40416(%rbp,%rax,4)
	addl	$1, -40428(%rbp)
	movl	-40424(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_prime(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40424(%rbp)
.L17:
	movl	-40432(%rbp), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L18
	movl	$0, -40420(%rbp)
	movl	-40420(%rbp), %eax
	movl	%eax, -40428(%rbp)
	jmp	.L19
.L22:
	movl	$0, -40424(%rbp)
	jmp	.L20
.L21:
	movl	-40428(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %edx
	movl	-40424(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-40420(%rbp), %eax
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40424(%rbp)
	addl	$1, -40420(%rbp)
.L20:
	movl	-40424(%rbp), %eax
	cmpl	-40428(%rbp), %eax
	jle	.L21
	addl	$1, -40428(%rbp)
.L19:
	movl	-40432(%rbp), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L22
	movl	-40420(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-40016(%rbp), %rax
	leaq	comp_ints(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-40432(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	leaq	-40432(%rbp), %rdx
	leaq	-40436(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40436(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L23
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	comp_ints
	.type	comp_ints, @function
comp_ints:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	comp_ints, .-comp_ints
	.p2align 4
	.globl	prime_table_init
	.type	prime_table_init, @function
prime_table_init:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	movl	$999998, %edx
	movl	$1, %esi
	leaq	2+is_prime(%rip), %rdi
	movw	%ax, is_prime(%rip)
	call	memset@PLT
	movl	$2, %edx
	movl	$4, %esi
	leaq	is_prime(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	cmpq	$999999, %rsi
	ja	.L4
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L5:
	movb	$0, (%rcx,%rax)
	addq	%rdx, %rax
	cmpl	$999999, %eax
	jle	.L5
.L4:
	addq	$1, %rdx
	addq	$2, %rsi
	cmpq	$1000000, %rdx
	jne	.L6
	movl	$999999, %eax
	movl	$-1, %edx
	leaq	next_prime(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L8:
	cmpb	$0, (%rcx,%rax)
	movl	%edx, (%rsi,%rax,4)
	cmovne	%eax, %edx
	subq	$1, %rax
	jnb	.L8
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	prime_table_init, .-prime_table_init
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3576, %rsp
	.cfi_def_cfa_offset 40496
	leaq	next_prime(%rip), %r13
	movq	%fs:40, %rax
	movq	%rax, 40424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	leaq	8(%rsp), %rbp
	call	prime_table_init
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r12, %rdx
	movq	%rbp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rax
	cmpl	$-1, %eax
	je	.L29
	movl	12(%rsp), %r15d
	movslq	0(%r13,%rax,4), %rax
	testl	%r15d, %r15d
	jle	.L23
	leaq	16(%rsp), %rcx
	leal	-1(%r15), %esi
	movq	%rcx, %rdx
	leaq	20(%rsp,%rsi,4), %rsi
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%eax, (%rdx)
	addq	$4, %rdx
	movslq	0(%r13,%rax,4), %rax
	cmpq	%rsi, %rdx
	jne	.L16
	movl	$1, %r9d
	xorl	%r11d, %r11d
	xorl	%esi, %esi
	leaq	416(%rsp), %r10
	.p2align 4,,10
	.p2align 3
.L20:
	movl	-4(%rcx,%r9,4), %r8d
	movl	%r9d, %r14d
	cmpl	$2, %esi
	jle	.L24
	movl	%r9d, %edx
	movslq	%r11d, %rax
	movd	%r8d, %xmm2
	shrl	$2, %edx
	leaq	(%r10,%rax,4), %rdi
	pshufd	$0, %xmm2, %xmm1
	xorl	%eax, %eax
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L18:
	movdqa	(%rcx,%rax), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%rdi,%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L18
	movl	%r14d, %eax
	andl	$-4, %eax
	leal	(%r11,%rax), %edx
	cmpl	%r14d, %eax
	je	.L19
.L17:
	movslq	%eax, %r14
	movslq	%edx, %rdi
	movl	16(%rsp,%r14,4), %ebx
	leal	1(%rdx), %r14d
	addl	%r8d, %ebx
	movl	%ebx, 416(%rsp,%rdi,4)
	leal	1(%rax), %edi
	cmpl	%esi, %edi
	jg	.L19
	movslq	%edi, %rdi
	movslq	%r14d, %r14
	addl	$2, %eax
	addl	$2, %edx
	movl	16(%rsp,%rdi,4), %ebx
	addl	%r8d, %ebx
	movl	%ebx, 416(%rsp,%r14,4)
	cmpl	%eax, %esi
	jl	.L19
	cltq
	movslq	%edx, %rdx
	addl	16(%rsp,%rax,4), %r8d
	movl	%r8d, 416(%rsp,%rdx,4)
.L19:
	leal	1(%rsi,%r11), %r11d
	addl	$1, %esi
	addq	$1, %r9
	cmpl	%esi, %r15d
	jne	.L20
	movslq	%r11d, %rsi
.L15:
	movq	%r10, %rdi
	leaq	comp_ints(%rip), %rcx
	movl	$4, %edx
	call	qsort@PLT
	movl	12(%rsp), %eax
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	subl	$1, %eax
	cltq
	movl	416(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L24:
	movl	%r11d, %edx
	xorl	%eax, %eax
	jmp	.L17
.L29:
	movq	40424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$40440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L23:
	.cfi_restore_state
	xorl	%esi, %esi
	leaq	416(%rsp), %r10
	jmp	.L15
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	next_prime
	.bss
	.align 32
	.type	next_prime, @object
	.size	next_prime, 4000000
next_prime:
	.zero	4000000
	.globl	is_prime
	.align 32
	.type	is_prime, @object
	.size	is_prime, 1000000
is_prime:
	.zero	1000000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	comp_ints
	.type	comp_ints, @function
comp_ints:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	comp_ints, .-comp_ints
	.p2align 4
	.globl	prime_table_init
	.type	prime_table_init, @function
prime_table_init:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	movl	$999998, %edx
	movl	$1, %esi
	leaq	2+is_prime(%rip), %rdi
	movw	%ax, is_prime(%rip)
	call	memset@PLT
	movl	$2, %edx
	movl	$4, %esi
	leaq	is_prime(%rip), %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	cmpq	$999999, %rsi
	ja	.L4
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L5:
	movb	$0, (%rcx,%rax)
	addq	%rdx, %rax
	cmpl	$999999, %eax
	jle	.L5
.L4:
	addq	$1, %rdx
	addq	$2, %rsi
	cmpq	$1000000, %rdx
	jne	.L6
	movl	$999999, %eax
	movl	$-1, %edx
	leaq	next_prime(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L8:
	cmpb	$0, (%rcx,%rax)
	movl	%edx, (%rsi,%rax,4)
	cmovne	%eax, %edx
	subq	$1, %rax
	jnb	.L8
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	prime_table_init, .-prime_table_init
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d %d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3576, %rsp
	.cfi_def_cfa_offset 40496
	leaq	next_prime(%rip), %r13
	movq	%fs:40, %rax
	movq	%rax, 40424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r12
	leaq	8(%rsp), %rbp
	call	prime_table_init
	.p2align 4,,10
	.p2align 3
.L14:
	movq	%r12, %rdx
	movq	%rbp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	8(%rsp), %rax
	cmpl	$-1, %eax
	je	.L29
	movl	12(%rsp), %r15d
	movslq	0(%r13,%rax,4), %rax
	testl	%r15d, %r15d
	jle	.L23
	leaq	16(%rsp), %rcx
	leal	-1(%r15), %esi
	movq	%rcx, %rdx
	leaq	20(%rsp,%rsi,4), %rsi
	.p2align 4,,10
	.p2align 3
.L16:
	movl	%eax, (%rdx)
	addq	$4, %rdx
	movslq	0(%r13,%rax,4), %rax
	cmpq	%rsi, %rdx
	jne	.L16
	movl	$1, %r9d
	xorl	%r11d, %r11d
	xorl	%esi, %esi
	leaq	416(%rsp), %r10
	.p2align 4,,10
	.p2align 3
.L20:
	movl	-4(%rcx,%r9,4), %r8d
	movl	%r9d, %r14d
	cmpl	$2, %esi
	jle	.L24
	movl	%r9d, %edx
	movslq	%r11d, %rax
	movd	%r8d, %xmm2
	shrl	$2, %edx
	leaq	(%r10,%rax,4), %rdi
	pshufd	$0, %xmm2, %xmm1
	xorl	%eax, %eax
	salq	$4, %rdx
	.p2align 4,,10
	.p2align 3
.L18:
	movdqa	(%rcx,%rax), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%rdi,%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L18
	movl	%r14d, %eax
	andl	$-4, %eax
	leal	(%r11,%rax), %edx
	cmpl	%r14d, %eax
	je	.L19
.L17:
	movslq	%eax, %r14
	movslq	%edx, %rdi
	movl	16(%rsp,%r14,4), %ebx
	leal	1(%rdx), %r14d
	addl	%r8d, %ebx
	movl	%ebx, 416(%rsp,%rdi,4)
	leal	1(%rax), %edi
	cmpl	%esi, %edi
	jg	.L19
	movslq	%edi, %rdi
	movslq	%r14d, %r14
	addl	$2, %eax
	addl	$2, %edx
	movl	16(%rsp,%rdi,4), %ebx
	addl	%r8d, %ebx
	movl	%ebx, 416(%rsp,%r14,4)
	cmpl	%eax, %esi
	jl	.L19
	cltq
	movslq	%edx, %rdx
	addl	16(%rsp,%rax,4), %r8d
	movl	%r8d, 416(%rsp,%rdx,4)
.L19:
	leal	1(%rsi,%r11), %r11d
	addl	$1, %esi
	addq	$1, %r9
	cmpl	%esi, %r15d
	jne	.L20
	movslq	%r11d, %rsi
.L15:
	movq	%r10, %rdi
	leaq	comp_ints(%rip), %rcx
	movl	$4, %edx
	call	qsort@PLT
	movl	12(%rsp), %eax
	movl	$1, %edi
	leaq	.LC0(%rip), %rsi
	subl	$1, %eax
	cltq
	movl	416(%rsp,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L24:
	movl	%r11d, %edx
	xorl	%eax, %eax
	jmp	.L17
.L29:
	movq	40424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$40440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L23:
	.cfi_restore_state
	xorl	%esi, %esi
	leaq	416(%rsp), %r10
	jmp	.L15
.L30:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	next_prime
	.bss
	.align 32
	.type	next_prime, @object
	.size	next_prime, 4000000
next_prime:
	.zero	4000000
	.globl	is_prime
	.align 32
	.type	is_prime, @object
	.size	is_prime, 1000000
is_prime:
	.zero	1000000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>

#define PRIME_TABLE_SIZE 1000000
#define P_MAX 100
#define UNKNOWN -1

char is_prime[PRIME_TABLE_SIZE];
int next_prime[PRIME_TABLE_SIZE];

int comp_ints(const void* a, const void*b) { return *(int*)a - *(int*)b; }

void prime_table_init()
{
    int i, j;

    /* sieve */

    is_prime[0] = is_prime[1] = 0;
    for(i = 2; i < PRIME_TABLE_SIZE; i++)
        is_prime[i] = 1;

    i = 2;
    while(i < PRIME_TABLE_SIZE)
    {
        for(j = i * 2; j < PRIME_TABLE_SIZE; j += i)
            is_prime[j] = 0;

        /* search for the next prime */
        for(i++; !is_prime[i] && PRIME_TABLE_SIZE < i; i++);
    }

    for(i = UNKNOWN, j = PRIME_TABLE_SIZE - 1; j >= 0; j--)
    {
        next_prime[j] = i;
        if(is_prime[j]) i = j;
    }
}

int main(void)
{
    int n, p, i, j, k, primes[P_MAX], sums[P_MAX * P_MAX];

    prime_table_init();

    while(scanf("%d %d", &n, &p), n != -1)
    {
        for(i = 0, j = next_prime[n]; i < p; i++, j = next_prime[j])
            primes[i] = j;
        for(i = k = 0; i < p; i++)
            for(j = 0; j <= i; j++, k++)
                sums[k] = primes[i] + primes[j];
        qsort(sums, k, sizeof(int), comp_ints);
        printf("%d\n", sums[p - 1]);
    }

    return 0;
}
0 55
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 5
10 6
11 1
11 2
11 3
100001 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 5
10 1
11 1
11 2
11 3
100001 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 5
19 6
11 1
11 2
11 3
100000 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 5
10 1
10 1
11 2
11 3
100001 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 5
10 1
10 1
18 2
11 3
100001 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 1
10 1
10 1
18 2
11 3
100001 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 2
19 3
10 4
10 1
10 1
10 1
18 2
11 3
100001 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
10 1
10 3
10 4
10 5
10 6
11 1
11 2
11 3
100000 100
-1 -1
 0 55
0 1
0 2
0 3
10 1
13 2
10 3
10 4
10 5
10 6
11 1
11 2
11 3
100001 100
-1 -1
 0 19
0 1
0 2
0 3
10 1
10 2
10 3
10 4
10 5
19 6
11 1
11 2
11 3
100000 100
-1 -1

42
4
5
6
22
24
26
28
30
30
26
30
32
200274
 42
4
5
6
22
24
26
28
30
22
26
30
32
200274
 42
4
5
6
22
24
26
28
30
60
26
30
32
200274
 42
4
5
6
22
24
26
28
30
22
22
30
32
200274
 42
4
5
6
22
24
26
28
30
22
22
42
32
200274
 42
4
5
6
22
24
26
28
22
22
22
42
32
200274
 42
4
5
6
22
24
54
28
22
22
22
42
32
200274
 42
4
5
6
22
22
26
28
30
30
26
30
32
200274
 42
4
5
6
22
36
26
28
30
30
26
30
32
200274
 20
4
5
6
22
24
26
28
30
60
26
30
32
200274

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>

#define PRIME_TABLE_SIZE 1000000
#define P_MAX 100
#define UNKNOWN -1

char is_prime[PRIME_TABLE_SIZE];
int next_prime[PRIME_TABLE_SIZE];

int comp_ints(const void* a, const void*b) { return *(int*)a - *(int*)b; }

void prime_table_init()
{
    int i, j;

    /* sieve */

    is_prime[0] = is_prime[1] = 0;
    for(i = 2; i < PRIME_TABLE_SIZE; i++)
        is_prime[i] = 1;

    i = 2;
    while(i < PRIME_TABLE_SIZE)
    {
        for(j = i * 2; j < PRIME_TABLE_SIZE; j += i)
            is_prime[j] = 0;

        /* search for the next prime */
        for(i++; !is_prime[i] && PRIME_TABLE_SIZE < i; i++);
    }

    for(i = UNKNOWN, j = PRIME_TABLE_SIZE - 1; j >= 0; j--)
    {
        next_prime[j] = i;
        if(is_prime[j]) i = j;
    }
}

int main(void)
{
    int n, p, i, j, k, primes[P_MAX], sums[P_MAX * P_MAX];

    prime_table_init();

    while(scanf("%d %d", &n, &p), n != -1)
    {
        for(i = 0, j = next_prime[n]; i < p; i++, j = next_prime[j])
            primes[i] = j;
        for(i = k = 0; i < p; i++)
            for(j = 0; j <= i; j++, k++)
                sums[k] = primes[i] + primes[j];
        qsort(sums, k, sizeof(int), comp_ints);
        printf("%d\n", sums[p - 1]);
    }

    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	is_prime
	.bss
	.align 32
	.type	is_prime, @object
	.size	is_prime, 1000000
is_prime:
	.zero	1000000
	.globl	next_prime
	.align 32
	.type	next_prime, @object
	.size	next_prime, 4000000
next_prime:
	.zero	4000000
	.text
	.globl	comp_ints
	.type	comp_ints, @function
comp_ints:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	comp_ints, .-comp_ints
	.globl	prime_table_init
	.type	prime_table_init, @function
prime_table_init:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movb	$0, 1+is_prime(%rip)
	movzbl	1+is_prime(%rip), %eax
	movb	%al, is_prime(%rip)
	movl	$2, -8(%rbp)
	jmp	.L4
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movb	$1, (%rax,%rdx)
	addl	$1, -8(%rbp)
.L4:
	cmpl	$999999, -8(%rbp)
	jle	.L5
	movl	$2, -8(%rbp)
	jmp	.L6
.L11:
	movl	-8(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -4(%rbp)
	jmp	.L7
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
.L7:
	cmpl	$999999, -4(%rbp)
	jle	.L8
	addl	$1, -8(%rbp)
	jmp	.L9
.L10:
	addl	$1, -8(%rbp)
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	jne	.L6
	cmpl	$1000000, -8(%rbp)
	jg	.L10
.L6:
	cmpl	$999999, -8(%rbp)
	jle	.L11
	movl	$-1, -8(%rbp)
	movl	$999999, -4(%rbp)
	jmp	.L12
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	next_prime(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L13
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L13:
	subl	$1, -4(%rbp)
.L12:
	cmpl	$0, -4(%rbp)
	jns	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	prime_table_init, .-prime_table_init
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3584, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	prime_table_init
	jmp	.L16
.L23:
	movl	$0, -40428(%rbp)
	movl	-40436(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_prime(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40424(%rbp)
	jmp	.L17
.L18:
	movl	-40428(%rbp), %eax
	cltq
	movl	-40424(%rbp), %edx
	movl	%edx, -40416(%rbp,%rax,4)
	addl	$1, -40428(%rbp)
	movl	-40424(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_prime(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40424(%rbp)
.L17:
	movl	-40432(%rbp), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L18
	movl	$0, -40420(%rbp)
	movl	-40420(%rbp), %eax
	movl	%eax, -40428(%rbp)
	jmp	.L19
.L22:
	movl	$0, -40424(%rbp)
	jmp	.L20
.L21:
	movl	-40428(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %edx
	movl	-40424(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-40420(%rbp), %eax
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40424(%rbp)
	addl	$1, -40420(%rbp)
.L20:
	movl	-40424(%rbp), %eax
	cmpl	-40428(%rbp), %eax
	jle	.L21
	addl	$1, -40428(%rbp)
.L19:
	movl	-40432(%rbp), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L22
	movl	-40420(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-40016(%rbp), %rax
	leaq	comp_ints(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-40432(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	leaq	-40432(%rbp), %rdx
	leaq	-40436(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40436(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L23
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	is_prime
	.bss
	.align 32
	.type	is_prime, @object
	.size	is_prime, 1000000
is_prime:
	.zero	1000000
	.globl	next_prime
	.align 32
	.type	next_prime, @object
	.size	next_prime, 4000000
next_prime:
	.zero	4000000
	.text
	.globl	comp_ints
	.type	comp_ints, @function
comp_ints:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	comp_ints, .-comp_ints
	.globl	prime_table_init
	.type	prime_table_init, @function
prime_table_init:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movb	$0, 1+is_prime(%rip)
	movzbl	1+is_prime(%rip), %eax
	movb	%al, is_prime(%rip)
	movl	$2, -8(%rbp)
	jmp	.L4
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movb	$1, (%rax,%rdx)
	addl	$1, -8(%rbp)
.L4:
	cmpl	$999999, -8(%rbp)
	jle	.L5
	movl	$2, -8(%rbp)
	jmp	.L6
.L11:
	movl	-8(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -4(%rbp)
	jmp	.L7
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-8(%rbp), %eax
	addl	%eax, -4(%rbp)
.L7:
	cmpl	$999999, -4(%rbp)
	jle	.L8
	addl	$1, -8(%rbp)
	jmp	.L9
.L10:
	addl	$1, -8(%rbp)
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	jne	.L6
	cmpl	$1000000, -8(%rbp)
	jg	.L10
.L6:
	cmpl	$999999, -8(%rbp)
	jle	.L11
	movl	$-1, -8(%rbp)
	movl	$999999, -4(%rbp)
	jmp	.L12
.L14:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	next_prime(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	is_prime(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L13
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L13:
	subl	$1, -4(%rbp)
.L12:
	cmpl	$0, -4(%rbp)
	jns	.L14
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	prime_table_init, .-prime_table_init
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d %d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3584, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	prime_table_init
	jmp	.L16
.L23:
	movl	$0, -40428(%rbp)
	movl	-40436(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_prime(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40424(%rbp)
	jmp	.L17
.L18:
	movl	-40428(%rbp), %eax
	cltq
	movl	-40424(%rbp), %edx
	movl	%edx, -40416(%rbp,%rax,4)
	addl	$1, -40428(%rbp)
	movl	-40424(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	next_prime(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40424(%rbp)
.L17:
	movl	-40432(%rbp), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L18
	movl	$0, -40420(%rbp)
	movl	-40420(%rbp), %eax
	movl	%eax, -40428(%rbp)
	jmp	.L19
.L22:
	movl	$0, -40424(%rbp)
	jmp	.L20
.L21:
	movl	-40428(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %edx
	movl	-40424(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-40420(%rbp), %eax
	cltq
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40424(%rbp)
	addl	$1, -40420(%rbp)
.L20:
	movl	-40424(%rbp), %eax
	cmpl	-40428(%rbp), %eax
	jle	.L21
	addl	$1, -40428(%rbp)
.L19:
	movl	-40432(%rbp), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L22
	movl	-40420(%rbp), %eax
	movslq	%eax, %rsi
	leaq	-40016(%rbp), %rax
	leaq	comp_ints(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rdi
	call	qsort@PLT
	movl	-40432(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-40016(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L16:
	leaq	-40432(%rbp), %rdx
	leaq	-40436(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40436(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L23
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
