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 N 100

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

main(){
  int n, i, j, e, v,c=0,k=0;
  int u = 0,mincost = 0;
  int cost[N];
  int d[N];
  int p[N],M[N][N];
  
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
  
  for(i=0;i < n;i++){
    d[i] = INFTY;
    p[i] = -1;
    cost[i] = 0;
  }
  
  d[0] = 0;
  
  while(1){
    u = -1;
    mincost = INFTY;
    
    for(i=0;i < n;i++){
      if(d[i] < mincost && cost[i] == 0){
	mincost = d[i];
	u = i;
      }
    }
    
    if(u == -1) break;
    
    cost[u] = 1;
    
    for(v=0;v <n;v++){
      if(d[v] > d[u]+M[u][v]){
	p[v] = u;
	d[v] = d[u]+M[u][v];
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
  
  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
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %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	-40960(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$288, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -41240(%rbp)
	movl	$0, -41236(%rbp)
	movl	$0, -41232(%rbp)
	movl	$0, -41220(%rbp)
	leaq	-41248(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -41228(%rbp)
	jmp	.L2
.L5:
	movl	$0, -41224(%rbp)
	jmp	.L3
.L4:
	movl	$2097152, %ecx
	movl	-41224(%rbp), %eax
	movslq	%eax, %rsi
	movl	-41228(%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	%rsi, %rax
	movl	%ecx, -40016(%rbp,%rax,4)
	addl	$1, -41224(%rbp)
.L3:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41224(%rbp)
	jl	.L4
	addl	$1, -41228(%rbp)
.L2:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L5
	movl	$0, -41228(%rbp)
	jmp	.L6
.L9:
	leaq	-41236(%rbp), %rdx
	leaq	-41232(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -41224(%rbp)
	jmp	.L7
.L8:
	leaq	-41240(%rbp), %rdx
	leaq	-41244(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %ecx
	movl	-41240(%rbp), %edx
	movslq	%ecx, %rsi
	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, -41224(%rbp)
.L7:
	movl	-41236(%rbp), %eax
	cmpl	%eax, -41224(%rbp)
	jl	.L8
	addl	$1, -41228(%rbp)
.L6:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L9
	movl	$0, -41228(%rbp)
	jmp	.L10
.L11:
	movl	$2097152, %edx
	movl	-41228(%rbp), %eax
	cltq
	movl	%edx, -40816(%rbp,%rax,4)
	movl	-41228(%rbp), %eax
	cltq
	movl	$-1, -40416(%rbp,%rax,4)
	movl	-41228(%rbp), %eax
	cltq
	movl	$0, -41216(%rbp,%rax,4)
	addl	$1, -41228(%rbp)
.L10:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L11
	movl	$0, -40816(%rbp)
.L20:
	movl	$-1, -41232(%rbp)
	movl	$2097152, -41220(%rbp)
	movl	$0, -41228(%rbp)
	jmp	.L12
.L14:
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	cmpl	%eax, -41220(%rbp)
	jle	.L13
	movl	-41228(%rbp), %eax
	cltq
	movl	-41216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L13
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	movl	%eax, -41220(%rbp)
	movl	-41228(%rbp), %eax
	movl	%eax, -41232(%rbp)
.L13:
	addl	$1, -41228(%rbp)
.L12:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L14
	movl	-41232(%rbp), %eax
	cmpl	$-1, %eax
	je	.L28
	movl	-41232(%rbp), %eax
	cltq
	movl	$1, -41216(%rbp,%rax,4)
	movl	$0, -41244(%rbp)
	jmp	.L17
.L19:
	movl	-41244(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %ecx
	movl	-41232(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %esi
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %edx
	movslq	%edx, %rdi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movl	-40016(%rbp,%rax,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L18
	movl	-41244(%rbp), %eax
	movl	-41232(%rbp), %edx
	cltq
	movl	%edx, -40416(%rbp,%rax,4)
	movl	-41232(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %ecx
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	-40016(%rbp,%rax,4), %edx
	movl	-41244(%rbp), %eax
	addl	%ecx, %edx
	cltq
	movl	%edx, -40816(%rbp,%rax,4)
.L18:
	movl	-41244(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -41244(%rbp)
.L17:
	movl	-41244(%rbp), %edx
	movl	-41248(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L19
	jmp	.L20
.L28:
	nop
	movl	$0, -41228(%rbp)
	jmp	.L21
.L24:
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	movl	$2097152, %edx
	cmpl	%edx, %eax
	je	.L22
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	jmp	.L23
.L22:
	movl	$-1, %eax
.L23:
	movl	-41228(%rbp), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -41228(%rbp)
.L21:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L24
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	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 %d"
.LC3:
	.string	"%d %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	$4024, %rsp
	.cfi_def_cfa_offset 40944
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40872(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rsi
	movl	$0, 52(%rsp)
	movl	$0, 56(%rsp)
	movl	$0, 60(%rsp)
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %ebp
	testl	%ebp, %ebp
	jle	.L60
	movl	%ebp, %eax
	movl	%ebp, %r8d
	movdqa	.LC1(%rip), %xmm0
	xorl	%edi, %edi
	shrl	$2, %eax
	leaq	864(%rsp), %rsi
	leal	-1(%rbp), %r10d
	andl	$-4, %r8d
	leal	-1(%rax), %r9d
	addq	$1, %r9
	salq	$4, %r9
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$2, %r10d
	jbe	.L29
	leaq	(%r9,%rsi), %rdx
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L4:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L4
	movl	%r8d, %eax
	cmpl	%r8d, %ebp
	je	.L5
.L3:
	movslq	%edi, %rdx
	movslq	%eax, %rcx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	salq	$2, %rdx
	addq	%rdx, %rcx
	movl	$2097152, 864(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %ebp
	jle	.L5
	movslq	%ecx, %rcx
	addl	$2, %eax
	addq	%rdx, %rcx
	movl	$2097152, 864(%rsp,%rcx,4)
	cmpl	%ebp, %eax
	jge	.L5
	cltq
	addq	%rax, %rdx
	movl	$2097152, 864(%rsp,%rdx,4)
.L5:
	addl	$1, %edi
	addq	$400, %rsi
	cmpl	%ebp, %edi
	jne	.L6
	leaq	60(%rsp), %rax
	xorl	%r13d, %r13d
	leaq	56(%rsp), %r15
	movq	%rax, (%rsp)
	leaq	.LC2(%rip), %rbx
	leaq	52(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	(%rsp), %rsi
	movq	%r15, %rdx
	movq	%rbx, %rdi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	leaq	48(%rsp), %rbp
	call	__isoc99_scanf@PLT
	movl	56(%rsp), %eax
	testl	%eax, %eax
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	60(%rsp), %rax
	movslq	48(%rsp), %rdx
	addl	$1, %r14d
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	movl	52(%rsp), %edx
	movl	%edx, 864(%rsp,%rax,4)
	cmpl	%r14d, 56(%rsp)
	jg	.L7
.L10:
	movl	44(%rsp), %ebp
	addl	$1, %r13d
	cmpl	%r13d, %ebp
	jg	.L8
	leal	-1(%rbp), %eax
	movl	%eax, (%rsp)
	testl	%ebp, %ebp
	jle	.L61
	cmpl	$2, %eax
	jbe	.L31
	movl	%ebp, %edx
	leaq	464(%rsp), %rbx
	leaq	480(%rsp), %r12
	movdqa	.LC1(%rip), %xmm0
	shrl	$2, %edx
	movq	%rbx, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L12
	movl	%ebp, %eax
	andl	$-4, %eax
	testb	$3, %bpl
	je	.L13
.L11:
	movslq	%eax, %rdx
	movl	$2097152, 464(%rsp,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ebp
	jle	.L13
	movslq	%edx, %rdx
	addl	$2, %eax
	movl	$2097152, 464(%rsp,%rdx,4)
	cmpl	%eax, %ebp
	jle	.L13
	cltq
	movl	$2097152, 464(%rsp,%rax,4)
.L13:
	movl	%ebp, %r13d
	leaq	64(%rsp), %rdi
	xorl	%esi, %esi
	leaq	0(,%r13,4), %rdx
	call	memset@PLT
.L2:
	leaq	0(,%r13,4), %rax
	movl	(%rsp), %edi
	xorl	%r14d, %r14d
	leaq	64(%rsp), %r9
	movq	%rax, 8(%rsp)
	movl	%ebp, %eax
	shrl	$2, %eax
	leaq	468(%rsp,%rdi,4), %r15
	movl	$0, 464(%rsp)
	subl	$1, %eax
	salq	$4, %rax
	leaq	(%r12,%rax), %r8
	movl	%ebp, %eax
	leaq	864(%rsp), %r12
	andl	$-4, %eax
	leal	1(%rax), %esi
	leal	2(%rax), %edx
	movl	%eax, 16(%rsp)
	movslq	%eax, %r10
	movl	%esi, 24(%rsp)
	movslq	%esi, %r11
	movslq	%edx, %r13
	movl	%edx, 28(%rsp)
	testl	%ebp, %ebp
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L63:
	xorl	%eax, %eax
	movl	$-1, %edx
	movl	$2097152, %esi
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L32:
	movq	%rcx, %rax
.L16:
	movl	(%rbx,%rax,4), %ecx
	cmpl	%ecx, %esi
	jle	.L15
	cmpl	$0, (%r9,%rax,4)
	cmove	%eax, %edx
	cmove	%ecx, %esi
.L15:
	leaq	1(%rax), %rcx
	cmpq	%rax, %rdi
	jne	.L32
	cmpl	$-1, %edx
	je	.L62
	movslq	%edx, %rdx
	movl	$1, 64(%rsp,%rdx,4)
	leaq	0(,%rdx,4), %rax
	cmpq	%rax, 8(%rsp)
	jg	.L19
	cmpl	$2, (%rsp)
	jbe	.L19
	movd	464(%rsp,%rdx,4), %xmm3
	leaq	(%rdx,%rdx,4), %rax
	leaq	(%rax,%rax,4), %rcx
	movq	%rbx, %rax
	salq	$4, %rcx
	pshufd	$0, %xmm3, %xmm2
	addq	%r12, %rcx
	.p2align 4,,10
	.p2align 3
.L20:
	movdqa	(%rcx), %xmm1
	movdqa	(%rax), %xmm0
	addq	$16, %rax
	addq	$16, %rcx
	paddd	%xmm2, %xmm1
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm1
	pandn	-16(%rax), %xmm0
	por	%xmm1, %xmm0
	movaps	%xmm0, -16(%rax)
	cmpq	%r8, %rax
	jne	.L20
	cmpl	16(%rsp), %ebp
	je	.L23
	leaq	(%rdx,%rdx,4), %rax
	movl	464(%rsp,%rdx,4), %esi
	leaq	(%rax,%rax,4), %rax
	salq	$2, %rax
	leaq	(%rax,%r10), %rcx
	addl	864(%rsp,%rcx,4), %esi
	movl	%esi, %ecx
	movl	464(%rsp,%r10,4), %esi
	cmpl	%esi, %ecx
	cmovg	%esi, %ecx
	movl	%ecx, 464(%rsp,%r10,4)
	cmpl	%ebp, 24(%rsp)
	jge	.L23
	movl	464(%rsp,%r11,4), %esi
	leaq	(%rax,%r11), %rcx
	movl	864(%rsp,%rcx,4), %ecx
	addl	464(%rsp,%rdx,4), %ecx
	cmpl	%esi, %ecx
	cmovg	%esi, %ecx
	movl	%ecx, 464(%rsp,%r11,4)
	cmpl	28(%rsp), %ebp
	jle	.L23
	addq	%r13, %rax
	movl	864(%rsp,%rax,4), %eax
	addl	464(%rsp,%rdx,4), %eax
	movl	464(%rsp,%r13,4), %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	movl	%eax, 464(%rsp,%r13,4)
.L23:
	movl	%ebp, 20(%rsp)
	movl	$1, %r14d
	testl	%ebp, %ebp
	jg	.L63
.L14:
	movq	40872(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L64
	addq	$40888, %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
.L19:
	.cfi_restore_state
	leaq	(%rdx,%rdx,4), %rax
	movq	%rbx, %rsi
	leaq	(%rax,%rax,4), %rcx
	salq	$4, %rcx
	addq	%r12, %rcx
.L22:
	movl	(%rsi), %r14d
	movl	464(%rsp,%rdx,4), %eax
	addl	(%rcx), %eax
	cmpl	%r14d, %eax
	cmovg	%r14d, %eax
	addq	$4, %rsi
	addq	$4, %rcx
	movl	%eax, -4(%rsi)
	cmpq	%rsi, %r15
	jne	.L22
	jmp	.L23
.L29:
	xorl	%eax, %eax
	jmp	.L3
.L60:
	leal	-1(%rbp), %eax
	leaq	464(%rsp), %rbx
	movl	%ebp, %r13d
	movl	%eax, (%rsp)
	leaq	480(%rsp), %r12
	jmp	.L2
.L31:
	xorl	%eax, %eax
	leaq	464(%rsp), %rbx
	leaq	480(%rsp), %r12
	jmp	.L11
.L61:
	leaq	464(%rsp), %rbx
	leaq	480(%rsp), %r12
	movl	%ebp, %r13d
	jmp	.L2
.L64:
	call	__stack_chk_fail@PLT
.L62:
	movl	$-1, 60(%rsp)
	testb	%r14b, %r14b
	je	.L18
	movl	20(%rsp), %eax
	movl	%eax, 48(%rsp)
.L18:
	xorl	%ebp, %ebp
	leaq	.LC3(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L27:
	movl	(%rbx,%rbp,4), %ecx
	movl	%ebp, %edx
	cmpl	$2097152, %ecx
	jne	.L58
	movl	$-1, %ecx
.L58:
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbp
	call	__printf_chk@PLT
	cmpl	%ebp, 44(%rsp)
	jg	.L27
	jmp	.L14
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	2097152
	.long	2097152
	.long	2097152
	.long	2097152
	.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 %d"
.LC3:
	.string	"%d %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	$4024, %rsp
	.cfi_def_cfa_offset 40944
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40872(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rsi
	movl	$0, 52(%rsp)
	movl	$0, 56(%rsp)
	movl	$0, 60(%rsp)
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %ebp
	testl	%ebp, %ebp
	jle	.L60
	movl	%ebp, %eax
	movl	%ebp, %r8d
	movdqa	.LC1(%rip), %xmm0
	xorl	%edi, %edi
	shrl	$2, %eax
	leaq	864(%rsp), %rsi
	leal	-1(%rbp), %r10d
	andl	$-4, %r8d
	leal	-1(%rax), %r9d
	addq	$1, %r9
	salq	$4, %r9
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$2, %r10d
	jbe	.L29
	leaq	(%r9,%rsi), %rdx
	movq	%rsi, %rax
	.p2align 4,,10
	.p2align 3
.L4:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L4
	movl	%r8d, %eax
	cmpl	%r8d, %ebp
	je	.L5
.L3:
	movslq	%edi, %rdx
	movslq	%eax, %rcx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	salq	$2, %rdx
	addq	%rdx, %rcx
	movl	$2097152, 864(%rsp,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %ebp
	jle	.L5
	movslq	%ecx, %rcx
	addl	$2, %eax
	addq	%rdx, %rcx
	movl	$2097152, 864(%rsp,%rcx,4)
	cmpl	%ebp, %eax
	jge	.L5
	cltq
	addq	%rax, %rdx
	movl	$2097152, 864(%rsp,%rdx,4)
.L5:
	addl	$1, %edi
	addq	$400, %rsi
	cmpl	%ebp, %edi
	jne	.L6
	leaq	60(%rsp), %rax
	xorl	%r13d, %r13d
	leaq	56(%rsp), %r15
	movq	%rax, (%rsp)
	leaq	.LC2(%rip), %rbx
	leaq	52(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L8:
	movq	(%rsp), %rsi
	movq	%r15, %rdx
	movq	%rbx, %rdi
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	leaq	48(%rsp), %rbp
	call	__isoc99_scanf@PLT
	movl	56(%rsp), %eax
	testl	%eax, %eax
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	60(%rsp), %rax
	movslq	48(%rsp), %rdx
	addl	$1, %r14d
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	movl	52(%rsp), %edx
	movl	%edx, 864(%rsp,%rax,4)
	cmpl	%r14d, 56(%rsp)
	jg	.L7
.L10:
	movl	44(%rsp), %ebp
	addl	$1, %r13d
	cmpl	%r13d, %ebp
	jg	.L8
	leal	-1(%rbp), %eax
	movl	%eax, (%rsp)
	testl	%ebp, %ebp
	jle	.L61
	cmpl	$2, %eax
	jbe	.L31
	movl	%ebp, %edx
	leaq	464(%rsp), %rbx
	leaq	480(%rsp), %r12
	movdqa	.LC1(%rip), %xmm0
	shrl	$2, %edx
	movq	%rbx, %rax
	subl	$1, %edx
	salq	$4, %rdx
	addq	%r12, %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L12
	movl	%ebp, %eax
	andl	$-4, %eax
	testb	$3, %bpl
	je	.L13
.L11:
	movslq	%eax, %rdx
	movl	$2097152, 464(%rsp,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ebp
	jle	.L13
	movslq	%edx, %rdx
	addl	$2, %eax
	movl	$2097152, 464(%rsp,%rdx,4)
	cmpl	%eax, %ebp
	jle	.L13
	cltq
	movl	$2097152, 464(%rsp,%rax,4)
.L13:
	movl	%ebp, %r13d
	leaq	64(%rsp), %rdi
	xorl	%esi, %esi
	leaq	0(,%r13,4), %rdx
	call	memset@PLT
.L2:
	leaq	0(,%r13,4), %rax
	movl	(%rsp), %edi
	xorl	%r14d, %r14d
	leaq	64(%rsp), %r9
	movq	%rax, 8(%rsp)
	movl	%ebp, %eax
	shrl	$2, %eax
	leaq	468(%rsp,%rdi,4), %r15
	movl	$0, 464(%rsp)
	subl	$1, %eax
	salq	$4, %rax
	leaq	(%r12,%rax), %r8
	movl	%ebp, %eax
	leaq	864(%rsp), %r12
	andl	$-4, %eax
	leal	1(%rax), %esi
	leal	2(%rax), %edx
	movl	%eax, 16(%rsp)
	movslq	%eax, %r10
	movl	%esi, 24(%rsp)
	movslq	%esi, %r11
	movslq	%edx, %r13
	movl	%edx, 28(%rsp)
	testl	%ebp, %ebp
	jle	.L14
	.p2align 4,,10
	.p2align 3
.L63:
	xorl	%eax, %eax
	movl	$-1, %edx
	movl	$2097152, %esi
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L32:
	movq	%rcx, %rax
.L16:
	movl	(%rbx,%rax,4), %ecx
	cmpl	%ecx, %esi
	jle	.L15
	cmpl	$0, (%r9,%rax,4)
	cmove	%eax, %edx
	cmove	%ecx, %esi
.L15:
	leaq	1(%rax), %rcx
	cmpq	%rax, %rdi
	jne	.L32
	cmpl	$-1, %edx
	je	.L62
	movslq	%edx, %rdx
	movl	$1, 64(%rsp,%rdx,4)
	leaq	0(,%rdx,4), %rax
	cmpq	%rax, 8(%rsp)
	jg	.L19
	cmpl	$2, (%rsp)
	jbe	.L19
	movd	464(%rsp,%rdx,4), %xmm3
	leaq	(%rdx,%rdx,4), %rax
	leaq	(%rax,%rax,4), %rcx
	movq	%rbx, %rax
	salq	$4, %rcx
	pshufd	$0, %xmm3, %xmm2
	addq	%r12, %rcx
	.p2align 4,,10
	.p2align 3
.L20:
	movdqa	(%rcx), %xmm1
	movdqa	(%rax), %xmm0
	addq	$16, %rax
	addq	$16, %rcx
	paddd	%xmm2, %xmm1
	pcmpgtd	%xmm1, %xmm0
	pand	%xmm0, %xmm1
	pandn	-16(%rax), %xmm0
	por	%xmm1, %xmm0
	movaps	%xmm0, -16(%rax)
	cmpq	%r8, %rax
	jne	.L20
	cmpl	16(%rsp), %ebp
	je	.L23
	leaq	(%rdx,%rdx,4), %rax
	movl	464(%rsp,%rdx,4), %esi
	leaq	(%rax,%rax,4), %rax
	salq	$2, %rax
	leaq	(%rax,%r10), %rcx
	addl	864(%rsp,%rcx,4), %esi
	movl	%esi, %ecx
	movl	464(%rsp,%r10,4), %esi
	cmpl	%esi, %ecx
	cmovg	%esi, %ecx
	movl	%ecx, 464(%rsp,%r10,4)
	cmpl	%ebp, 24(%rsp)
	jge	.L23
	movl	464(%rsp,%r11,4), %esi
	leaq	(%rax,%r11), %rcx
	movl	864(%rsp,%rcx,4), %ecx
	addl	464(%rsp,%rdx,4), %ecx
	cmpl	%esi, %ecx
	cmovg	%esi, %ecx
	movl	%ecx, 464(%rsp,%r11,4)
	cmpl	28(%rsp), %ebp
	jle	.L23
	addq	%r13, %rax
	movl	864(%rsp,%rax,4), %eax
	addl	464(%rsp,%rdx,4), %eax
	movl	464(%rsp,%r13,4), %edx
	cmpl	%edx, %eax
	cmovg	%edx, %eax
	movl	%eax, 464(%rsp,%r13,4)
.L23:
	movl	%ebp, 20(%rsp)
	movl	$1, %r14d
	testl	%ebp, %ebp
	jg	.L63
.L14:
	movq	40872(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L64
	addq	$40888, %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
.L19:
	.cfi_restore_state
	leaq	(%rdx,%rdx,4), %rax
	movq	%rbx, %rsi
	leaq	(%rax,%rax,4), %rcx
	salq	$4, %rcx
	addq	%r12, %rcx
.L22:
	movl	(%rsi), %r14d
	movl	464(%rsp,%rdx,4), %eax
	addl	(%rcx), %eax
	cmpl	%r14d, %eax
	cmovg	%r14d, %eax
	addq	$4, %rsi
	addq	$4, %rcx
	movl	%eax, -4(%rsi)
	cmpq	%rsi, %r15
	jne	.L22
	jmp	.L23
.L29:
	xorl	%eax, %eax
	jmp	.L3
.L60:
	leal	-1(%rbp), %eax
	leaq	464(%rsp), %rbx
	movl	%ebp, %r13d
	movl	%eax, (%rsp)
	leaq	480(%rsp), %r12
	jmp	.L2
.L31:
	xorl	%eax, %eax
	leaq	464(%rsp), %rbx
	leaq	480(%rsp), %r12
	jmp	.L11
.L61:
	leaq	464(%rsp), %rbx
	leaq	480(%rsp), %r12
	movl	%ebp, %r13d
	jmp	.L2
.L64:
	call	__stack_chk_fail@PLT
.L62:
	movl	$-1, 60(%rsp)
	testb	%r14b, %r14b
	je	.L18
	movl	20(%rsp), %eax
	movl	%eax, 48(%rsp)
.L18:
	xorl	%ebp, %ebp
	leaq	.LC3(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L27:
	movl	(%rbx,%rbp,4), %ecx
	movl	%ebp, %edx
	cmpl	$2097152, %ecx
	jne	.L58
	movl	$-1, %ecx
.L58:
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbp
	call	__printf_chk@PLT
	cmpl	%ebp, 44(%rsp)
	jg	.L27
	jmp	.L14
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	2097152
	.long	2097152
	.long	2097152
	.long	2097152
	.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 N 100

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

main(){
  int n, i, j, e, v,c=0,k=0;
  int u = 0,mincost = 0;
  int cost[N];
  int d[N];
  int p[N],M[N][N];
  
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
  
  for(i=0;i < n;i++){
    d[i] = INFTY;
    p[i] = -1;
    cost[i] = 0;
  }
  
  d[0] = 0;
  
  while(1){
    u = -1;
    mincost = INFTY;
    
    for(i=0;i < n;i++){
      if(d[i] < mincost && cost[i] == 0){
	mincost = d[i];
	u = i;
      }
    }
    
    if(u == -1) break;
    
    cost[u] = 1;
    
    for(v=0;v <n;v++){
      if(d[v] > d[u]+M[u][v]){
	p[v] = u;
	d[v] = d[u]+M[u][v];
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
  
  return 0;
}
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

0 0
1 2
2 2
3 1
4 3

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 N 100

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

main(){
  int n, i, j, e, v,c=0,k=0;
  int u = 0,mincost = 0;
  int cost[N];
  int d[N];
  int p[N],M[N][N];
  
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
  
  for(i=0;i < n;i++){
    d[i] = INFTY;
    p[i] = -1;
    cost[i] = 0;
  }
  
  d[0] = 0;
  
  while(1){
    u = -1;
    mincost = INFTY;
    
    for(i=0;i < n;i++){
      if(d[i] < mincost && cost[i] == 0){
	mincost = d[i];
	u = i;
      }
    }
    
    if(u == -1) break;
    
    cost[u] = 1;
    
    for(v=0;v <n;v++){
      if(d[v] > d[u]+M[u][v]){
	p[v] = u;
	d[v] = d[u]+M[u][v];
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
  
  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
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %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	-40960(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$288, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -41240(%rbp)
	movl	$0, -41236(%rbp)
	movl	$0, -41232(%rbp)
	movl	$0, -41220(%rbp)
	leaq	-41248(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -41228(%rbp)
	jmp	.L2
.L5:
	movl	$0, -41224(%rbp)
	jmp	.L3
.L4:
	movl	$2097152, %ecx
	movl	-41224(%rbp), %eax
	movslq	%eax, %rsi
	movl	-41228(%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	%rsi, %rax
	movl	%ecx, -40016(%rbp,%rax,4)
	addl	$1, -41224(%rbp)
.L3:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41224(%rbp)
	jl	.L4
	addl	$1, -41228(%rbp)
.L2:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L5
	movl	$0, -41228(%rbp)
	jmp	.L6
.L9:
	leaq	-41236(%rbp), %rdx
	leaq	-41232(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -41224(%rbp)
	jmp	.L7
.L8:
	leaq	-41240(%rbp), %rdx
	leaq	-41244(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %ecx
	movl	-41240(%rbp), %edx
	movslq	%ecx, %rsi
	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, -41224(%rbp)
.L7:
	movl	-41236(%rbp), %eax
	cmpl	%eax, -41224(%rbp)
	jl	.L8
	addl	$1, -41228(%rbp)
.L6:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L9
	movl	$0, -41228(%rbp)
	jmp	.L10
.L11:
	movl	$2097152, %edx
	movl	-41228(%rbp), %eax
	cltq
	movl	%edx, -40816(%rbp,%rax,4)
	movl	-41228(%rbp), %eax
	cltq
	movl	$-1, -40416(%rbp,%rax,4)
	movl	-41228(%rbp), %eax
	cltq
	movl	$0, -41216(%rbp,%rax,4)
	addl	$1, -41228(%rbp)
.L10:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L11
	movl	$0, -40816(%rbp)
.L20:
	movl	$-1, -41232(%rbp)
	movl	$2097152, -41220(%rbp)
	movl	$0, -41228(%rbp)
	jmp	.L12
.L14:
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	cmpl	%eax, -41220(%rbp)
	jle	.L13
	movl	-41228(%rbp), %eax
	cltq
	movl	-41216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L13
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	movl	%eax, -41220(%rbp)
	movl	-41228(%rbp), %eax
	movl	%eax, -41232(%rbp)
.L13:
	addl	$1, -41228(%rbp)
.L12:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L14
	movl	-41232(%rbp), %eax
	cmpl	$-1, %eax
	je	.L28
	movl	-41232(%rbp), %eax
	cltq
	movl	$1, -41216(%rbp,%rax,4)
	movl	$0, -41244(%rbp)
	jmp	.L17
.L19:
	movl	-41244(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %ecx
	movl	-41232(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %esi
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %edx
	movslq	%edx, %rdi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movl	-40016(%rbp,%rax,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L18
	movl	-41244(%rbp), %eax
	movl	-41232(%rbp), %edx
	cltq
	movl	%edx, -40416(%rbp,%rax,4)
	movl	-41232(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %ecx
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	-40016(%rbp,%rax,4), %edx
	movl	-41244(%rbp), %eax
	addl	%ecx, %edx
	cltq
	movl	%edx, -40816(%rbp,%rax,4)
.L18:
	movl	-41244(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -41244(%rbp)
.L17:
	movl	-41244(%rbp), %edx
	movl	-41248(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L19
	jmp	.L20
.L28:
	nop
	movl	$0, -41228(%rbp)
	jmp	.L21
.L24:
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	movl	$2097152, %edx
	cmpl	%edx, %eax
	je	.L22
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	jmp	.L23
.L22:
	movl	$-1, %eax
.L23:
	movl	-41228(%rbp), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -41228(%rbp)
.L21:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L24
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	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
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %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	-40960(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$288, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -41240(%rbp)
	movl	$0, -41236(%rbp)
	movl	$0, -41232(%rbp)
	movl	$0, -41220(%rbp)
	leaq	-41248(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -41228(%rbp)
	jmp	.L2
.L5:
	movl	$0, -41224(%rbp)
	jmp	.L3
.L4:
	movl	$2097152, %ecx
	movl	-41224(%rbp), %eax
	movslq	%eax, %rsi
	movl	-41228(%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	%rsi, %rax
	movl	%ecx, -40016(%rbp,%rax,4)
	addl	$1, -41224(%rbp)
.L3:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41224(%rbp)
	jl	.L4
	addl	$1, -41228(%rbp)
.L2:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L5
	movl	$0, -41228(%rbp)
	jmp	.L6
.L9:
	leaq	-41236(%rbp), %rdx
	leaq	-41232(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -41224(%rbp)
	jmp	.L7
.L8:
	leaq	-41240(%rbp), %rdx
	leaq	-41244(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %ecx
	movl	-41240(%rbp), %edx
	movslq	%ecx, %rsi
	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, -41224(%rbp)
.L7:
	movl	-41236(%rbp), %eax
	cmpl	%eax, -41224(%rbp)
	jl	.L8
	addl	$1, -41228(%rbp)
.L6:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L9
	movl	$0, -41228(%rbp)
	jmp	.L10
.L11:
	movl	$2097152, %edx
	movl	-41228(%rbp), %eax
	cltq
	movl	%edx, -40816(%rbp,%rax,4)
	movl	-41228(%rbp), %eax
	cltq
	movl	$-1, -40416(%rbp,%rax,4)
	movl	-41228(%rbp), %eax
	cltq
	movl	$0, -41216(%rbp,%rax,4)
	addl	$1, -41228(%rbp)
.L10:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L11
	movl	$0, -40816(%rbp)
.L20:
	movl	$-1, -41232(%rbp)
	movl	$2097152, -41220(%rbp)
	movl	$0, -41228(%rbp)
	jmp	.L12
.L14:
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	cmpl	%eax, -41220(%rbp)
	jle	.L13
	movl	-41228(%rbp), %eax
	cltq
	movl	-41216(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L13
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	movl	%eax, -41220(%rbp)
	movl	-41228(%rbp), %eax
	movl	%eax, -41232(%rbp)
.L13:
	addl	$1, -41228(%rbp)
.L12:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L14
	movl	-41232(%rbp), %eax
	cmpl	$-1, %eax
	je	.L28
	movl	-41232(%rbp), %eax
	cltq
	movl	$1, -41216(%rbp,%rax,4)
	movl	$0, -41244(%rbp)
	jmp	.L17
.L19:
	movl	-41244(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %ecx
	movl	-41232(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %esi
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %edx
	movslq	%edx, %rdi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movl	-40016(%rbp,%rax,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L18
	movl	-41244(%rbp), %eax
	movl	-41232(%rbp), %edx
	cltq
	movl	%edx, -40416(%rbp,%rax,4)
	movl	-41232(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %ecx
	movl	-41232(%rbp), %eax
	movl	-41244(%rbp), %edx
	movslq	%edx, %rsi
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	-40016(%rbp,%rax,4), %edx
	movl	-41244(%rbp), %eax
	addl	%ecx, %edx
	cltq
	movl	%edx, -40816(%rbp,%rax,4)
.L18:
	movl	-41244(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -41244(%rbp)
.L17:
	movl	-41244(%rbp), %edx
	movl	-41248(%rbp), %eax
	cmpl	%eax, %edx
	jl	.L19
	jmp	.L20
.L28:
	nop
	movl	$0, -41228(%rbp)
	jmp	.L21
.L24:
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	movl	$2097152, %edx
	cmpl	%edx, %eax
	je	.L22
	movl	-41228(%rbp), %eax
	cltq
	movl	-40816(%rbp,%rax,4), %eax
	jmp	.L23
.L22:
	movl	$-1, %eax
.L23:
	movl	-41228(%rbp), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -41228(%rbp)
.L21:
	movl	-41248(%rbp), %eax
	cmpl	%eax, -41228(%rbp)
	jl	.L24
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	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:
