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 100000000

struct NODE {
    int distance;
    int state;
} vertex[101];

int W[101][101];
int n, m;

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

int prim(int start) {
    int x, p, step, sum = 0;

    for (x = 0; x < n; x++) {
	vertex[x].distance = MAX; vertex[x].state = 0;
    }
    vertex[start].distance = 0; 
    for (step = 1; step <= n; step++) {
	int minimum = MAX;
	for (x = 0; x < n; x++)
	    if (vertex[x].state == 0 && vertex[x].distance < minimum) {
		p = x; minimum = vertex[x].distance;
	    }
	vertex[p].state = 1;
	sum += minimum;
	for (x = 0 ; x < n; x++)
		vertex[x].distance = min(vertex[x].distance, W[p][x]);
    }
    return sum;
}

int main(void) {
    int i, j;
    int from, to, cost;
     
    while (1) {
	scanf("%d", &n);
	scanf("%d", &m);
        if (n == 0) break;
         
        for (i = 0; i < n; i++)
            for (j = 0; j < n; j++)
                W[i][j] = MAX;
         
	for (i = 0; i < m; i++) {
            scanf("%d %d %d", &from, &to, &cost);
            W[from][to] = cost;
	    W[to][from] = cost;
        }

	printf("%d\n", prim(0));
    }
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	vertex
	.bss
	.align 32
	.type	vertex, @object
	.size	vertex, 808
vertex:
	.zero	808
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 40804
W:
	.zero	40804
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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	prim
	.type	prim, @function
prim:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$40, %rsp
	movl	%edi, -36(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L4
.L5:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L5
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$1, -12(%rbp)
	jmp	.L6
.L12:
	movl	$100000000, -4(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L7
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L8
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L8
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
.L8:
	addl	$1, -20(%rbp)
.L7:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L9
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	addl	%eax, -8(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L10
.L11:
	movl	-20(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	vertex(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	vertex(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -20(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	addl	$1, -12(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L12
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	prim, .-prim
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L23:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	m(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L27
	movl	$0, -16(%rbp)
	jmp	.L17
.L20:
	movl	$0, -12(%rbp)
	jmp	.L18
.L19:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L19
	addl	$1, -16(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-20(%rbp), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L21:
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	movl	$0, %edi
	call	prim
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L23
.L27:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	prim
	.type	prim, @function
prim:
.LFB24:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r9d
	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
	testl	%r9d, %r9d
	jle	.L4
	cmpl	$1, %r9d
	je	.L15
	movl	%r9d, %ecx
	leaq	vertex(%rip), %rax
	movdqa	.LC0(%rip), %xmm0
	shrl	%ecx
	leaq	16(%rax), %rsi
	movq	%rax, %rdx
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%rsi, %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movaps	%xmm0, (%rdx)
	addq	$16, %rdx
	cmpq	%rcx, %rdx
	jne	.L6
	movl	%r9d, %edx
	andl	$-2, %edx
	testb	$1, %r9b
	je	.L7
.L5:
	movq	.LC1(%rip), %rcx
	movslq	%edx, %rdx
	movq	%rcx, (%rax,%rdx,8)
.L7:
	movl	%r9d, %edx
	movslq	%edi, %rdi
	leal	1(%r9), %ebx
	movl	%r9d, %r13d
	shrl	$2, %edx
	movl	$0, (%rax,%rdi,8)
	xorl	%r12d, %r12d
	movl	%r9d, %ecx
	leal	-1(%rdx), %r14d
	movl	%ebx, -12(%rsp)
	leal	-1(%r9), %ebx
	andl	$-4, %r13d
	addq	$1, %r14
	movl	%ebx, -16(%rsp)
	movl	$1, %r11d
	leaq	4+vertex(%rip), %rdx
	leaq	W(%rip), %rbx
	salq	$4, %r14
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%esi, %esi
	movl	$100000000, %r8d
	.p2align 4,,10
	.p2align 3
.L9:
	movl	(%rdx,%rsi,8), %edi
	testl	%edi, %edi
	jne	.L8
	movl	(%rax,%rsi,8), %edi
	cmpl	%r8d, %edi
	jge	.L8
	movl	%edi, %r8d
	movl	%esi, %ebp
.L8:
	addq	$1, %rsi
	cmpq	%rcx, %rsi
	jne	.L9
	movslq	%ebp, %rdi
	addl	%r8d, %r12d
	cmpl	$2, -16(%rsp)
	movl	$1, 4(%rax,%rdi,8)
	jbe	.L17
	imulq	$404, %rdi, %r8
	leaq	vertex(%rip), %rsi
	addq	%rbx, %r8
	leaq	(%r14,%r8), %r10
	.p2align 4,,10
	.p2align 3
.L11:
	movdqu	(%r8), %xmm3
	movdqa	(%rsi), %xmm2
	addq	$16, %r8
	addq	$32, %rsi
	shufps	$136, -16(%rsi), %xmm2
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm3, %xmm0
	movdqa	%xmm3, %xmm1
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	pshufd	$85, %xmm0, %xmm1
	movd	%xmm0, -32(%rsi)
	movd	%xmm1, -24(%rsi)
	movdqa	%xmm0, %xmm1
	punpckhdq	%xmm0, %xmm1
	pshufd	$255, %xmm0, %xmm0
	movd	%xmm1, -16(%rsi)
	movd	%xmm0, -8(%rsi)
	cmpq	%r10, %r8
	jne	.L11
	movl	%r13d, %esi
	cmpl	%r9d, %r13d
	je	.L12
.L10:
	leaq	(%rdi,%rdi,4), %r8
	movslq	%esi, %r10
	leaq	(%r8,%r8,4), %r8
	movl	(%rax,%r10,8), %r15d
	leaq	(%rdi,%r8,4), %r8
	leaq	(%r8,%r10), %rdi
	movl	(%rbx,%rdi,4), %edi
	cmpl	%r15d, %edi
	cmovg	%r15d, %edi
	movl	%edi, (%rax,%r10,8)
	leal	1(%rsi), %edi
	cmpl	%edi, %r9d
	jle	.L12
	movslq	%edi, %rdi
	leaq	(%r8,%rdi), %r15
	movl	(%rax,%rdi,8), %r10d
	movl	(%rbx,%r15,4), %r15d
	cmpl	%r15d, %r10d
	cmovg	%r15d, %r10d
	addl	$2, %esi
	movl	%r10d, (%rax,%rdi,8)
	cmpl	%esi, %r9d
	jle	.L12
	movslq	%esi, %rsi
	addq	%rsi, %r8
	movl	(%rax,%rsi,8), %edi
	movl	(%rbx,%r8,4), %r8d
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	movl	%edi, (%rax,%rsi,8)
.L12:
	addl	$1, %r11d
	cmpl	-12(%rsp), %r11d
	jne	.L13
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	movl	%r12d, %eax
	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
	.p2align 4,,10
	.p2align 3
.L17:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L10
.L4:
	leaq	vertex(%rip), %rax
	xorl	%r12d, %r12d
	movslq	%edi, %rdi
	movl	$0, (%rax,%rdi,8)
	movl	%r12d, %eax
	popq	%rbx
	.cfi_remember_state
	.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
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	leaq	vertex(%rip), %rax
	jmp	.L5
	.cfi_endproc
.LFE24:
	.size	prim, .-prim
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC4:
	.string	"%d %d %d"
.LC5:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	W(%rip), %r15
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L33:
	leaq	n(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	m(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	je	.L24
	movdqa	.LC3(%rip), %xmm0
	jle	.L25
	movl	%ecx, %eax
	movl	%ecx, %r9d
	leaq	W(%rip), %rsi
	xorl	%edi, %edi
	shrl	$2, %eax
	leal	-1(%rcx), %r11d
	andl	$-4, %r9d
	leal	-1(%rax), %r10d
	addq	$1, %r10
	salq	$4, %r10
	.p2align 4,,10
	.p2align 3
.L26:
	cmpl	$2, %r11d
	jbe	.L35
	leaq	(%r10,%rsi), %rdx
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L28:
	movups	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L28
	movl	%r9d, %eax
	cmpl	%ecx, %r9d
	je	.L27
.L30:
	movslq	%edi, %rbx
	movslq	%eax, %rdx
	leaq	(%rbx,%rbx,4), %rbp
	leaq	0(%rbp,%rbp,4), %rbp
	leaq	(%rbx,%rbp,4), %rbx
	addq	%rbx, %rdx
	movl	$100000000, (%r15,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jle	.L27
	movslq	%edx, %rdx
	addl	$2, %eax
	addq	%rbx, %rdx
	movl	$100000000, (%r15,%rdx,4)
	cmpl	%eax, %ecx
	jle	.L27
	cltq
	addq	%rax, %rbx
	movl	$100000000, (%r15,%rbx,4)
.L27:
	addl	$1, %edi
	addq	$404, %rsi
	cmpl	%edi, %ecx
	jne	.L26
.L25:
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L31
	xorl	%r14d, %r14d
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %r12
	leaq	12(%rsp), %rbp
	leaq	.LC4(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L32:
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	movslq	16(%rsp), %rdx
	movl	20(%rsp), %esi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rcx
	addq	%rdx, %rcx
	movl	%esi, (%r15,%rcx,4)
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rdx
	addq	%rdx, %rax
	cmpl	%r14d, m(%rip)
	movl	%esi, (%r15,%rax,4)
	jg	.L32
.L31:
	xorl	%edi, %edi
	call	prim
	leaq	.LC5(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L35:
	xorl	%eax, %eax
	jmp	.L30
.L24:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$40, %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
.L40:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 40804
W:
	.zero	40804
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 808
vertex:
	.zero	808
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	100000000
	.long	0
	.long	100000000
	.long	0
	.set	.LC1,.LC0
	.align 16
.LC3:
	.long	100000000
	.long	100000000
	.long	100000000
	.long	100000000
	.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	prim
	.type	prim, @function
prim:
.LFB24:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r9d
	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
	testl	%r9d, %r9d
	jle	.L4
	cmpl	$1, %r9d
	je	.L15
	movl	%r9d, %ecx
	leaq	vertex(%rip), %rax
	movdqa	.LC0(%rip), %xmm0
	shrl	%ecx
	leaq	16(%rax), %rsi
	movq	%rax, %rdx
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%rsi, %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movaps	%xmm0, (%rdx)
	addq	$16, %rdx
	cmpq	%rcx, %rdx
	jne	.L6
	movl	%r9d, %edx
	andl	$-2, %edx
	testb	$1, %r9b
	je	.L7
.L5:
	movq	.LC1(%rip), %rcx
	movslq	%edx, %rdx
	movq	%rcx, (%rax,%rdx,8)
.L7:
	movl	%r9d, %edx
	movslq	%edi, %rdi
	leal	1(%r9), %ebx
	movl	%r9d, %r13d
	shrl	$2, %edx
	movl	$0, (%rax,%rdi,8)
	xorl	%r12d, %r12d
	movl	%r9d, %ecx
	leal	-1(%rdx), %r14d
	movl	%ebx, -12(%rsp)
	leal	-1(%r9), %ebx
	andl	$-4, %r13d
	addq	$1, %r14
	movl	%ebx, -16(%rsp)
	movl	$1, %r11d
	leaq	4+vertex(%rip), %rdx
	leaq	W(%rip), %rbx
	salq	$4, %r14
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%esi, %esi
	movl	$100000000, %r8d
	.p2align 4,,10
	.p2align 3
.L9:
	movl	(%rdx,%rsi,8), %edi
	testl	%edi, %edi
	jne	.L8
	movl	(%rax,%rsi,8), %edi
	cmpl	%r8d, %edi
	jge	.L8
	movl	%edi, %r8d
	movl	%esi, %ebp
.L8:
	addq	$1, %rsi
	cmpq	%rcx, %rsi
	jne	.L9
	movslq	%ebp, %rdi
	addl	%r8d, %r12d
	cmpl	$2, -16(%rsp)
	movl	$1, 4(%rax,%rdi,8)
	jbe	.L17
	imulq	$404, %rdi, %r8
	leaq	vertex(%rip), %rsi
	addq	%rbx, %r8
	leaq	(%r14,%r8), %r10
	.p2align 4,,10
	.p2align 3
.L11:
	movdqu	(%r8), %xmm3
	movdqa	(%rsi), %xmm2
	addq	$16, %r8
	addq	$32, %rsi
	shufps	$136, -16(%rsi), %xmm2
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm3, %xmm0
	movdqa	%xmm3, %xmm1
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	pshufd	$85, %xmm0, %xmm1
	movd	%xmm0, -32(%rsi)
	movd	%xmm1, -24(%rsi)
	movdqa	%xmm0, %xmm1
	punpckhdq	%xmm0, %xmm1
	pshufd	$255, %xmm0, %xmm0
	movd	%xmm1, -16(%rsi)
	movd	%xmm0, -8(%rsi)
	cmpq	%r10, %r8
	jne	.L11
	movl	%r13d, %esi
	cmpl	%r9d, %r13d
	je	.L12
.L10:
	leaq	(%rdi,%rdi,4), %r8
	movslq	%esi, %r10
	leaq	(%r8,%r8,4), %r8
	movl	(%rax,%r10,8), %r15d
	leaq	(%rdi,%r8,4), %r8
	leaq	(%r8,%r10), %rdi
	movl	(%rbx,%rdi,4), %edi
	cmpl	%r15d, %edi
	cmovg	%r15d, %edi
	movl	%edi, (%rax,%r10,8)
	leal	1(%rsi), %edi
	cmpl	%edi, %r9d
	jle	.L12
	movslq	%edi, %rdi
	leaq	(%r8,%rdi), %r15
	movl	(%rax,%rdi,8), %r10d
	movl	(%rbx,%r15,4), %r15d
	cmpl	%r15d, %r10d
	cmovg	%r15d, %r10d
	addl	$2, %esi
	movl	%r10d, (%rax,%rdi,8)
	cmpl	%esi, %r9d
	jle	.L12
	movslq	%esi, %rsi
	addq	%rsi, %r8
	movl	(%rax,%rsi,8), %edi
	movl	(%rbx,%r8,4), %r8d
	cmpl	%r8d, %edi
	cmovg	%r8d, %edi
	movl	%edi, (%rax,%rsi,8)
.L12:
	addl	$1, %r11d
	cmpl	-12(%rsp), %r11d
	jne	.L13
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	movl	%r12d, %eax
	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
	.p2align 4,,10
	.p2align 3
.L17:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L10
.L4:
	leaq	vertex(%rip), %rax
	xorl	%r12d, %r12d
	movslq	%edi, %rdi
	movl	$0, (%rax,%rdi,8)
	movl	%r12d, %eax
	popq	%rbx
	.cfi_remember_state
	.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
.L15:
	.cfi_restore_state
	xorl	%edx, %edx
	leaq	vertex(%rip), %rax
	jmp	.L5
	.cfi_endproc
.LFE24:
	.size	prim, .-prim
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC4:
	.string	"%d %d %d"
.LC5:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	W(%rip), %r15
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L33:
	leaq	n(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	m(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	je	.L24
	movdqa	.LC3(%rip), %xmm0
	jle	.L25
	movl	%ecx, %eax
	movl	%ecx, %r9d
	leaq	W(%rip), %rsi
	xorl	%edi, %edi
	shrl	$2, %eax
	leal	-1(%rcx), %r11d
	andl	$-4, %r9d
	leal	-1(%rax), %r10d
	addq	$1, %r10
	salq	$4, %r10
	.p2align 4,,10
	.p2align 3
.L26:
	cmpl	$2, %r11d
	jbe	.L35
	leaq	(%r10,%rsi), %rdx
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L28:
	movups	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L28
	movl	%r9d, %eax
	cmpl	%ecx, %r9d
	je	.L27
.L30:
	movslq	%edi, %rbx
	movslq	%eax, %rdx
	leaq	(%rbx,%rbx,4), %rbp
	leaq	0(%rbp,%rbp,4), %rbp
	leaq	(%rbx,%rbp,4), %rbx
	addq	%rbx, %rdx
	movl	$100000000, (%r15,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jle	.L27
	movslq	%edx, %rdx
	addl	$2, %eax
	addq	%rbx, %rdx
	movl	$100000000, (%r15,%rdx,4)
	cmpl	%eax, %ecx
	jle	.L27
	cltq
	addq	%rax, %rbx
	movl	$100000000, (%r15,%rbx,4)
.L27:
	addl	$1, %edi
	addq	$404, %rsi
	cmpl	%edi, %ecx
	jne	.L26
.L25:
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L31
	xorl	%r14d, %r14d
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %r12
	leaq	12(%rsp), %rbp
	leaq	.LC4(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L32:
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	movslq	16(%rsp), %rdx
	movl	20(%rsp), %esi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rcx
	addq	%rdx, %rcx
	movl	%esi, (%r15,%rcx,4)
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rdx
	addq	%rdx, %rax
	cmpl	%r14d, m(%rip)
	movl	%esi, (%r15,%rax,4)
	jg	.L32
.L31:
	xorl	%edi, %edi
	call	prim
	leaq	.LC5(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L35:
	xorl	%eax, %eax
	jmp	.L30
.L24:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	addq	$40, %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
.L40:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 40804
W:
	.zero	40804
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 808
vertex:
	.zero	808
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	100000000
	.long	0
	.long	100000000
	.long	0
	.set	.LC1,.LC0
	.align 16
.LC3:
	.long	100000000
	.long	100000000
	.long	100000000
	.long	100000000
	.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 100000000

struct NODE {
    int distance;
    int state;
} vertex[101];

int W[101][101];
int n, m;

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

int prim(int start) {
    int x, p, step, sum = 0;

    for (x = 0; x < n; x++) {
	vertex[x].distance = MAX; vertex[x].state = 0;
    }
    vertex[start].distance = 0; 
    for (step = 1; step <= n; step++) {
	int minimum = MAX;
	for (x = 0; x < n; x++)
	    if (vertex[x].state == 0 && vertex[x].distance < minimum) {
		p = x; minimum = vertex[x].distance;
	    }
	vertex[p].state = 1;
	sum += minimum;
	for (x = 0 ; x < n; x++)
		vertex[x].distance = min(vertex[x].distance, W[p][x]);
    }
    return sum;
}

int main(void) {
    int i, j;
    int from, to, cost;
     
    while (1) {
	scanf("%d", &n);
	scanf("%d", &m);
        if (n == 0) break;
         
        for (i = 0; i < n; i++)
            for (j = 0; j < n; j++)
                W[i][j] = MAX;
         
	for (i = 0; i < m; i++) {
            scanf("%d %d %d", &from, &to, &cost);
            W[from][to] = cost;
	    W[to][from] = cost;
        }

	printf("%d\n", prim(0));
    }
    return 0;
}
5 6
0 2 1
2 1 3
2 3 8
1 3 1
3 4 5
1 4 4
3 3
1 2 3
2 0 3
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 8
1 3 3
3 4 5
1 4 4
3 3
1 2 3
2 0 3
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 8
1 3 0
3 4 5
1 4 4
3 3
1 2 3
2 0 3
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 6
0 3 1
3 4 8
1 3 4
3 3
1 2 3
2 0 3
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 8
1 3 2
3 4 5
1 4 4
3 3
1 2 3
2 0 4
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 8
1 3 1
3 4 2
1 4 4
3 3
1 2 3
2 0 3
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 6
0 3 1
3 4 8
1 3 4
3 3
1 2 3
2 0 3
0 1 1
0 0
 5 6
0 1 1
2 1 3
2 3 8
1 3 2
3 4 5
1 4 5
3 3
1 2 2
2 0 4
0 1 3
0 0
 5 6
0 2 1
2 1 3
2 3 6
0 3 1
3 4 8
1 3 4
3 3
1 2 3
2 0 3
0 1 0
0 0
 5 6
0 2 1
2 1 3
2 3 6
0 3 2
3 4 8
1 3 4
3 3
1 2 3
2 0 3
0 1 1
0 0

9
6
 11
6
 8
6
 13
6
 10
6
 7
6
 13
4
 11
5
 13
3
 14
4

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 100000000

struct NODE {
    int distance;
    int state;
} vertex[101];

int W[101][101];
int n, m;

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

int prim(int start) {
    int x, p, step, sum = 0;

    for (x = 0; x < n; x++) {
	vertex[x].distance = MAX; vertex[x].state = 0;
    }
    vertex[start].distance = 0; 
    for (step = 1; step <= n; step++) {
	int minimum = MAX;
	for (x = 0; x < n; x++)
	    if (vertex[x].state == 0 && vertex[x].distance < minimum) {
		p = x; minimum = vertex[x].distance;
	    }
	vertex[p].state = 1;
	sum += minimum;
	for (x = 0 ; x < n; x++)
		vertex[x].distance = min(vertex[x].distance, W[p][x]);
    }
    return sum;
}

int main(void) {
    int i, j;
    int from, to, cost;
     
    while (1) {
	scanf("%d", &n);
	scanf("%d", &m);
        if (n == 0) break;
         
        for (i = 0; i < n; i++)
            for (j = 0; j < n; j++)
                W[i][j] = MAX;
         
	for (i = 0; i < m; i++) {
            scanf("%d %d %d", &from, &to, &cost);
            W[from][to] = cost;
	    W[to][from] = cost;
        }

	printf("%d\n", prim(0));
    }
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	vertex
	.bss
	.align 32
	.type	vertex, @object
	.size	vertex, 808
vertex:
	.zero	808
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 40804
W:
	.zero	40804
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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	prim
	.type	prim, @function
prim:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$40, %rsp
	movl	%edi, -36(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L4
.L5:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L5
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$1, -12(%rbp)
	jmp	.L6
.L12:
	movl	$100000000, -4(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L7
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L8
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L8
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
.L8:
	addl	$1, -20(%rbp)
.L7:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L9
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	addl	%eax, -8(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L10
.L11:
	movl	-20(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	vertex(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	vertex(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -20(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	addl	$1, -12(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L12
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	prim, .-prim
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L23:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	m(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L27
	movl	$0, -16(%rbp)
	jmp	.L17
.L20:
	movl	$0, -12(%rbp)
	jmp	.L18
.L19:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L19
	addl	$1, -16(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-20(%rbp), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L21:
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	movl	$0, %edi
	call	prim
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L23
.L27:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	vertex
	.bss
	.align 32
	.type	vertex, @object
	.size	vertex, 808
vertex:
	.zero	808
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 40804
W:
	.zero	40804
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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	prim
	.type	prim, @function
prim:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$40, %rsp
	movl	%edi, -36(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L4
.L5:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -20(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L5
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$1, -12(%rbp)
	jmp	.L6
.L12:
	movl	$100000000, -4(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L7
.L9:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L8
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L8
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
.L8:
	addl	$1, -20(%rbp)
.L7:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L9
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+vertex(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	addl	%eax, -8(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L10
.L11:
	movl	-20(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	vertex(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	vertex(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -20(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	addl	$1, -12(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L12
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	prim, .-prim
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
.LC2:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L23:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	m(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L27
	movl	$0, -16(%rbp)
	jmp	.L17
.L20:
	movl	$0, -12(%rbp)
	jmp	.L18
.L19:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L19
	addl	$1, -16(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-24(%rbp), %eax
	movl	-28(%rbp), %edx
	movl	-20(%rbp), %ecx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	W(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L21:
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	movl	$0, %edi
	call	prim
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L23
.L27:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
