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>

static const int MAX = 500;
static const int INFTY = (1<<21);

#define NIL -1

int p[100];

int key[100];

int n;


main(){
  int i, j, e, v, sum;
 
  int u;

  int M[100][100];

  int l[100];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }



  for(u=0;u<n;u++){
    key[u] =100000000;

    p[u] =NIL;

    l[u]=NIL;
  }
  key[0] = 0;

  while(1){
    int u=NIL;
    int v = 100000000;


    for(i=0;i<n;i++){
     

      if(key[i]<v && l[i]==NIL){
	v = key[i];
	u=i;
      }
    }
	
      
    
    if(u==NIL){
      break;
    }

    for(v=0;v<n;v++){
      if(M[u][v] < key[v] && l[v]==NIL){
	key[v] = M[u][v];
	p[v]= u;
      }
    }
    l[u]=0;
  }


  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
	.align 4
	.type	MAX, @object
	.size	MAX, 4
MAX:
	.long	500
	.align 4
	.type	INFTY, @object
	.size	INFTY, 4
INFTY:
	.long	2097152
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.globl	key
	.align 32
	.type	key, @object
	.size	key, 400
key:
	.zero	400
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3584, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40440(%rbp)
	jmp	.L2
.L7:
	movl	$0, -40436(%rbp)
	jmp	.L3
.L6:
	leaq	-40444(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40444(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L4
	movl	$2097152, %edx
	jmp	.L5
.L4:
	movl	-40444(%rbp), %edx
.L5:
	movl	-40436(%rbp), %eax
	movslq	%eax, %rsi
	movl	-40440(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40436(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -40436(%rbp)
	jl	.L6
	addl	$1, -40440(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L7
	movl	$0, -40428(%rbp)
	jmp	.L8
.L9:
	movl	-40428(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	movl	-40428(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-40428(%rbp), %eax
	cltq
	movl	$-1, -40416(%rbp,%rax,4)
	addl	$1, -40428(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L9
	movl	$0, key(%rip)
.L18:
	movl	$-1, -40424(%rbp)
	movl	$100000000, -40420(%rbp)
	movl	$0, -40440(%rbp)
	jmp	.L10
.L12:
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -40420(%rbp)
	jle	.L11
	movl	-40440(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L11
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40420(%rbp)
	movl	-40440(%rbp), %eax
	movl	%eax, -40424(%rbp)
.L11:
	addl	$1, -40440(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L12
	cmpl	$-1, -40424(%rbp)
	je	.L25
	movl	$0, -40420(%rbp)
	jmp	.L15
.L17:
	movl	-40420(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40424(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %edx
	movl	-40420(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	key(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L16
	movl	-40420(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L16
	movl	-40420(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40424(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %eax
	movl	-40420(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	key(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-40420(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-40424(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L16:
	addl	$1, -40420(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -40420(%rbp)
	jl	.L17
	movl	-40424(%rbp), %eax
	cltq
	movl	$0, -40416(%rbp,%rax,4)
	jmp	.L18
.L25:
	nop
	movl	$0, -40432(%rbp)
	movl	$0, -40440(%rbp)
	jmp	.L19
.L21:
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	je	.L20
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rcx
	movl	-40440(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %eax
	addl	%eax, -40432(%rbp)
.L20:
	addl	$1, -40440(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L21
	movl	-40432(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3576, %rsp
	.cfi_def_cfa_offset 40496
	leaq	.LC0(%rip), %r12
	leaq	n(%rip), %rsi
	xorl	%r14d, %r14d
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 40424(%rsp)
	xorl	%eax, %eax
	leaq	416(%rsp), %rbp
	leaq	12(%rsp), %r13
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r15d
	testl	%r15d, %r15d
	jle	.L3
	.p2align 4,,10
	.p2align 3
.L19:
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	cmpl	$-1, %eax
	je	.L4
	movl	n(%rip), %r15d
	movl	%eax, 0(%rbp,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, %r15d
	jg	.L7
.L6:
	addl	$1, %r14d
	cmpl	%r14d, %r15d
	jle	.L39
	addq	$400, %rbp
	jmp	.L19
.L39:
	testl	%r15d, %r15d
	jle	.L3
	leal	-1(%r15), %eax
	cmpl	$2, %eax
	jbe	.L23
	movl	%r15d, %edx
	leaq	key(%rip), %rcx
	movdqa	.LC1(%rip), %xmm0
	shrl	$2, %edx
	leaq	16(%rcx), %rsi
	movq	%rcx, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L9
	movl	%r15d, %eax
	andl	$-4, %eax
	testb	$3, %r15b
	je	.L10
.L8:
	movslq	%eax, %rdx
	movl	$100000000, (%rcx,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%r15d, %edx
	jge	.L10
	movslq	%edx, %rdx
	addl	$2, %eax
	movl	$100000000, (%rcx,%rdx,4)
	cmpl	%eax, %r15d
	jle	.L10
	cltq
	movl	$100000000, (%rcx,%rax,4)
.L10:
	movl	%r15d, %r12d
	leaq	p(%rip), %r9
	movl	$255, %esi
	salq	$2, %r12
	movq	%r9, %rdi
	movq	%r12, %rdx
	call	memset@PLT
	leaq	16(%rsp), %rdi
	movq	%r12, %rdx
	movl	$255, %esi
	call	memset@PLT
.L3:
	movslq	%r15d, %rdi
	leaq	key(%rip), %rsi
	movl	$0, key(%rip)
	leaq	16(%rsp), %r9
	leaq	416(%rsp), %r11
	leaq	p(%rip), %r10
	testl	%r15d, %r15d
	jle	.L24
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%eax, %eax
	movl	$100000000, %ecx
	movl	$-1, %r8d
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jle	.L12
	cmpl	$-1, (%r9,%rax,4)
	cmove	%edx, %ecx
	cmove	%eax, %r8d
.L12:
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L13
	cmpl	$-1, %r8d
	je	.L25
	movslq	%r8d, %rbx
	leaq	(%rbx,%rbx,4), %rax
	leaq	(%rax,%rax,4), %rcx
	xorl	%eax, %eax
	salq	$4, %rcx
	addq	%r11, %rcx
	.p2align 4,,10
	.p2align 3
.L16:
	movl	(%rcx,%rax,4), %edx
	cmpl	(%rsi,%rax,4), %edx
	jge	.L15
	cmpl	$-1, (%r9,%rax,4)
	jne	.L15
	movl	%edx, (%rsi,%rax,4)
	movl	%r8d, (%r10,%rax,4)
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L16
	movl	$0, 16(%rsp,%rbx,4)
	testl	%r15d, %r15d
	jg	.L40
.L24:
	xorl	%r8d, %r8d
.L11:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$40440, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	n(%rip), %r15d
	movl	$2097152, 0(%rbp,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, %r15d
	jg	.L7
	jmp	.L6
.L25:
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	leaq	p(%rip), %r9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	(%r9,%rax,4), %rdx
	cmpl	$-1, %edx
	je	.L18
	movslq	%eax, %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rdx
	addl	416(%rsp,%rdx,4), %r8d
.L18:
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L14
	jmp	.L11
.L23:
	xorl	%eax, %eax
	leaq	key(%rip), %rcx
	jmp	.L8
.L41:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	key
	.align 32
	.type	key, @object
	.size	key, 400
key:
	.zero	400
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	-36864(%rsp), %r11
	.cfi_def_cfa 11, 36920
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3576, %rsp
	.cfi_def_cfa_offset 40496
	leaq	.LC0(%rip), %r12
	leaq	n(%rip), %rsi
	xorl	%r14d, %r14d
	movq	%r12, %rdi
	movq	%fs:40, %rax
	movq	%rax, 40424(%rsp)
	xorl	%eax, %eax
	leaq	416(%rsp), %rbp
	leaq	12(%rsp), %r13
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r15d
	testl	%r15d, %r15d
	jle	.L3
	.p2align 4,,10
	.p2align 3
.L19:
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	cmpl	$-1, %eax
	je	.L4
	movl	n(%rip), %r15d
	movl	%eax, 0(%rbp,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, %r15d
	jg	.L7
.L6:
	addl	$1, %r14d
	cmpl	%r14d, %r15d
	jle	.L39
	addq	$400, %rbp
	jmp	.L19
.L39:
	testl	%r15d, %r15d
	jle	.L3
	leal	-1(%r15), %eax
	cmpl	$2, %eax
	jbe	.L23
	movl	%r15d, %edx
	leaq	key(%rip), %rcx
	movdqa	.LC1(%rip), %xmm0
	shrl	$2, %edx
	leaq	16(%rcx), %rsi
	movq	%rcx, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L9:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L9
	movl	%r15d, %eax
	andl	$-4, %eax
	testb	$3, %r15b
	je	.L10
.L8:
	movslq	%eax, %rdx
	movl	$100000000, (%rcx,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%r15d, %edx
	jge	.L10
	movslq	%edx, %rdx
	addl	$2, %eax
	movl	$100000000, (%rcx,%rdx,4)
	cmpl	%eax, %r15d
	jle	.L10
	cltq
	movl	$100000000, (%rcx,%rax,4)
.L10:
	movl	%r15d, %r12d
	leaq	p(%rip), %r9
	movl	$255, %esi
	salq	$2, %r12
	movq	%r9, %rdi
	movq	%r12, %rdx
	call	memset@PLT
	leaq	16(%rsp), %rdi
	movq	%r12, %rdx
	movl	$255, %esi
	call	memset@PLT
.L3:
	movslq	%r15d, %rdi
	leaq	key(%rip), %rsi
	movl	$0, key(%rip)
	leaq	16(%rsp), %r9
	leaq	416(%rsp), %r11
	leaq	p(%rip), %r10
	testl	%r15d, %r15d
	jle	.L24
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%eax, %eax
	movl	$100000000, %ecx
	movl	$-1, %r8d
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%rsi,%rax,4), %edx
	cmpl	%edx, %ecx
	jle	.L12
	cmpl	$-1, (%r9,%rax,4)
	cmove	%edx, %ecx
	cmove	%eax, %r8d
.L12:
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L13
	cmpl	$-1, %r8d
	je	.L25
	movslq	%r8d, %rbx
	leaq	(%rbx,%rbx,4), %rax
	leaq	(%rax,%rax,4), %rcx
	xorl	%eax, %eax
	salq	$4, %rcx
	addq	%r11, %rcx
	.p2align 4,,10
	.p2align 3
.L16:
	movl	(%rcx,%rax,4), %edx
	cmpl	(%rsi,%rax,4), %edx
	jge	.L15
	cmpl	$-1, (%r9,%rax,4)
	jne	.L15
	movl	%edx, (%rsi,%rax,4)
	movl	%r8d, (%r10,%rax,4)
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L16
	movl	$0, 16(%rsp,%rbx,4)
	testl	%r15d, %r15d
	jg	.L40
.L24:
	xorl	%r8d, %r8d
.L11:
	xorl	%eax, %eax
	movl	%r8d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	40424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$40440, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	n(%rip), %r15d
	movl	$2097152, 0(%rbp,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, %r15d
	jg	.L7
	jmp	.L6
.L25:
	xorl	%eax, %eax
	xorl	%r8d, %r8d
	leaq	p(%rip), %r9
	.p2align 4,,10
	.p2align 3
.L14:
	movslq	(%r9,%rax,4), %rdx
	cmpl	$-1, %edx
	je	.L18
	movslq	%eax, %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rdx
	addl	416(%rsp,%rdx,4), %r8d
.L18:
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L14
	jmp	.L11
.L23:
	xorl	%eax, %eax
	leaq	key(%rip), %rcx
	jmp	.L8
.L41:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	key
	.align 32
	.type	key, @object
	.size	key, 400
key:
	.zero	400
	.globl	p
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.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>

static const int MAX = 500;
static const int INFTY = (1<<21);

#define NIL -1

int p[100];

int key[100];

int n;


main(){
  int i, j, e, v, sum;
 
  int u;

  int M[100][100];

  int l[100];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }



  for(u=0;u<n;u++){
    key[u] =100000000;

    p[u] =NIL;

    l[u]=NIL;
  }
  key[0] = 0;

  while(1){
    int u=NIL;
    int v = 100000000;


    for(i=0;i<n;i++){
     

      if(key[i]<v && l[i]==NIL){
	v = key[i];
	u=i;
      }
    }
	
      
    
    if(u==NIL){
      break;
    }

    for(v=0;v<n;v++){
      if(M[u][v] < key[v] && l[v]==NIL){
	key[v] = M[u][v];
	p[v]= u;
      }
    }
    l[u]=0;
  }


  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}
5
 -1 2 3 1 -1
 2 -1 -1 4 -1
 3 -1 -1 1 1
 1 4 1 -1 3
 -1 -1 1 3 -1

5

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>

static const int MAX = 500;
static const int INFTY = (1<<21);

#define NIL -1

int p[100];

int key[100];

int n;


main(){
  int i, j, e, v, sum;
 
  int u;

  int M[100][100];

  int l[100];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }



  for(u=0;u<n;u++){
    key[u] =100000000;

    p[u] =NIL;

    l[u]=NIL;
  }
  key[0] = 0;

  while(1){
    int u=NIL;
    int v = 100000000;


    for(i=0;i<n;i++){
     

      if(key[i]<v && l[i]==NIL){
	v = key[i];
	u=i;
      }
    }
	
      
    
    if(u==NIL){
      break;
    }

    for(v=0;v<n;v++){
      if(M[u][v] < key[v] && l[v]==NIL){
	key[v] = M[u][v];
	p[v]= u;
      }
    }
    l[u]=0;
  }


  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
	.align 4
	.type	MAX, @object
	.size	MAX, 4
MAX:
	.long	500
	.align 4
	.type	INFTY, @object
	.size	INFTY, 4
INFTY:
	.long	2097152
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.globl	key
	.align 32
	.type	key, @object
	.size	key, 400
key:
	.zero	400
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3584, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40440(%rbp)
	jmp	.L2
.L7:
	movl	$0, -40436(%rbp)
	jmp	.L3
.L6:
	leaq	-40444(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40444(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L4
	movl	$2097152, %edx
	jmp	.L5
.L4:
	movl	-40444(%rbp), %edx
.L5:
	movl	-40436(%rbp), %eax
	movslq	%eax, %rsi
	movl	-40440(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40436(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -40436(%rbp)
	jl	.L6
	addl	$1, -40440(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L7
	movl	$0, -40428(%rbp)
	jmp	.L8
.L9:
	movl	-40428(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	movl	-40428(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-40428(%rbp), %eax
	cltq
	movl	$-1, -40416(%rbp,%rax,4)
	addl	$1, -40428(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L9
	movl	$0, key(%rip)
.L18:
	movl	$-1, -40424(%rbp)
	movl	$100000000, -40420(%rbp)
	movl	$0, -40440(%rbp)
	jmp	.L10
.L12:
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -40420(%rbp)
	jle	.L11
	movl	-40440(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L11
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40420(%rbp)
	movl	-40440(%rbp), %eax
	movl	%eax, -40424(%rbp)
.L11:
	addl	$1, -40440(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L12
	cmpl	$-1, -40424(%rbp)
	je	.L25
	movl	$0, -40420(%rbp)
	jmp	.L15
.L17:
	movl	-40420(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40424(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %edx
	movl	-40420(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	key(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L16
	movl	-40420(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L16
	movl	-40420(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40424(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %eax
	movl	-40420(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	key(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-40420(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-40424(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L16:
	addl	$1, -40420(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -40420(%rbp)
	jl	.L17
	movl	-40424(%rbp), %eax
	cltq
	movl	$0, -40416(%rbp,%rax,4)
	jmp	.L18
.L25:
	nop
	movl	$0, -40432(%rbp)
	movl	$0, -40440(%rbp)
	jmp	.L19
.L21:
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	je	.L20
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rcx
	movl	-40440(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %eax
	addl	%eax, -40432(%rbp)
.L20:
	addl	$1, -40440(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L21
	movl	-40432(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata
	.align 4
	.type	MAX, @object
	.size	MAX, 4
MAX:
	.long	500
	.align 4
	.type	INFTY, @object
	.size	INFTY, 4
INFTY:
	.long	2097152
	.globl	p
	.bss
	.align 32
	.type	p, @object
	.size	p, 400
p:
	.zero	400
	.globl	key
	.align 32
	.type	key, @object
	.size	key, 400
key:
	.zero	400
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-36864(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3584, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40440(%rbp)
	jmp	.L2
.L7:
	movl	$0, -40436(%rbp)
	jmp	.L3
.L6:
	leaq	-40444(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-40444(%rbp), %eax
	cmpl	$-1, %eax
	jne	.L4
	movl	$2097152, %edx
	jmp	.L5
.L4:
	movl	-40444(%rbp), %edx
.L5:
	movl	-40436(%rbp), %eax
	movslq	%eax, %rsi
	movl	-40440(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	%edx, -40016(%rbp,%rax,4)
	addl	$1, -40436(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -40436(%rbp)
	jl	.L6
	addl	$1, -40440(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L7
	movl	$0, -40428(%rbp)
	jmp	.L8
.L9:
	movl	-40428(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	$100000000, (%rdx,%rax)
	movl	-40428(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-40428(%rbp), %eax
	cltq
	movl	$-1, -40416(%rbp,%rax,4)
	addl	$1, -40428(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -40428(%rbp)
	jl	.L9
	movl	$0, key(%rip)
.L18:
	movl	$-1, -40424(%rbp)
	movl	$100000000, -40420(%rbp)
	movl	$0, -40440(%rbp)
	jmp	.L10
.L12:
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -40420(%rbp)
	jle	.L11
	movl	-40440(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L11
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	key(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -40420(%rbp)
	movl	-40440(%rbp), %eax
	movl	%eax, -40424(%rbp)
.L11:
	addl	$1, -40440(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L12
	cmpl	$-1, -40424(%rbp)
	je	.L25
	movl	$0, -40420(%rbp)
	jmp	.L15
.L17:
	movl	-40420(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40424(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %edx
	movl	-40420(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	key(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jge	.L16
	movl	-40420(%rbp), %eax
	cltq
	movl	-40416(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L16
	movl	-40420(%rbp), %eax
	movslq	%eax, %rcx
	movl	-40424(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %eax
	movl	-40420(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	key(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-40420(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	p(%rip), %rdx
	movl	-40424(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L16:
	addl	$1, -40420(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -40420(%rbp)
	jl	.L17
	movl	-40424(%rbp), %eax
	cltq
	movl	$0, -40416(%rbp,%rax,4)
	jmp	.L18
.L25:
	nop
	movl	$0, -40432(%rbp)
	movl	$0, -40440(%rbp)
	jmp	.L19
.L21:
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	je	.L20
	movl	-40440(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rcx
	movl	-40440(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	-40016(%rbp,%rax,4), %eax
	addl	%eax, -40432(%rbp)
.L20:
	addl	$1, -40440(%rbp)
.L19:
	movl	n(%rip), %eax
	cmpl	%eax, -40440(%rbp)
	jl	.L21
	movl	-40432(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
