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>
#include<stdbool.h>
#include<math.h>
#define MAX 1000
#define VMAX 10000
int n,A[MAX],s;
int B[MAX], T[VMAX+1];
 
void swap(int *a,int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
void qsort(int X[], int left, int right){
  int i,j;
  int pivot;
  i=left;j=right;
  pivot = X[(left+right)/2];
 
  while(1) {
    while(X[i]<pivot)i++;
    while(pivot<X[j])j--;
    if(i>=j) break;
 
    swap(&X[i],&X[j]);
    i++;  j--;
  }
  if(left < i-1) qsort(X,left,i-1);
  if(j+1<right) qsort(X,j+1,right);
}
int solve() {
  int i;
  int ans = 0;
 
  bool V[MAX];
  for(i=0;i<n;i++){
    B[i] = A[i];
    V[i]=false;
  }
  qsort(B,0,n-1);
  for(i=0;i<n;i++) T[B[i]] = i;
  for(i=0;i<n;i++) {
    if(V[i]) continue;
    int cur=i;
    int S=0;
    int m=VMAX;
    int an=0;
    while(1) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = fmin(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=fmin(S+(an - 2) * m , m+S+(an+1)*s);
 
  }
  return ans;
}
int main(){
  int i;
  scanf("%d",&n);
  s=VMAX;
  for(i=0;i<n;i++) {
    scanf("%d",&A[i]);
    s=fmin(s , A[i]);
  }
  int 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	swap
	.type	swap, @function
swap:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.globl	qsort
	.type	qsort, @function
qsort:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L3
.L4:
	addl	$1, -12(%rbp)
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L4
	jmp	.L5
.L6:
	subl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L13
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	addl	$1, -12(%rbp)
	subl	$1, -8(%rbp)
	jmp	.L3
.L13:
	nop
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -28(%rbp)
	jge	.L10
	movl	-12(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	qsort
.L10:
	movl	-8(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jle	.L14
	movl	-8(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	qsort
.L14:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	qsort, .-qsort
	.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	$1056, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1032(%rbp)
	movl	$0, -1036(%rbp)
	jmp	.L16
.L17:
	movl	-1036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-1036(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-1036(%rbp), %eax
	cltq
	movb	$0, -1008(%rbp,%rax)
	addl	$1, -1036(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L17
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, %edx
	movl	$0, %esi
	leaq	B(%rip), %rax
	movq	%rax, %rdi
	call	qsort
	movl	$0, -1036(%rbp)
	jmp	.L18
.L19:
	movl	-1036(%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	-1036(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -1036(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L19
	movl	$0, -1036(%rbp)
	jmp	.L20
.L26:
	movl	-1036(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L30
	movl	-1036(%rbp), %eax
	movl	%eax, -1028(%rbp)
	movl	$0, -1024(%rbp)
	movl	$10000, -1020(%rbp)
	movl	$0, -1016(%rbp)
.L25:
	movl	-1028(%rbp), %eax
	cltq
	movb	$1, -1008(%rbp,%rax)
	addl	$1, -1016(%rbp)
	movl	-1028(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -1012(%rbp)
	pxor	%xmm0, %xmm0
	cvtsi2sdl	-1012(%rbp), %xmm0
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-1020(%rbp), %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -1020(%rbp)
	movl	-1012(%rbp), %eax
	addl	%eax, -1024(%rbp)
	movl	-1012(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -1028(%rbp)
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L31
	jmp	.L25
.L31:
	nop
	pxor	%xmm3, %xmm3
	cvtsi2sdl	-1032(%rbp), %xmm3
	movsd	%xmm3, -1048(%rbp)
	movl	-1020(%rbp), %edx
	movl	-1024(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-1016(%rbp), %eax
	leal	1(%rax), %edx
	movl	s(%rip), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	-1016(%rbp), %eax
	subl	$2, %eax
	imull	-1020(%rbp), %eax
	movl	%eax, %edx
	movl	-1024(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm4, %xmm4
	cvtsi2sdl	%eax, %xmm4
	movq	%xmm4, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	addsd	-1048(%rbp), %xmm0
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -1032(%rbp)
	jmp	.L22
.L30:
	nop
.L22:
	addl	$1, -1036(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L26
	movl	-1032(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	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	.L33
.L34:
	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), %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	s(%rip), %eax
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, s(%rip)
	addl	$1, -8(%rbp)
.L33:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L34
	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	swap
	.type	swap, @function
swap:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE23:
	.size	swap, .-swap
	.p2align 4
	.globl	qsort
	.type	qsort, @function
qsort:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edx, %rax
	movq	%rdi, %r9
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movl	%eax, 56(%rsp)
	movq	%rax, 96(%rsp)
.L10:
	movl	56(%rsp), %ecx
	movl	%r14d, %edx
	movslq	%r14d, %rbx
	movl	%r14d, %r8d
	leaq	(%r9,%rbx,4), %rdi
	addl	%ecx, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	96(%rsp), %rax
.L4:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %r10
	movl	(%r10), %edx
	cmpl	%esi, %r11d
	jl	.L5
	cmpl	%edx, %esi
	jge	.L6
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rax, %r10
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%esi, %edx
	jg	.L7
.L6:
	cmpl	%ecx, %r8d
	jge	.L8
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r10)
	movslq	%ecx, %rax
.L5:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L4
.L8:
	leal	-1(%r8), %eax
	movl	%ecx, 60(%rsp)
	movl	%eax, 28(%rsp)
	cmpl	%r14d, %eax
	jg	.L104
.L18:
	movl	60(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	56(%rsp), %eax
	jl	.L10
	addq	$136, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L104:
	.cfi_restore_state
	cltq
	movq	%rax, 88(%rsp)
.L9:
	movl	28(%rsp), %ecx
	movl	%r14d, %r8d
	leaq	(%r9,%rbx,4), %rdi
	movl	%ecx, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	88(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %r10
	movl	(%r10), %edx
	cmpl	%r11d, %esi
	jg	.L13
	cmpl	%edx, %esi
	jge	.L14
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rax, %r10
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%edx, %esi
	jl	.L15
.L14:
	cmpl	%ecx, %r8d
	jge	.L16
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r10)
	movslq	%ecx, %rax
.L13:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L12
.L16:
	leal	-1(%r8), %eax
	movl	%ecx, 64(%rsp)
	movl	%eax, 32(%rsp)
	cmpl	%eax, %r14d
	jl	.L105
.L25:
	movl	64(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 28(%rsp)
	jle	.L18
	movslq	%eax, %rbx
	jmp	.L9
.L105:
	cltq
	movq	%r9, %r8
	movq	%rax, 80(%rsp)
.L17:
	movl	32(%rsp), %ecx
	movl	%r14d, %r10d
	leaq	(%r8,%rbx,4), %rdi
	movl	%ecx, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r8,%rax,4), %esi
	movq	80(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%rdi), %r11d
	leaq	(%r8,%rax,4), %r9
	movl	(%r9), %edx
	cmpl	%r11d, %esi
	jg	.L20
	cmpl	%edx, %esi
	jge	.L21
	leaq	-4(%r8,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%rax, %r9
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%edx, %esi
	jl	.L22
.L21:
	cmpl	%ecx, %r10d
	jge	.L23
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r9)
	movslq	%ecx, %rax
.L20:
	addq	$4, %rdi
	addl	$1, %r10d
	jmp	.L19
.L23:
	leal	-1(%r10), %eax
	movl	%ecx, 68(%rsp)
	movl	%eax, 36(%rsp)
	cmpl	%eax, %r14d
	jl	.L106
	movl	68(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 32(%rsp)
	jle	.L96
.L116:
	movslq	%eax, %rbx
	jmp	.L17
.L106:
	cltq
	movq	%r8, %r9
	movq	%rax, 72(%rsp)
.L24:
	movl	36(%rsp), %ecx
	movl	%r14d, %r8d
	leaq	(%r9,%rbx,4), %rdi
	movl	%ecx, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	72(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L26:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %r10
	movl	(%r10), %edx
	cmpl	%r11d, %esi
	jg	.L27
	cmpl	%edx, %esi
	jge	.L28
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rax, %r10
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%edx, %esi
	jl	.L29
.L28:
	cmpl	%ecx, %r8d
	jge	.L30
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r10)
	movslq	%ecx, %rax
.L27:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L26
.L30:
	leal	-1(%r8), %eax
	movl	%ecx, 104(%rsp)
	movl	%eax, 24(%rsp)
	cmpl	%eax, %r14d
	jl	.L107
	movl	104(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 36(%rsp)
	jle	.L97
.L115:
	movslq	%eax, %rbx
	jmp	.L24
.L107:
	cltq
	movq	%r9, %r15
	movq	%rax, 48(%rsp)
.L31:
	movl	24(%rsp), %r8d
	movl	%r14d, %r10d
	leaq	(%r15,%rbx,4), %rdi
	movl	%r8d, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r15,%rax,4), %esi
	movq	48(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L33:
	movl	(%rdi), %r9d
	leaq	(%r15,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r9d, %esi
	jg	.L34
	cmpl	%edx, %esi
	jge	.L35
	leaq	-4(%r15,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L36:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r8d
	cmpl	%edx, %esi
	jl	.L36
.L35:
	cmpl	%r8d, %r10d
	jge	.L37
	movl	%edx, (%rdi)
	subl	$1, %r8d
	movl	%r9d, (%rcx)
	movslq	%r8d, %rax
.L34:
	addq	$4, %rdi
	addl	$1, %r10d
	jmp	.L33
.L37:
	leal	-1(%r10), %eax
	movl	%eax, 12(%rsp)
	cmpl	%eax, %r14d
	jl	.L108
	leal	1(%r8), %eax
	movl	%eax, %r14d
	cmpl	%eax, 24(%rsp)
	jle	.L98
.L114:
	movslq	%eax, %rbx
	jmp	.L31
.L108:
	cltq
	movl	%r8d, 108(%rsp)
	movq	%rax, 40(%rsp)
.L38:
	movl	12(%rsp), %r9d
	movl	%r14d, %r8d
	leaq	(%r15,%rbx,4), %rdi
	movl	%r9d, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r15,%rax,4), %esi
	movq	40(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L40:
	movl	(%rdi), %r10d
	leaq	(%r15,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r10d, %esi
	jg	.L41
	cmpl	%edx, %esi
	jge	.L42
	leaq	-4(%r15,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L43:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r9d
	cmpl	%edx, %esi
	jl	.L43
.L42:
	cmpl	%r9d, %r8d
	jge	.L44
	movl	%edx, (%rdi)
	subl	$1, %r9d
	movl	%r10d, (%rcx)
	movslq	%r9d, %rax
.L41:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L40
.L44:
	leal	-1(%r8), %eax
	movl	%eax, 8(%rsp)
	cmpl	%eax, %r14d
	jl	.L109
	leal	1(%r9), %eax
	movl	%eax, %r14d
	cmpl	%eax, 12(%rsp)
	jle	.L99
.L113:
	movslq	%eax, %rbx
	jmp	.L38
.L109:
	cltq
	movl	%r9d, 112(%rsp)
	movl	%r14d, %r10d
	movq	%rax, 16(%rsp)
.L45:
	movl	8(%rsp), %r12d
	leaq	(%r15,%rbx,4), %rdi
	movl	%r10d, %r14d
	leal	(%r12,%r10), %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r15,%rax,4), %esi
	movq	16(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L47:
	movl	(%rdi), %r8d
	leaq	(%r15,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r8d, %esi
	jg	.L48
	cmpl	%edx, %esi
	jge	.L49
	leaq	-4(%r15,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L50:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r12d
	cmpl	%edx, %esi
	jl	.L50
.L49:
	cmpl	%r12d, %r14d
	jge	.L51
	movl	%edx, (%rdi)
	subl	$1, %r12d
	movl	%r8d, (%rcx)
	movslq	%r12d, %rax
.L48:
	addq	$4, %rdi
	addl	$1, %r14d
	jmp	.L47
.L51:
	subl	$1, %r14d
	cmpl	%r14d, %r10d
	jl	.L110
	leal	1(%r12), %r10d
	cmpl	%r10d, 8(%rsp)
	jle	.L100
.L112:
	movslq	%r10d, %rbx
	jmp	.L45
.L110:
	movl	%r12d, 116(%rsp)
	movslq	%r14d, %rax
	movq	%r15, %r9
	movq	%rax, %r15
.L52:
	leal	(%r14,%r10), %edx
	leaq	(%r9,%rbx,4), %rdi
	movl	%r10d, %r13d
	movl	%r14d, %ebp
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	%r15, %rax
	.p2align 4,,10
	.p2align 3
.L54:
	movl	(%rdi), %r8d
	leaq	(%r9,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r8d, %esi
	jg	.L55
	cmpl	%edx, %esi
	jge	.L56
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L57:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ebp
	cmpl	%edx, %esi
	jl	.L57
.L56:
	cmpl	%ebp, %r13d
	jge	.L58
	movl	%edx, (%rdi)
	subl	$1, %ebp
	movl	%r8d, (%rcx)
	movslq	%ebp, %rax
.L55:
	addq	$4, %rdi
	addl	$1, %r13d
	jmp	.L54
.L58:
	subl	$1, %r13d
	movslq	%r13d, %r12
	cmpl	%r13d, %r10d
	jl	.L59
.L67:
	leal	1(%rbp), %r10d
	cmpl	%r10d, %r14d
	jle	.L101
	movslq	%r10d, %rbx
	jmp	.L52
	.p2align 4,,10
	.p2align 3
.L65:
	leal	-1(%r8), %edx
	cmpl	%edx, %r10d
	jl	.L111
.L66:
	leal	1(%rbx), %r10d
	cmpl	%r10d, %r13d
	jle	.L67
	movslq	%r10d, %rbx
.L59:
	leal	0(%r13,%r10), %edx
	leaq	(%r9,%rbx,4), %rdi
	movl	%r10d, %r8d
	movl	%r13d, %ebx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	%r12, %rax
	.p2align 4,,10
	.p2align 3
.L61:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r11d, %esi
	jg	.L62
	cmpl	%edx, %esi
	jge	.L63
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L64:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ebx
	cmpl	%edx, %esi
	jl	.L64
.L63:
	cmpl	%ebx, %r8d
	jge	.L65
	movl	%edx, (%rdi)
	subl	$1, %ebx
	movl	%r11d, (%rcx)
	movslq	%ebx, %rax
.L62:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L61
.L101:
	movl	116(%rsp), %r12d
	movq	%r9, %r15
	leal	1(%r12), %r10d
	cmpl	%r10d, 8(%rsp)
	jg	.L112
.L100:
	movl	112(%rsp), %r9d
	leal	1(%r9), %eax
	movl	%eax, %r14d
	cmpl	%eax, 12(%rsp)
	jg	.L113
.L99:
	movl	108(%rsp), %r8d
	leal	1(%r8), %eax
	movl	%eax, %r14d
	cmpl	%eax, 24(%rsp)
	jg	.L114
.L98:
	movl	104(%rsp), %eax
	movq	%r15, %r9
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 36(%rsp)
	jg	.L115
.L97:
	movl	68(%rsp), %eax
	movq	%r9, %r8
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 32(%rsp)
	jg	.L116
.L96:
	movq	%r8, %r9
	jmp	.L25
.L111:
	movq	%r9, %rdi
	movl	%r10d, %esi
	movq	%r9, 120(%rsp)
	call	qsort
	movq	120(%rsp), %r9
	jmp	.L66
	.cfi_endproc
.LFE24:
	.size	qsort, .-qsort
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1048, %rsp
	.cfi_def_cfa_offset 1104
	movl	n(%rip), %r12d
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	testl	%r12d, %r12d
	jle	.L140
	movslq	%r12d, %r13
	leaq	B(%rip), %rbp
	leaq	A(%rip), %rsi
	leaq	0(,%r13,4), %rdx
	movq	%rbp, %rdi
	call	memcpy@PLT
	leaq	32(%rsp), %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	memset@PLT
.L120:
	subl	$1, %r12d
	xorl	%r10d, %r10d
	movslq	%r12d, %r13
.L119:
	leal	(%r12,%r10), %edx
	movl	%r10d, %r8d
	movl	%r12d, %ebx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	0(%rbp,%rax,4), %esi
	movslq	%r10d, %rax
	leaq	0(%rbp,%rax,4), %rdi
	movq	%r13, %rax
	.p2align 4,,10
	.p2align 3
.L121:
	movl	(%rdi), %r9d
	leaq	0(%rbp,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r9d, %esi
	jg	.L122
	cmpl	%edx, %esi
	jge	.L123
	leaq	-4(%rbp,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L124:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ebx
	cmpl	%edx, %esi
	jl	.L124
.L123:
	cmpl	%ebx, %r8d
	jge	.L125
	movl	%edx, (%rdi)
	subl	$1, %ebx
	movl	%r9d, (%rcx)
	movslq	%ebx, %rax
.L122:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L121
	.p2align 4,,10
	.p2align 3
.L125:
	leal	-1(%r8), %edx
	cmpl	%edx, %r10d
	jl	.L141
.L126:
	leal	1(%rbx), %r10d
	cmpl	%r10d, %r12d
	jg	.L119
	movl	n(%rip), %r15d
	testl	%r15d, %r15d
	jle	.L133
	movslq	%r15d, %rax
	leaq	T(%rip), %r13
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L128:
	movslq	0(%rbp,%rax,4), %rdx
	movl	%eax, 0(%r13,%rdx,4)
	addq	$1, %rax
	cmpq	%rax, 8(%rsp)
	jne	.L128
	movl	s(%rip), %eax
	movl	$0, 24(%rsp)
	xorl	%r12d, %r12d
	movl	%eax, 28(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 16(%rsp)
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L129:
	addq	$1, %r12
	cmpq	8(%rsp), %r12
	je	.L117
.L131:
	movq	16(%rsp), %rdi
	movslq	%r12d, %rax
	cmpb	$0, (%rdi,%r12)
	jne	.L129
	xorl	%r15d, %r15d
	movl	$10000, %ecx
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L130:
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	movb	$1, 32(%rsp,%rax)
	movl	%r15d, %ebp
	cvtsi2sdl	%ecx, %xmm0
	leaq	A(%rip), %rdi
	addl	$1, %r15d
	movl	(%rdi,%rax,4), %r14d
	cvtsi2sdl	%r14d, %xmm1
	addl	%r14d, %ebx
	call	fmin@PLT
	movslq	%r14d, %rax
	movslq	0(%r13,%rax,4), %rax
	cvttsd2sil	%xmm0, %ecx
	cmpb	$0, 32(%rsp,%rax)
	je	.L130
	leal	2(%rbp), %edx
	subl	$1, %ebp
	leal	(%rcx,%rbx), %eax
	addq	$1, %r12
	imull	%ecx, %ebp
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	imull	28(%rsp), %edx
	addl	%eax, %edx
	leal	0(%rbp,%rbx), %eax
	cvtsi2sdl	%eax, %xmm0
	cvtsi2sdl	%edx, %xmm1
	call	fmin@PLT
	movapd	%xmm0, %xmm1
	pxor	%xmm0, %xmm0
	cvtsi2sdl	24(%rsp), %xmm0
	addsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %eax
	movl	%eax, 24(%rsp)
	cmpq	8(%rsp), %r12
	jne	.L131
.L117:
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L142
	movl	24(%rsp), %eax
	addq	$1048, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L141:
	.cfi_restore_state
	movl	%r10d, %esi
	movq	%rbp, %rdi
	call	qsort
	jmp	.L126
.L140:
	leaq	B(%rip), %rbp
	jmp	.L120
.L133:
	movl	$0, 24(%rsp)
	jmp	.L117
.L142:
	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	.L144
	leaq	A(%rip), %rbx
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L145:
	movq	%rbx, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	addq	$4, %rbx
	cvtsi2sdl	-4(%rbx), %xmm1
	cvtsi2sdl	s(%rip), %xmm0
	call	fmin@PLT
	cmpl	%ebp, n(%rip)
	cvttsd2sil	%xmm0, %eax
	movl	%eax, s(%rip)
	jg	.L145
.L144:
	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	swap
	.type	swap, @function
swap:
.LFB23:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE23:
	.size	swap, .-swap
	.p2align 4
	.globl	qsort
	.type	qsort, @function
qsort:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edx, %rax
	movq	%rdi, %r9
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
	movl	%eax, 56(%rsp)
	movq	%rax, 96(%rsp)
.L10:
	movl	56(%rsp), %ecx
	movl	%r14d, %edx
	movslq	%r14d, %rbx
	movl	%r14d, %r8d
	leaq	(%r9,%rbx,4), %rdi
	addl	%ecx, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	96(%rsp), %rax
.L4:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %r10
	movl	(%r10), %edx
	cmpl	%esi, %r11d
	jl	.L5
	cmpl	%edx, %esi
	jge	.L6
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rax, %r10
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%esi, %edx
	jg	.L7
.L6:
	cmpl	%ecx, %r8d
	jge	.L8
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r10)
	movslq	%ecx, %rax
.L5:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L4
.L8:
	leal	-1(%r8), %eax
	movl	%ecx, 60(%rsp)
	movl	%eax, 28(%rsp)
	cmpl	%r14d, %eax
	jg	.L104
.L18:
	movl	60(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	56(%rsp), %eax
	jl	.L10
	addq	$136, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L104:
	.cfi_restore_state
	cltq
	movq	%rax, 88(%rsp)
.L9:
	movl	28(%rsp), %ecx
	movl	%r14d, %r8d
	leaq	(%r9,%rbx,4), %rdi
	movl	%ecx, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	88(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %r10
	movl	(%r10), %edx
	cmpl	%r11d, %esi
	jg	.L13
	cmpl	%edx, %esi
	jge	.L14
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rax, %r10
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%edx, %esi
	jl	.L15
.L14:
	cmpl	%ecx, %r8d
	jge	.L16
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r10)
	movslq	%ecx, %rax
.L13:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L12
.L16:
	leal	-1(%r8), %eax
	movl	%ecx, 64(%rsp)
	movl	%eax, 32(%rsp)
	cmpl	%eax, %r14d
	jl	.L105
.L25:
	movl	64(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 28(%rsp)
	jle	.L18
	movslq	%eax, %rbx
	jmp	.L9
.L105:
	cltq
	movq	%r9, %r8
	movq	%rax, 80(%rsp)
.L17:
	movl	32(%rsp), %ecx
	movl	%r14d, %r10d
	leaq	(%r8,%rbx,4), %rdi
	movl	%ecx, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r8,%rax,4), %esi
	movq	80(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%rdi), %r11d
	leaq	(%r8,%rax,4), %r9
	movl	(%r9), %edx
	cmpl	%r11d, %esi
	jg	.L20
	cmpl	%edx, %esi
	jge	.L21
	leaq	-4(%r8,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%rax, %r9
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%edx, %esi
	jl	.L22
.L21:
	cmpl	%ecx, %r10d
	jge	.L23
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r9)
	movslq	%ecx, %rax
.L20:
	addq	$4, %rdi
	addl	$1, %r10d
	jmp	.L19
.L23:
	leal	-1(%r10), %eax
	movl	%ecx, 68(%rsp)
	movl	%eax, 36(%rsp)
	cmpl	%eax, %r14d
	jl	.L106
	movl	68(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 32(%rsp)
	jle	.L96
.L116:
	movslq	%eax, %rbx
	jmp	.L17
.L106:
	cltq
	movq	%r8, %r9
	movq	%rax, 72(%rsp)
.L24:
	movl	36(%rsp), %ecx
	movl	%r14d, %r8d
	leaq	(%r9,%rbx,4), %rdi
	movl	%ecx, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	72(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L26:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %r10
	movl	(%r10), %edx
	cmpl	%r11d, %esi
	jg	.L27
	cmpl	%edx, %esi
	jge	.L28
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rax, %r10
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ecx
	cmpl	%edx, %esi
	jl	.L29
.L28:
	cmpl	%ecx, %r8d
	jge	.L30
	movl	%edx, (%rdi)
	subl	$1, %ecx
	movl	%r11d, (%r10)
	movslq	%ecx, %rax
.L27:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L26
.L30:
	leal	-1(%r8), %eax
	movl	%ecx, 104(%rsp)
	movl	%eax, 24(%rsp)
	cmpl	%eax, %r14d
	jl	.L107
	movl	104(%rsp), %eax
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 36(%rsp)
	jle	.L97
.L115:
	movslq	%eax, %rbx
	jmp	.L24
.L107:
	cltq
	movq	%r9, %r15
	movq	%rax, 48(%rsp)
.L31:
	movl	24(%rsp), %r8d
	movl	%r14d, %r10d
	leaq	(%r15,%rbx,4), %rdi
	movl	%r8d, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r15,%rax,4), %esi
	movq	48(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L33:
	movl	(%rdi), %r9d
	leaq	(%r15,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r9d, %esi
	jg	.L34
	cmpl	%edx, %esi
	jge	.L35
	leaq	-4(%r15,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L36:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r8d
	cmpl	%edx, %esi
	jl	.L36
.L35:
	cmpl	%r8d, %r10d
	jge	.L37
	movl	%edx, (%rdi)
	subl	$1, %r8d
	movl	%r9d, (%rcx)
	movslq	%r8d, %rax
.L34:
	addq	$4, %rdi
	addl	$1, %r10d
	jmp	.L33
.L37:
	leal	-1(%r10), %eax
	movl	%eax, 12(%rsp)
	cmpl	%eax, %r14d
	jl	.L108
	leal	1(%r8), %eax
	movl	%eax, %r14d
	cmpl	%eax, 24(%rsp)
	jle	.L98
.L114:
	movslq	%eax, %rbx
	jmp	.L31
.L108:
	cltq
	movl	%r8d, 108(%rsp)
	movq	%rax, 40(%rsp)
.L38:
	movl	12(%rsp), %r9d
	movl	%r14d, %r8d
	leaq	(%r15,%rbx,4), %rdi
	movl	%r9d, %edx
	addl	%r14d, %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r15,%rax,4), %esi
	movq	40(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L40:
	movl	(%rdi), %r10d
	leaq	(%r15,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r10d, %esi
	jg	.L41
	cmpl	%edx, %esi
	jge	.L42
	leaq	-4(%r15,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L43:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r9d
	cmpl	%edx, %esi
	jl	.L43
.L42:
	cmpl	%r9d, %r8d
	jge	.L44
	movl	%edx, (%rdi)
	subl	$1, %r9d
	movl	%r10d, (%rcx)
	movslq	%r9d, %rax
.L41:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L40
.L44:
	leal	-1(%r8), %eax
	movl	%eax, 8(%rsp)
	cmpl	%eax, %r14d
	jl	.L109
	leal	1(%r9), %eax
	movl	%eax, %r14d
	cmpl	%eax, 12(%rsp)
	jle	.L99
.L113:
	movslq	%eax, %rbx
	jmp	.L38
.L109:
	cltq
	movl	%r9d, 112(%rsp)
	movl	%r14d, %r10d
	movq	%rax, 16(%rsp)
.L45:
	movl	8(%rsp), %r12d
	leaq	(%r15,%rbx,4), %rdi
	movl	%r10d, %r14d
	leal	(%r12,%r10), %edx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r15,%rax,4), %esi
	movq	16(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L47:
	movl	(%rdi), %r8d
	leaq	(%r15,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r8d, %esi
	jg	.L48
	cmpl	%edx, %esi
	jge	.L49
	leaq	-4(%r15,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L50:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %r12d
	cmpl	%edx, %esi
	jl	.L50
.L49:
	cmpl	%r12d, %r14d
	jge	.L51
	movl	%edx, (%rdi)
	subl	$1, %r12d
	movl	%r8d, (%rcx)
	movslq	%r12d, %rax
.L48:
	addq	$4, %rdi
	addl	$1, %r14d
	jmp	.L47
.L51:
	subl	$1, %r14d
	cmpl	%r14d, %r10d
	jl	.L110
	leal	1(%r12), %r10d
	cmpl	%r10d, 8(%rsp)
	jle	.L100
.L112:
	movslq	%r10d, %rbx
	jmp	.L45
.L110:
	movl	%r12d, 116(%rsp)
	movslq	%r14d, %rax
	movq	%r15, %r9
	movq	%rax, %r15
.L52:
	leal	(%r14,%r10), %edx
	leaq	(%r9,%rbx,4), %rdi
	movl	%r10d, %r13d
	movl	%r14d, %ebp
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	%r15, %rax
	.p2align 4,,10
	.p2align 3
.L54:
	movl	(%rdi), %r8d
	leaq	(%r9,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r8d, %esi
	jg	.L55
	cmpl	%edx, %esi
	jge	.L56
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L57:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ebp
	cmpl	%edx, %esi
	jl	.L57
.L56:
	cmpl	%ebp, %r13d
	jge	.L58
	movl	%edx, (%rdi)
	subl	$1, %ebp
	movl	%r8d, (%rcx)
	movslq	%ebp, %rax
.L55:
	addq	$4, %rdi
	addl	$1, %r13d
	jmp	.L54
.L58:
	subl	$1, %r13d
	movslq	%r13d, %r12
	cmpl	%r13d, %r10d
	jl	.L59
.L67:
	leal	1(%rbp), %r10d
	cmpl	%r10d, %r14d
	jle	.L101
	movslq	%r10d, %rbx
	jmp	.L52
	.p2align 4,,10
	.p2align 3
.L65:
	leal	-1(%r8), %edx
	cmpl	%edx, %r10d
	jl	.L111
.L66:
	leal	1(%rbx), %r10d
	cmpl	%r10d, %r13d
	jle	.L67
	movslq	%r10d, %rbx
.L59:
	leal	0(%r13,%r10), %edx
	leaq	(%r9,%rbx,4), %rdi
	movl	%r10d, %r8d
	movl	%r13d, %ebx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	(%r9,%rax,4), %esi
	movq	%r12, %rax
	.p2align 4,,10
	.p2align 3
.L61:
	movl	(%rdi), %r11d
	leaq	(%r9,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r11d, %esi
	jg	.L62
	cmpl	%edx, %esi
	jge	.L63
	leaq	-4(%r9,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L64:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ebx
	cmpl	%edx, %esi
	jl	.L64
.L63:
	cmpl	%ebx, %r8d
	jge	.L65
	movl	%edx, (%rdi)
	subl	$1, %ebx
	movl	%r11d, (%rcx)
	movslq	%ebx, %rax
.L62:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L61
.L101:
	movl	116(%rsp), %r12d
	movq	%r9, %r15
	leal	1(%r12), %r10d
	cmpl	%r10d, 8(%rsp)
	jg	.L112
.L100:
	movl	112(%rsp), %r9d
	leal	1(%r9), %eax
	movl	%eax, %r14d
	cmpl	%eax, 12(%rsp)
	jg	.L113
.L99:
	movl	108(%rsp), %r8d
	leal	1(%r8), %eax
	movl	%eax, %r14d
	cmpl	%eax, 24(%rsp)
	jg	.L114
.L98:
	movl	104(%rsp), %eax
	movq	%r15, %r9
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 36(%rsp)
	jg	.L115
.L97:
	movl	68(%rsp), %eax
	movq	%r9, %r8
	addl	$1, %eax
	movl	%eax, %r14d
	cmpl	%eax, 32(%rsp)
	jg	.L116
.L96:
	movq	%r8, %r9
	jmp	.L25
.L111:
	movq	%r9, %rdi
	movl	%r10d, %esi
	movq	%r9, 120(%rsp)
	call	qsort
	movq	120(%rsp), %r9
	jmp	.L66
	.cfi_endproc
.LFE24:
	.size	qsort, .-qsort
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1048, %rsp
	.cfi_def_cfa_offset 1104
	movl	n(%rip), %r12d
	movq	%fs:40, %rax
	movq	%rax, 1032(%rsp)
	xorl	%eax, %eax
	testl	%r12d, %r12d
	jle	.L140
	movslq	%r12d, %r13
	leaq	B(%rip), %rbp
	leaq	A(%rip), %rsi
	leaq	0(,%r13,4), %rdx
	movq	%rbp, %rdi
	call	memcpy@PLT
	leaq	32(%rsp), %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	memset@PLT
.L120:
	subl	$1, %r12d
	xorl	%r10d, %r10d
	movslq	%r12d, %r13
.L119:
	leal	(%r12,%r10), %edx
	movl	%r10d, %r8d
	movl	%r12d, %ebx
	movl	%edx, %eax
	shrl	$31, %eax
	addl	%edx, %eax
	sarl	%eax
	cltq
	movl	0(%rbp,%rax,4), %esi
	movslq	%r10d, %rax
	leaq	0(%rbp,%rax,4), %rdi
	movq	%r13, %rax
	.p2align 4,,10
	.p2align 3
.L121:
	movl	(%rdi), %r9d
	leaq	0(%rbp,%rax,4), %rcx
	movl	(%rcx), %edx
	cmpl	%r9d, %esi
	jg	.L122
	cmpl	%edx, %esi
	jge	.L123
	leaq	-4(%rbp,%rax,4), %rax
	.p2align 4,,10
	.p2align 3
.L124:
	movq	%rax, %rcx
	movl	(%rax), %edx
	subq	$4, %rax
	subl	$1, %ebx
	cmpl	%edx, %esi
	jl	.L124
.L123:
	cmpl	%ebx, %r8d
	jge	.L125
	movl	%edx, (%rdi)
	subl	$1, %ebx
	movl	%r9d, (%rcx)
	movslq	%ebx, %rax
.L122:
	addq	$4, %rdi
	addl	$1, %r8d
	jmp	.L121
	.p2align 4,,10
	.p2align 3
.L125:
	leal	-1(%r8), %edx
	cmpl	%edx, %r10d
	jl	.L141
.L126:
	leal	1(%rbx), %r10d
	cmpl	%r10d, %r12d
	jg	.L119
	movl	n(%rip), %r15d
	testl	%r15d, %r15d
	jle	.L133
	movslq	%r15d, %rax
	leaq	T(%rip), %r13
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L128:
	movslq	0(%rbp,%rax,4), %rdx
	movl	%eax, 0(%r13,%rdx,4)
	addq	$1, %rax
	cmpq	%rax, 8(%rsp)
	jne	.L128
	movl	s(%rip), %eax
	movl	$0, 24(%rsp)
	xorl	%r12d, %r12d
	movl	%eax, 28(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 16(%rsp)
	jmp	.L131
	.p2align 4,,10
	.p2align 3
.L129:
	addq	$1, %r12
	cmpq	8(%rsp), %r12
	je	.L117
.L131:
	movq	16(%rsp), %rdi
	movslq	%r12d, %rax
	cmpb	$0, (%rdi,%r12)
	jne	.L129
	xorl	%r15d, %r15d
	movl	$10000, %ecx
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L130:
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	movb	$1, 32(%rsp,%rax)
	movl	%r15d, %ebp
	cvtsi2sdl	%ecx, %xmm0
	leaq	A(%rip), %rdi
	addl	$1, %r15d
	movl	(%rdi,%rax,4), %r14d
	cvtsi2sdl	%r14d, %xmm1
	addl	%r14d, %ebx
	call	fmin@PLT
	movslq	%r14d, %rax
	movslq	0(%r13,%rax,4), %rax
	cvttsd2sil	%xmm0, %ecx
	cmpb	$0, 32(%rsp,%rax)
	je	.L130
	leal	2(%rbp), %edx
	subl	$1, %ebp
	leal	(%rcx,%rbx), %eax
	addq	$1, %r12
	imull	%ecx, %ebp
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	imull	28(%rsp), %edx
	addl	%eax, %edx
	leal	0(%rbp,%rbx), %eax
	cvtsi2sdl	%eax, %xmm0
	cvtsi2sdl	%edx, %xmm1
	call	fmin@PLT
	movapd	%xmm0, %xmm1
	pxor	%xmm0, %xmm0
	cvtsi2sdl	24(%rsp), %xmm0
	addsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %eax
	movl	%eax, 24(%rsp)
	cmpq	8(%rsp), %r12
	jne	.L131
.L117:
	movq	1032(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L142
	movl	24(%rsp), %eax
	addq	$1048, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L141:
	.cfi_restore_state
	movl	%r10d, %esi
	movq	%rbp, %rdi
	call	qsort
	jmp	.L126
.L140:
	leaq	B(%rip), %rbp
	jmp	.L120
.L133:
	movl	$0, 24(%rsp)
	jmp	.L117
.L142:
	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	.L144
	leaq	A(%rip), %rbx
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L145:
	movq	%rbx, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	addq	$4, %rbx
	cvtsi2sdl	-4(%rbx), %xmm1
	cvtsi2sdl	s(%rip), %xmm0
	call	fmin@PLT
	cmpl	%ebp, n(%rip)
	cvttsd2sil	%xmm0, %eax
	movl	%eax, s(%rip)
	jg	.L145
.L144:
	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>
#include<stdbool.h>
#include<math.h>
#define MAX 1000
#define VMAX 10000
int n,A[MAX],s;
int B[MAX], T[VMAX+1];
 
void swap(int *a,int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
void qsort(int X[], int left, int right){
  int i,j;
  int pivot;
  i=left;j=right;
  pivot = X[(left+right)/2];
 
  while(1) {
    while(X[i]<pivot)i++;
    while(pivot<X[j])j--;
    if(i>=j) break;
 
    swap(&X[i],&X[j]);
    i++;  j--;
  }
  if(left < i-1) qsort(X,left,i-1);
  if(j+1<right) qsort(X,j+1,right);
}
int solve() {
  int i;
  int ans = 0;
 
  bool V[MAX];
  for(i=0;i<n;i++){
    B[i] = A[i];
    V[i]=false;
  }
  qsort(B,0,n-1);
  for(i=0;i<n;i++) T[B[i]] = i;
  for(i=0;i<n;i++) {
    if(V[i]) continue;
    int cur=i;
    int S=0;
    int m=VMAX;
    int an=0;
    while(1) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = fmin(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=fmin(S+(an - 2) * m , m+S+(an+1)*s);
 
  }
  return ans;
}
int main(){
  int i;
  scanf("%d",&n);
  s=VMAX;
  for(i=0;i<n;i++) {
    scanf("%d",&A[i]);
    s=fmin(s , A[i]);
  }
  int 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>
#include<stdbool.h>
#include<math.h>
#define MAX 1000
#define VMAX 10000
int n,A[MAX],s;
int B[MAX], T[VMAX+1];
 
void swap(int *a,int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}
void qsort(int X[], int left, int right){
  int i,j;
  int pivot;
  i=left;j=right;
  pivot = X[(left+right)/2];
 
  while(1) {
    while(X[i]<pivot)i++;
    while(pivot<X[j])j--;
    if(i>=j) break;
 
    swap(&X[i],&X[j]);
    i++;  j--;
  }
  if(left < i-1) qsort(X,left,i-1);
  if(j+1<right) qsort(X,j+1,right);
}
int solve() {
  int i;
  int ans = 0;
 
  bool V[MAX];
  for(i=0;i<n;i++){
    B[i] = A[i];
    V[i]=false;
  }
  qsort(B,0,n-1);
  for(i=0;i<n;i++) T[B[i]] = i;
  for(i=0;i<n;i++) {
    if(V[i]) continue;
    int cur=i;
    int S=0;
    int m=VMAX;
    int an=0;
    while(1) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = fmin(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=fmin(S+(an - 2) * m , m+S+(an+1)*s);
 
  }
  return ans;
}
int main(){
  int i;
  scanf("%d",&n);
  s=VMAX;
  for(i=0;i<n;i++) {
    scanf("%d",&A[i]);
    s=fmin(s , A[i]);
  }
  int 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	swap
	.type	swap, @function
swap:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.globl	qsort
	.type	qsort, @function
qsort:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L3
.L4:
	addl	$1, -12(%rbp)
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L4
	jmp	.L5
.L6:
	subl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L13
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	addl	$1, -12(%rbp)
	subl	$1, -8(%rbp)
	jmp	.L3
.L13:
	nop
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -28(%rbp)
	jge	.L10
	movl	-12(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	qsort
.L10:
	movl	-8(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jle	.L14
	movl	-8(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	qsort
.L14:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	qsort, .-qsort
	.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	$1056, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1032(%rbp)
	movl	$0, -1036(%rbp)
	jmp	.L16
.L17:
	movl	-1036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-1036(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-1036(%rbp), %eax
	cltq
	movb	$0, -1008(%rbp,%rax)
	addl	$1, -1036(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L17
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, %edx
	movl	$0, %esi
	leaq	B(%rip), %rax
	movq	%rax, %rdi
	call	qsort
	movl	$0, -1036(%rbp)
	jmp	.L18
.L19:
	movl	-1036(%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	-1036(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -1036(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L19
	movl	$0, -1036(%rbp)
	jmp	.L20
.L26:
	movl	-1036(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L30
	movl	-1036(%rbp), %eax
	movl	%eax, -1028(%rbp)
	movl	$0, -1024(%rbp)
	movl	$10000, -1020(%rbp)
	movl	$0, -1016(%rbp)
.L25:
	movl	-1028(%rbp), %eax
	cltq
	movb	$1, -1008(%rbp,%rax)
	addl	$1, -1016(%rbp)
	movl	-1028(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -1012(%rbp)
	pxor	%xmm0, %xmm0
	cvtsi2sdl	-1012(%rbp), %xmm0
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-1020(%rbp), %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -1020(%rbp)
	movl	-1012(%rbp), %eax
	addl	%eax, -1024(%rbp)
	movl	-1012(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -1028(%rbp)
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L31
	jmp	.L25
.L31:
	nop
	pxor	%xmm3, %xmm3
	cvtsi2sdl	-1032(%rbp), %xmm3
	movsd	%xmm3, -1048(%rbp)
	movl	-1020(%rbp), %edx
	movl	-1024(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-1016(%rbp), %eax
	leal	1(%rax), %edx
	movl	s(%rip), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	-1016(%rbp), %eax
	subl	$2, %eax
	imull	-1020(%rbp), %eax
	movl	%eax, %edx
	movl	-1024(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm4, %xmm4
	cvtsi2sdl	%eax, %xmm4
	movq	%xmm4, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	addsd	-1048(%rbp), %xmm0
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -1032(%rbp)
	jmp	.L22
.L30:
	nop
.L22:
	addl	$1, -1036(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L26
	movl	-1032(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	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	.L33
.L34:
	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), %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	s(%rip), %eax
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, s(%rip)
	addl	$1, -8(%rbp)
.L33:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L34
	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	swap
	.type	swap, @function
swap:
.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, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	swap, .-swap
	.globl	qsort
	.type	qsort, @function
qsort:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	-28(%rbp), %eax
	movl	%eax, -12(%rbp)
	movl	-32(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	-28(%rbp), %edx
	movl	-32(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	jmp	.L3
.L4:
	addl	$1, -12(%rbp)
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L4
	jmp	.L5
.L6:
	subl	$1, -8(%rbp)
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L6
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L13
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	addl	$1, -12(%rbp)
	subl	$1, -8(%rbp)
	jmp	.L3
.L13:
	nop
	movl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -28(%rbp)
	jge	.L10
	movl	-12(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %ecx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	qsort
.L10:
	movl	-8(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -32(%rbp)
	jle	.L14
	movl	-8(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-32(%rbp), %edx
	movq	-24(%rbp), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	qsort
.L14:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	qsort, .-qsort
	.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	$1056, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -1032(%rbp)
	movl	$0, -1036(%rbp)
	jmp	.L16
.L17:
	movl	-1036(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-1036(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	B(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-1036(%rbp), %eax
	cltq
	movb	$0, -1008(%rbp,%rax)
	addl	$1, -1036(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L17
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, %edx
	movl	$0, %esi
	leaq	B(%rip), %rax
	movq	%rax, %rdi
	call	qsort
	movl	$0, -1036(%rbp)
	jmp	.L18
.L19:
	movl	-1036(%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	-1036(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -1036(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L19
	movl	$0, -1036(%rbp)
	jmp	.L20
.L26:
	movl	-1036(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L30
	movl	-1036(%rbp), %eax
	movl	%eax, -1028(%rbp)
	movl	$0, -1024(%rbp)
	movl	$10000, -1020(%rbp)
	movl	$0, -1016(%rbp)
.L25:
	movl	-1028(%rbp), %eax
	cltq
	movb	$1, -1008(%rbp,%rax)
	addl	$1, -1016(%rbp)
	movl	-1028(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	A(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -1012(%rbp)
	pxor	%xmm0, %xmm0
	cvtsi2sdl	-1012(%rbp), %xmm0
	pxor	%xmm2, %xmm2
	cvtsi2sdl	-1020(%rbp), %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -1020(%rbp)
	movl	-1012(%rbp), %eax
	addl	%eax, -1024(%rbp)
	movl	-1012(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	T(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -1028(%rbp)
	movl	-1028(%rbp), %eax
	cltq
	movzbl	-1008(%rbp,%rax), %eax
	testb	%al, %al
	jne	.L31
	jmp	.L25
.L31:
	nop
	pxor	%xmm3, %xmm3
	cvtsi2sdl	-1032(%rbp), %xmm3
	movsd	%xmm3, -1048(%rbp)
	movl	-1020(%rbp), %edx
	movl	-1024(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-1016(%rbp), %eax
	leal	1(%rax), %edx
	movl	s(%rip), %eax
	imull	%edx, %eax
	addl	%ecx, %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	-1016(%rbp), %eax
	subl	$2, %eax
	imull	-1020(%rbp), %eax
	movl	%eax, %edx
	movl	-1024(%rbp), %eax
	addl	%edx, %eax
	pxor	%xmm4, %xmm4
	cvtsi2sdl	%eax, %xmm4
	movq	%xmm4, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	addsd	-1048(%rbp), %xmm0
	cvttsd2sil	%xmm0, %eax
	movl	%eax, -1032(%rbp)
	jmp	.L22
.L30:
	nop
.L22:
	addl	$1, -1036(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -1036(%rbp)
	jl	.L26
	movl	-1032(%rbp), %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	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	.L33
.L34:
	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), %eax
	pxor	%xmm0, %xmm0
	cvtsi2sdl	%eax, %xmm0
	movl	s(%rip), %eax
	pxor	%xmm2, %xmm2
	cvtsi2sdl	%eax, %xmm2
	movq	%xmm2, %rax
	movapd	%xmm0, %xmm1
	movq	%rax, %xmm0
	call	fmin@PLT
	cvttsd2sil	%xmm0, %eax
	movl	%eax, s(%rip)
	addl	$1, -8(%rbp)
.L33:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L34
	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:
