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 check(int *a, int x)
{
	int i = 0;
	while (a[i])
	{
		if (x == a[i])
			return 1;
		i++;
	}
	return (0);
}

// int		main(void)
// {
// 	int n,m,x;
// 	scanf("%d%d%d", &n, &m, &x);
// 	int a[m];
// 	int i = 0;
// 	int count1 = 0;
// 	int count2 = 0;
// 	while (i < m)
// 		scanf("%d", &a[i++]);
// 	i = x;
// 	int zero = a[0] - 1;
// 	if (x < n)
// 	{
// 		while (i < x)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i++;
// 		}
// 	}
// 	else
// 	{
// 		while (i > n)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i--;
// 		}
// 	}
// 	i = x;
// 	while (i > zero)
// 	{
// 		if (check(a, i))
// 			count2++;
// 		i--;
// 	}
// 	if (count1 < count2)
// 		printf("%d\n", count1);
// 	else
// 		printf("%d\n", count2);
// 	return (0);
// }

int		main(void)
{
	int n,m,x;
	scanf("%d%d%d", &n, &m, &x);
	int a[m];
	int i = 0;
	int count1 = 0;
	int count2 = 0;
	while (i < m)
		scanf("%d", &a[i++]);
	i = 0;
	int zero = a[0] - 1;
	while (i < m)
	{
		if(x < a[i])
			count1++;
		else
			count2++;
		i++;
	}
	// i = x;
	// while (i > zero)
	// {
	// 	if (check(a, i))
	// 		count2++;
	// 	i--;
	// }
	if (count1 < count2)
		printf("%d\n", count1);
	else
		printf("%d\n", count2);
	return (0);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	$1, %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-92(%rbp), %rcx
	leaq	-96(%rbp), %rdx
	leaq	-100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L7:
	cmpq	%rdx, %rsp
	je	.L8
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L7
.L8:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L9
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L9:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	movl	$0, -84(%rbp)
	movl	$0, -80(%rbp)
	jmp	.L10
.L11:
	movl	-88(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -88(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
.L10:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L11
	movl	$0, -88(%rbp)
	movq	-64(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, -76(%rbp)
	jmp	.L12
.L15:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	-92(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L13
	addl	$1, -84(%rbp)
	jmp	.L14
.L13:
	addl	$1, -80(%rbp)
.L14:
	addl	$1, -88(%rbp)
.L12:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L15
	movl	-84(%rbp), %eax
	cmpl	-80(%rbp), %eax
	jge	.L16
	movl	-84(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L16:
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L17:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	check
	.type	check, @function
check:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	testl	%eax, %eax
	je	.L1
	addq	$4, %rdi
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	movl	(%rdi), %eax
	addq	$4, %rdi
	testl	%eax, %eax
	je	.L10
.L3:
	cmpl	%eax, %esi
	jne	.L11
	movl	$1, %eax
.L1:
	ret
	.p2align 4,,10
	.p2align 3
.L10:
	ret
	.cfi_endproc
.LFE23:
	.size	check, .-check
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	pushq	%r13
	leaq	-68(%rbp), %rsi
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rcx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L14
.L41:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L41
.L14:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L42
.L15:
	movq	%rsp, %r13
	testl	%ecx, %ecx
	jle	.L16
	movq	%r13, %r15
	movq	%r13, %r12
	leaq	.LC1(%rip), %r14
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	addq	$4, %r12
	cmpl	%ebx, %eax
	jg	.L17
	testl	%eax, %eax
	jle	.L16
	leal	-1(%rax), %edx
	movl	-60(%rbp), %esi
	cmpl	$3, %edx
	jbe	.L33
	movl	%eax, %edx
	movd	%esi, %xmm5
	pxor	%xmm1, %xmm1
	movdqa	.LC2(%rip), %xmm3
	shrl	$2, %edx
	pshufd	$0, %xmm5, %xmm4
	movdqa	%xmm1, %xmm2
	salq	$4, %rdx
	addq	%r13, %rdx
	.p2align 4,,10
	.p2align 3
.L19:
	movdqu	(%r15), %xmm0
	addq	$16, %r15
	pcmpgtd	%xmm4, %xmm0
	psubd	%xmm0, %xmm2
	pandn	%xmm3, %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%r15, %rdx
	jne	.L19
	movdqa	%xmm1, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm2, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm1, %edx
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %r8d
	testb	$3, %al
	je	.L20
.L18:
	movslq	%ecx, %rdi
	leaq	0(%r13,%rdi,4), %rdi
	cmpl	(%rdi), %esi
	jge	.L21
	addl	$1, %r8d
.L22:
	leal	1(%rcx), %r9d
	cmpl	%r9d, %eax
	jle	.L20
	cmpl	4(%rdi), %esi
	jge	.L23
	addl	$1, %r8d
.L24:
	leal	2(%rcx), %r9d
	cmpl	%r9d, %eax
	jle	.L20
	cmpl	%esi, 8(%rdi)
	jle	.L25
	addl	$1, %r8d
.L26:
	addl	$3, %ecx
	cmpl	%eax, %ecx
	jge	.L20
	cmpl	12(%rdi), %esi
	jl	.L27
	addl	$1, %edx
.L20:
	cmpl	%edx, %r8d
	jge	.L30
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L31:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L43
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L16:
	.cfi_restore_state
	xorl	%edx, %edx
.L30:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L31
.L21:
	addl	$1, %edx
	jmp	.L22
.L23:
	addl	$1, %edx
	jmp	.L24
.L25:
	addl	$1, %edx
	jmp	.L26
.L27:
	addl	$1, %r8d
	jmp	.L20
.L42:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L15
.L33:
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	jmp	.L18
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	1
	.long	1
	.long	1
	.long	1
	.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
	.p2align 4
	.globl	check
	.type	check, @function
check:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	testl	%eax, %eax
	je	.L1
	addq	$4, %rdi
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L11:
	movl	(%rdi), %eax
	addq	$4, %rdi
	testl	%eax, %eax
	je	.L10
.L3:
	cmpl	%eax, %esi
	jne	.L11
	movl	$1, %eax
.L1:
	ret
	.p2align 4,,10
	.p2align 3
.L10:
	ret
	.cfi_endproc
.LFE23:
	.size	check, .-check
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	pushq	%r13
	leaq	-68(%rbp), %rsi
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movq	%rsp, %rsi
	movq	%rax, %rcx
	leaq	15(,%rax,4), %rax
	movq	%rax, %rdx
	andq	$-4096, %rax
	subq	%rax, %rsi
	andq	$-16, %rdx
	cmpq	%rsi, %rsp
	je	.L14
.L41:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L41
.L14:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L42
.L15:
	movq	%rsp, %r13
	testl	%ecx, %ecx
	jle	.L16
	movq	%r13, %r15
	movq	%r13, %r12
	leaq	.LC1(%rip), %r14
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	addq	$4, %r12
	cmpl	%ebx, %eax
	jg	.L17
	testl	%eax, %eax
	jle	.L16
	leal	-1(%rax), %edx
	movl	-60(%rbp), %esi
	cmpl	$3, %edx
	jbe	.L33
	movl	%eax, %edx
	movd	%esi, %xmm5
	pxor	%xmm1, %xmm1
	movdqa	.LC2(%rip), %xmm3
	shrl	$2, %edx
	pshufd	$0, %xmm5, %xmm4
	movdqa	%xmm1, %xmm2
	salq	$4, %rdx
	addq	%r13, %rdx
	.p2align 4,,10
	.p2align 3
.L19:
	movdqu	(%r15), %xmm0
	addq	$16, %r15
	pcmpgtd	%xmm4, %xmm0
	psubd	%xmm0, %xmm2
	pandn	%xmm3, %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%r15, %rdx
	jne	.L19
	movdqa	%xmm1, %xmm0
	movl	%eax, %ecx
	psrldq	$8, %xmm0
	andl	$-4, %ecx
	paddd	%xmm0, %xmm1
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movdqa	%xmm2, %xmm0
	psrldq	$8, %xmm0
	movd	%xmm1, %edx
	paddd	%xmm0, %xmm2
	movdqa	%xmm2, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm2
	movd	%xmm2, %r8d
	testb	$3, %al
	je	.L20
.L18:
	movslq	%ecx, %rdi
	leaq	0(%r13,%rdi,4), %rdi
	cmpl	(%rdi), %esi
	jge	.L21
	addl	$1, %r8d
.L22:
	leal	1(%rcx), %r9d
	cmpl	%r9d, %eax
	jle	.L20
	cmpl	4(%rdi), %esi
	jge	.L23
	addl	$1, %r8d
.L24:
	leal	2(%rcx), %r9d
	cmpl	%r9d, %eax
	jle	.L20
	cmpl	%esi, 8(%rdi)
	jle	.L25
	addl	$1, %r8d
.L26:
	addl	$3, %ecx
	cmpl	%eax, %ecx
	jge	.L20
	cmpl	12(%rdi), %esi
	jl	.L27
	addl	$1, %edx
.L20:
	cmpl	%edx, %r8d
	jge	.L30
	movl	%r8d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L31:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L43
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L16:
	.cfi_restore_state
	xorl	%edx, %edx
.L30:
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L31
.L21:
	addl	$1, %edx
	jmp	.L22
.L23:
	addl	$1, %edx
	jmp	.L24
.L25:
	addl	$1, %edx
	jmp	.L26
.L27:
	addl	$1, %r8d
	jmp	.L20
.L42:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L15
.L33:
	xorl	%edx, %edx
	xorl	%r8d, %r8d
	xorl	%ecx, %ecx
	jmp	.L18
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	1
	.long	1
	.long	1
	.long	1
	.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 check(int *a, int x)
{
	int i = 0;
	while (a[i])
	{
		if (x == a[i])
			return 1;
		i++;
	}
	return (0);
}

// int		main(void)
// {
// 	int n,m,x;
// 	scanf("%d%d%d", &n, &m, &x);
// 	int a[m];
// 	int i = 0;
// 	int count1 = 0;
// 	int count2 = 0;
// 	while (i < m)
// 		scanf("%d", &a[i++]);
// 	i = x;
// 	int zero = a[0] - 1;
// 	if (x < n)
// 	{
// 		while (i < x)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i++;
// 		}
// 	}
// 	else
// 	{
// 		while (i > n)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i--;
// 		}
// 	}
// 	i = x;
// 	while (i > zero)
// 	{
// 		if (check(a, i))
// 			count2++;
// 		i--;
// 	}
// 	if (count1 < count2)
// 		printf("%d\n", count1);
// 	else
// 		printf("%d\n", count2);
// 	return (0);
// }

int		main(void)
{
	int n,m,x;
	scanf("%d%d%d", &n, &m, &x);
	int a[m];
	int i = 0;
	int count1 = 0;
	int count2 = 0;
	while (i < m)
		scanf("%d", &a[i++]);
	i = 0;
	int zero = a[0] - 1;
	while (i < m)
	{
		if(x < a[i])
			count1++;
		else
			count2++;
		i++;
	}
	// i = x;
	// while (i > zero)
	// {
	// 	if (check(a, i))
	// 		count2++;
	// 	i--;
	// }
	if (count1 < count2)
		printf("%d\n", count1);
	else
		printf("%d\n", count2);
	return (0);
}

5 3 3
1 2 4

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>

int check(int *a, int x)
{
	int i = 0;
	while (a[i])
	{
		if (x == a[i])
			return 1;
		i++;
	}
	return (0);
}

// int		main(void)
// {
// 	int n,m,x;
// 	scanf("%d%d%d", &n, &m, &x);
// 	int a[m];
// 	int i = 0;
// 	int count1 = 0;
// 	int count2 = 0;
// 	while (i < m)
// 		scanf("%d", &a[i++]);
// 	i = x;
// 	int zero = a[0] - 1;
// 	if (x < n)
// 	{
// 		while (i < x)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i++;
// 		}
// 	}
// 	else
// 	{
// 		while (i > n)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i--;
// 		}
// 	}
// 	i = x;
// 	while (i > zero)
// 	{
// 		if (check(a, i))
// 			count2++;
// 		i--;
// 	}
// 	if (count1 < count2)
// 		printf("%d\n", count1);
// 	else
// 		printf("%d\n", count2);
// 	return (0);
// }

int		main(void)
{
	int n,m,x;
	scanf("%d%d%d", &n, &m, &x);
	int a[m];
	int i = 0;
	int count1 = 0;
	int count2 = 0;
	while (i < m)
		scanf("%d", &a[i++]);
	i = 0;
	int zero = a[0] - 1;
	while (i < m)
	{
		if(x < a[i])
			count1++;
		else
			count2++;
		i++;
	}
	// i = x;
	// while (i > zero)
	// {
	// 	if (check(a, i))
	// 		count2++;
	// 	i--;
	// }
	if (count1 < count2)
		printf("%d\n", count1);
	else
		printf("%d\n", count2);
	return (0);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	$1, %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-92(%rbp), %rcx
	leaq	-96(%rbp), %rdx
	leaq	-100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L7:
	cmpq	%rdx, %rsp
	je	.L8
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L7
.L8:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L9
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L9:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	movl	$0, -84(%rbp)
	movl	$0, -80(%rbp)
	jmp	.L10
.L11:
	movl	-88(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -88(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
.L10:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L11
	movl	$0, -88(%rbp)
	movq	-64(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, -76(%rbp)
	jmp	.L12
.L15:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	-92(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L13
	addl	$1, -84(%rbp)
	jmp	.L14
.L13:
	addl	$1, -80(%rbp)
.L14:
	addl	$1, -88(%rbp)
.L12:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L15
	movl	-84(%rbp), %eax
	cmpl	-80(%rbp), %eax
	jge	.L16
	movl	-84(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L16:
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L17:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	check
	.type	check, @function
check:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	$1, %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-92(%rbp), %rcx
	leaq	-96(%rbp), %rdx
	leaq	-100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	movslq	%eax, %rdx
	subq	$1, %rdx
	movq	%rdx, -72(%rbp)
	movslq	%eax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	movslq	%eax, %rdx
	movq	%rdx, %r12
	movl	$0, %r13d
	cltq
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L7:
	cmpq	%rdx, %rsp
	je	.L8
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L7
.L8:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L9
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L9:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -88(%rbp)
	movl	$0, -84(%rbp)
	movl	$0, -80(%rbp)
	jmp	.L10
.L11:
	movl	-88(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -88(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
.L10:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L11
	movl	$0, -88(%rbp)
	movq	-64(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, -76(%rbp)
	jmp	.L12
.L15:
	movq	-64(%rbp), %rax
	movl	-88(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movl	-92(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L13
	addl	$1, -84(%rbp)
	jmp	.L14
.L13:
	addl	$1, -80(%rbp)
.L14:
	addl	$1, -88(%rbp)
.L12:
	movl	-96(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	jl	.L15
	movl	-84(%rbp), %eax
	cmpl	-80(%rbp), %eax
	jge	.L16
	movl	-84(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L16:
	movl	-80(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L17:
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
