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>

int main(void)
{
    static char prime[1000002];
    int i, j;
    int n, ans;
    
    for (i = 1; i <= 1000000; i += 2){
        prime[i] = 1;
    }
    
    prime[1] = 0;
    prime[2] = 1;
    
    for (i = 1; i <= 1000; i += 2){
        if (prime[i] == 1){
            for (j = 3; i * j <= 1000000; j += 2){
                prime[i * j] = 0;
            }
        }
    }
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        ans = 0;
        for (i = 2; i <= n / 2; i++){
            if (prime[i] && prime[n - i]){
                ans++;
            }
        }
        
        printf("%d\n", ans);
    }
    return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, -20(%rbp)
	jmp	.L2
.L3:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movb	$1, (%rax,%rdx)
	addl	$2, -20(%rbp)
.L2:
	cmpl	$1000000, -20(%rbp)
	jle	.L3
	movb	$0, 1+prime.0(%rip)
	movb	$1, 2+prime.0(%rip)
	movl	$1, -20(%rbp)
	jmp	.L4
.L8:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$1, %al
	jne	.L5
	movl	$3, -16(%rbp)
	jmp	.L6
.L7:
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movb	$0, (%rax,%rdx)
	addl	$2, -16(%rbp)
.L6:
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	cmpl	$1000000, %eax
	jle	.L7
.L5:
	addl	$2, -20(%rbp)
.L4:
	cmpl	$1000, -20(%rbp)
	jle	.L8
.L14:
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L18
	movl	$0, -12(%rbp)
	movl	$2, -20(%rbp)
	jmp	.L11
.L13:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L12
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L12
	addl	$1, -12(%rbp)
.L12:
	addl	$1, -20(%rbp)
.L11:
	movl	-24(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jle	.L13
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.local	prime.0
	.comm	prime.0,1000002,32
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	leaq	1+prime.0(%rip), %rax
	leaq	1000000(%rax), %rdx
	.p2align 4,,10
	.p2align 3
.L2:
	movb	$1, (%rax)
	addq	$2, %rax
	cmpq	%rdx, %rax
	jne	.L2
	movl	$256, %eax
	movl	$9, %ecx
	movl	$3, %edx
	movw	%ax, 1+prime.0(%rip)
	leaq	prime.0(%rip), %rbx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$2, %rdx
	addq	$6, %rcx
	cmpq	$1001, %rdx
	je	.L19
.L5:
	cmpb	$1, (%rbx,%rdx)
	jne	.L3
	leaq	(%rdx,%rdx), %rsi
	movq	%rcx, %rax
	.p2align 4,,10
	.p2align 3
.L4:
	movb	$0, (%rbx,%rax)
	addq	%rsi, %rax
	cmpl	$1000000, %eax
	jle	.L4
	jmp	.L3
.L19:
	leaq	4(%rsp), %r12
	leaq	.LC0(%rip), %rbp
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %esi
	testl	%esi, %esi
	je	.L6
	movl	%esi, %ecx
	shrl	$31, %ecx
	addl	%esi, %ecx
	sarl	%ecx
	cmpl	$3, %esi
	jle	.L12
	movl	$2, %eax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$0, (%rbx,%rax)
	je	.L8
	movl	%esi, %edx
	subl	%eax, %edx
	movslq	%edx, %rdx
	cmpb	$1, (%rbx,%rdx)
	sbbl	$-1, %r8d
.L8:
	addq	$1, %rax
	cmpl	%eax, %ecx
	jge	.L9
.L7:
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
.L6:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L12:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L7
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.local	prime.0
	.comm	prime.0,1000002,32
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	leaq	1+prime.0(%rip), %rax
	leaq	1000000(%rax), %rdx
	.p2align 4,,10
	.p2align 3
.L2:
	movb	$1, (%rax)
	addq	$2, %rax
	cmpq	%rdx, %rax
	jne	.L2
	movl	$256, %eax
	movl	$9, %ecx
	movl	$3, %edx
	movw	%ax, 1+prime.0(%rip)
	leaq	prime.0(%rip), %rbx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$2, %rdx
	addq	$6, %rcx
	cmpq	$1001, %rdx
	je	.L19
.L5:
	cmpb	$1, (%rbx,%rdx)
	jne	.L3
	leaq	(%rdx,%rdx), %rsi
	movq	%rcx, %rax
	.p2align 4,,10
	.p2align 3
.L4:
	movb	$0, (%rbx,%rax)
	addq	%rsi, %rax
	cmpl	$1000000, %eax
	jle	.L4
	jmp	.L3
.L19:
	leaq	4(%rsp), %r12
	leaq	.LC0(%rip), %rbp
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %esi
	testl	%esi, %esi
	je	.L6
	movl	%esi, %ecx
	shrl	$31, %ecx
	addl	%esi, %ecx
	sarl	%ecx
	cmpl	$3, %esi
	jle	.L12
	movl	$2, %eax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L9:
	cmpb	$0, (%rbx,%rax)
	je	.L8
	movl	%esi, %edx
	subl	%eax, %edx
	movslq	%edx, %rdx
	cmpb	$1, (%rbx,%rdx)
	sbbl	$-1, %r8d
.L8:
	addq	$1, %rax
	cmpl	%eax, %ecx
	jge	.L9
.L7:
	movl	%r8d, %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
.L6:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L12:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L7
.L20:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.local	prime.0
	.comm	prime.0,1000002,32
	.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>

int main(void)
{
    static char prime[1000002];
    int i, j;
    int n, ans;
    
    for (i = 1; i <= 1000000; i += 2){
        prime[i] = 1;
    }
    
    prime[1] = 0;
    prime[2] = 1;
    
    for (i = 1; i <= 1000; i += 2){
        if (prime[i] == 1){
            for (j = 3; i * j <= 1000000; j += 2){
                prime[i * j] = 0;
            }
        }
    }
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        ans = 0;
        for (i = 2; i <= n / 2; i++){
            if (prime[i] && prime[n - i]){
                ans++;
            }
        }
        
        printf("%d\n", ans);
    }
    return (0);
}
6
1
12
0
 6
10
8
0
 6
4
12
0
 6
1
3
0
 6
4
2
0
 6
0
2
0
 6
4
0
0
 6
2
14
0
 6
1
0
0
 6
16
0
0

1
0
1
 1
2
1
 1
1
1
 1
0
0
 1
1
0
 1
 1
1
 1
0
2
 1
0
 1
2

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>

int main(void)
{
    static char prime[1000002];
    int i, j;
    int n, ans;
    
    for (i = 1; i <= 1000000; i += 2){
        prime[i] = 1;
    }
    
    prime[1] = 0;
    prime[2] = 1;
    
    for (i = 1; i <= 1000; i += 2){
        if (prime[i] == 1){
            for (j = 3; i * j <= 1000000; j += 2){
                prime[i * j] = 0;
            }
        }
    }
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        
        ans = 0;
        for (i = 2; i <= n / 2; i++){
            if (prime[i] && prime[n - i]){
                ans++;
            }
        }
        
        printf("%d\n", ans);
    }
    return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, -20(%rbp)
	jmp	.L2
.L3:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movb	$1, (%rax,%rdx)
	addl	$2, -20(%rbp)
.L2:
	cmpl	$1000000, -20(%rbp)
	jle	.L3
	movb	$0, 1+prime.0(%rip)
	movb	$1, 2+prime.0(%rip)
	movl	$1, -20(%rbp)
	jmp	.L4
.L8:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$1, %al
	jne	.L5
	movl	$3, -16(%rbp)
	jmp	.L6
.L7:
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movb	$0, (%rax,%rdx)
	addl	$2, -16(%rbp)
.L6:
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	cmpl	$1000000, %eax
	jle	.L7
.L5:
	addl	$2, -20(%rbp)
.L4:
	cmpl	$1000, -20(%rbp)
	jle	.L8
.L14:
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L18
	movl	$0, -12(%rbp)
	movl	$2, -20(%rbp)
	jmp	.L11
.L13:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L12
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L12
	addl	$1, -12(%rbp)
.L12:
	addl	$1, -20(%rbp)
.L11:
	movl	-24(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jle	.L13
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.local	prime.0
	.comm	prime.0,1000002,32
	.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
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, -20(%rbp)
	jmp	.L2
.L3:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movb	$1, (%rax,%rdx)
	addl	$2, -20(%rbp)
.L2:
	cmpl	$1000000, -20(%rbp)
	jle	.L3
	movb	$0, 1+prime.0(%rip)
	movb	$1, 2+prime.0(%rip)
	movl	$1, -20(%rbp)
	jmp	.L4
.L8:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	cmpb	$1, %al
	jne	.L5
	movl	$3, -16(%rbp)
	jmp	.L6
.L7:
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movb	$0, (%rax,%rdx)
	addl	$2, -16(%rbp)
.L6:
	movl	-20(%rbp), %eax
	imull	-16(%rbp), %eax
	cmpl	$1000000, %eax
	jle	.L7
.L5:
	addl	$2, -20(%rbp)
.L4:
	cmpl	$1000, -20(%rbp)
	jle	.L8
.L14:
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	testl	%eax, %eax
	je	.L18
	movl	$0, -12(%rbp)
	movl	$2, -20(%rbp)
	jmp	.L11
.L13:
	movl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L12
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	cltq
	leaq	prime.0(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L12
	addl	$1, -12(%rbp)
.L12:
	addl	$1, -20(%rbp)
.L11:
	movl	-24(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jle	.L13
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.local	prime.0
	.comm	prime.0,1000002,32
	.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:
