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_N 1000
#define MAX_W 10000

int n;
int w[MAX_N];
int sorted_w[MAX_N];
int idx[MAX_W+1];
int used[MAX_N];

int min(int a, int b) {
  return a > b ? b : a;
}

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void bubbleSort() {
  int i, j;
  for(i = 0; i < n-1; i++) {
    for(j = n-1; j > i; j--) {
      if(sorted_w[j] < sorted_w[j-1]) {
	swap(&sorted_w[j], &sorted_w[j-1]);
      }
    }
  }
}

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", w+i);
    sorted_w[i] = w[i];
  }
  bubbleSort();
  for(i = 0; i < n; i++) idx[sorted_w[i]] = i;
  int minimam = sorted_w[0];
  int ans = 0;
  for(i = 0; i < n; i++) {
    if(used[i]) continue;
    int pos = i;
    int minimal = MAX_W;
    int sum = 0;
    int cnt = 0;
    while(!used[pos]) {
      used[pos] = 1;
      if(w[pos] < minimal) minimal = w[pos];
      sum += w[pos];
      cnt++;
      pos = idx[w[pos]];
    }
    //printf("%d %d %d\n", pos, minimal, sum);
    ans += min(sum-minimal+(cnt-1)*minimal,
	       sum-minimal+(cnt-1)*minimam+(minimam+minimal)*2);
  }
  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	w
	.align 32
	.type	w, @object
	.size	w, 4000
w:
	.zero	4000
	.globl	sorted_w
	.align 32
	.type	sorted_w, @object
	.size	sorted_w, 4000
sorted_w:
	.zero	4000
	.globl	idx
	.align 32
	.type	idx, @object
	.size	idx, 40004
idx:
	.zero	40004
	.globl	used
	.align 32
	.type	used, @object
	.size	used, 4000
used:
	.zero	4000
	.text
	.globl	min
	.type	min, @function
min:
.LFB0:
	.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), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.globl	swap
	.type	swap, @function
swap:
.LFB1:
	.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
.LFE1:
	.size	swap, .-swap
	.globl	bubbleSort
	.type	bubbleSort, @function
bubbleSort:
.LFB2:
	.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
	movl	$0, -8(%rbp)
	jmp	.L5
.L9:
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L6
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	sorted_w(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	sorted_w(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L7:
	subl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L8
	addl	$1, -8(%rbp)
.L5:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L9
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	bubbleSort, .-bubbleSort
	.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	$32, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L11
.L12:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sorted_w(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L12
	movl	$0, %eax
	call	bubbleSort
	movl	$0, -28(%rbp)
	jmp	.L13
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	idx(%rip), %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L14
	movl	sorted_w(%rip), %eax
	movl	%eax, -4(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L15
.L21:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L23
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	$10000, -16(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L18
.L20:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L19
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	idx(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
.L18:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L20
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	subl	$1, %eax
	imull	-4(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-4(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, %eax
	leal	(%rcx,%rax), %edx
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %ecx
	movl	-8(%rbp), %eax
	subl	$1, %eax
	imull	-16(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	addl	%eax, -24(%rbp)
	jmp	.L17
.L23:
	nop
.L17:
	addl	$1, -28(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movl	-24(%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	min
	.type	min, @function
min:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	min, .-min
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB24:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE24:
	.size	swap, .-swap
	.p2align 4
	.globl	bubbleSort
	.type	bubbleSort, @function
bubbleSort:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	n(%rip), %rax
	leal	-1(%rax), %r8d
	testl	%r8d, %r8d
	jle	.L4
	leaq	sorted_w(%rip), %rdx
	xorl	%edi, %edi
	leaq	(%rdx,%rax,4), %r9
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r9, %rdx
	movl	%r8d, %ecx
	.p2align 4,,10
	.p2align 3
.L7:
	movq	-8(%rdx), %xmm0
	subl	$1, %ecx
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %eax
	movd	%xmm2, %esi
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jge	.L6
	movq	%xmm1, -8(%rdx)
.L6:
	subq	$4, %rdx
	cmpl	%edi, %ecx
	jg	.L7
	addl	$1, %edi
	cmpl	%edi, %r8d
	jne	.L8
.L4:
	ret
	.cfi_endproc
.LFE25:
	.size	bubbleSort, .-bubbleSort
	.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	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L12
	leaq	w(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	sorted_w(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	addq	$4, %rbp
	call	__isoc99_scanf@PLT
	movl	-4(%rbp), %eax
	movl	%eax, (%r12,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, n(%rip)
	jg	.L13
.L12:
	xorl	%eax, %eax
	call	bubbleSort
	movslq	n(%rip), %r10
	testl	%r10d, %r10d
	jle	.L20
	xorl	%eax, %eax
	leaq	sorted_w(%rip), %r12
	leaq	idx(%rip), %r8
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	(%r12,%rax,4), %rdx
	movl	%eax, (%r8,%rdx,4)
	addq	$1, %rax
	cmpq	%rax, %r10
	jne	.L15
	movl	(%r12), %ebx
	xorl	%edi, %edi
	xorl	%r11d, %r11d
	leaq	used(%rip), %rsi
	leaq	w(%rip), %r9
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rdi
	cmpq	%rdi, %r10
	je	.L14
.L19:
	movl	(%rsi,%rdi,4), %ebp
	movslq	%edi, %rax
	testl	%ebp, %ebp
	jne	.L17
	xorl	%ecx, %ecx
	movl	$10000, %edx
	.p2align 4,,10
	.p2align 3
.L18:
	movl	$1, (%rsi,%rax,4)
	movslq	(%r9,%rax,4), %rax
	movl	%ecx, %r12d
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addl	%eax, %ebp
	movslq	(%r8,%rax,4), %rax
	addl	$1, %ecx
	movl	(%rsi,%rax,4), %r13d
	testl	%r13d, %r13d
	je	.L18
	movl	%ebx, %eax
	subl	%edx, %ebp
	leal	(%rbx,%rdx), %ecx
	imull	%r12d, %eax
	imull	%r12d, %edx
	addl	%ebp, %eax
	leal	(%rax,%rcx,2), %eax
	addl	%ebp, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	addq	$1, %rdi
	addl	%eax, %r11d
	cmpq	%rdi, %r10
	jne	.L19
.L14:
	movl	%r11d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore_state
	xorl	%r11d, %r11d
	jmp	.L14
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	used
	.bss
	.align 32
	.type	used, @object
	.size	used, 4000
used:
	.zero	4000
	.globl	idx
	.align 32
	.type	idx, @object
	.size	idx, 40004
idx:
	.zero	40004
	.globl	sorted_w
	.align 32
	.type	sorted_w, @object
	.size	sorted_w, 4000
sorted_w:
	.zero	4000
	.globl	w
	.align 32
	.type	w, @object
	.size	w, 4000
w:
	.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	min
	.type	min, @function
min:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovle	%edi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	min, .-min
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB24:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	movl	(%rsi), %edx
	movl	%edx, (%rdi)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE24:
	.size	swap, .-swap
	.p2align 4
	.globl	bubbleSort
	.type	bubbleSort, @function
bubbleSort:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	n(%rip), %rax
	leal	-1(%rax), %r8d
	testl	%r8d, %r8d
	jle	.L4
	leaq	sorted_w(%rip), %rdx
	xorl	%edi, %edi
	leaq	(%rdx,%rax,4), %r9
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%r9, %rdx
	movl	%r8d, %ecx
	.p2align 4,,10
	.p2align 3
.L7:
	movq	-8(%rdx), %xmm0
	subl	$1, %ecx
	pshufd	$0xe5, %xmm0, %xmm2
	movd	%xmm0, %eax
	movd	%xmm2, %esi
	pshufd	$225, %xmm0, %xmm1
	cmpl	%eax, %esi
	jge	.L6
	movq	%xmm1, -8(%rdx)
.L6:
	subq	$4, %rdx
	cmpl	%edi, %ecx
	jg	.L7
	addl	$1, %edi
	cmpl	%edi, %r8d
	jne	.L8
.L4:
	ret
	.cfi_endproc
.LFE25:
	.size	bubbleSort, .-bubbleSort
	.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	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L12
	leaq	w(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	sorted_w(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r13, %rdi
	addq	$4, %rbp
	call	__isoc99_scanf@PLT
	movl	-4(%rbp), %eax
	movl	%eax, (%r12,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, n(%rip)
	jg	.L13
.L12:
	xorl	%eax, %eax
	call	bubbleSort
	movslq	n(%rip), %r10
	testl	%r10d, %r10d
	jle	.L20
	xorl	%eax, %eax
	leaq	sorted_w(%rip), %r12
	leaq	idx(%rip), %r8
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	(%r12,%rax,4), %rdx
	movl	%eax, (%r8,%rdx,4)
	addq	$1, %rax
	cmpq	%rax, %r10
	jne	.L15
	movl	(%r12), %ebx
	xorl	%edi, %edi
	xorl	%r11d, %r11d
	leaq	used(%rip), %rsi
	leaq	w(%rip), %r9
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rdi
	cmpq	%rdi, %r10
	je	.L14
.L19:
	movl	(%rsi,%rdi,4), %ebp
	movslq	%edi, %rax
	testl	%ebp, %ebp
	jne	.L17
	xorl	%ecx, %ecx
	movl	$10000, %edx
	.p2align 4,,10
	.p2align 3
.L18:
	movl	$1, (%rsi,%rax,4)
	movslq	(%r9,%rax,4), %rax
	movl	%ecx, %r12d
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	addl	%eax, %ebp
	movslq	(%r8,%rax,4), %rax
	addl	$1, %ecx
	movl	(%rsi,%rax,4), %r13d
	testl	%r13d, %r13d
	je	.L18
	movl	%ebx, %eax
	subl	%edx, %ebp
	leal	(%rbx,%rdx), %ecx
	imull	%r12d, %eax
	imull	%r12d, %edx
	addl	%ebp, %eax
	leal	(%rax,%rcx,2), %eax
	addl	%ebp, %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	addq	$1, %rdi
	addl	%eax, %r11d
	cmpq	%rdi, %r10
	jne	.L19
.L14:
	movl	%r11d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore_state
	xorl	%r11d, %r11d
	jmp	.L14
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	used
	.bss
	.align 32
	.type	used, @object
	.size	used, 4000
used:
	.zero	4000
	.globl	idx
	.align 32
	.type	idx, @object
	.size	idx, 40004
idx:
	.zero	40004
	.globl	sorted_w
	.align 32
	.type	sorted_w, @object
	.size	sorted_w, 4000
sorted_w:
	.zero	4000
	.globl	w
	.align 32
	.type	w, @object
	.size	w, 4000
w:
	.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_N 1000
#define MAX_W 10000

int n;
int w[MAX_N];
int sorted_w[MAX_N];
int idx[MAX_W+1];
int used[MAX_N];

int min(int a, int b) {
  return a > b ? b : a;
}

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void bubbleSort() {
  int i, j;
  for(i = 0; i < n-1; i++) {
    for(j = n-1; j > i; j--) {
      if(sorted_w[j] < sorted_w[j-1]) {
	swap(&sorted_w[j], &sorted_w[j-1]);
      }
    }
  }
}

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", w+i);
    sorted_w[i] = w[i];
  }
  bubbleSort();
  for(i = 0; i < n; i++) idx[sorted_w[i]] = i;
  int minimam = sorted_w[0];
  int ans = 0;
  for(i = 0; i < n; i++) {
    if(used[i]) continue;
    int pos = i;
    int minimal = MAX_W;
    int sum = 0;
    int cnt = 0;
    while(!used[pos]) {
      used[pos] = 1;
      if(w[pos] < minimal) minimal = w[pos];
      sum += w[pos];
      cnt++;
      pos = idx[w[pos]];
    }
    //printf("%d %d %d\n", pos, minimal, sum);
    ans += min(sum-minimal+(cnt-1)*minimal,
	       sum-minimal+(cnt-1)*minimam+(minimam+minimal)*2);
  }
  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_N 1000
#define MAX_W 10000

int n;
int w[MAX_N];
int sorted_w[MAX_N];
int idx[MAX_W+1];
int used[MAX_N];

int min(int a, int b) {
  return a > b ? b : a;
}

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void bubbleSort() {
  int i, j;
  for(i = 0; i < n-1; i++) {
    for(j = n-1; j > i; j--) {
      if(sorted_w[j] < sorted_w[j-1]) {
	swap(&sorted_w[j], &sorted_w[j-1]);
      }
    }
  }
}

int main() {
  int i;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", w+i);
    sorted_w[i] = w[i];
  }
  bubbleSort();
  for(i = 0; i < n; i++) idx[sorted_w[i]] = i;
  int minimam = sorted_w[0];
  int ans = 0;
  for(i = 0; i < n; i++) {
    if(used[i]) continue;
    int pos = i;
    int minimal = MAX_W;
    int sum = 0;
    int cnt = 0;
    while(!used[pos]) {
      used[pos] = 1;
      if(w[pos] < minimal) minimal = w[pos];
      sum += w[pos];
      cnt++;
      pos = idx[w[pos]];
    }
    //printf("%d %d %d\n", pos, minimal, sum);
    ans += min(sum-minimal+(cnt-1)*minimal,
	       sum-minimal+(cnt-1)*minimam+(minimam+minimal)*2);
  }
  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	w
	.align 32
	.type	w, @object
	.size	w, 4000
w:
	.zero	4000
	.globl	sorted_w
	.align 32
	.type	sorted_w, @object
	.size	sorted_w, 4000
sorted_w:
	.zero	4000
	.globl	idx
	.align 32
	.type	idx, @object
	.size	idx, 40004
idx:
	.zero	40004
	.globl	used
	.align 32
	.type	used, @object
	.size	used, 4000
used:
	.zero	4000
	.text
	.globl	min
	.type	min, @function
min:
.LFB0:
	.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), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.globl	swap
	.type	swap, @function
swap:
.LFB1:
	.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
.LFE1:
	.size	swap, .-swap
	.globl	bubbleSort
	.type	bubbleSort, @function
bubbleSort:
.LFB2:
	.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
	movl	$0, -8(%rbp)
	jmp	.L5
.L9:
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L6
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	sorted_w(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	sorted_w(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L7:
	subl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L8
	addl	$1, -8(%rbp)
.L5:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L9
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	bubbleSort, .-bubbleSort
	.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	$32, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L11
.L12:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sorted_w(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L12
	movl	$0, %eax
	call	bubbleSort
	movl	$0, -28(%rbp)
	jmp	.L13
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	idx(%rip), %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L14
	movl	sorted_w(%rip), %eax
	movl	%eax, -4(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L15
.L21:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L23
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	$10000, -16(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L18
.L20:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L19
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	idx(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
.L18:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L20
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	subl	$1, %eax
	imull	-4(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-4(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, %eax
	leal	(%rcx,%rax), %edx
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %ecx
	movl	-8(%rbp), %eax
	subl	$1, %eax
	imull	-16(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	addl	%eax, -24(%rbp)
	jmp	.L17
.L23:
	nop
.L17:
	addl	$1, -28(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movl	-24(%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	w
	.align 32
	.type	w, @object
	.size	w, 4000
w:
	.zero	4000
	.globl	sorted_w
	.align 32
	.type	sorted_w, @object
	.size	sorted_w, 4000
sorted_w:
	.zero	4000
	.globl	idx
	.align 32
	.type	idx, @object
	.size	idx, 40004
idx:
	.zero	40004
	.globl	used
	.align 32
	.type	used, @object
	.size	used, 4000
used:
	.zero	4000
	.text
	.globl	min
	.type	min, @function
min:
.LFB0:
	.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), %edx
	movl	-8(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	min, .-min
	.globl	swap
	.type	swap, @function
swap:
.LFB1:
	.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
.LFE1:
	.size	swap, .-swap
	.globl	bubbleSort
	.type	bubbleSort, @function
bubbleSort:
.LFB2:
	.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
	movl	$0, -8(%rbp)
	jmp	.L5
.L9:
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -4(%rbp)
	jmp	.L6
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	sorted_w(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L7
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	sorted_w(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
.L7:
	subl	$1, -4(%rbp)
.L6:
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L8
	addl	$1, -8(%rbp)
.L5:
	movl	n(%rip), %eax
	subl	$1, %eax
	cmpl	%eax, -8(%rbp)
	jl	.L9
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	bubbleSort, .-bubbleSort
	.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	$32, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L11
.L12:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sorted_w(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L12
	movl	$0, %eax
	call	bubbleSort
	movl	$0, -28(%rbp)
	jmp	.L13
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sorted_w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	idx(%rip), %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L14
	movl	sorted_w(%rip), %eax
	movl	%eax, -4(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L15
.L21:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L23
	movl	-28(%rbp), %eax
	movl	%eax, -20(%rbp)
	movl	$10000, -16(%rbp)
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L18
.L20:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L19
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	w(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	idx(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
.L18:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	used(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L20
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %edx
	movl	-8(%rbp), %eax
	subl	$1, %eax
	imull	-4(%rbp), %eax
	leal	(%rdx,%rax), %ecx
	movl	-4(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	addl	%eax, %eax
	leal	(%rcx,%rax), %edx
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, %ecx
	movl	-8(%rbp), %eax
	subl	$1, %eax
	imull	-16(%rbp), %eax
	addl	%ecx, %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	addl	%eax, -24(%rbp)
	jmp	.L17
.L23:
	nop
.L17:
	addl	$1, -28(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movl	-24(%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:
