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 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int i,v,minv;
  int d[MAX],color[MAX];

  for(i = 0; i< n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v<n ; v++){
      if(color[v] != BLACK && M[u][v] !=INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i<n; i++){
    printf("%d %d\n",i,(d[i] == INFTY?-1:d[i]));
  }
}


int main(){
  int i,j;
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    for(j = 0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  int k,c,u,v;
  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;
    }
  }
  dijkstra();

  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40000
M:
	.zero	40000
	.section	.rodata
.LC0:
	.string	"%d %d\n"
	.text
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$832, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -832(%rbp)
	jmp	.L2
.L3:
	movl	-832(%rbp), %eax
	cltq
	movl	$2097152, -816(%rbp,%rax,4)
	movl	-832(%rbp), %eax
	cltq
	movl	$0, -416(%rbp,%rax,4)
	addl	$1, -832(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L3
	movl	$0, -816(%rbp)
	movl	$1, -416(%rbp)
.L12:
	movl	$2097152, -824(%rbp)
	movl	$-1, -820(%rbp)
	movl	$0, -832(%rbp)
	jmp	.L4
.L6:
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	%eax, -824(%rbp)
	jle	.L5
	movl	-832(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	$2, %eax
	je	.L5
	movl	-832(%rbp), %eax
	movl	%eax, -820(%rbp)
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	movl	%eax, -824(%rbp)
.L5:
	addl	$1, -832(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L6
	cmpl	$-1, -820(%rbp)
	je	.L19
	movl	-820(%rbp), %eax
	cltq
	movl	$2, -416(%rbp,%rax,4)
	movl	$0, -828(%rbp)
	jmp	.L9
.L11:
	movl	-828(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	$2, %eax
	je	.L10
	movl	-828(%rbp), %eax
	movslq	%eax, %rcx
	movl	-820(%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
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	je	.L10
	movl	-828(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %ecx
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %esi
	movl	-828(%rbp), %eax
	movslq	%eax, %rdi
	movl	-820(%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	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L10
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %ecx
	movl	-828(%rbp), %eax
	movslq	%eax, %rsi
	movl	-820(%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
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	(%rcx,%rax), %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
	movl	-828(%rbp), %eax
	cltq
	movl	$1, -416(%rbp,%rax,4)
.L10:
	addl	$1, -828(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -828(%rbp)
	jl	.L11
	jmp	.L12
.L19:
	nop
	movl	$0, -832(%rbp)
	jmp	.L13
.L16:
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	$2097152, %eax
	je	.L14
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	jmp	.L15
.L14:
	movl	$-1, %eax
.L15:
	movl	-832(%rbp), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -832(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L16
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dijkstra, .-dijkstra
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L21
.L24:
	movl	$0, -12(%rbp)
	jmp	.L22
.L23:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	$2097152, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L22:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	addl	$1, -16(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L24
	movl	$0, -16(%rbp)
	jmp	.L25
.L28:
	leaq	-32(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L26
.L27:
	leaq	-28(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-20(%rbp), %ecx
	movl	-28(%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
	leaq	0(,%rax,4), %rcx
	leaq	M(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -12(%rbp)
.L26:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L27
	addl	$1, -16(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L28
	movl	$0, %eax
	call	dijkstra
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
.LC1:
	.string	"%d %d\n"
	.text
	.p2align 4
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$816, %rsp
	.cfi_def_cfa_offset 848
	movl	n(%rip), %ebp
	movq	%fs:40, %rax
	movq	%rax, 808(%rsp)
	xorl	%eax, %eax
	leaq	400(%rsp), %rdi
	leal	-1(%rbp), %ebx
	testl	%ebp, %ebp
	jle	.L2
	cmpl	$2, %ebx
	jbe	.L17
	movl	%ebp, %edx
	movdqa	.LC0(%rip), %xmm0
	movq	%rsp, %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L4:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L4
	movl	%ebp, %eax
	andl	$-4, %eax
	testb	$3, %bpl
	je	.L5
.L3:
	movslq	%eax, %rdx
	movl	$2097152, (%rsp,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%ebp, %edx
	jge	.L5
	movslq	%edx, %rdx
	addl	$2, %eax
	movl	$2097152, (%rsp,%rdx,4)
	cmpl	%ebp, %eax
	jge	.L5
	cltq
	movl	$2097152, (%rsp,%rax,4)
.L5:
	movl	%ebp, %edx
	leaq	400(%rsp), %rdi
	xorl	%esi, %esi
	salq	$2, %rdx
	call	memset@PLT
	movq	%rax, %rdi
.L2:
	movl	%ebx, %r8d
	movl	$0, (%rsp)
	movq	%rsp, %rbx
	leaq	M(%rip), %r10
	movl	$1, 400(%rsp)
	leaq	404(%rsp,%r8,4), %r9
	testl	%ebp, %ebp
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L30:
	xorl	%eax, %eax
	movl	$-1, %ecx
	movl	$2097152, %esi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rdx, %rax
.L8:
	movl	(%rbx,%rax,4), %edx
	cmpl	%edx, %esi
	jle	.L7
	cmpl	$2, (%rdi,%rax,4)
	cmovne	%eax, %ecx
	cmovne	%edx, %esi
.L7:
	leaq	1(%rax), %rdx
	cmpq	%rax, %r8
	jne	.L18
	cmpl	$-1, %ecx
	je	.L19
	movslq	%ecx, %r11
	movq	%rbx, %rsi
	movl	$2, 400(%rsp,%r11,4)
	leaq	(%r11,%r11,4), %rax
	leaq	(%rax,%rax,4), %rdx
	movq	%rdi, %rax
	salq	$4, %rdx
	addq	%r10, %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	cmpl	$2, (%rax)
	je	.L11
	movl	(%rdx), %ecx
	cmpl	$2097152, %ecx
	je	.L11
	addl	(%rsp,%r11,4), %ecx
	cmpl	%ecx, (%rsi)
	jle	.L11
	movl	%ecx, (%rsi)
	movl	$1, (%rax)
.L11:
	addq	$4, %rax
	addq	$4, %rdx
	addq	$4, %rsi
	cmpq	%r9, %rax
	jne	.L12
	testl	%ebp, %ebp
	jg	.L30
.L1:
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$816, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L10:
	movl	(%rbx,%rbp,4), %ecx
	movl	%ebp, %edx
	cmpl	$2097152, %ecx
	jne	.L28
	movl	$-1, %ecx
.L28:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movl	$1, %edi
	addq	$1, %rbp
	call	__printf_chk@PLT
	cmpl	%ebp, n(%rip)
	jg	.L10
	jmp	.L1
.L17:
	xorl	%eax, %eax
	jmp	.L3
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	dijkstra, .-dijkstra
	.section	.rodata.str1.1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	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	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L33
	movl	%esi, %eax
	leaq	M(%rip), %rbx
	movl	%esi, %r9d
	xorl	%r8d, %r8d
	shrl	$2, %eax
	movq	%rbx, %rdi
	leal	-1(%rsi), %r11d
	andl	$-4, %r9d
	leal	-1(%rax), %r10d
	movdqa	.LC0(%rip), %xmm0
	addq	$1, %r10
	salq	$4, %r10
	.p2align 4,,10
	.p2align 3
.L37:
	cmpl	$2, %r11d
	jbe	.L42
	leaq	(%r10,%rdi), %rdx
	movq	%rdi, %rax
	.p2align 4,,10
	.p2align 3
.L35:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L35
	movl	%r9d, %eax
	cmpl	%esi, %r9d
	je	.L36
.L34:
	movslq	%r8d, %rdx
	movslq	%eax, %rcx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	salq	$2, %rdx
	addq	%rdx, %rcx
	movl	$2097152, (%rbx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %esi
	jle	.L36
	movslq	%ecx, %rcx
	addl	$2, %eax
	addq	%rdx, %rcx
	movl	$2097152, (%rbx,%rcx,4)
	cmpl	%eax, %esi
	jle	.L36
	cltq
	addq	%rax, %rdx
	movl	$2097152, (%rbx,%rdx,4)
.L36:
	addl	$1, %r8d
	addq	$400, %rdi
	cmpl	%esi, %r8d
	jne	.L37
	leaq	24(%rsp), %rax
	xorl	%r14d, %r14d
	leaq	28(%rsp), %r13
	movq	%rax, 8(%rsp)
	leaq	32(%rsp), %rax
	leaq	.LC3(%rip), %rbp
	movq	%rax, (%rsp)
	.p2align 4,,10
	.p2align 3
.L40:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	testl	%eax, %eax
	jle	.L38
	xorl	%r15d, %r15d
	leaq	36(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L39:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %rax
	movslq	36(%rsp), %rdx
	addl	$1, %r15d
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	movl	28(%rsp), %edx
	movl	%edx, (%rbx,%rax,4)
	cmpl	%r15d, 24(%rsp)
	jg	.L39
.L38:
	addl	$1, %r14d
	cmpl	%r14d, n(%rip)
	jg	.L40
.L33:
	xorl	%eax, %eax
	call	dijkstra
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	addq	$56, %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
.L42:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L34
.L48:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	M
	.bss
	.align 32
	.type	M, @object
	.size	M, 40000
M:
	.zero	40000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.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
.LC1:
	.string	"%d %d\n"
	.text
	.p2align 4
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$816, %rsp
	.cfi_def_cfa_offset 848
	movl	n(%rip), %ebp
	movq	%fs:40, %rax
	movq	%rax, 808(%rsp)
	xorl	%eax, %eax
	leaq	400(%rsp), %rdi
	leal	-1(%rbp), %ebx
	testl	%ebp, %ebp
	jle	.L2
	cmpl	$2, %ebx
	jbe	.L17
	movl	%ebp, %edx
	movdqa	.LC0(%rip), %xmm0
	movq	%rsp, %rax
	shrl	$2, %edx
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%rsp,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L4:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L4
	movl	%ebp, %eax
	andl	$-4, %eax
	testb	$3, %bpl
	je	.L5
.L3:
	movslq	%eax, %rdx
	movl	$2097152, (%rsp,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%ebp, %edx
	jge	.L5
	movslq	%edx, %rdx
	addl	$2, %eax
	movl	$2097152, (%rsp,%rdx,4)
	cmpl	%ebp, %eax
	jge	.L5
	cltq
	movl	$2097152, (%rsp,%rax,4)
.L5:
	movl	%ebp, %edx
	leaq	400(%rsp), %rdi
	xorl	%esi, %esi
	salq	$2, %rdx
	call	memset@PLT
	movq	%rax, %rdi
.L2:
	movl	%ebx, %r8d
	movl	$0, (%rsp)
	movq	%rsp, %rbx
	leaq	M(%rip), %r10
	movl	$1, 400(%rsp)
	leaq	404(%rsp,%r8,4), %r9
	testl	%ebp, %ebp
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L30:
	xorl	%eax, %eax
	movl	$-1, %ecx
	movl	$2097152, %esi
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rdx, %rax
.L8:
	movl	(%rbx,%rax,4), %edx
	cmpl	%edx, %esi
	jle	.L7
	cmpl	$2, (%rdi,%rax,4)
	cmovne	%eax, %ecx
	cmovne	%edx, %esi
.L7:
	leaq	1(%rax), %rdx
	cmpq	%rax, %r8
	jne	.L18
	cmpl	$-1, %ecx
	je	.L19
	movslq	%ecx, %r11
	movq	%rbx, %rsi
	movl	$2, 400(%rsp,%r11,4)
	leaq	(%r11,%r11,4), %rax
	leaq	(%rax,%rax,4), %rdx
	movq	%rdi, %rax
	salq	$4, %rdx
	addq	%r10, %rdx
	.p2align 4,,10
	.p2align 3
.L12:
	cmpl	$2, (%rax)
	je	.L11
	movl	(%rdx), %ecx
	cmpl	$2097152, %ecx
	je	.L11
	addl	(%rsp,%r11,4), %ecx
	cmpl	%ecx, (%rsi)
	jle	.L11
	movl	%ecx, (%rsi)
	movl	$1, (%rax)
.L11:
	addq	$4, %rax
	addq	$4, %rdx
	addq	$4, %rsi
	cmpq	%r9, %rax
	jne	.L12
	testl	%ebp, %ebp
	jg	.L30
.L1:
	movq	808(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$816, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L19:
	.cfi_restore_state
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L10:
	movl	(%rbx,%rbp,4), %ecx
	movl	%ebp, %edx
	cmpl	$2097152, %ecx
	jne	.L28
	movl	$-1, %ecx
.L28:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movl	$1, %edi
	addq	$1, %rbp
	call	__printf_chk@PLT
	cmpl	%ebp, n(%rip)
	jg	.L10
	jmp	.L1
.L17:
	xorl	%eax, %eax
	jmp	.L3
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	dijkstra, .-dijkstra
	.section	.rodata.str1.1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	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	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L33
	movl	%esi, %eax
	leaq	M(%rip), %rbx
	movl	%esi, %r9d
	xorl	%r8d, %r8d
	shrl	$2, %eax
	movq	%rbx, %rdi
	leal	-1(%rsi), %r11d
	andl	$-4, %r9d
	leal	-1(%rax), %r10d
	movdqa	.LC0(%rip), %xmm0
	addq	$1, %r10
	salq	$4, %r10
	.p2align 4,,10
	.p2align 3
.L37:
	cmpl	$2, %r11d
	jbe	.L42
	leaq	(%r10,%rdi), %rdx
	movq	%rdi, %rax
	.p2align 4,,10
	.p2align 3
.L35:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rdx, %rax
	jne	.L35
	movl	%r9d, %eax
	cmpl	%esi, %r9d
	je	.L36
.L34:
	movslq	%r8d, %rdx
	movslq	%eax, %rcx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	salq	$2, %rdx
	addq	%rdx, %rcx
	movl	$2097152, (%rbx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %esi
	jle	.L36
	movslq	%ecx, %rcx
	addl	$2, %eax
	addq	%rdx, %rcx
	movl	$2097152, (%rbx,%rcx,4)
	cmpl	%eax, %esi
	jle	.L36
	cltq
	addq	%rax, %rdx
	movl	$2097152, (%rbx,%rdx,4)
.L36:
	addl	$1, %r8d
	addq	$400, %rdi
	cmpl	%esi, %r8d
	jne	.L37
	leaq	24(%rsp), %rax
	xorl	%r14d, %r14d
	leaq	28(%rsp), %r13
	movq	%rax, 8(%rsp)
	leaq	32(%rsp), %rax
	leaq	.LC3(%rip), %rbp
	movq	%rax, (%rsp)
	.p2align 4,,10
	.p2align 3
.L40:
	movq	8(%rsp), %rdx
	movq	(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	testl	%eax, %eax
	jle	.L38
	xorl	%r15d, %r15d
	leaq	36(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L39:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %rax
	movslq	36(%rsp), %rdx
	addl	$1, %r15d
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,4), %rax
	movl	28(%rsp), %edx
	movl	%edx, (%rbx,%rax,4)
	cmpl	%r15d, 24(%rsp)
	jg	.L39
.L38:
	addl	$1, %r14d
	cmpl	%r14d, n(%rip)
	jg	.L40
.L33:
	xorl	%eax, %eax
	call	dijkstra
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	addq	$56, %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
.L42:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L34
.L48:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.globl	M
	.bss
	.align 32
	.type	M, @object
	.size	M, 40000
M:
	.zero	40000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.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 MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int i,v,minv;
  int d[MAX],color[MAX];

  for(i = 0; i< n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v<n ; v++){
      if(color[v] != BLACK && M[u][v] !=INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i<n; i++){
    printf("%d %d\n",i,(d[i] == INFTY?-1:d[i]));
  }
}


int main(){
  int i,j;
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    for(j = 0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  int k,c,u,v;
  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;
    }
  }
  dijkstra();

  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 MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
  int i,v,minv;
  int d[MAX],color[MAX];

  for(i = 0; i< n ; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    int u = -1;
    for(i = 0; i < n; i++){
      if(minv > d[i] && color[i] != BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v<n ; v++){
      if(color[v] != BLACK && M[u][v] !=INFTY){
	if(d[v] > d[u] + M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i = 0; i<n; i++){
    printf("%d %d\n",i,(d[i] == INFTY?-1:d[i]));
  }
}


int main(){
  int i,j;
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    for(j = 0; j<n; j++){
      M[i][j] = INFTY;
    }
  }

  int k,c,u,v;
  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;
    }
  }
  dijkstra();

  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40000
M:
	.zero	40000
	.section	.rodata
.LC0:
	.string	"%d %d\n"
	.text
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$832, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -832(%rbp)
	jmp	.L2
.L3:
	movl	-832(%rbp), %eax
	cltq
	movl	$2097152, -816(%rbp,%rax,4)
	movl	-832(%rbp), %eax
	cltq
	movl	$0, -416(%rbp,%rax,4)
	addl	$1, -832(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L3
	movl	$0, -816(%rbp)
	movl	$1, -416(%rbp)
.L12:
	movl	$2097152, -824(%rbp)
	movl	$-1, -820(%rbp)
	movl	$0, -832(%rbp)
	jmp	.L4
.L6:
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	%eax, -824(%rbp)
	jle	.L5
	movl	-832(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	$2, %eax
	je	.L5
	movl	-832(%rbp), %eax
	movl	%eax, -820(%rbp)
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	movl	%eax, -824(%rbp)
.L5:
	addl	$1, -832(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L6
	cmpl	$-1, -820(%rbp)
	je	.L19
	movl	-820(%rbp), %eax
	cltq
	movl	$2, -416(%rbp,%rax,4)
	movl	$0, -828(%rbp)
	jmp	.L9
.L11:
	movl	-828(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	$2, %eax
	je	.L10
	movl	-828(%rbp), %eax
	movslq	%eax, %rcx
	movl	-820(%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
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	je	.L10
	movl	-828(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %ecx
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %esi
	movl	-828(%rbp), %eax
	movslq	%eax, %rdi
	movl	-820(%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	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L10
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %ecx
	movl	-828(%rbp), %eax
	movslq	%eax, %rsi
	movl	-820(%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
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	(%rcx,%rax), %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
	movl	-828(%rbp), %eax
	cltq
	movl	$1, -416(%rbp,%rax,4)
.L10:
	addl	$1, -828(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -828(%rbp)
	jl	.L11
	jmp	.L12
.L19:
	nop
	movl	$0, -832(%rbp)
	jmp	.L13
.L16:
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	$2097152, %eax
	je	.L14
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	jmp	.L15
.L14:
	movl	$-1, %eax
.L15:
	movl	-832(%rbp), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -832(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L16
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dijkstra, .-dijkstra
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L21
.L24:
	movl	$0, -12(%rbp)
	jmp	.L22
.L23:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	$2097152, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L22:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	addl	$1, -16(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L24
	movl	$0, -16(%rbp)
	jmp	.L25
.L28:
	leaq	-32(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L26
.L27:
	leaq	-28(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-20(%rbp), %ecx
	movl	-28(%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
	leaq	0(,%rax,4), %rcx
	leaq	M(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -12(%rbp)
.L26:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L27
	addl	$1, -16(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L28
	movl	$0, %eax
	call	dijkstra
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40000
M:
	.zero	40000
	.section	.rodata
.LC0:
	.string	"%d %d\n"
	.text
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$832, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -832(%rbp)
	jmp	.L2
.L3:
	movl	-832(%rbp), %eax
	cltq
	movl	$2097152, -816(%rbp,%rax,4)
	movl	-832(%rbp), %eax
	cltq
	movl	$0, -416(%rbp,%rax,4)
	addl	$1, -832(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L3
	movl	$0, -816(%rbp)
	movl	$1, -416(%rbp)
.L12:
	movl	$2097152, -824(%rbp)
	movl	$-1, -820(%rbp)
	movl	$0, -832(%rbp)
	jmp	.L4
.L6:
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	%eax, -824(%rbp)
	jle	.L5
	movl	-832(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	$2, %eax
	je	.L5
	movl	-832(%rbp), %eax
	movl	%eax, -820(%rbp)
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	movl	%eax, -824(%rbp)
.L5:
	addl	$1, -832(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L6
	cmpl	$-1, -820(%rbp)
	je	.L19
	movl	-820(%rbp), %eax
	cltq
	movl	$2, -416(%rbp,%rax,4)
	movl	$0, -828(%rbp)
	jmp	.L9
.L11:
	movl	-828(%rbp), %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	cmpl	$2, %eax
	je	.L10
	movl	-828(%rbp), %eax
	movslq	%eax, %rcx
	movl	-820(%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
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	je	.L10
	movl	-828(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %ecx
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %esi
	movl	-828(%rbp), %eax
	movslq	%eax, %rdi
	movl	-820(%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	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L10
	movl	-820(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %ecx
	movl	-828(%rbp), %eax
	movslq	%eax, %rsi
	movl	-820(%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
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	(%rcx,%rax), %edx
	movl	-828(%rbp), %eax
	cltq
	movl	%edx, -816(%rbp,%rax,4)
	movl	-828(%rbp), %eax
	cltq
	movl	$1, -416(%rbp,%rax,4)
.L10:
	addl	$1, -828(%rbp)
.L9:
	movl	n(%rip), %eax
	cmpl	%eax, -828(%rbp)
	jl	.L11
	jmp	.L12
.L19:
	nop
	movl	$0, -832(%rbp)
	jmp	.L13
.L16:
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	cmpl	$2097152, %eax
	je	.L14
	movl	-832(%rbp), %eax
	cltq
	movl	-816(%rbp,%rax,4), %eax
	jmp	.L15
.L14:
	movl	$-1, %eax
.L15:
	movl	-832(%rbp), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -832(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -832(%rbp)
	jl	.L16
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dijkstra, .-dijkstra
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L21
.L24:
	movl	$0, -12(%rbp)
	jmp	.L22
.L23:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	M(%rip), %rax
	movl	$2097152, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L22:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	addl	$1, -16(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L24
	movl	$0, -16(%rbp)
	jmp	.L25
.L28:
	leaq	-32(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L26
.L27:
	leaq	-28(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-20(%rbp), %ecx
	movl	-28(%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
	leaq	0(,%rax,4), %rcx
	leaq	M(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -12(%rbp)
.L26:
	movl	-32(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L27
	addl	$1, -16(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L28
	movl	$0, %eax
	call	dijkstra
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
