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

```c
o[1<<20],n,r;
main(i){
 for(;++i<999;)
  if(!o[i])
   for(r=i+i;r<1<<20;r+=i)
    o[r]=1;
 for(;scanf("%d",&n),n;printf("%d\n",r))
  for(i=1,r=0;++i<=n/2;)
   o[i]+o[n-i]||r++;
 exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	o
	.bss
	.align 32
	.type	o, @object
	.size	o, 4194304
o:
	.zero	4194304
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, r(%rip)
	jmp	.L3
.L4:
	movl	r(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	r(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
.L3:
	movl	r(%rip), %eax
	cmpl	$1048575, %eax
	jle	.L4
.L2:
	addl	$1, -4(%rbp)
	cmpl	$998, -4(%rbp)
	jle	.L5
	jmp	.L6
.L11:
	movl	$1, -4(%rbp)
	movl	$0, r(%rip)
	jmp	.L7
.L10:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	n(%rip), %eax
	subl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	testl	%eax, %eax
	jne	.L7
	movl	r(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, r(%rip)
	testl	%eax, %eax
.L7:
	addl	$1, -4(%rbp)
	movl	n(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -4(%rbp)
	jle	.L10
	movl	r(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leal	1(%rdi), %edx
	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	$8, %rsp
	.cfi_def_cfa_offset 48
	cmpl	$998, %edx
	jg	.L3
	movslq	%edx, %rcx
	xorl	%edi, %edi
	leaq	o(%rip), %r8
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rcx
	cmpl	$998, %ecx
	jg	.L24
.L6:
	movl	(%r8,%rcx,4), %edx
	movl	%ecx, %esi
	testl	%edx, %edx
	jne	.L4
	leal	(%rcx,%rcx), %eax
	leaq	0(,%rcx,4), %rdi
	movslq	%eax, %rdx
	leaq	(%r8,%rdx,4), %rdx
	.p2align 4,,10
	.p2align 3
.L5:
	addl	%esi, %eax
	movl	$1, (%rdx)
	addq	%rdi, %rdx
	cmpl	$1048575, %eax
	jle	.L5
	addq	$1, %rcx
	movl	$1, %edi
	cmpl	$998, %ecx
	jle	.L6
.L24:
	testb	%dil, %dil
	je	.L3
	movl	%eax, r(%rip)
.L3:
	leaq	n(%rip), %rbp
	leaq	.LC1(%rip), %rbx
	leaq	o(%rip), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	n(%rip), %rax
	testl	%eax, %eax
	je	.L25
	movl	$0, r(%rip)
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%eax, %esi
	sarl	%esi
	cmpl	$3, %eax
	jle	.L14
	leaq	0(%r13,%rax,4), %rdx
	xorl	%edi, %edi
	movl	$2, %eax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	movl	0(%r13,%rax,4), %ecx
	addl	-8(%rdx), %ecx
	jne	.L10
	addl	$1, %r8d
	movl	$1, %edi
.L10:
	addq	$1, %rax
	subq	$4, %rdx
	cmpl	%eax, %esi
	jge	.L11
	testb	%dil, %dil
	je	.L14
	movl	%r8d, r(%rip)
.L9:
	movl	%r8d, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%r8d, %r8d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	o
	.align 32
	.type	o, @object
	.size	o, 4194304
o:
	.zero	4194304
	.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\n"
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leal	1(%rdi), %edx
	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	$8, %rsp
	.cfi_def_cfa_offset 48
	cmpl	$998, %edx
	jg	.L3
	movslq	%edx, %rcx
	xorl	%edi, %edi
	leaq	o(%rip), %r8
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rcx
	cmpl	$998, %ecx
	jg	.L24
.L6:
	movl	(%r8,%rcx,4), %edx
	movl	%ecx, %esi
	testl	%edx, %edx
	jne	.L4
	leal	(%rcx,%rcx), %eax
	leaq	0(,%rcx,4), %rdi
	movslq	%eax, %rdx
	leaq	(%r8,%rdx,4), %rdx
	.p2align 4,,10
	.p2align 3
.L5:
	addl	%esi, %eax
	movl	$1, (%rdx)
	addq	%rdi, %rdx
	cmpl	$1048575, %eax
	jle	.L5
	addq	$1, %rcx
	movl	$1, %edi
	cmpl	$998, %ecx
	jle	.L6
.L24:
	testb	%dil, %dil
	je	.L3
	movl	%eax, r(%rip)
.L3:
	leaq	n(%rip), %rbp
	leaq	.LC1(%rip), %rbx
	leaq	o(%rip), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movslq	n(%rip), %rax
	testl	%eax, %eax
	je	.L25
	movl	$0, r(%rip)
	movl	%eax, %esi
	shrl	$31, %esi
	addl	%eax, %esi
	sarl	%esi
	cmpl	$3, %eax
	jle	.L14
	leaq	0(%r13,%rax,4), %rdx
	xorl	%edi, %edi
	movl	$2, %eax
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L11:
	movl	0(%r13,%rax,4), %ecx
	addl	-8(%rdx), %ecx
	jne	.L10
	addl	$1, %r8d
	movl	$1, %edi
.L10:
	addq	$1, %rax
	subq	$4, %rdx
	cmpl	%eax, %esi
	jge	.L11
	testb	%dil, %dil
	je	.L14
	movl	%r8d, r(%rip)
.L9:
	movl	%r8d, %esi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	printf@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%r8d, %r8d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%edi, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	r
	.bss
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	o
	.align 32
	.type	o, @object
	.size	o, 4194304
o:
	.zero	4194304
	.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:

o[1<<20],n,r;
main(i){
 for(;++i<999;)
  if(!o[i])
   for(r=i+i;r<1<<20;r+=i)
    o[r]=1;
 for(;scanf("%d",&n),n;printf("%d\n",r))
  for(i=1,r=0;++i<=n/2;)
   o[i]+o[n-i]||r++;
 exit(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
o[1<<20],n,r;
main(i){
 for(;++i<999;)
  if(!o[i])
   for(r=i+i;r<1<<20;r+=i)
    o[r]=1;
 for(;scanf("%d",&n),n;printf("%d\n",r))
  for(i=1,r=0;++i<=n/2;)
   o[i]+o[n-i]||r++;
 exit(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	o
	.bss
	.align 32
	.type	o, @object
	.size	o, 4194304
o:
	.zero	4194304
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, r(%rip)
	jmp	.L3
.L4:
	movl	r(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	r(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
.L3:
	movl	r(%rip), %eax
	cmpl	$1048575, %eax
	jle	.L4
.L2:
	addl	$1, -4(%rbp)
	cmpl	$998, -4(%rbp)
	jle	.L5
	jmp	.L6
.L11:
	movl	$1, -4(%rbp)
	movl	$0, r(%rip)
	jmp	.L7
.L10:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	n(%rip), %eax
	subl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	testl	%eax, %eax
	jne	.L7
	movl	r(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, r(%rip)
	testl	%eax, %eax
.L7:
	addl	$1, -4(%rbp)
	movl	n(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -4(%rbp)
	jle	.L10
	movl	r(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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	o
	.bss
	.align 32
	.type	o, @object
	.size	o, 4194304
o:
	.zero	4194304
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d\n"
.LC1:
	.string	"%d"
	.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	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L2
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, r(%rip)
	jmp	.L3
.L4:
	movl	r(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	r(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
.L3:
	movl	r(%rip), %eax
	cmpl	$1048575, %eax
	jle	.L4
.L2:
	addl	$1, -4(%rbp)
	cmpl	$998, -4(%rbp)
	jle	.L5
	jmp	.L6
.L11:
	movl	$1, -4(%rbp)
	movl	$0, r(%rip)
	jmp	.L7
.L10:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	n(%rip), %eax
	subl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	o(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	testl	%eax, %eax
	jne	.L7
	movl	r(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, r(%rip)
	testl	%eax, %eax
.L7:
	addl	$1, -4(%rbp)
	movl	n(%rip), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -4(%rbp)
	jle	.L10
	movl	r(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$0, %edi
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.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:
