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

```c
/*
 * FileName:     lower_bound_fix_2
 * CreatedDate:  2020-08-19 14:42:40 +0900
 * LastModified: 2020-08-19 15:14:07 +0900
 */

#include <stdio.h>
#include <stdlib.h>
void binary_search(int k, int *a, int n){
    int left = -1, right = n;
    while(left+1<right){
        int middle = (left+right) / 2;
        if(a[middle] < k){
            left = middle;
        }
        else{
            right = middle;
        }
    }
    printf("%d\n", right);
}


int main(void){
    int n;scanf("%d", &n);
    int *a = malloc(n*sizeof(int));
    for(int i=0; i<n; i++) scanf("%d", a+i);
    int q;scanf("%d", &q);
    for(int i=0; i<q; i++){
        int k;scanf("%d", &k);
//        if( k<=a[0] ){
//            printf("0\n");
//            continue;
//        }
        binary_search(k, a, n);
    }
    free(a);
    return 0;
}

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	binary_search
	.type	binary_search, @function
binary_search:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$-1, %ecx
	xorl	%r8d, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	leal	(%rcx,%rdx), %eax
	sarl	%eax
	movslq	%eax, %r9
	cmpl	%edi, (%rsi,%r9,4)
	jge	.L7
	movl	%eax, %ecx
	leal	1(%rax), %r8d
.L3:
	cmpl	%edx, %r8d
	jl	.L4
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE39:
	.size	binary_search, .-binary_search
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rbp, %rdi
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%ebx, %ebx
	jle	.L9
	movq	%rax, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebx, 12(%rsp)
	jg	.L10
.L9:
	leaq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	xorl	%ebx, %ebx
	leaq	20(%rsp), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	movl	20(%rsp), %edi
	xorl	%ecx, %ecx
	movl	$-1, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	leal	(%rdx,%r8), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r14,%rsi,4), %edi
	jle	.L21
	movl	%eax, %edx
	leal	1(%rax), %ecx
.L13:
	cmpl	%r8d, %ecx
	jl	.L14
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jg	.L15
.L11:
	movq	%r14, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$32, %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
.L21:
	.cfi_restore_state
	movl	%eax, %r8d
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	binary_search
	.type	binary_search, @function
binary_search:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$-1, %ecx
	xorl	%r8d, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	leal	(%rcx,%rdx), %eax
	sarl	%eax
	movslq	%eax, %r9
	cmpl	%edi, (%rsi,%r9,4)
	jge	.L7
	movl	%eax, %ecx
	leal	1(%rax), %r8d
.L3:
	cmpl	%edx, %r8d
	jl	.L4
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE39:
	.size	binary_search, .-binary_search
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rbp, %rdi
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%ebx, %ebx
	jle	.L9
	movq	%rax, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebx, 12(%rsp)
	jg	.L10
.L9:
	leaq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	xorl	%ebx, %ebx
	leaq	20(%rsp), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	movl	20(%rsp), %edi
	xorl	%ecx, %ecx
	movl	$-1, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	leal	(%rdx,%r8), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r14,%rsi,4), %edi
	jle	.L21
	movl	%eax, %edx
	leal	1(%rax), %ecx
.L13:
	cmpl	%r8d, %ecx
	jl	.L14
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jg	.L15
.L11:
	movq	%r14, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$32, %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
.L21:
	.cfi_restore_state
	movl	%eax, %r8d
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	binary_search
	.type	binary_search, @function
binary_search:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$-1, %ecx
	xorl	%r8d, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	leal	(%rcx,%rdx), %eax
	sarl	%eax
	movslq	%eax, %r9
	cmpl	%edi, (%rsi,%r9,4)
	jge	.L7
	movl	%eax, %ecx
	leal	1(%rax), %r8d
.L3:
	cmpl	%edx, %r8d
	jl	.L4
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE39:
	.size	binary_search, .-binary_search
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rbp, %rdi
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%ebx, %ebx
	jle	.L9
	movq	%rax, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebx, 12(%rsp)
	jg	.L10
.L9:
	leaq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	xorl	%ebx, %ebx
	leaq	20(%rsp), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	movl	20(%rsp), %edi
	xorl	%ecx, %ecx
	movl	$-1, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	leal	(%rdx,%r8), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r14,%rsi,4), %edi
	jle	.L21
	movl	%eax, %edx
	leal	1(%rax), %ecx
.L13:
	cmpl	%r8d, %ecx
	jl	.L14
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jg	.L15
.L11:
	movq	%r14, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$32, %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
.L21:
	.cfi_restore_state
	movl	%eax, %r8d
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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:
```
```c
/*
 * FileName:     lower_bound_fix_2
 * CreatedDate:  2020-08-19 14:42:40 +0900
 * LastModified: 2020-08-19 15:14:07 +0900
 */

#include <stdio.h>
#include <stdlib.h>
void binary_search(int k, int *a, int n){
    int left = -1, right = n;
    while(left+1<right){
        int middle = (left+right) / 2;
        if(a[middle] < k){
            left = middle;
        }
        else{
            right = middle;
        }
    }
    printf("%d\n", right);
}


int main(void){
    int n;scanf("%d", &n);
    int *a = malloc(n*sizeof(int));
    for(int i=0; i<n; i++) scanf("%d", a+i);
    int q;scanf("%d", &q);
    for(int i=0; i<q; i++){
        int k;scanf("%d", &k);
//        if( k<=a[0] ){
//            printf("0\n");
//            continue;
//        }
        binary_search(k, a, n);
    }
    free(a);
    return 0;
}

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

```c
/*
 * FileName:     lower_bound_fix_2
 * CreatedDate:  2020-08-19 14:42:40 +0900
 * LastModified: 2020-08-19 15:14:07 +0900
 */

#include <stdio.h>
#include <stdlib.h>
void binary_search(int k, int *a, int n){
    int left = -1, right = n;
    while(left+1<right){
        int middle = (left+right) / 2;
        if(a[middle] < k){
            left = middle;
        }
        else{
            right = middle;
        }
    }
    printf("%d\n", right);
}


int main(void){
    int n;scanf("%d", &n);
    int *a = malloc(n*sizeof(int));
    for(int i=0; i<n; i++) scanf("%d", a+i);
    int q;scanf("%d", &q);
    for(int i=0; i<q; i++){
        int k;scanf("%d", &k);
//        if( k<=a[0] ){
//            printf("0\n");
//            continue;
//        }
        binary_search(k, a, n);
    }
    free(a);
    return 0;
}

```

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 6
3
2
3
5
 4
1 0 2 6
3
2
3
5
 4
1 0 2 6
4
2
3
5
 4
1 0 2 4
3
2
3
5
 4
1 0 2 4
3
2
6
6
 4
1 0 0 4
3
2
6
6
 4
1 0 0 4
3
4
12
0
 4
1 0 0 5
3
7
23
0
 4
1 0 -1 5
3
7
40
0
 4
0 0 -1 9
3
7
40
0

1
3
3
 2
3
3
 2
3
3
3
 2
3
4
 2
4
4
 3
4
4
 3
4
0
 4
4
0
 4
4
0
 3
4
0

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

```c
/*
 * FileName:     lower_bound_fix_2
 * CreatedDate:  2020-08-19 14:42:40 +0900
 * LastModified: 2020-08-19 15:14:07 +0900
 */

#include <stdio.h>
#include <stdlib.h>
void binary_search(int k, int *a, int n){
    int left = -1, right = n;
    while(left+1<right){
        int middle = (left+right) / 2;
        if(a[middle] < k){
            left = middle;
        }
        else{
            right = middle;
        }
    }
    printf("%d\n", right);
}


int main(void){
    int n;scanf("%d", &n);
    int *a = malloc(n*sizeof(int));
    for(int i=0; i<n; i++) scanf("%d", a+i);
    int q;scanf("%d", &q);
    for(int i=0; i<q; i++){
        int k;scanf("%d", &k);
//        if( k<=a[0] ){
//            printf("0\n");
//            continue;
//        }
        binary_search(k, a, n);
    }
    free(a);
    return 0;
}

```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	binary_search
	.type	binary_search, @function
binary_search:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$-1, %ecx
	xorl	%r8d, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	leal	(%rcx,%rdx), %eax
	sarl	%eax
	movslq	%eax, %r9
	cmpl	%edi, (%rsi,%r9,4)
	jge	.L7
	movl	%eax, %ecx
	leal	1(%rax), %r8d
.L3:
	cmpl	%edx, %r8d
	jl	.L4
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE39:
	.size	binary_search, .-binary_search
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rbp, %rdi
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%ebx, %ebx
	jle	.L9
	movq	%rax, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebx, 12(%rsp)
	jg	.L10
.L9:
	leaq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	xorl	%ebx, %ebx
	leaq	20(%rsp), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	movl	20(%rsp), %edi
	xorl	%ecx, %ecx
	movl	$-1, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	leal	(%rdx,%r8), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r14,%rsi,4), %edi
	jle	.L21
	movl	%eax, %edx
	leal	1(%rax), %ecx
.L13:
	cmpl	%r8d, %ecx
	jl	.L14
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jg	.L15
.L11:
	movq	%r14, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$32, %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
.L21:
	.cfi_restore_state
	movl	%eax, %r8d
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	binary_search
	.type	binary_search, @function
binary_search:
.LFB39:
	.cfi_startproc
	endbr64
	movl	$-1, %ecx
	xorl	%r8d, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	leal	(%rcx,%rdx), %eax
	sarl	%eax
	movslq	%eax, %r9
	cmpl	%edi, (%rsi,%r9,4)
	jge	.L7
	movl	%eax, %ecx
	leal	1(%rax), %r8d
.L3:
	cmpl	%edx, %r8d
	jl	.L4
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%eax, %edx
	jmp	.L3
	.cfi_endproc
.LFE39:
	.size	binary_search, .-binary_search
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.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
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movq	%rbp, %rdi
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rdi
	movq	%rdi, %rbx
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%ebx, %ebx
	jle	.L9
	movq	%rax, %r12
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r12
	cmpl	%ebx, 12(%rsp)
	jg	.L10
.L9:
	leaq	16(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	16(%rsp), %eax
	testl	%eax, %eax
	jle	.L11
	xorl	%ebx, %ebx
	leaq	20(%rsp), %r13
	leaq	.LC0(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rbp, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %r8d
	movl	20(%rsp), %edi
	xorl	%ecx, %ecx
	movl	$-1, %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	leal	(%rdx,%r8), %eax
	sarl	%eax
	movslq	%eax, %rsi
	cmpl	(%r14,%rsi,4), %edi
	jle	.L21
	movl	%eax, %edx
	leal	1(%rax), %ecx
.L13:
	cmpl	%r8d, %ecx
	jl	.L14
	movl	%r8d, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jg	.L15
.L11:
	movq	%r14, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$32, %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
.L21:
	.cfi_restore_state
	movl	%eax, %r8d
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.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:
```