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)
{
	int n,p[100],i,j,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	for(i=0;;i++){
		x=0;
		for(j=0;j<n;j++){
			if(p[j]>=i){
				x++;
			}
		}
		if(x<i){
			break;
		}
	}
	printf("%d\n",i-1);
	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	$432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -428(%rbp)
	jmp	.L2
.L3:
	leaq	-416(%rbp), %rdx
	movl	-428(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -428(%rbp)
.L2:
	movl	-432(%rbp), %eax
	cmpl	%eax, -428(%rbp)
	jl	.L3
	movl	$0, -428(%rbp)
.L9:
	movl	$0, -420(%rbp)
	movl	$0, -424(%rbp)
	jmp	.L4
.L6:
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -428(%rbp)
	jg	.L5
	addl	$1, -420(%rbp)
.L5:
	addl	$1, -424(%rbp)
.L4:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L6
	movl	-420(%rbp), %eax
	cmpl	-428(%rbp), %eax
	jl	.L13
	addl	$1, -428(%rbp)
	jmp	.L9
.L13:
	nop
	movl	-428(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC1(%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"
.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
	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
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	16(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	testl	%esi, %esi
	jle	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L3
.L2:
	movl	%esi, %eax
	movl	%esi, %r9d
	leal	-1(%rsi), %r10d
	xorl	%edx, %edx
	shrl	$2, %eax
	andl	$-4, %r9d
	pxor	%xmm3, %xmm3
	subl	$1, %eax
	salq	$4, %rax
	leaq	32(%rsp,%rax), %rdi
	testl	%esi, %esi
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L24:
	cmpl	$2, %r10d
	jbe	.L17
	movd	%edx, %xmm4
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	pshufd	$0, %xmm4, %xmm2
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	%xmm2, %xmm1
	addq	$16, %rax
	pcmpgtd	-16(%rax), %xmm1
	pcmpeqd	%xmm3, %xmm1
	psubd	%xmm1, %xmm0
	cmpq	%rax, %rdi
	jne	.L6
	movdqa	%xmm0, %xmm1
	movl	%r9d, %ecx
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	cmpl	%r9d, %esi
	je	.L4
.L5:
	movslq	%ecx, %r8
	cmpl	16(%rsp,%r8,4), %edx
	jg	.L9
	addl	$1, %eax
.L9:
	leal	1(%rcx), %r8d
	cmpl	%esi, %r8d
	jge	.L4
	movslq	%r8d, %r8
	cmpl	16(%rsp,%r8,4), %edx
	jg	.L10
	addl	$1, %eax
.L10:
	addl	$2, %ecx
	cmpl	%ecx, %esi
	jle	.L4
	movslq	%ecx, %rcx
	cmpl	16(%rsp,%rcx,4), %edx
	jg	.L4
	addl	$1, %eax
.L4:
	cmpl	%eax, %edx
	jg	.L13
.L25:
	addl	$1, %edx
	testl	%esi, %esi
	jg	.L24
.L16:
	xorl	%eax, %eax
	cmpl	%eax, %edx
	jle	.L25
	.p2align 4,,10
	.p2align 3
.L13:
	subl	$1, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$440, %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
.L17:
	.cfi_restore_state
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	jmp	.L5
.L26:
	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"
.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
	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
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	leaq	16(%rsp), %rbx
	movq	%rbx, %r12
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	testl	%esi, %esi
	jle	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %esi
	addq	$4, %r12
	cmpl	%ebp, %esi
	jg	.L3
.L2:
	movl	%esi, %eax
	movl	%esi, %r9d
	leal	-1(%rsi), %r10d
	xorl	%edx, %edx
	shrl	$2, %eax
	andl	$-4, %r9d
	pxor	%xmm3, %xmm3
	subl	$1, %eax
	salq	$4, %rax
	leaq	32(%rsp,%rax), %rdi
	testl	%esi, %esi
	jle	.L16
	.p2align 4,,10
	.p2align 3
.L24:
	cmpl	$2, %r10d
	jbe	.L17
	movd	%edx, %xmm4
	movq	%rbx, %rax
	pxor	%xmm0, %xmm0
	pshufd	$0, %xmm4, %xmm2
	.p2align 4,,10
	.p2align 3
.L6:
	movdqa	%xmm2, %xmm1
	addq	$16, %rax
	pcmpgtd	-16(%rax), %xmm1
	pcmpeqd	%xmm3, %xmm1
	psubd	%xmm1, %xmm0
	cmpq	%rax, %rdi
	jne	.L6
	movdqa	%xmm0, %xmm1
	movl	%r9d, %ecx
	psrldq	$8, %xmm1
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	cmpl	%r9d, %esi
	je	.L4
.L5:
	movslq	%ecx, %r8
	cmpl	16(%rsp,%r8,4), %edx
	jg	.L9
	addl	$1, %eax
.L9:
	leal	1(%rcx), %r8d
	cmpl	%esi, %r8d
	jge	.L4
	movslq	%r8d, %r8
	cmpl	16(%rsp,%r8,4), %edx
	jg	.L10
	addl	$1, %eax
.L10:
	addl	$2, %ecx
	cmpl	%ecx, %esi
	jle	.L4
	movslq	%ecx, %rcx
	cmpl	16(%rsp,%rcx,4), %edx
	jg	.L4
	addl	$1, %eax
.L4:
	cmpl	%eax, %edx
	jg	.L13
.L25:
	addl	$1, %edx
	testl	%esi, %esi
	jg	.L24
.L16:
	xorl	%eax, %eax
	cmpl	%eax, %edx
	jle	.L25
	.p2align 4,,10
	.p2align 3
.L13:
	subl	$1, %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	addq	$440, %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
.L17:
	.cfi_restore_state
	xorl	%eax, %eax
	xorl	%ecx, %ecx
	jmp	.L5
.L26:
	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(void)
{
	int n,p[100],i,j,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	for(i=0;;i++){
		x=0;
		for(j=0;j<n;j++){
			if(p[j]>=i){
				x++;
			}
		}
		if(x<i){
			break;
		}
	}
	printf("%d\n",i-1);
	return 0;
}
7
5 4 3 14 2 4 1
 3
1 0 100
 3
2 0 100
 7
0 1 5 37 2 4 1
 7
5 4 3 14 2 7 1
 7
5 4 2 14 2 7 1
 7
5 4 4 14 2 7 1
 7
5 4 4 14 1 7 1
 7
10 4 4 14 1 7 1
 7
10 4 4 14 1 7 2

4
 1
 2
 3
 4
 4
 4
 4
 4
 4

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)
{
	int n,p[100],i,j,x;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	for(i=0;;i++){
		x=0;
		for(j=0;j<n;j++){
			if(p[j]>=i){
				x++;
			}
		}
		if(x<i){
			break;
		}
	}
	printf("%d\n",i-1);
	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	$432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -428(%rbp)
	jmp	.L2
.L3:
	leaq	-416(%rbp), %rdx
	movl	-428(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -428(%rbp)
.L2:
	movl	-432(%rbp), %eax
	cmpl	%eax, -428(%rbp)
	jl	.L3
	movl	$0, -428(%rbp)
.L9:
	movl	$0, -420(%rbp)
	movl	$0, -424(%rbp)
	jmp	.L4
.L6:
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -428(%rbp)
	jg	.L5
	addl	$1, -420(%rbp)
.L5:
	addl	$1, -424(%rbp)
.L4:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L6
	movl	-420(%rbp), %eax
	cmpl	-428(%rbp), %eax
	jl	.L13
	addl	$1, -428(%rbp)
	jmp	.L9
.L13:
	nop
	movl	-428(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC1(%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"
.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	$432, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-432(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -428(%rbp)
	jmp	.L2
.L3:
	leaq	-416(%rbp), %rdx
	movl	-428(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -428(%rbp)
.L2:
	movl	-432(%rbp), %eax
	cmpl	%eax, -428(%rbp)
	jl	.L3
	movl	$0, -428(%rbp)
.L9:
	movl	$0, -420(%rbp)
	movl	$0, -424(%rbp)
	jmp	.L4
.L6:
	movl	-424(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	%eax, -428(%rbp)
	jg	.L5
	addl	$1, -420(%rbp)
.L5:
	addl	$1, -424(%rbp)
.L4:
	movl	-432(%rbp), %eax
	cmpl	%eax, -424(%rbp)
	jl	.L6
	movl	-420(%rbp), %eax
	cmpl	-428(%rbp), %eax
	jl	.L13
	addl	$1, -428(%rbp)
	jmp	.L9
.L13:
	nop
	movl	-428(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC1(%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:
