Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int a[100010],n;
int bs(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return a[l]==k;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d\n",bs(k));
	}
}

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bs
	.type	bs, @function
bs:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	%edi, a(%rip)
	jg	.L1
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	leaq	a(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r8,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L4:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L5
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpl	%edi, (%r8,%rdx,4)
	sete	%al
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	bs, .-bs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	a(%rip), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebp, n(%rip)
	jg	.L11
.L10:
	movq	%rsp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	je	.L12
	leaq	a(%rip), %r13
	leaq	4(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edi
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	cmpl	0(%r13), %edi
	jge	.L15
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	0(%r13,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L15:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L16
	movslq	%edx, %rdx
	cmpl	%edi, 0(%r13,%rdx,4)
	sete	%dl
	movzbl	%dl, %edx
.L13:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	jne	.L17
.L12:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400040
a:
	.zero	400040
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bs
	.type	bs, @function
bs:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	%edi, a(%rip)
	jg	.L1
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	leaq	a(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r8,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L4:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L5
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpl	%edi, (%r8,%rdx,4)
	sete	%al
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	bs, .-bs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	a(%rip), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebp, n(%rip)
	jg	.L11
.L10:
	movq	%rsp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	je	.L12
	leaq	a(%rip), %r13
	leaq	4(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edi
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	cmpl	0(%r13), %edi
	jge	.L15
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	0(%r13,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L15:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L16
	movslq	%edx, %rdx
	cmpl	%edi, 0(%r13,%rdx,4)
	sete	%dl
	movzbl	%dl, %edx
.L13:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	jne	.L17
.L12:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400040
a:
	.zero	400040
	.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
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bs
	.type	bs, @function
bs:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	%edi, a(%rip)
	jg	.L1
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	leaq	a(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r8,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L4:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L5
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpl	%edi, (%r8,%rdx,4)
	sete	%al
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	bs, .-bs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	a(%rip), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebp, n(%rip)
	jg	.L11
.L10:
	movq	%rsp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	je	.L12
	leaq	a(%rip), %r13
	leaq	4(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edi
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	cmpl	0(%r13), %edi
	jge	.L15
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	0(%r13,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L15:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L16
	movslq	%edx, %rdx
	cmpl	%edi, 0(%r13,%rdx,4)
	sete	%dl
	movzbl	%dl, %edx
.L13:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	jne	.L17
.L12:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400040
a:
	.zero	400040
	.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:
```
```c
#include <stdio.h>

int a[100010],n;
int bs(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return a[l]==k;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d\n",bs(k));
	}
}

```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int a[100010],n;
int bs(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return a[l]==k;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d\n",bs(k));
	}
}

```

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.
Optimized Assembly Code:

4
1 2 2 4
3
2
3
6
 4
1 1 2 4
3
0
3
8
 4
0 1 2 7
3
0
7
10
 4
0 1 2 6
3
0
3
6
 4
1 2 1 4
2
0
3
8
 4
0 1 2 7
1
0
5
3
 4
0 2 3 4
3
2
3
4
 4
0 1 2 7
1
-1
5
3
 4
0 2 1 3
3
-1
3
6
 4
0 2 2 1
3
4
3
0

1
0
0
 0
0
0
 1
1
0
 1
0
1
 0
0
 1
 1
1
1
 0
 0
1
0
 0
0
1

Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>

int a[100010],n;
int bs(int k){
	if(a[0]>k)return 0;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(a[m]<=k)l=m;
		else r=m;
	}
	return a[l]==k;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	int q;
	scanf("%d",&q);
	while(q--){
		int k;
		scanf("%d",&k);
		printf("%d\n",bs(k));
	}
}

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bs
	.type	bs, @function
bs:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	%edi, a(%rip)
	jg	.L1
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	leaq	a(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r8,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L4:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L5
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpl	%edi, (%r8,%rdx,4)
	sete	%al
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	bs, .-bs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	a(%rip), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebp, n(%rip)
	jg	.L11
.L10:
	movq	%rsp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	je	.L12
	leaq	a(%rip), %r13
	leaq	4(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edi
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	cmpl	0(%r13), %edi
	jge	.L15
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	0(%r13,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L15:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L16
	movslq	%edx, %rdx
	cmpl	%edi, 0(%r13,%rdx,4)
	sete	%dl
	movzbl	%dl, %edx
.L13:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	jne	.L17
.L12:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400040
a:
	.zero	400040
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bs
	.type	bs, @function
bs:
.LFB23:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	%edi, a(%rip)
	jg	.L1
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	leaq	a(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r8,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L4:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L5
	movslq	%edx, %rdx
	xorl	%eax, %eax
	cmpl	%edi, (%r8,%rdx,4)
	sete	%al
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	bs, .-bs
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L10
	leaq	a(%rip), %r12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r12, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebp, n(%rip)
	jg	.L11
.L10:
	movq	%rsp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	je	.L12
	leaq	a(%rip), %r13
	leaq	4(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbx, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %edi
	movl	n(%rip), %ecx
	xorl	%edx, %edx
	cmpl	0(%r13), %edi
	jge	.L15
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L16:
	leal	(%rdx,%rcx), %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	0(%r13,%rsi,4), %edi
	cmovl	%eax, %ecx
	cmovge	%eax, %edx
.L15:
	movl	%ecx, %eax
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L16
	movslq	%edx, %rdx
	cmpl	%edi, 0(%r13,%rdx,4)
	sete	%dl
	movzbl	%dl, %edx
.L13:
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, (%rsp)
	testl	%eax, %eax
	jne	.L17
.L12:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	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
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400040
a:
	.zero	400040
	.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:
```