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>
#define MAX 1000
#define VMAX 10000
#define TRUE 1
#define FALSE 0
 
int n,A[MAX],s;
int B[MAX],T[VMAX+1];
void sort(){
  int j,i,v;
  for(i=1;i<n;i++){
    v=B[i];
    j=i-1;
    while(j>=0 && B[j]>v){
      B[j+1]=B[j];
      j--;
    }
    B[j+1]=v;
  }
}
int smini(int x,int y){
  if(x>y)return y;
  else return x;
}
int solve(){
  int ans=0,V[MAX],i;
  int cur,S,m,an,v;
  for(i=0;i<n;i++){
    B[i]=A[i];
    V[i]=FALSE; // 0
  }
  sort();
  for(i=0;i<n;i++)T[B[i]]=i;
  for(i=0;i<n;i++){
    if(V[i])continue;
    cur=i;
    S=0;
    m=VMAX;
    an=0;
    while(1){
      V[cur]=TRUE;
      an++;
      v=A[cur];
      m=smini(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=smini(S+(an-2)*m,m+S+(an+1)*s);
}
  return ans;
}



int main(){
  int i,ans;
  scanf("%d",&n);
  s=VMAX;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    s=smini(s,A[i]);//minimam
}
  ans=solve();
  printf("%d\n",ans);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 4000
A:
	.zero	4000
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 4000
B:
	.zero	4000
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 40004
T:
	.zero	40004
	.text
	.globl	sort
	.type	sort, @function
sort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$1, -8(%rbp)
	jmp	.L2
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L3
.L5:
	movl	-12(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	subl	$1, -12(%rbp)
.L3:
	cmpl	$0, -12(%rbp)
	js	.L4
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
.L4:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	B(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L6
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	sort, .-sort
	.globl	smini
	.type	smini, @function
smini:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L8
	movl	-8(%rbp), %eax
	jmp	.L9
.L8:
	movl	-4(%rbp), %eax
.L9:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	smini, .-smini
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -4044(%rbp)
	movl	$0, -4040(%rbp)
	jmp	.L11
.L12:
	movl	-4040(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4040(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4040(%rbp), %eax
	cltq
	movl	$0, -4016(%rbp,%rax,4)
	addl	$1, -4040(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L12
	movl	$0, %eax
	call	sort
	movl	$0, -4040(%rbp)
	jmp	.L13
.L14:
	movl	-4040(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	T(%rip), %rdx
	movl	-4040(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -4040(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L14
	movl	$0, -4040(%rbp)
	jmp	.L15
.L21:
	movl	-4040(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L25
	movl	-4040(%rbp), %eax
	movl	%eax, -4036(%rbp)
	movl	$0, -4032(%rbp)
	movl	$10000, -4028(%rbp)
	movl	$0, -4024(%rbp)
.L20:
	movl	-4036(%rbp), %eax
	cltq
	movl	$1, -4016(%rbp,%rax,4)
	addl	$1, -4024(%rbp)
	movl	-4036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4020(%rbp)
	movl	-4020(%rbp), %edx
	movl	-4028(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	movl	%eax, -4028(%rbp)
	movl	-4020(%rbp), %eax
	addl	%eax, -4032(%rbp)
	movl	-4020(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4036(%rbp)
	movl	-4036(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L26
	jmp	.L20
.L26:
	nop
	movl	-4028(%rbp), %edx
	movl	-4032(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-4024(%rbp), %eax
	leal	1(%rax), %edx
	movl	s(%rip), %eax
	imull	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-4024(%rbp), %eax
	subl	$2, %eax
	imull	-4028(%rbp), %eax
	movl	%eax, %ecx
	movl	-4032(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	addl	%eax, -4044(%rbp)
	jmp	.L17
.L25:
	nop
.L17:
	addl	$1, -4040(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L21
	movl	-4044(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$10000, s(%rip)
	movl	$0, -8(%rbp)
	jmp	.L28
.L29:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	s(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	movl	%eax, s(%rip)
	addl	$1, -8(%rbp)
.L28:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L29
	movl	$0, %eax
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	sort
	.type	sort, @function
sort:
.LFB23:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r9d
	leaq	4+B(%rip), %r8
	movl	$1, %edi
	leaq	-4(%r8), %r10
	cmpl	$1, %r9d
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L6:
	movl	(%r8), %esi
	movl	%edi, %eax
	movq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L3:
	movl	-4(%rdx), %ecx
	cmpl	%esi, %ecx
	jle	.L4
	movl	%ecx, (%rdx)
	subq	$4, %rdx
	subl	$1, %eax
	jne	.L3
	xorl	%eax, %eax
.L4:
	cltq
	addl	$1, %edi
	addq	$4, %r8
	movl	%esi, (%r10,%rax,4)
	cmpl	%r9d, %edi
	jne	.L6
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	sort, .-sort
	.p2align 4
	.globl	smini
	.type	smini, @function
smini:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	smini, .-smini
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.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
	subq	$4016, %rsp
	.cfi_def_cfa_offset 4048
	movl	n(%rip), %ebx
	movq	%fs:40, %rax
	movq	%rax, 4008(%rsp)
	xorl	%eax, %eax
	testl	%ebx, %ebx
	jle	.L14
	movslq	%ebx, %r12
	leaq	B(%rip), %rbp
	leaq	A(%rip), %rsi
	salq	$2, %r12
	movq	%rbp, %rdi
	movq	%r12, %rdx
	call	memcpy@PLT
	movq	%rsp, %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rdi
	cmpl	$1, %ebx
	jle	.L14
	leaq	4(%rbp), %r9
	movl	$1, %r8d
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%r9), %esi
	movl	%r8d, %eax
	movq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L15:
	movl	-4(%rdx), %ecx
	cmpl	%ecx, %esi
	jge	.L16
	movl	%ecx, (%rdx)
	subq	$4, %rdx
	subl	$1, %eax
	jne	.L15
	xorl	%eax, %eax
.L16:
	cltq
	addl	$1, %r8d
	addq	$4, %r9
	movl	%esi, 0(%rbp,%rax,4)
	cmpl	%ebx, %r8d
	jne	.L18
	xorl	%eax, %eax
	leaq	T(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L19:
	movslq	0(%rbp,%rax,4), %rdx
	movl	%eax, (%r10,%rdx,4)
	addq	$1, %rax
	cmpl	%eax, %ebx
	jg	.L19
.L25:
	movl	s(%rip), %ebp
	xorl	%r9d, %r9d
	xorl	%r12d, %r12d
	leaq	A(%rip), %r11
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L22:
	addq	$1, %r9
	cmpl	%r9d, %ebx
	jle	.L13
.L24:
	movl	(%rdi,%r9,4), %edx
	movslq	%r9d, %rax
	testl	%edx, %edx
	jne	.L22
	xorl	%esi, %esi
	movl	$10000, %ecx
	.p2align 4,,10
	.p2align 3
.L23:
	movl	$1, (%rsp,%rax,4)
	movslq	(%r11,%rax,4), %rax
	movl	%edx, %r8d
	addl	$1, %edx
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	addl	%eax, %esi
	movslq	(%r10,%rax,4), %rax
	cmpl	$0, (%rsp,%rax,4)
	je	.L23
	leal	2(%r8), %edx
	subl	$1, %r8d
	leal	(%rcx,%rsi), %eax
	imull	%ebp, %edx
	imull	%ecx, %r8d
	addl	%eax, %edx
	leal	(%r8,%rsi), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addq	$1, %r9
	addl	%edx, %r12d
	cmpl	%r9d, %ebx
	jg	.L24
.L13:
	movq	4008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	addq	$4016, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	%r12d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	cmpl	$1, %ebx
	je	.L20
	xorl	%r12d, %r12d
	jmp	.L13
.L20:
	movslq	B(%rip), %rax
	leaq	T(%rip), %r10
	movq	%rsp, %rdi
	movl	$0, (%r10,%rax,4)
	jmp	.L25
.L33:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	solve, .-solve
	.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:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	movl	$10000, s(%rip)
	testl	%eax, %eax
	jle	.L35
	leaq	A(%rip), %rbx
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L36:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %edx
	movl	s(%rip), %eax
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, n(%rip)
	movl	%eax, s(%rip)
	jg	.L36
.L35:
	xorl	%eax, %eax
	call	solve
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	T
	.bss
	.align 32
	.type	T, @object
	.size	T, 40004
T:
	.zero	40004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 4000
B:
	.zero	4000
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 4000
A:
	.zero	4000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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	sort
	.type	sort, @function
sort:
.LFB23:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r9d
	leaq	4+B(%rip), %r8
	movl	$1, %edi
	leaq	-4(%r8), %r10
	cmpl	$1, %r9d
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L6:
	movl	(%r8), %esi
	movl	%edi, %eax
	movq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L3:
	movl	-4(%rdx), %ecx
	cmpl	%esi, %ecx
	jle	.L4
	movl	%ecx, (%rdx)
	subq	$4, %rdx
	subl	$1, %eax
	jne	.L3
	xorl	%eax, %eax
.L4:
	cltq
	addl	$1, %edi
	addq	$4, %r8
	movl	%esi, (%r10,%rax,4)
	cmpl	%r9d, %edi
	jne	.L6
.L1:
	ret
	.cfi_endproc
.LFE23:
	.size	sort, .-sort
	.p2align 4
	.globl	smini
	.type	smini, @function
smini:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	smini, .-smini
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.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
	subq	$4016, %rsp
	.cfi_def_cfa_offset 4048
	movl	n(%rip), %ebx
	movq	%fs:40, %rax
	movq	%rax, 4008(%rsp)
	xorl	%eax, %eax
	testl	%ebx, %ebx
	jle	.L14
	movslq	%ebx, %r12
	leaq	B(%rip), %rbp
	leaq	A(%rip), %rsi
	salq	$2, %r12
	movq	%rbp, %rdi
	movq	%r12, %rdx
	call	memcpy@PLT
	movq	%rsp, %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rdi
	cmpl	$1, %ebx
	jle	.L14
	leaq	4(%rbp), %r9
	movl	$1, %r8d
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%r9), %esi
	movl	%r8d, %eax
	movq	%r9, %rdx
	.p2align 4,,10
	.p2align 3
.L15:
	movl	-4(%rdx), %ecx
	cmpl	%ecx, %esi
	jge	.L16
	movl	%ecx, (%rdx)
	subq	$4, %rdx
	subl	$1, %eax
	jne	.L15
	xorl	%eax, %eax
.L16:
	cltq
	addl	$1, %r8d
	addq	$4, %r9
	movl	%esi, 0(%rbp,%rax,4)
	cmpl	%ebx, %r8d
	jne	.L18
	xorl	%eax, %eax
	leaq	T(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L19:
	movslq	0(%rbp,%rax,4), %rdx
	movl	%eax, (%r10,%rdx,4)
	addq	$1, %rax
	cmpl	%eax, %ebx
	jg	.L19
.L25:
	movl	s(%rip), %ebp
	xorl	%r9d, %r9d
	xorl	%r12d, %r12d
	leaq	A(%rip), %r11
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L22:
	addq	$1, %r9
	cmpl	%r9d, %ebx
	jle	.L13
.L24:
	movl	(%rdi,%r9,4), %edx
	movslq	%r9d, %rax
	testl	%edx, %edx
	jne	.L22
	xorl	%esi, %esi
	movl	$10000, %ecx
	.p2align 4,,10
	.p2align 3
.L23:
	movl	$1, (%rsp,%rax,4)
	movslq	(%r11,%rax,4), %rax
	movl	%edx, %r8d
	addl	$1, %edx
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	addl	%eax, %esi
	movslq	(%r10,%rax,4), %rax
	cmpl	$0, (%rsp,%rax,4)
	je	.L23
	leal	2(%r8), %edx
	subl	$1, %r8d
	leal	(%rcx,%rsi), %eax
	imull	%ebp, %edx
	imull	%ecx, %r8d
	addl	%eax, %edx
	leal	(%r8,%rsi), %eax
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addq	$1, %r9
	addl	%edx, %r12d
	cmpl	%r9d, %ebx
	jg	.L24
.L13:
	movq	4008(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	addq	$4016, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	movl	%r12d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L14:
	.cfi_restore_state
	cmpl	$1, %ebx
	je	.L20
	xorl	%r12d, %r12d
	jmp	.L13
.L20:
	movslq	B(%rip), %rax
	leaq	T(%rip), %r10
	movq	%rsp, %rdi
	movl	$0, (%r10,%rax,4)
	jmp	.L25
.L33:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	solve, .-solve
	.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:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	movl	$10000, s(%rip)
	testl	%eax, %eax
	jle	.L35
	leaq	A(%rip), %rbx
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L36:
	movq	%rbx, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	(%rbx), %edx
	movl	s(%rip), %eax
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, n(%rip)
	movl	%eax, s(%rip)
	jg	.L36
.L35:
	xorl	%eax, %eax
	call	solve
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	T
	.bss
	.align 32
	.type	T, @object
	.size	T, 40004
T:
	.zero	40004
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 4000
B:
	.zero	4000
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 4000
A:
	.zero	4000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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>
#define MAX 1000
#define VMAX 10000
#define TRUE 1
#define FALSE 0
 
int n,A[MAX],s;
int B[MAX],T[VMAX+1];
void sort(){
  int j,i,v;
  for(i=1;i<n;i++){
    v=B[i];
    j=i-1;
    while(j>=0 && B[j]>v){
      B[j+1]=B[j];
      j--;
    }
    B[j+1]=v;
  }
}
int smini(int x,int y){
  if(x>y)return y;
  else return x;
}
int solve(){
  int ans=0,V[MAX],i;
  int cur,S,m,an,v;
  for(i=0;i<n;i++){
    B[i]=A[i];
    V[i]=FALSE; // 0
  }
  sort();
  for(i=0;i<n;i++)T[B[i]]=i;
  for(i=0;i<n;i++){
    if(V[i])continue;
    cur=i;
    S=0;
    m=VMAX;
    an=0;
    while(1){
      V[cur]=TRUE;
      an++;
      v=A[cur];
      m=smini(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=smini(S+(an-2)*m,m+S+(an+1)*s);
}
  return ans;
}



int main(){
  int i,ans;
  scanf("%d",&n);
  s=VMAX;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    s=smini(s,A[i]);//minimam
}
  ans=solve();
  printf("%d\n",ans);

  return 0;
}
4
8 3 2 1
 5
0 5 3 4 2
 5
0 5 3 1 2
 5
1 8 3 4 2
 5
0 9 3 1 2
 5
1 8 3 4 0
 5
0 15 3 1 2
 5
1 5 3 8 2
 5
0 5 6 4 2
 5
0 5 3 1 4

14
 7
 12
 10
 16
 9
 22
 17
 19
 11

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>
#define MAX 1000
#define VMAX 10000
#define TRUE 1
#define FALSE 0
 
int n,A[MAX],s;
int B[MAX],T[VMAX+1];
void sort(){
  int j,i,v;
  for(i=1;i<n;i++){
    v=B[i];
    j=i-1;
    while(j>=0 && B[j]>v){
      B[j+1]=B[j];
      j--;
    }
    B[j+1]=v;
  }
}
int smini(int x,int y){
  if(x>y)return y;
  else return x;
}
int solve(){
  int ans=0,V[MAX],i;
  int cur,S,m,an,v;
  for(i=0;i<n;i++){
    B[i]=A[i];
    V[i]=FALSE; // 0
  }
  sort();
  for(i=0;i<n;i++)T[B[i]]=i;
  for(i=0;i<n;i++){
    if(V[i])continue;
    cur=i;
    S=0;
    m=VMAX;
    an=0;
    while(1){
      V[cur]=TRUE;
      an++;
      v=A[cur];
      m=smini(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=smini(S+(an-2)*m,m+S+(an+1)*s);
}
  return ans;
}



int main(){
  int i,ans;
  scanf("%d",&n);
  s=VMAX;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    s=smini(s,A[i]);//minimam
}
  ans=solve();
  printf("%d\n",ans);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 4000
A:
	.zero	4000
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 4000
B:
	.zero	4000
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 40004
T:
	.zero	40004
	.text
	.globl	sort
	.type	sort, @function
sort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$1, -8(%rbp)
	jmp	.L2
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L3
.L5:
	movl	-12(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	subl	$1, -12(%rbp)
.L3:
	cmpl	$0, -12(%rbp)
	js	.L4
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
.L4:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	B(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L6
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	sort, .-sort
	.globl	smini
	.type	smini, @function
smini:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L8
	movl	-8(%rbp), %eax
	jmp	.L9
.L8:
	movl	-4(%rbp), %eax
.L9:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	smini, .-smini
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -4044(%rbp)
	movl	$0, -4040(%rbp)
	jmp	.L11
.L12:
	movl	-4040(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4040(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4040(%rbp), %eax
	cltq
	movl	$0, -4016(%rbp,%rax,4)
	addl	$1, -4040(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L12
	movl	$0, %eax
	call	sort
	movl	$0, -4040(%rbp)
	jmp	.L13
.L14:
	movl	-4040(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	T(%rip), %rdx
	movl	-4040(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -4040(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L14
	movl	$0, -4040(%rbp)
	jmp	.L15
.L21:
	movl	-4040(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L25
	movl	-4040(%rbp), %eax
	movl	%eax, -4036(%rbp)
	movl	$0, -4032(%rbp)
	movl	$10000, -4028(%rbp)
	movl	$0, -4024(%rbp)
.L20:
	movl	-4036(%rbp), %eax
	cltq
	movl	$1, -4016(%rbp,%rax,4)
	addl	$1, -4024(%rbp)
	movl	-4036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4020(%rbp)
	movl	-4020(%rbp), %edx
	movl	-4028(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	movl	%eax, -4028(%rbp)
	movl	-4020(%rbp), %eax
	addl	%eax, -4032(%rbp)
	movl	-4020(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4036(%rbp)
	movl	-4036(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L26
	jmp	.L20
.L26:
	nop
	movl	-4028(%rbp), %edx
	movl	-4032(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-4024(%rbp), %eax
	leal	1(%rax), %edx
	movl	s(%rip), %eax
	imull	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-4024(%rbp), %eax
	subl	$2, %eax
	imull	-4028(%rbp), %eax
	movl	%eax, %ecx
	movl	-4032(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	addl	%eax, -4044(%rbp)
	jmp	.L17
.L25:
	nop
.L17:
	addl	$1, -4040(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L21
	movl	-4044(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$10000, s(%rip)
	movl	$0, -8(%rbp)
	jmp	.L28
.L29:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	s(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	movl	%eax, s(%rip)
	addl	$1, -8(%rbp)
.L28:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L29
	movl	$0, %eax
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	A
	.align 32
	.type	A, @object
	.size	A, 4000
A:
	.zero	4000
	.globl	s
	.align 4
	.type	s, @object
	.size	s, 4
s:
	.zero	4
	.globl	B
	.align 32
	.type	B, @object
	.size	B, 4000
B:
	.zero	4000
	.globl	T
	.align 32
	.type	T, @object
	.size	T, 40004
T:
	.zero	40004
	.text
	.globl	sort
	.type	sort, @function
sort:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$1, -8(%rbp)
	jmp	.L2
.L6:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L3
.L5:
	movl	-12(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	subl	$1, -12(%rbp)
.L3:
	cmpl	$0, -12(%rbp)
	js	.L4
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
.L4:
	movl	-12(%rbp), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	B(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L6
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	sort, .-sort
	.globl	smini
	.type	smini, @function
smini:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L8
	movl	-8(%rbp), %eax
	jmp	.L9
.L8:
	movl	-4(%rbp), %eax
.L9:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	smini, .-smini
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4048, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -4044(%rbp)
	movl	$0, -4040(%rbp)
	jmp	.L11
.L12:
	movl	-4040(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4040(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4040(%rbp), %eax
	cltq
	movl	$0, -4016(%rbp,%rax,4)
	addl	$1, -4040(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L12
	movl	$0, %eax
	call	sort
	movl	$0, -4040(%rbp)
	jmp	.L13
.L14:
	movl	-4040(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	B(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	T(%rip), %rdx
	movl	-4040(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -4040(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L14
	movl	$0, -4040(%rbp)
	jmp	.L15
.L21:
	movl	-4040(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L25
	movl	-4040(%rbp), %eax
	movl	%eax, -4036(%rbp)
	movl	$0, -4032(%rbp)
	movl	$10000, -4028(%rbp)
	movl	$0, -4024(%rbp)
.L20:
	movl	-4036(%rbp), %eax
	cltq
	movl	$1, -4016(%rbp,%rax,4)
	addl	$1, -4024(%rbp)
	movl	-4036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4020(%rbp)
	movl	-4020(%rbp), %edx
	movl	-4028(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	movl	%eax, -4028(%rbp)
	movl	-4020(%rbp), %eax
	addl	%eax, -4032(%rbp)
	movl	-4020(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4036(%rbp)
	movl	-4036(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L26
	jmp	.L20
.L26:
	nop
	movl	-4028(%rbp), %edx
	movl	-4032(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-4024(%rbp), %eax
	leal	1(%rax), %edx
	movl	s(%rip), %eax
	imull	%edx, %eax
	leal	(%rcx,%rax), %edx
	movl	-4024(%rbp), %eax
	subl	$2, %eax
	imull	-4028(%rbp), %eax
	movl	%eax, %ecx
	movl	-4032(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	addl	%eax, -4044(%rbp)
	jmp	.L17
.L25:
	nop
.L17:
	addl	$1, -4040(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -4040(%rbp)
	jl	.L21
	movl	-4044(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$10000, s(%rip)
	movl	$0, -8(%rbp)
	jmp	.L28
.L29:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	s(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	smini
	movl	%eax, s(%rip)
	addl	$1, -8(%rbp)
.L28:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L29
	movl	$0, %eax
	call	solve
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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:
