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 x,n,p[101],q[102]={0},i,a,b,s;
    scanf("%d%d",&x,&n);
    for(i=0;i<n;i++)
        scanf("%d",&p[i]);
    for(i=0;i<n;i++)
        q[p[i]]=1;
    a=x; b=x;
    while(1){
        if(q[a]==0){
            s=a;
            break;
        }
        else if(q[b]==0){
            s=b;
            break;
        }
        a--; b++;
    }
    printf("%d\n",s);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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	$864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-416(%rbp), %rdx
	movl	$0, %eax
	movl	$51, %ecx
	movq	%rdx, %rdi
	rep stosq
	leaq	-852(%rbp), %rdx
	leaq	-856(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -848(%rbp)
	jmp	.L2
.L3:
	leaq	-832(%rbp), %rdx
	movl	-848(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -848(%rbp)
.L2:
	movl	-852(%rbp), %eax
	cmpl	%eax, -848(%rbp)
	jl	.L3
	movl	$0, -848(%rbp)
	jmp	.L4
.L5:
	movl	-848(%rbp), %eax
	cltq
	movl	-832(%rbp,%rax,4), %eax
	cltq
	movl	$1, -416(%rbp,%rax,4)
	addl	$1, -848(%rbp)
.L4:
	movl	-852(%rbp), %eax
	cmpl	%eax, -848(%rbp)
	jl	.L5
	movl	-856(%rbp), %eax
	movl	%eax, -844(%rbp)
	movl	-856(%rbp), %eax
	movl	%eax, -840(%rbp)
.L9:
	movl	-844(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L6
	movl	-844(%rbp), %eax
	movl	%eax, -836(%rbp)
	jmp	.L7
.L6:
	movl	-840(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L8
	movl	-840(%rbp), %eax
	movl	%eax, -836(%rbp)
	jmp	.L7
.L8:
	subl	$1, -844(%rbp)
	addl	$1, -840(%rbp)
	jmp	.L9
.L7:
	movl	-836(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%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%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.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
	movl	$51, %ecx
	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
	subq	$848, %rsp
	.cfi_def_cfa_offset 896
	movq	%fs:40, %rax
	movq	%rax, 840(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	leaq	432(%rsp), %rbp
	movq	%rbp, %rdi
	rep stosq
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	leaq	16(%rsp), %r13
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r14
	movq	%r13, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %r12
	cmpl	%ebx, %eax
	jg	.L3
	testl	%eax, %eax
	jle	.L2
	leal	-1(%rax), %edx
	leaq	4(%r13), %rax
	leaq	(%rax,%rdx,4), %rcx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$4, %rax
.L4:
	movslq	0(%r13), %rdx
	movq	%rax, %r13
	movl	$1, 432(%rsp,%rdx,4)
	cmpq	%rcx, %rax
	jne	.L14
.L2:
	movslq	8(%rsp), %rax
	movl	432(%rsp,%rax,4), %esi
	movq	%rax, %r8
	testl	%esi, %esi
	je	.L5
	leal	-1(%rax), %eax
	addl	$1, %r8d
	cltq
	movslq	%r8d, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	0(%rbp,%rax,4), %ecx
	movl	%eax, %r8d
	movl	%edx, %esi
	testl	%ecx, %ecx
	je	.L5
	movl	0(%rbp,%rdx,4), %ecx
	subq	$1, %rax
	addq	$1, %rdx
	testl	%ecx, %ecx
	jne	.L6
	movl	%esi, %r8d
.L5:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	840(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$848, %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
.L15:
	.cfi_restore_state
	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%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.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
	movl	$51, %ecx
	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
	subq	$848, %rsp
	.cfi_def_cfa_offset 896
	movq	%fs:40, %rax
	movq	%rax, 840(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rdx
	leaq	8(%rsp), %rsi
	leaq	432(%rsp), %rbp
	movq	%rbp, %rdi
	rep stosq
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L2
	leaq	16(%rsp), %r13
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r14
	movq	%r13, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$4, %r12
	cmpl	%ebx, %eax
	jg	.L3
	testl	%eax, %eax
	jle	.L2
	leal	-1(%rax), %edx
	leaq	4(%r13), %rax
	leaq	(%rax,%rdx,4), %rcx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L14:
	addq	$4, %rax
.L4:
	movslq	0(%r13), %rdx
	movq	%rax, %r13
	movl	$1, 432(%rsp,%rdx,4)
	cmpq	%rcx, %rax
	jne	.L14
.L2:
	movslq	8(%rsp), %rax
	movl	432(%rsp,%rax,4), %esi
	movq	%rax, %r8
	testl	%esi, %esi
	je	.L5
	leal	-1(%rax), %eax
	addl	$1, %r8d
	cltq
	movslq	%r8d, %rdx
	.p2align 4,,10
	.p2align 3
.L6:
	movl	0(%rbp,%rax,4), %ecx
	movl	%eax, %r8d
	movl	%edx, %esi
	testl	%ecx, %ecx
	je	.L5
	movl	0(%rbp,%rdx,4), %ecx
	subq	$1, %rax
	addq	$1, %rdx
	testl	%ecx, %ecx
	jne	.L6
	movl	%esi, %r8d
.L5:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	840(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$848, %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
.L15:
	.cfi_restore_state
	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 x,n,p[101],q[102]={0},i,a,b,s;
    scanf("%d%d",&x,&n);
    for(i=0;i<n;i++)
        scanf("%d",&p[i]);
    for(i=0;i<n;i++)
        q[p[i]]=1;
    a=x; b=x;
    while(1){
        if(q[a]==0){
            s=a;
            break;
        }
        else if(q[b]==0){
            s=b;
            break;
        }
        a--; b++;
    }
    printf("%d\n",s);
    return 0;
}
6 2
4 7 10 6 5
 10 3
4 7 10 6 5
 6 2
4 7 10 8 5
 10 3
4 7 9 6 5
 15 3
7 5 3 6 5
 12 1
2 5 3 16 11
 2 1
4 5 0 16 4
 6 5
3 7 10 6 5
 19 5
4 7 10 6 5
 101 0

6
 9
 6
 10
 15
 12
 2
 4
 19
 101

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 x,n,p[101],q[102]={0},i,a,b,s;
    scanf("%d%d",&x,&n);
    for(i=0;i<n;i++)
        scanf("%d",&p[i]);
    for(i=0;i<n;i++)
        q[p[i]]=1;
    a=x; b=x;
    while(1){
        if(q[a]==0){
            s=a;
            break;
        }
        else if(q[b]==0){
            s=b;
            break;
        }
        a--; b++;
    }
    printf("%d\n",s);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.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	$864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-416(%rbp), %rdx
	movl	$0, %eax
	movl	$51, %ecx
	movq	%rdx, %rdi
	rep stosq
	leaq	-852(%rbp), %rdx
	leaq	-856(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -848(%rbp)
	jmp	.L2
.L3:
	leaq	-832(%rbp), %rdx
	movl	-848(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -848(%rbp)
.L2:
	movl	-852(%rbp), %eax
	cmpl	%eax, -848(%rbp)
	jl	.L3
	movl	$0, -848(%rbp)
	jmp	.L4
.L5:
	movl	-848(%rbp), %eax
	cltq
	movl	-832(%rbp,%rax,4), %eax
	cltq
	movl	$1, -416(%rbp,%rax,4)
	addl	$1, -848(%rbp)
.L4:
	movl	-852(%rbp), %eax
	cmpl	%eax, -848(%rbp)
	jl	.L5
	movl	-856(%rbp), %eax
	movl	%eax, -844(%rbp)
	movl	-856(%rbp), %eax
	movl	%eax, -840(%rbp)
.L9:
	movl	-844(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L6
	movl	-844(%rbp), %eax
	movl	%eax, -836(%rbp)
	jmp	.L7
.L6:
	movl	-840(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L8
	movl	-840(%rbp), %eax
	movl	%eax, -836(%rbp)
	jmp	.L7
.L8:
	subl	$1, -844(%rbp)
	addl	$1, -840(%rbp)
	jmp	.L9
.L7:
	movl	-836(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%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%d"
.LC1:
	.string	"%d"
.LC2:
	.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	$864, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-416(%rbp), %rdx
	movl	$0, %eax
	movl	$51, %ecx
	movq	%rdx, %rdi
	rep stosq
	leaq	-852(%rbp), %rdx
	leaq	-856(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -848(%rbp)
	jmp	.L2
.L3:
	leaq	-832(%rbp), %rdx
	movl	-848(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -848(%rbp)
.L2:
	movl	-852(%rbp), %eax
	cmpl	%eax, -848(%rbp)
	jl	.L3
	movl	$0, -848(%rbp)
	jmp	.L4
.L5:
	movl	-848(%rbp), %eax
	cltq
	movl	-832(%rbp,%rax,4), %eax
	cltq
	movl	$1, -416(%rbp,%rax,4)
	addl	$1, -848(%rbp)
.L4:
	movl	-852(%rbp), %eax
	cmpl	%eax, -848(%rbp)
	jl	.L5
	movl	-856(%rbp), %eax
	movl	%eax, -844(%rbp)
	movl	-856(%rbp), %eax
	movl	%eax, -840(%rbp)
.L9:
	movl	-844(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L6
	movl	-844(%rbp), %eax
	movl	%eax, -836(%rbp)
	jmp	.L7
.L6:
	movl	-840(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L8
	movl	-840(%rbp), %eax
	movl	%eax, -836(%rbp)
	jmp	.L7
.L8:
	subl	$1, -844(%rbp)
	addl	$1, -840(%rbp)
	jmp	.L9
.L7:
	movl	-836(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%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:
