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(){
  int n,i,tmp;
  int *a;
  
  scanf("%d",&n);
  a=(int*)calloc(n,sizeof(int));
  
  for(i=0;i<n;i++){
    scanf("%d",&tmp);
    a[tmp]++;
    if(a[tmp]>2 || a[0]>1){
      printf("0");
      return 0;
    }
  }
  
  tmp=1;
  for(i=0;i<n/2;i++){
    tmp*=2;
    tmp=tmp%1000000007;
  }
  printf("%d",tmp);
  free(a);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L2
.L6:
	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
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$2, %eax
	jg	.L3
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	jle	.L4
.L3:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L5
.L4:
	addl	$1, -20(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movl	$1, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L7
.L8:
	movl	-24(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1152921497, %rax, %rax
	shrq	$32, %rax
	sarl	$28, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000000007, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -24(%rbp)
	addl	$1, -20(%rbp)
.L7:
	movl	-28(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jl	.L8
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
.L5:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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"
	.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
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	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)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movslq	(%rsp), %rdi
	movl	$4, %esi
	movq	%rdi, %rbx
	call	calloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	xorl	%ebx, %ebx
	leaq	4(%rsp), %r12
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L16:
	cmpl	$1, 0(%rbp)
	jg	.L3
	movl	(%rsp), %ecx
	addl	$1, %ebx
	cmpl	%ebx, %ecx
	jle	.L15
.L6:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rax
	leaq	0(%rbp,%rax,4), %rdx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	cmpl	$2, %eax
	jle	.L16
.L3:
	movl	$48, %edi
	call	putchar@PLT
.L5:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	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
.L15:
	.cfi_restore_state
	movl	%ecx, %eax
	movl	$2, %esi
	movl	$1, 4(%rsp)
	cltd
	idivl	%esi
	subl	$1, %ecx
	jle	.L7
	movl	$1, %edx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L8:
	leal	(%rdx,%rdx), %ecx
	addl	$1, %esi
	movslq	%ecx, %rdx
	movl	%ecx, %edi
	imulq	$1152921497, %rdx, %rdx
	sarl	$31, %edi
	sarq	$60, %rdx
	subl	%edi, %edx
	imull	$1000000007, %edx, %edi
	subl	%edi, %ecx
	movl	%ecx, %edx
	cmpl	%eax, %esi
	jl	.L8
	movl	%ecx, 4(%rsp)
.L7:
	movl	4(%rsp), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	jmp	.L5
.L2:
	movl	$1, 4(%rsp)
	jmp	.L7
.L17:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.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
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	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)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movslq	(%rsp), %rdi
	movl	$4, %esi
	movq	%rdi, %rbx
	call	calloc@PLT
	movq	%rax, %rbp
	testl	%ebx, %ebx
	jle	.L2
	xorl	%ebx, %ebx
	leaq	4(%rsp), %r12
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L16:
	cmpl	$1, 0(%rbp)
	jg	.L3
	movl	(%rsp), %ecx
	addl	$1, %ebx
	cmpl	%ebx, %ecx
	jle	.L15
.L6:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	4(%rsp), %rax
	leaq	0(%rbp,%rax,4), %rdx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	cmpl	$2, %eax
	jle	.L16
.L3:
	movl	$48, %edi
	call	putchar@PLT
.L5:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	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
.L15:
	.cfi_restore_state
	movl	%ecx, %eax
	movl	$2, %esi
	movl	$1, 4(%rsp)
	cltd
	idivl	%esi
	subl	$1, %ecx
	jle	.L7
	movl	$1, %edx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L8:
	leal	(%rdx,%rdx), %ecx
	addl	$1, %esi
	movslq	%ecx, %rdx
	movl	%ecx, %edi
	imulq	$1152921497, %rdx, %rdx
	sarl	$31, %edi
	sarq	$60, %rdx
	subl	%edi, %edx
	imull	$1000000007, %edx, %edi
	subl	%edi, %ecx
	movl	%ecx, %edx
	cmpl	%eax, %esi
	jl	.L8
	movl	%ecx, 4(%rsp)
.L7:
	movl	4(%rsp), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbp, %rdi
	call	free@PLT
	jmp	.L5
.L2:
	movl	$1, 4(%rsp)
	jmp	.L7
.L17:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

#include <stdio.h>
int main(){
  int n,i,tmp;
  int *a;
  
  scanf("%d",&n);
  a=(int*)calloc(n,sizeof(int));
  
  for(i=0;i<n;i++){
    scanf("%d",&tmp);
    a[tmp]++;
    if(a[tmp]>2 || a[0]>1){
      printf("0");
      return 0;
    }
  }
  
  tmp=1;
  for(i=0;i<n/2;i++){
    tmp*=2;
    tmp=tmp%1000000007;
  }
  printf("%d",tmp);
  free(a);
}
8
7 5 1 2 7 3 5 3
 7
6 4 0 2 4 0 4
 5
0 4 4 0 2
 7
6 4 0 2 4 -1 4
 5
0 4 4 0 1

16 0 0 0 0
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(){
  int n,i,tmp;
  int *a;
  
  scanf("%d",&n);
  a=(int*)calloc(n,sizeof(int));
  
  for(i=0;i<n;i++){
    scanf("%d",&tmp);
    a[tmp]++;
    if(a[tmp]>2 || a[0]>1){
      printf("0");
      return 0;
    }
  }
  
  tmp=1;
  for(i=0;i<n/2;i++){
    tmp*=2;
    tmp=tmp%1000000007;
  }
  printf("%d",tmp);
  free(a);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L2
.L6:
	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
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$2, %eax
	jg	.L3
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	jle	.L4
.L3:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L5
.L4:
	addl	$1, -20(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movl	$1, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L7
.L8:
	movl	-24(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1152921497, %rax, %rax
	shrq	$32, %rax
	sarl	$28, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000000007, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -24(%rbp)
	addl	$1, -20(%rbp)
.L7:
	movl	-28(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jl	.L8
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
.L5:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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
	.section	.rodata
.LC0:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L2
.L6:
	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
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$2, %eax
	jg	.L3
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	jle	.L4
.L3:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L5
.L4:
	addl	$1, -20(%rbp)
.L2:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movl	$1, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L7
.L8:
	movl	-24(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1152921497, %rax, %rax
	shrq	$32, %rax
	sarl	$28, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000000007, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -24(%rbp)
	addl	$1, -20(%rbp)
.L7:
	movl	-28(%rbp), %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cmpl	%eax, -20(%rbp)
	jl	.L8
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, %eax
.L5:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.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:
