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 <string.h>

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

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

int main(void)
{
    int i, j;
    int n, m, h, k;
    int depth, from;
    int score[1001], vertex[1001];
    static int amida[1001][1001];
    static int adj[1001][1001];
    int ans, sum;
    
    while (1){
        if (scanf("%d%d%d%d", &n, &m, &h, &k) == EOF){
            break;
        }
        
        if (n + m + h + k == 0){
            break;
        }
        
        for (i = 1; i <= n; i++){
            vertex[i] = i;
            scanf("%d", &score[i]);
        }
        
        memset(amida, 0, sizeof(amida));
        memset(adj, 0, sizeof(adj));
        for (i = 0; i < m; i++){
            scanf("%d%d", &from, &depth);
            amida[from][depth] = 1;
        }
        
        for (i = 1; i < h; i++){
            for (j = 1; j < n; j++){
                if (amida[j][i] == 1){
                    swap(&vertex[j], &vertex[j + 1]);
                    adj[vertex[j]][vertex[j + 1]] = adj[vertex[j + 1]][vertex[j]] = 1;
                }
            }
        }
        
        sum = 0;
        for (i = 1; i <= n; i++){
            if (vertex[i] <= k){
                sum += score[i];
            }
        }
        
        ans = sum;
        for (i = 1; i <= n; i++){
            for (j = 1; j <= n; j++){
                if (vertex[i] <= k && vertex[j] > k && adj[vertex[i]][vertex[j]]){
                    ans = min(ans, sum - score[i] + score[j]);
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.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	-8(%rbp), %edx
	movl	-4(%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, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	swap, .-swap
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$3984, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L25:
	leaq	-8060(%rbp), %rsi
	leaq	-8064(%rbp), %rcx
	leaq	-8068(%rbp), %rdx
	leaq	-8072(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L28
	movl	-8072(%rbp), %edx
	movl	-8068(%rbp), %eax
	addl	%eax, %edx
	movl	-8064(%rbp), %eax
	addl	%eax, %edx
	movl	-8060(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	je	.L29
	movl	$1, -8048(%rbp)
	jmp	.L8
.L9:
	movl	-8048(%rbp), %eax
	cltq
	movl	-8048(%rbp), %edx
	movl	%edx, -4016(%rbp,%rax,4)
	leaq	-8032(%rbp), %rdx
	movl	-8048(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8048(%rbp)
.L8:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L9
	movl	$4008004, %edx
	movl	$0, %esi
	leaq	amida.1(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$4008004, %edx
	movl	$0, %esi
	leaq	adj.0(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -8048(%rbp)
	jmp	.L10
.L11:
	leaq	-8056(%rbp), %rdx
	leaq	-8052(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-8052(%rbp), %eax
	movl	-8056(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	amida.1(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -8048(%rbp)
.L10:
	movl	-8068(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jl	.L11
	movl	$1, -8048(%rbp)
	jmp	.L12
.L16:
	movl	$1, -8044(%rbp)
	jmp	.L13
.L15:
	movl	-8048(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8044(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	amida.1(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L14
	movl	-8044(%rbp), %eax
	addl	$1, %eax
	leaq	-4016(%rbp), %rdx
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-4016(%rbp), %rcx
	movl	-8044(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	movl	-8044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	movl	-8044(%rbp), %edx
	movslq	%edx, %rdx
	movl	-4016(%rbp,%rdx,4), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$1001, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	adj.0(%rip), %rcx
	movl	$1, (%rsi,%rcx)
	movl	-8044(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	-4016(%rbp,%rcx,4), %esi
	movl	-8044(%rbp), %ecx
	addl	$1, %ecx
	movslq	%ecx, %rcx
	movl	-4016(%rbp,%rcx,4), %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rcx
	movslq	%esi, %rdx
	imulq	$1001, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	adj.0(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L14:
	addl	$1, -8044(%rbp)
.L13:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8044(%rbp)
	jl	.L15
	addl	$1, -8048(%rbp)
.L12:
	movl	-8064(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jl	.L16
	movl	$0, -8036(%rbp)
	movl	$1, -8048(%rbp)
	jmp	.L17
.L19:
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L18
	movl	-8048(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %eax
	addl	%eax, -8036(%rbp)
.L18:
	addl	$1, -8048(%rbp)
.L17:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L19
	movl	-8036(%rbp), %eax
	movl	%eax, -8040(%rbp)
	movl	$1, -8048(%rbp)
	jmp	.L20
.L24:
	movl	$1, -8044(%rbp)
	jmp	.L21
.L23:
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L22
	movl	-8044(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L22
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8044(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-8048(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %edx
	movl	-8036(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-8044(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %eax
	leal	(%rcx,%rax), %edx
	movl	-8040(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, -8040(%rbp)
.L22:
	addl	$1, -8044(%rbp)
.L21:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8044(%rbp)
	jle	.L23
	addl	$1, -8048(%rbp)
.L20:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L24
	movl	-8040(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L25
.L28:
	nop
	jmp	.L6
.L29:
	nop
.L6:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.local	amida.1
	.comm	amida.1,4008004,32
	.local	adj.0
	.comm	adj.0,4008004,32
	.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:
.LFB35:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovle	%esi, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	min, .-min
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB36:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	xorl	(%rsi), %eax
	movl	%eax, (%rdi)
	xorl	(%rsi), %eax
	movl	%eax, (%rsi)
	xorl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE36:
	.size	swap, .-swap
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$4008, %rsp
	.cfi_def_cfa_offset 8160
	movq	%fs:40, %rax
	movq	%rax, 8088(%rsp)
	xorl	%eax, %eax
	leaq	52(%rsp), %rax
	leaq	64(%rsp), %rbx
	movq	%rax, 16(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, (%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L27:
	movq	16(%rsp), %r8
	movq	8(%rsp), %rcx
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdi
	movq	(%rsp), %rdx
	movq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L5
	movl	40(%rsp), %r12d
	movl	44(%rsp), %r13d
	leal	(%r12,%r13), %eax
	addl	48(%rsp), %eax
	addl	52(%rsp), %eax
	je	.L5
	testl	%r12d, %r12d
	jle	.L6
	leaq	68(%rsp), %r14
	movl	$1, %r13d
	leaq	4080(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%r13d, 0(%rbp,%r13,4)
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	addq	$1, %r13
	addq	$4, %r14
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %r12d
	cmpl	%r13d, %r12d
	jge	.L7
	movl	44(%rsp), %r13d
.L6:
	xorl	%esi, %esi
	movl	$4008004, %edx
	leaq	amida.1(%rip), %rdi
	call	memset@PLT
	leaq	adj.0(%rip), %r15
	xorl	%esi, %esi
	movl	$4008004, %edx
	movq	%r15, %rdi
	call	memset@PLT
	testl	%r13d, %r13d
	jle	.L8
	xorl	%ebp, %ebp
	leaq	56(%rsp), %r14
	leaq	60(%rsp), %r13
	leaq	.LC2(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r14, %rdx
	movq	%r12, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	60(%rsp), %rax
	movslq	56(%rsp), %rdx
	addl	$1, %ebp
	leaq	amida.1(%rip), %rdi
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	$1, (%rdi,%rax,4)
	cmpl	%ebp, 44(%rsp)
	jg	.L9
	movl	40(%rsp), %r12d
.L8:
	movl	48(%rsp), %eax
	cmpl	$1, %eax
	jle	.L10
	cmpl	$1, %r12d
	jle	.L10
	leaq	4+amida.1(%rip), %r10
	leal	-2(%rax), %edx
	leaq	4(%r10), %rax
	leaq	4084(%rsp), %r11
	leaq	(%rax,%rdx,4), %rbp
	leal	-2(%r12), %eax
	leaq	4088(%rsp,%rax,4), %r9
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r11, %rax
	movq	%r10, %rcx
	.p2align 4,,10
	.p2align 3
.L13:
	cmpl	$1, 4004(%rcx)
	jne	.L12
	movslq	(%rax), %rsi
	movslq	4(%rax), %rdx
	imulq	$1001, %rsi, %rdi
	movl	%edx, (%rax)
	movl	%esi, 4(%rax)
	addq	%rdx, %rdi
	imulq	$1001, %rdx, %rdx
	movl	$1, (%r15,%rdi,4)
	addq	%rsi, %rdx
	movl	$1, (%r15,%rdx,4)
.L12:
	addq	$4, %rax
	addq	$4004, %rcx
	cmpq	%r9, %rax
	jne	.L13
	addq	$4, %r10
	cmpq	%rbp, %r10
	jne	.L11
.L14:
	leal	-1(%r12), %eax
	movl	52(%rsp), %ecx
	cmpl	$2, %eax
	jbe	.L30
	movl	%r12d, %eax
	movd	%ecx, %xmm4
	pxor	%xmm1, %xmm1
	shrl	$2, %eax
	pshufd	$0, %xmm4, %xmm2
	leaq	4080(%rsp), %rbp
	leal	-1(%rax), %edx
	movl	$4, %eax
	salq	$4, %rdx
	addq	$20, %rdx
	.p2align 4,,10
	.p2align 3
.L17:
	movdqu	0(%rbp,%rax), %xmm0
	movdqu	(%rbx,%rax), %xmm3
	addq	$16, %rax
	pcmpgtd	%xmm2, %xmm0
	pandn	%xmm3, %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L17
	movdqa	%xmm1, %xmm0
	movl	%r12d, %edx
	psrldq	$8, %xmm0
	andl	$-4, %edx
	paddd	%xmm0, %xmm1
	leal	1(%rdx), %eax
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %r10d
	cmpl	%edx, %r12d
	je	.L18
.L16:
	movslq	%eax, %rdx
	cmpl	4080(%rsp,%rdx,4), %ecx
	jl	.L19
	addl	64(%rsp,%rdx,4), %r10d
.L19:
	leal	1(%rax), %edx
	cmpl	%r12d, %edx
	jg	.L18
	movslq	%edx, %rdx
	cmpl	4080(%rsp,%rdx,4), %ecx
	jl	.L20
	addl	64(%rsp,%rdx,4), %r10d
.L20:
	addl	$2, %eax
	cmpl	%r12d, %eax
	jg	.L18
	cltq
	cmpl	4080(%rsp,%rax,4), %ecx
	jl	.L18
	addl	64(%rsp,%rax,4), %r10d
.L18:
	leal	1(%r12), %esi
	movl	%r10d, %r9d
	movl	$1, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	movslq	0(%rbp,%r11,4), %rdx
	cmpl	%edx, %ecx
	jl	.L23
	imulq	$1001, %rdx, %rdi
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L25:
	movslq	0(%rbp,%rax,4), %rdx
	cmpl	%edx, %ecx
	jge	.L24
	addq	%rdi, %rdx
	movl	(%r15,%rdx,4), %edx
	testl	%edx, %edx
	je	.L24
	movl	%r10d, %edx
	subl	(%rbx,%r11,4), %edx
	addl	(%rbx,%rax,4), %edx
	cmpl	%edx, %r9d
	cmovg	%edx, %r9d
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L25
.L23:
	addq	$1, %r11
	cmpq	%r11, %rsi
	jne	.L26
.L15:
	movl	%r9d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L27
.L10:
	xorl	%r9d, %r9d
	testl	%r12d, %r12d
	jle	.L15
	jmp	.L14
.L5:
	movq	8088(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$8104, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L30:
	.cfi_restore_state
	xorl	%r10d, %r10d
	movl	$1, %eax
	leaq	4080(%rsp), %rbp
	jmp	.L16
.L45:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.local	adj.0
	.comm	adj.0,4008004,32
	.local	amida.1
	.comm	amida.1,4008004,32
	.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:
.LFB35:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovle	%esi, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	min, .-min
	.p2align 4
	.globl	swap
	.type	swap, @function
swap:
.LFB36:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	xorl	(%rsi), %eax
	movl	%eax, (%rdi)
	xorl	(%rsi), %eax
	movl	%eax, (%rsi)
	xorl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE36:
	.size	swap, .-swap
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$4008, %rsp
	.cfi_def_cfa_offset 8160
	movq	%fs:40, %rax
	movq	%rax, 8088(%rsp)
	xorl	%eax, %eax
	leaq	52(%rsp), %rax
	leaq	64(%rsp), %rbx
	movq	%rax, 16(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 8(%rsp)
	leaq	44(%rsp), %rax
	movq	%rax, (%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L27:
	movq	16(%rsp), %r8
	movq	8(%rsp), %rcx
	xorl	%eax, %eax
	leaq	.LC0(%rip), %rdi
	movq	(%rsp), %rdx
	movq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L5
	movl	40(%rsp), %r12d
	movl	44(%rsp), %r13d
	leal	(%r12,%r13), %eax
	addl	48(%rsp), %eax
	addl	52(%rsp), %eax
	je	.L5
	testl	%r12d, %r12d
	jle	.L6
	leaq	68(%rsp), %r14
	movl	$1, %r13d
	leaq	4080(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	movl	%r13d, 0(%rbp,%r13,4)
	movq	%r14, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	addq	$1, %r13
	addq	$4, %r14
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %r12d
	cmpl	%r13d, %r12d
	jge	.L7
	movl	44(%rsp), %r13d
.L6:
	xorl	%esi, %esi
	movl	$4008004, %edx
	leaq	amida.1(%rip), %rdi
	call	memset@PLT
	leaq	adj.0(%rip), %r15
	xorl	%esi, %esi
	movl	$4008004, %edx
	movq	%r15, %rdi
	call	memset@PLT
	testl	%r13d, %r13d
	jle	.L8
	xorl	%ebp, %ebp
	leaq	56(%rsp), %r14
	leaq	60(%rsp), %r13
	leaq	.LC2(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r14, %rdx
	movq	%r12, %rdi
	movq	%r13, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	60(%rsp), %rax
	movslq	56(%rsp), %rdx
	addl	$1, %ebp
	leaq	amida.1(%rip), %rdi
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	movl	$1, (%rdi,%rax,4)
	cmpl	%ebp, 44(%rsp)
	jg	.L9
	movl	40(%rsp), %r12d
.L8:
	movl	48(%rsp), %eax
	cmpl	$1, %eax
	jle	.L10
	cmpl	$1, %r12d
	jle	.L10
	leaq	4+amida.1(%rip), %r10
	leal	-2(%rax), %edx
	leaq	4(%r10), %rax
	leaq	4084(%rsp), %r11
	leaq	(%rax,%rdx,4), %rbp
	leal	-2(%r12), %eax
	leaq	4088(%rsp,%rax,4), %r9
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%r11, %rax
	movq	%r10, %rcx
	.p2align 4,,10
	.p2align 3
.L13:
	cmpl	$1, 4004(%rcx)
	jne	.L12
	movslq	(%rax), %rsi
	movslq	4(%rax), %rdx
	imulq	$1001, %rsi, %rdi
	movl	%edx, (%rax)
	movl	%esi, 4(%rax)
	addq	%rdx, %rdi
	imulq	$1001, %rdx, %rdx
	movl	$1, (%r15,%rdi,4)
	addq	%rsi, %rdx
	movl	$1, (%r15,%rdx,4)
.L12:
	addq	$4, %rax
	addq	$4004, %rcx
	cmpq	%r9, %rax
	jne	.L13
	addq	$4, %r10
	cmpq	%rbp, %r10
	jne	.L11
.L14:
	leal	-1(%r12), %eax
	movl	52(%rsp), %ecx
	cmpl	$2, %eax
	jbe	.L30
	movl	%r12d, %eax
	movd	%ecx, %xmm4
	pxor	%xmm1, %xmm1
	shrl	$2, %eax
	pshufd	$0, %xmm4, %xmm2
	leaq	4080(%rsp), %rbp
	leal	-1(%rax), %edx
	movl	$4, %eax
	salq	$4, %rdx
	addq	$20, %rdx
	.p2align 4,,10
	.p2align 3
.L17:
	movdqu	0(%rbp,%rax), %xmm0
	movdqu	(%rbx,%rax), %xmm3
	addq	$16, %rax
	pcmpgtd	%xmm2, %xmm0
	pandn	%xmm3, %xmm0
	paddd	%xmm0, %xmm1
	cmpq	%rdx, %rax
	jne	.L17
	movdqa	%xmm1, %xmm0
	movl	%r12d, %edx
	psrldq	$8, %xmm0
	andl	$-4, %edx
	paddd	%xmm0, %xmm1
	leal	1(%rdx), %eax
	movdqa	%xmm1, %xmm0
	psrldq	$4, %xmm0
	paddd	%xmm0, %xmm1
	movd	%xmm1, %r10d
	cmpl	%edx, %r12d
	je	.L18
.L16:
	movslq	%eax, %rdx
	cmpl	4080(%rsp,%rdx,4), %ecx
	jl	.L19
	addl	64(%rsp,%rdx,4), %r10d
.L19:
	leal	1(%rax), %edx
	cmpl	%r12d, %edx
	jg	.L18
	movslq	%edx, %rdx
	cmpl	4080(%rsp,%rdx,4), %ecx
	jl	.L20
	addl	64(%rsp,%rdx,4), %r10d
.L20:
	addl	$2, %eax
	cmpl	%r12d, %eax
	jg	.L18
	cltq
	cmpl	4080(%rsp,%rax,4), %ecx
	jl	.L18
	addl	64(%rsp,%rax,4), %r10d
.L18:
	leal	1(%r12), %esi
	movl	%r10d, %r9d
	movl	$1, %r11d
	.p2align 4,,10
	.p2align 3
.L26:
	movslq	0(%rbp,%r11,4), %rdx
	cmpl	%edx, %ecx
	jl	.L23
	imulq	$1001, %rdx, %rdi
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L25:
	movslq	0(%rbp,%rax,4), %rdx
	cmpl	%edx, %ecx
	jge	.L24
	addq	%rdi, %rdx
	movl	(%r15,%rdx,4), %edx
	testl	%edx, %edx
	je	.L24
	movl	%r10d, %edx
	subl	(%rbx,%r11,4), %edx
	addl	(%rbx,%rax,4), %edx
	cmpl	%edx, %r9d
	cmovg	%edx, %r9d
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L25
.L23:
	addq	$1, %r11
	cmpq	%r11, %rsi
	jne	.L26
.L15:
	movl	%r9d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L27
.L10:
	xorl	%r9d, %r9d
	testl	%r12d, %r12d
	jle	.L15
	jmp	.L14
.L5:
	movq	8088(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$8104, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	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
.L30:
	.cfi_restore_state
	xorl	%r10d, %r10d
	movl	$1, %eax
	leaq	4080(%rsp), %rbp
	jmp	.L16
.L45:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.local	adj.0
	.comm	adj.0,4008004,32
	.local	amida.1
	.comm	amida.1,4008004,32
	.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 <string.h>

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

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

int main(void)
{
    int i, j;
    int n, m, h, k;
    int depth, from;
    int score[1001], vertex[1001];
    static int amida[1001][1001];
    static int adj[1001][1001];
    int ans, sum;
    
    while (1){
        if (scanf("%d%d%d%d", &n, &m, &h, &k) == EOF){
            break;
        }
        
        if (n + m + h + k == 0){
            break;
        }
        
        for (i = 1; i <= n; i++){
            vertex[i] = i;
            scanf("%d", &score[i]);
        }
        
        memset(amida, 0, sizeof(amida));
        memset(adj, 0, sizeof(adj));
        for (i = 0; i < m; i++){
            scanf("%d%d", &from, &depth);
            amida[from][depth] = 1;
        }
        
        for (i = 1; i < h; i++){
            for (j = 1; j < n; j++){
                if (amida[j][i] == 1){
                    swap(&vertex[j], &vertex[j + 1]);
                    adj[vertex[j]][vertex[j + 1]] = adj[vertex[j + 1]][vertex[j]] = 1;
                }
            }
        }
        
        sum = 0;
        for (i = 1; i <= n; i++){
            if (vertex[i] <= k){
                sum += score[i];
            }
        }
        
        ans = sum;
        for (i = 1; i <= n; i++){
            for (j = 1; j <= n; j++){
                if (vertex[i] <= k && vertex[j] > k && adj[vertex[i]][vertex[j]]){
                    ans = min(ans, sum - score[i] + score[j]);
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}
4 5 7 2
20
80
100
50
1 1
2 6
2 3
1 5
3 1
2 2 5 1
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
38
80
100
50
1 1
2 6
2 3
1 5
3 1
2 2 5 1
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
38
80
100
50
1 1
2 4
2 3
1 5
3 1
2 2 5 0
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
3 8
1 5
3 1
2 2 5 1
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
3 8
1 5
3 1
2 2 5 1
16
19
1 1
1 3
0 0 0 0
 4 5 7 2
27
80
100
50
1 1
2 4
2 3
1 5
3 1
2 2 16 0
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
3 8
1 5
3 0
2 2 5 1
12
34
1 1
1 3
0 0 0 0
 4 5 12 2
20
80
100
50
1 1
2 6
2 2
1 5
3 1
2 0 5 1
10
20
1 1
1 0
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
4 8
1 5
3 1
2 2 5 1
16
19
1 1
1 3
0 0 0 0
 4 5 7 2
38
80
100
50
2 1
2 6
3 8
1 5
3 0
2 2 5 1
16
34
1 1
1 3
0 0 0 0

100
10
 118
10
 118
0
 70
10
 70
16
 107
0
 100
12
 100
10
0
0
 70
16
 118
16

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 <string.h>

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

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

int main(void)
{
    int i, j;
    int n, m, h, k;
    int depth, from;
    int score[1001], vertex[1001];
    static int amida[1001][1001];
    static int adj[1001][1001];
    int ans, sum;
    
    while (1){
        if (scanf("%d%d%d%d", &n, &m, &h, &k) == EOF){
            break;
        }
        
        if (n + m + h + k == 0){
            break;
        }
        
        for (i = 1; i <= n; i++){
            vertex[i] = i;
            scanf("%d", &score[i]);
        }
        
        memset(amida, 0, sizeof(amida));
        memset(adj, 0, sizeof(adj));
        for (i = 0; i < m; i++){
            scanf("%d%d", &from, &depth);
            amida[from][depth] = 1;
        }
        
        for (i = 1; i < h; i++){
            for (j = 1; j < n; j++){
                if (amida[j][i] == 1){
                    swap(&vertex[j], &vertex[j + 1]);
                    adj[vertex[j]][vertex[j + 1]] = adj[vertex[j + 1]][vertex[j]] = 1;
                }
            }
        }
        
        sum = 0;
        for (i = 1; i <= n; i++){
            if (vertex[i] <= k){
                sum += score[i];
            }
        }
        
        ans = sum;
        for (i = 1; i <= n; i++){
            for (j = 1; j <= n; j++){
                if (vertex[i] <= k && vertex[j] > k && adj[vertex[i]][vertex[j]]){
                    ans = min(ans, sum - score[i] + score[j]);
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.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	-8(%rbp), %edx
	movl	-4(%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, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	swap, .-swap
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$3984, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L25:
	leaq	-8060(%rbp), %rsi
	leaq	-8064(%rbp), %rcx
	leaq	-8068(%rbp), %rdx
	leaq	-8072(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L28
	movl	-8072(%rbp), %edx
	movl	-8068(%rbp), %eax
	addl	%eax, %edx
	movl	-8064(%rbp), %eax
	addl	%eax, %edx
	movl	-8060(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	je	.L29
	movl	$1, -8048(%rbp)
	jmp	.L8
.L9:
	movl	-8048(%rbp), %eax
	cltq
	movl	-8048(%rbp), %edx
	movl	%edx, -4016(%rbp,%rax,4)
	leaq	-8032(%rbp), %rdx
	movl	-8048(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8048(%rbp)
.L8:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L9
	movl	$4008004, %edx
	movl	$0, %esi
	leaq	amida.1(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$4008004, %edx
	movl	$0, %esi
	leaq	adj.0(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -8048(%rbp)
	jmp	.L10
.L11:
	leaq	-8056(%rbp), %rdx
	leaq	-8052(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-8052(%rbp), %eax
	movl	-8056(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	amida.1(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -8048(%rbp)
.L10:
	movl	-8068(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jl	.L11
	movl	$1, -8048(%rbp)
	jmp	.L12
.L16:
	movl	$1, -8044(%rbp)
	jmp	.L13
.L15:
	movl	-8048(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8044(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	amida.1(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L14
	movl	-8044(%rbp), %eax
	addl	$1, %eax
	leaq	-4016(%rbp), %rdx
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-4016(%rbp), %rcx
	movl	-8044(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	movl	-8044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	movl	-8044(%rbp), %edx
	movslq	%edx, %rdx
	movl	-4016(%rbp,%rdx,4), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$1001, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	adj.0(%rip), %rcx
	movl	$1, (%rsi,%rcx)
	movl	-8044(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	-4016(%rbp,%rcx,4), %esi
	movl	-8044(%rbp), %ecx
	addl	$1, %ecx
	movslq	%ecx, %rcx
	movl	-4016(%rbp,%rcx,4), %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rcx
	movslq	%esi, %rdx
	imulq	$1001, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	adj.0(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L14:
	addl	$1, -8044(%rbp)
.L13:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8044(%rbp)
	jl	.L15
	addl	$1, -8048(%rbp)
.L12:
	movl	-8064(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jl	.L16
	movl	$0, -8036(%rbp)
	movl	$1, -8048(%rbp)
	jmp	.L17
.L19:
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L18
	movl	-8048(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %eax
	addl	%eax, -8036(%rbp)
.L18:
	addl	$1, -8048(%rbp)
.L17:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L19
	movl	-8036(%rbp), %eax
	movl	%eax, -8040(%rbp)
	movl	$1, -8048(%rbp)
	jmp	.L20
.L24:
	movl	$1, -8044(%rbp)
	jmp	.L21
.L23:
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L22
	movl	-8044(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L22
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8044(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-8048(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %edx
	movl	-8036(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-8044(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %eax
	leal	(%rcx,%rax), %edx
	movl	-8040(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, -8040(%rbp)
.L22:
	addl	$1, -8044(%rbp)
.L21:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8044(%rbp)
	jle	.L23
	addl	$1, -8048(%rbp)
.L20:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L24
	movl	-8040(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L25
.L28:
	nop
	jmp	.L6
.L29:
	nop
.L6:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.local	amida.1
	.comm	amida.1,4008004,32
	.local	adj.0
	.comm	adj.0,4008004,32
	.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	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	-8(%rbp), %edx
	movl	-4(%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, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	swap, .-swap
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$3984, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L25:
	leaq	-8060(%rbp), %rsi
	leaq	-8064(%rbp), %rcx
	leaq	-8068(%rbp), %rdx
	leaq	-8072(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L28
	movl	-8072(%rbp), %edx
	movl	-8068(%rbp), %eax
	addl	%eax, %edx
	movl	-8064(%rbp), %eax
	addl	%eax, %edx
	movl	-8060(%rbp), %eax
	addl	%edx, %eax
	testl	%eax, %eax
	je	.L29
	movl	$1, -8048(%rbp)
	jmp	.L8
.L9:
	movl	-8048(%rbp), %eax
	cltq
	movl	-8048(%rbp), %edx
	movl	%edx, -4016(%rbp,%rax,4)
	leaq	-8032(%rbp), %rdx
	movl	-8048(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -8048(%rbp)
.L8:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L9
	movl	$4008004, %edx
	movl	$0, %esi
	leaq	amida.1(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$4008004, %edx
	movl	$0, %esi
	leaq	adj.0(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -8048(%rbp)
	jmp	.L10
.L11:
	leaq	-8056(%rbp), %rdx
	leaq	-8052(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-8052(%rbp), %eax
	movl	-8056(%rbp), %edx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	amida.1(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -8048(%rbp)
.L10:
	movl	-8068(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jl	.L11
	movl	$1, -8048(%rbp)
	jmp	.L12
.L16:
	movl	$1, -8044(%rbp)
	jmp	.L13
.L15:
	movl	-8048(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8044(%rbp), %eax
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	amida.1(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L14
	movl	-8044(%rbp), %eax
	addl	$1, %eax
	leaq	-4016(%rbp), %rdx
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	leaq	-4016(%rbp), %rcx
	movl	-8044(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	swap
	movl	-8044(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	movl	-8044(%rbp), %edx
	movslq	%edx, %rdx
	movl	-4016(%rbp,%rdx,4), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rcx
	imulq	$1001, %rcx, %rcx
	addq	%rsi, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	adj.0(%rip), %rcx
	movl	$1, (%rsi,%rcx)
	movl	-8044(%rbp), %ecx
	movslq	%ecx, %rcx
	movl	-4016(%rbp,%rcx,4), %esi
	movl	-8044(%rbp), %ecx
	addl	$1, %ecx
	movslq	%ecx, %rcx
	movl	-4016(%rbp,%rcx,4), %ecx
	movslq	%edx, %rdx
	cltq
	imulq	$1001, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%ecx, %rcx
	movslq	%esi, %rdx
	imulq	$1001, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	adj.0(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L14:
	addl	$1, -8044(%rbp)
.L13:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8044(%rbp)
	jl	.L15
	addl	$1, -8048(%rbp)
.L12:
	movl	-8064(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jl	.L16
	movl	$0, -8036(%rbp)
	movl	$1, -8048(%rbp)
	jmp	.L17
.L19:
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L18
	movl	-8048(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %eax
	addl	%eax, -8036(%rbp)
.L18:
	addl	$1, -8048(%rbp)
.L17:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L19
	movl	-8036(%rbp), %eax
	movl	%eax, -8040(%rbp)
	movl	$1, -8048(%rbp)
	jmp	.L20
.L24:
	movl	$1, -8044(%rbp)
	jmp	.L21
.L23:
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jg	.L22
	movl	-8044(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8060(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L22
	movl	-8048(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %edx
	movl	-8044(%rbp), %eax
	cltq
	movl	-4016(%rbp,%rax,4), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1001, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	adj.0(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-8048(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %edx
	movl	-8036(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-8044(%rbp), %eax
	cltq
	movl	-8032(%rbp,%rax,4), %eax
	leal	(%rcx,%rax), %edx
	movl	-8040(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	%eax, -8040(%rbp)
.L22:
	addl	$1, -8044(%rbp)
.L21:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8044(%rbp)
	jle	.L23
	addl	$1, -8048(%rbp)
.L20:
	movl	-8072(%rbp), %eax
	cmpl	%eax, -8048(%rbp)
	jle	.L24
	movl	-8040(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L25
.L28:
	nop
	jmp	.L6
.L29:
	nop
.L6:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L27
	call	__stack_chk_fail@PLT
.L27:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.local	amida.1
	.comm	amida.1,4008004,32
	.local	adj.0
	.comm	adj.0,4008004,32
	.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:
