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>

long search(long bmax, long b[],long a){
  if(a < b[0]){
    return 0;
  }
  long low = 0;
  long high = bmax;
  long mid = (low + high)/2;
  while(high - 1 > low){
    if(a < b[mid]){
      high = mid;
      mid = (low + high)/2;
    }else{
      low = mid;
      mid = (low + high)/2;
    }
  }
  if(a < b[low]){
    return low;
  }else{
    return high;
  }
}

int main(){
  long n;
  long a[100000];
  scanf("%ld",&n);
  for(int i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  long b[100000];
  b[0] = a[n-1];
  long bmax = 0;
  long tmp;
  for(int i=n-2;i>=0;i--){
    if(b[bmax] <= a[i]){
      bmax += 1;
      b[bmax] = a[i];
    }else{
      tmp = search(bmax,b,a[i]);
      b[tmp] = a[i];
    }
  }
  printf("%ld\n",bmax+1);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	search
	.type	search, @function
search:
.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, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%rdx, -56(%rbp)
	movq	-48(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movq	$0, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
	jmp	.L4
.L6:
	movq	-8(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L5
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
	jmp	.L4
.L5:
	movq	-8(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
.L4:
	movq	-16(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -24(%rbp)
	jl	.L6
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L7
	movq	-24(%rbp), %rax
	jmp	.L3
.L7:
	movq	-16(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	search, .-search
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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
	leaq	-1597440(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2608, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1600040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1600048(%rbp)
	jmp	.L9
.L10:
	leaq	-1600016(%rbp), %rdx
	movl	-1600048(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -1600048(%rbp)
.L9:
	movl	-1600048(%rbp), %eax
	movslq	%eax, %rdx
	movq	-1600040(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L10
	movq	-1600040(%rbp), %rax
	subq	$1, %rax
	movq	-1600016(%rbp,%rax,8), %rax
	movq	%rax, -800016(%rbp)
	movq	$0, -1600032(%rbp)
	movq	-1600040(%rbp), %rax
	subl	$2, %eax
	movl	%eax, -1600044(%rbp)
	jmp	.L11
.L14:
	movq	-1600032(%rbp), %rax
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jg	.L12
	addq	$1, -1600032(%rbp)
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	movq	-1600032(%rbp), %rax
	movq	%rdx, -800016(%rbp,%rax,8)
	jmp	.L13
.L12:
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	leaq	-800016(%rbp), %rcx
	movq	-1600032(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	search
	movq	%rax, -1600024(%rbp)
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	movq	-1600024(%rbp), %rax
	movq	%rdx, -800016(%rbp,%rax,8)
.L13:
	subl	$1, -1600044(%rbp)
.L11:
	cmpl	$0, -1600044(%rbp)
	jns	.L14
	movq	-1600032(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rsi
	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	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.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	search
	.type	search, @function
search:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	xorl	%r8d, %r8d
	movq	%rdx, %rdi
	cmpq	%rdx, (%rsi)
	jg	.L1
	movq	%rcx, %rax
	shrq	$63, %rax
	addq	%rcx, %rax
	sarq	%rax
	cmpq	$1, %rcx
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L6:
	cmpq	(%rsi,%rax,8), %rdi
	jge	.L3
.L14:
	leaq	(%r8,%rax), %rcx
	movq	%rcx, %rdx
	shrq	$63, %rdx
	addq	%rcx, %rdx
	leaq	-1(%rax), %rcx
	sarq	%rdx
	cmpq	%r8, %rcx
	jle	.L13
	movq	%rax, %rcx
	movq	%rdx, %rax
	cmpq	(%rsi,%rax,8), %rdi
	jl	.L14
.L3:
	leaq	(%rcx,%rax), %r8
	movq	%r8, %rdx
	shrq	$63, %rdx
	addq	%r8, %rdx
	leaq	-1(%rcx), %r8
	sarq	%rdx
	cmpq	%rax, %r8
	jle	.L10
	movq	%rax, %r8
	movq	%rdx, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rcx, %r8
.L1:
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L13:
	cmpq	(%rsi,%r8,8), %rdi
	jl	.L1
	movq	%rax, %r8
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	search, .-search
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-1597440(%rsp), %r11
	.cfi_def_cfa 11, 1597472
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2592, %rsp
	.cfi_def_cfa_offset 1600064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 1600024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	testq	%rcx, %rcx
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	addq	$8, %rbp
	cmpq	%rbx, %rcx
	jg	.L17
.L16:
	movq	8(%rsp,%rcx,8), %rax
	movq	%rax, 800016(%rsp)
	subl	$2, %ecx
	js	.L28
	movslq	%ecx, %rcx
	xorl	%edx, %edx
	leaq	16(%rsp), %r10
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L36:
	addq	$1, %rdx
	subq	$1, %rcx
	movq	%rsi, 800016(%rsp,%rdx,8)
	testl	%ecx, %ecx
	js	.L18
.L40:
	movq	800016(%rsp,%rdx,8), %rax
.L26:
	movq	(%r10,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jge	.L36
	xorl	%edi, %edi
	cmpq	800016(%rsp), %rsi
	jl	.L21
	movq	%rdx, %rax
	sarq	%rax
	cmpq	$1, %rdx
	jle	.L30
	movq	%rdx, %r9
	.p2align 4,,10
	.p2align 3
.L25:
	cmpq	800016(%rsp,%rax,8), %rsi
	jge	.L22
.L38:
	leaq	(%rdi,%rax), %r8
	leaq	-1(%rax), %r9
	sarq	%r8
	cmpq	%rdi, %r9
	jle	.L37
	movq	%rax, %r9
	movq	%r8, %rax
	cmpq	800016(%rsp,%rax,8), %rsi
	jl	.L38
.L22:
	leaq	(%r9,%rax), %rdi
	sarq	%rdi
	movq	%rdi, %r8
	leaq	-1(%r9), %rdi
	cmpq	%rdi, %rax
	jge	.L32
	movq	%rax, %rdi
	movq	%r8, %rax
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L37:
	cmpq	800016(%rsp,%rdi,8), %rsi
	jge	.L39
.L21:
	movq	%rsi, 800016(%rsp,%rdi,8)
.L42:
	subq	$1, %rcx
	testl	%ecx, %ecx
	jns	.L40
.L18:
	addq	$1, %rdx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	1600024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$1600032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L32:
	.cfi_restore_state
	movq	%r9, %rdi
	movq	%rsi, 800016(%rsp,%rdi,8)
	jmp	.L42
.L30:
	movq	%rdx, %rdi
	jmp	.L21
.L28:
	xorl	%edx, %edx
	jmp	.L18
.L39:
	movq	%rax, %rdi
	jmp	.L21
.L41:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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
	.p2align 4
	.globl	search
	.type	search, @function
search:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rdi, %rcx
	xorl	%r8d, %r8d
	movq	%rdx, %rdi
	cmpq	%rdx, (%rsi)
	jg	.L1
	movq	%rcx, %rax
	shrq	$63, %rax
	addq	%rcx, %rax
	sarq	%rax
	cmpq	$1, %rcx
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L6:
	cmpq	(%rsi,%rax,8), %rdi
	jge	.L3
.L14:
	leaq	(%r8,%rax), %rcx
	movq	%rcx, %rdx
	shrq	$63, %rdx
	addq	%rcx, %rdx
	leaq	-1(%rax), %rcx
	sarq	%rdx
	cmpq	%r8, %rcx
	jle	.L13
	movq	%rax, %rcx
	movq	%rdx, %rax
	cmpq	(%rsi,%rax,8), %rdi
	jl	.L14
.L3:
	leaq	(%rcx,%rax), %r8
	movq	%r8, %rdx
	shrq	$63, %rdx
	addq	%r8, %rdx
	leaq	-1(%rcx), %r8
	sarq	%rdx
	cmpq	%rax, %r8
	jle	.L10
	movq	%rax, %r8
	movq	%rdx, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rcx, %r8
.L1:
	movq	%r8, %rax
	ret
	.p2align 4,,10
	.p2align 3
.L13:
	cmpq	(%rsi,%r8,8), %rdi
	jl	.L1
	movq	%rax, %r8
	jmp	.L1
	.cfi_endproc
.LFE23:
	.size	search, .-search
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	-1597440(%rsp), %r11
	.cfi_def_cfa 11, 1597472
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2592, %rsp
	.cfi_def_cfa_offset 1600064
	leaq	.LC0(%rip), %r12
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 1600024(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	testq	%rcx, %rcx
	jle	.L16
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	addq	$8, %rbp
	cmpq	%rbx, %rcx
	jg	.L17
.L16:
	movq	8(%rsp,%rcx,8), %rax
	movq	%rax, 800016(%rsp)
	subl	$2, %ecx
	js	.L28
	movslq	%ecx, %rcx
	xorl	%edx, %edx
	leaq	16(%rsp), %r10
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L36:
	addq	$1, %rdx
	subq	$1, %rcx
	movq	%rsi, 800016(%rsp,%rdx,8)
	testl	%ecx, %ecx
	js	.L18
.L40:
	movq	800016(%rsp,%rdx,8), %rax
.L26:
	movq	(%r10,%rcx,8), %rsi
	cmpq	%rax, %rsi
	jge	.L36
	xorl	%edi, %edi
	cmpq	800016(%rsp), %rsi
	jl	.L21
	movq	%rdx, %rax
	sarq	%rax
	cmpq	$1, %rdx
	jle	.L30
	movq	%rdx, %r9
	.p2align 4,,10
	.p2align 3
.L25:
	cmpq	800016(%rsp,%rax,8), %rsi
	jge	.L22
.L38:
	leaq	(%rdi,%rax), %r8
	leaq	-1(%rax), %r9
	sarq	%r8
	cmpq	%rdi, %r9
	jle	.L37
	movq	%rax, %r9
	movq	%r8, %rax
	cmpq	800016(%rsp,%rax,8), %rsi
	jl	.L38
.L22:
	leaq	(%r9,%rax), %rdi
	sarq	%rdi
	movq	%rdi, %r8
	leaq	-1(%r9), %rdi
	cmpq	%rdi, %rax
	jge	.L32
	movq	%rax, %rdi
	movq	%r8, %rax
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L37:
	cmpq	800016(%rsp,%rdi,8), %rsi
	jge	.L39
.L21:
	movq	%rsi, 800016(%rsp,%rdi,8)
.L42:
	subq	$1, %rcx
	testl	%ecx, %ecx
	jns	.L40
.L18:
	addq	$1, %rdx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	1600024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$1600032, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L32:
	.cfi_restore_state
	movq	%r9, %rdi
	movq	%rsi, 800016(%rsp,%rdi,8)
	jmp	.L42
.L30:
	movq	%rdx, %rdi
	jmp	.L21
.L28:
	xorl	%edx, %edx
	jmp	.L18
.L39:
	movq	%rax, %rdi
	jmp	.L21
.L41:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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>

long search(long bmax, long b[],long a){
  if(a < b[0]){
    return 0;
  }
  long low = 0;
  long high = bmax;
  long mid = (low + high)/2;
  while(high - 1 > low){
    if(a < b[mid]){
      high = mid;
      mid = (low + high)/2;
    }else{
      low = mid;
      mid = (low + high)/2;
    }
  }
  if(a < b[low]){
    return low;
  }else{
    return high;
  }
}

int main(){
  long n;
  long a[100000];
  scanf("%ld",&n);
  for(int i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  long b[100000];
  b[0] = a[n-1];
  long bmax = 0;
  long tmp;
  for(int i=n-2;i>=0;i--){
    if(b[bmax] <= a[i]){
      bmax += 1;
      b[bmax] = a[i];
    }else{
      tmp = search(bmax,b,a[i]);
      b[tmp] = a[i];
    }
  }
  printf("%ld\n",bmax+1);
  return 0;
}
4
0
-1
0
0
 4
1
0
0
0
 5
10
-1
1
13
3
 5
0
0
0
0
0
 5
1
4
5
7
14
 5
4
1
4
5
3
 4
1
-1
0
0
 5
4
1
4
9
3
 5
7
1
4
9
3
 4
-1
0
0
0

3
 4
 2
 5
 1
 3
 3
 3
 3
 3

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>

long search(long bmax, long b[],long a){
  if(a < b[0]){
    return 0;
  }
  long low = 0;
  long high = bmax;
  long mid = (low + high)/2;
  while(high - 1 > low){
    if(a < b[mid]){
      high = mid;
      mid = (low + high)/2;
    }else{
      low = mid;
      mid = (low + high)/2;
    }
  }
  if(a < b[low]){
    return low;
  }else{
    return high;
  }
}

int main(){
  long n;
  long a[100000];
  scanf("%ld",&n);
  for(int i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  long b[100000];
  b[0] = a[n-1];
  long bmax = 0;
  long tmp;
  for(int i=n-2;i>=0;i--){
    if(b[bmax] <= a[i]){
      bmax += 1;
      b[bmax] = a[i];
    }else{
      tmp = search(bmax,b,a[i]);
      b[tmp] = a[i];
    }
  }
  printf("%ld\n",bmax+1);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	search
	.type	search, @function
search:
.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, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%rdx, -56(%rbp)
	movq	-48(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movq	$0, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
	jmp	.L4
.L6:
	movq	-8(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L5
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
	jmp	.L4
.L5:
	movq	-8(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
.L4:
	movq	-16(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -24(%rbp)
	jl	.L6
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L7
	movq	-24(%rbp), %rax
	jmp	.L3
.L7:
	movq	-16(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	search, .-search
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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
	leaq	-1597440(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2608, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1600040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1600048(%rbp)
	jmp	.L9
.L10:
	leaq	-1600016(%rbp), %rdx
	movl	-1600048(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -1600048(%rbp)
.L9:
	movl	-1600048(%rbp), %eax
	movslq	%eax, %rdx
	movq	-1600040(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L10
	movq	-1600040(%rbp), %rax
	subq	$1, %rax
	movq	-1600016(%rbp,%rax,8), %rax
	movq	%rax, -800016(%rbp)
	movq	$0, -1600032(%rbp)
	movq	-1600040(%rbp), %rax
	subl	$2, %eax
	movl	%eax, -1600044(%rbp)
	jmp	.L11
.L14:
	movq	-1600032(%rbp), %rax
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jg	.L12
	addq	$1, -1600032(%rbp)
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	movq	-1600032(%rbp), %rax
	movq	%rdx, -800016(%rbp,%rax,8)
	jmp	.L13
.L12:
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	leaq	-800016(%rbp), %rcx
	movq	-1600032(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	search
	movq	%rax, -1600024(%rbp)
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	movq	-1600024(%rbp), %rax
	movq	%rdx, -800016(%rbp,%rax,8)
.L13:
	subl	$1, -1600044(%rbp)
.L11:
	cmpl	$0, -1600044(%rbp)
	jns	.L14
	movq	-1600032(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rsi
	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	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.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	search
	.type	search, @function
search:
.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, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%rdx, -56(%rbp)
	movq	-48(%rbp), %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L2
	movl	$0, %eax
	jmp	.L3
.L2:
	movq	$0, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
	jmp	.L4
.L6:
	movq	-8(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L5
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
	jmp	.L4
.L5:
	movq	-8(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-24(%rbp), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -8(%rbp)
.L4:
	movq	-16(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -24(%rbp)
	jl	.L6
	movq	-24(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	cmpq	%rax, -56(%rbp)
	jge	.L7
	movq	-24(%rbp), %rax
	jmp	.L3
.L7:
	movq	-16(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	search, .-search
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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
	leaq	-1597440(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2608, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1600040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1600048(%rbp)
	jmp	.L9
.L10:
	leaq	-1600016(%rbp), %rdx
	movl	-1600048(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -1600048(%rbp)
.L9:
	movl	-1600048(%rbp), %eax
	movslq	%eax, %rdx
	movq	-1600040(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L10
	movq	-1600040(%rbp), %rax
	subq	$1, %rax
	movq	-1600016(%rbp,%rax,8), %rax
	movq	%rax, -800016(%rbp)
	movq	$0, -1600032(%rbp)
	movq	-1600040(%rbp), %rax
	subl	$2, %eax
	movl	%eax, -1600044(%rbp)
	jmp	.L11
.L14:
	movq	-1600032(%rbp), %rax
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jg	.L12
	addq	$1, -1600032(%rbp)
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	movq	-1600032(%rbp), %rax
	movq	%rdx, -800016(%rbp,%rax,8)
	jmp	.L13
.L12:
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	leaq	-800016(%rbp), %rcx
	movq	-1600032(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	search
	movq	%rax, -1600024(%rbp)
	movl	-1600044(%rbp), %eax
	cltq
	movq	-1600016(%rbp,%rax,8), %rdx
	movq	-1600024(%rbp), %rax
	movq	%rdx, -800016(%rbp,%rax,8)
.L13:
	subl	$1, -1600044(%rbp)
.L11:
	cmpl	$0, -1600044(%rbp)
	jns	.L14
	movq	-1600032(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rsi
	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	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.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:
