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>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
int main() {
	int n, c[100001] ={0}, ans = 0, a = 0;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d",&a);
		if (a>1e5) ans++;
		else c[a]++;
	}
	rep(i, 100001) {
		if (c[i] > i)ans += c[i] - i;
		else if (c[i] < i)ans += c[i];
	}
	printf("%d", ans);
}```

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
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2736, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-400016(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -400028(%rbp)
	movl	$0, -400032(%rbp)
	leaq	-400036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400024(%rbp)
	jmp	.L2
.L5:
	leaq	-400032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-400032(%rbp), %eax
	cmpl	$100000, %eax
	jle	.L3
	addl	$1, -400028(%rbp)
	jmp	.L4
.L3:
	movl	-400032(%rbp), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
.L4:
	addl	$1, -400024(%rbp)
.L2:
	movl	-400036(%rbp), %eax
	cmpl	%eax, -400024(%rbp)
	jl	.L5
	movl	$0, -400020(%rbp)
	jmp	.L6
.L9:
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -400020(%rbp)
	jge	.L7
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	subl	-400020(%rbp), %eax
	addl	%eax, -400028(%rbp)
	jmp	.L8
.L7:
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -400020(%rbp)
	jle	.L8
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%eax, -400028(%rbp)
.L8:
	addl	$1, -400020(%rbp)
.L6:
	cmpl	$100000, -400020(%rbp)
	jle	.L9
	movl	-400028(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397360
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400080
	movl	$400004, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %r14
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	call	memset@PLT
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	movl	$0, 12(%rsp)
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L10
	xorl	%ebp, %ebp
	xorl	%r12d, %r12d
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	cmpl	$100000, %eax
	jle	.L3
	addl	$1, %r12d
	addl	$1, %ebp
	cmpl	8(%rsp), %ebp
	jl	.L5
.L2:
	xorl	%eax, %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	subl	%eax, %edx
	addl	%edx, %r12d
.L7:
	addq	$1, %rax
	cmpq	$100001, %rax
	je	.L14
.L8:
	movl	(%rbx,%rax,4), %edx
	cmpl	%edx, %eax
	jl	.L15
	jle	.L7
	addq	$1, %rax
	addl	%edx, %r12d
	cmpq	$100001, %rax
	jne	.L8
.L14:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	addl	$1, 16(%rsp,%rax,4)
	addl	$1, %ebp
	cmpl	%ebp, 8(%rsp)
	jg	.L5
	jmp	.L2
.L10:
	xorl	%r12d, %r12d
	jmp	.L2
.L16:
	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	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-397312(%rsp), %r11
	.cfi_def_cfa 11, 397360
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2720, %rsp
	.cfi_def_cfa_offset 400080
	movl	$400004, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %r14
	movq	%fs:40, %rax
	movq	%rax, 400024(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	call	memset@PLT
	leaq	8(%rsp), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	movl	$0, 12(%rsp)
	call	__isoc99_scanf@PLT
	movl	8(%rsp), %eax
	testl	%eax, %eax
	jle	.L10
	xorl	%ebp, %ebp
	xorl	%r12d, %r12d
	leaq	12(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	cmpl	$100000, %eax
	jle	.L3
	addl	$1, %r12d
	addl	$1, %ebp
	cmpl	8(%rsp), %ebp
	jl	.L5
.L2:
	xorl	%eax, %eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L15:
	subl	%eax, %edx
	addl	%edx, %r12d
.L7:
	addq	$1, %rax
	cmpq	$100001, %rax
	je	.L14
.L8:
	movl	(%rbx,%rax,4), %edx
	cmpl	%edx, %eax
	jl	.L15
	jle	.L7
	addq	$1, %rax
	addl	%edx, %r12d
	cmpq	$100001, %rax
	jne	.L8
.L14:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	400024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$400032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	addl	$1, 16(%rsp,%rax,4)
	addl	$1, %ebp
	cmpl	%ebp, 8(%rsp)
	jg	.L5
	jmp	.L2
.L10:
	xorl	%r12d, %r12d
	jmp	.L2
.L16:
	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>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
int main() {
	int n, c[100001] ={0}, ans = 0, a = 0;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d",&a);
		if (a>1e5) ans++;
		else c[a]++;
	}
	rep(i, 100001) {
		if (c[i] > i)ans += c[i] - i;
		else if (c[i] < i)ans += c[i];
	}
	printf("%d", ans);
}
4
3 3 3 3

1
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>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
int main() {
	int n, c[100001] ={0}, ans = 0, a = 0;
	scanf("%d", &n);
	rep(i, n) {
		scanf("%d",&a);
		if (a>1e5) ans++;
		else c[a]++;
	}
	rep(i, 100001) {
		if (c[i] > i)ans += c[i] - i;
		else if (c[i] < i)ans += c[i];
	}
	printf("%d", ans);
}```

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
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2736, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-400016(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -400028(%rbp)
	movl	$0, -400032(%rbp)
	leaq	-400036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400024(%rbp)
	jmp	.L2
.L5:
	leaq	-400032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-400032(%rbp), %eax
	cmpl	$100000, %eax
	jle	.L3
	addl	$1, -400028(%rbp)
	jmp	.L4
.L3:
	movl	-400032(%rbp), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
.L4:
	addl	$1, -400024(%rbp)
.L2:
	movl	-400036(%rbp), %eax
	cmpl	%eax, -400024(%rbp)
	jl	.L5
	movl	$0, -400020(%rbp)
	jmp	.L6
.L9:
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -400020(%rbp)
	jge	.L7
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	subl	-400020(%rbp), %eax
	addl	%eax, -400028(%rbp)
	jmp	.L8
.L7:
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -400020(%rbp)
	jle	.L8
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%eax, -400028(%rbp)
.L8:
	addl	$1, -400020(%rbp)
.L6:
	cmpl	$100000, -400020(%rbp)
	jle	.L9
	movl	-400028(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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
	leaq	-397312(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2736, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-400016(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -400028(%rbp)
	movl	$0, -400032(%rbp)
	leaq	-400036(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -400024(%rbp)
	jmp	.L2
.L5:
	leaq	-400032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-400032(%rbp), %eax
	cmpl	$100000, %eax
	jle	.L3
	addl	$1, -400028(%rbp)
	jmp	.L4
.L3:
	movl	-400032(%rbp), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
.L4:
	addl	$1, -400024(%rbp)
.L2:
	movl	-400036(%rbp), %eax
	cmpl	%eax, -400024(%rbp)
	jl	.L5
	movl	$0, -400020(%rbp)
	jmp	.L6
.L9:
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -400020(%rbp)
	jge	.L7
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	subl	-400020(%rbp), %eax
	addl	%eax, -400028(%rbp)
	jmp	.L8
.L7:
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -400020(%rbp)
	jle	.L8
	movl	-400020(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	addl	%eax, -400028(%rbp)
.L8:
	addl	$1, -400020(%rbp)
.L6:
	cmpl	$100000, -400020(%rbp)
	jle	.L9
	movl	-400028(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
