Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, const char *argv[])
{
  int h, w;
  int c[10][10];
  
  scanf("%d %d", &h, &w);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  int d[10];
  for (int i = 0; i < 10; i++) d[i] = INT_MAX;
  d[1] = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
	if (d[j] != INT_MAX && d[i] > d[j] + c[i][j]) {
	  d[i] = d[j] + c[i][j];
	  update = true;
	}
      }
    }
    if (!update) break;
  }

  int ans = 0, a;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &a);
      if (a != -1) ans += d[a];
    }
  }

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

  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$528, %rsp
	movl	%edi, -516(%rbp)
	movq	%rsi, -528(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-504(%rbp), %rdx
	leaq	-508(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -496(%rbp)
	jmp	.L2
.L5:
	movl	$0, -492(%rbp)
	jmp	.L3
.L4:
	leaq	-416(%rbp), %rcx
	movl	-492(%rbp), %eax
	movslq	%eax, %rsi
	movl	-496(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -492(%rbp)
.L3:
	cmpl	$9, -492(%rbp)
	jle	.L4
	addl	$1, -496(%rbp)
.L2:
	cmpl	$9, -496(%rbp)
	jle	.L5
	movl	$0, -488(%rbp)
	jmp	.L6
.L7:
	movl	-488(%rbp), %eax
	cltq
	movl	$2147483647, -464(%rbp,%rax,4)
	addl	$1, -488(%rbp)
.L6:
	cmpl	$9, -488(%rbp)
	jle	.L7
	movl	$0, -460(%rbp)
.L15:
	movb	$0, -509(%rbp)
	movl	$0, -484(%rbp)
	jmp	.L8
.L12:
	movl	$0, -480(%rbp)
	jmp	.L9
.L11:
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %eax
	cmpl	$2147483647, %eax
	je	.L10
	movl	-484(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %ecx
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %esi
	movl	-480(%rbp), %eax
	movslq	%eax, %rdi
	movl	-484(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	movl	-416(%rbp,%rax,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L10
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %ecx
	movl	-480(%rbp), %eax
	movslq	%eax, %rsi
	movl	-484(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	movl	-416(%rbp,%rax,4), %eax
	leal	(%rcx,%rax), %edx
	movl	-484(%rbp), %eax
	cltq
	movl	%edx, -464(%rbp,%rax,4)
	movb	$1, -509(%rbp)
.L10:
	addl	$1, -480(%rbp)
.L9:
	cmpl	$9, -480(%rbp)
	jle	.L11
	addl	$1, -484(%rbp)
.L8:
	cmpl	$9, -484(%rbp)
	jle	.L12
	movzbl	-509(%rbp), %eax
	xorl	$1, %eax
	testb	%al, %al
	jne	.L24
	jmp	.L15
.L24:
	nop
	movl	$0, -476(%rbp)
	movl	$0, -472(%rbp)
	jmp	.L16
.L20:
	movl	$0, -468(%rbp)
	jmp	.L17
.L19:
	leaq	-500(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-500(%rbp), %eax
	cmpl	$-1, %eax
	je	.L18
	movl	-500(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %eax
	addl	%eax, -476(%rbp)
.L18:
	addl	$1, -468(%rbp)
.L17:
	movl	-504(%rbp), %eax
	cmpl	%eax, -468(%rbp)
	jl	.L19
	addl	$1, -472(%rbp)
.L16:
	movl	-508(%rbp), %eax
	cmpl	%eax, -472(%rbp)
	jl	.L20
	movl	-476(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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 %d"
.LC1:
	.string	"%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$480, %rsp
	.cfi_def_cfa_offset 528
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	leaq	64(%rsp), %r12
	leaq	104(%rsp), %r13
	leaq	504(%rsp), %r14
	call	__isoc99_scanf@PLT
.L2:
	leaq	-40(%r13), %rbx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r13
	jne	.L3
	addq	$40, %r13
	cmpq	%r13, %r14
	jne	.L2
	movdqa	.LC2(%rip), %xmm0
	movq	.LC3(%rip), %rax
	leaq	16(%rsp), %r8
	leaq	400(%r12), %rdi
	movaps	%xmm0, 16(%rsp)
	movq	%rax, 48(%rsp)
	movl	$0, 20(%rsp)
	movaps	%xmm0, 32(%rsp)
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%r8, %rax
	movq	%r12, %rdx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L15:
	movl	16(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L5
	addl	(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L5
	movl	%ecx, (%rax)
	movl	$1, %esi
.L5:
	movl	20(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L6
	addl	4(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L6
	movl	%ecx, (%rax)
	movl	$1, %esi
.L6:
	movl	24(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L7
	addl	8(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L7
	movl	%ecx, (%rax)
	movl	$1, %esi
.L7:
	movl	28(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L8
	addl	12(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L8
	movl	%ecx, (%rax)
	movl	$1, %esi
.L8:
	movl	32(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L9
	addl	16(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L9
	movl	%ecx, (%rax)
	movl	$1, %esi
.L9:
	movl	36(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L10
	addl	20(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L10
	movl	%ecx, (%rax)
	movl	$1, %esi
.L10:
	movl	40(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L11
	addl	24(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L11
	movl	%ecx, (%rax)
	movl	$1, %esi
.L11:
	movl	44(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L12
	addl	28(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L12
	movl	%ecx, (%rax)
	movl	$1, %esi
.L12:
	movl	48(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L13
	addl	32(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L13
	movl	%ecx, (%rax)
	movl	$1, %esi
.L13:
	movl	52(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L14
	addl	36(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L14
	movl	%ecx, (%rax)
	movl	$1, %esi
.L14:
	addq	$40, %rdx
	addq	$4, %rax
	cmpq	%rdx, %rdi
	jne	.L15
	testb	%sil, %sil
	jne	.L16
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L23
	movl	8(%rsp), %eax
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	leaq	12(%rsp), %rbx
.L18:
	testl	%eax, %eax
	jle	.L17
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	cmpl	$-1, %eax
	je	.L19
	addl	16(%rsp,%rax,4), %r12d
.L19:
	movl	8(%rsp), %eax
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jg	.L20
	addl	$1, %r13d
	cmpl	%r13d, 4(%rsp)
	jg	.L18
.L17:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L65
	addq	$480, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L23:
	.cfi_restore_state
	xorl	%r12d, %r12d
	jmp	.L17
.L65:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.set	.LC3,.LC2
	.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 %d"
.LC1:
	.string	"%d"
.LC4:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$480, %rsp
	.cfi_def_cfa_offset 528
	movq	%fs:40, %rax
	movq	%rax, 472(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	leaq	64(%rsp), %r12
	leaq	104(%rsp), %r13
	leaq	504(%rsp), %r14
	call	__isoc99_scanf@PLT
.L2:
	leaq	-40(%r13), %rbx
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r13
	jne	.L3
	addq	$40, %r13
	cmpq	%r13, %r14
	jne	.L2
	movdqa	.LC2(%rip), %xmm0
	movq	.LC3(%rip), %rax
	leaq	16(%rsp), %r8
	leaq	400(%r12), %rdi
	movaps	%xmm0, 16(%rsp)
	movq	%rax, 48(%rsp)
	movl	$0, 20(%rsp)
	movaps	%xmm0, 32(%rsp)
	.p2align 4,,10
	.p2align 3
.L16:
	movq	%r8, %rax
	movq	%r12, %rdx
	xorl	%esi, %esi
	.p2align 4,,10
	.p2align 3
.L15:
	movl	16(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L5
	addl	(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L5
	movl	%ecx, (%rax)
	movl	$1, %esi
.L5:
	movl	20(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L6
	addl	4(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L6
	movl	%ecx, (%rax)
	movl	$1, %esi
.L6:
	movl	24(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L7
	addl	8(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L7
	movl	%ecx, (%rax)
	movl	$1, %esi
.L7:
	movl	28(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L8
	addl	12(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L8
	movl	%ecx, (%rax)
	movl	$1, %esi
.L8:
	movl	32(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L9
	addl	16(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L9
	movl	%ecx, (%rax)
	movl	$1, %esi
.L9:
	movl	36(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L10
	addl	20(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L10
	movl	%ecx, (%rax)
	movl	$1, %esi
.L10:
	movl	40(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L11
	addl	24(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L11
	movl	%ecx, (%rax)
	movl	$1, %esi
.L11:
	movl	44(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L12
	addl	28(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L12
	movl	%ecx, (%rax)
	movl	$1, %esi
.L12:
	movl	48(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L13
	addl	32(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L13
	movl	%ecx, (%rax)
	movl	$1, %esi
.L13:
	movl	52(%rsp), %ecx
	cmpl	$2147483647, %ecx
	je	.L14
	addl	36(%rdx), %ecx
	cmpl	%ecx, (%rax)
	jle	.L14
	movl	%ecx, (%rax)
	movl	$1, %esi
.L14:
	addq	$40, %rdx
	addq	$4, %rax
	cmpq	%rdx, %rdi
	jne	.L15
	testb	%sil, %sil
	jne	.L16
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L23
	movl	8(%rsp), %eax
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	leaq	12(%rsp), %rbx
.L18:
	testl	%eax, %eax
	jle	.L17
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %rax
	cmpl	$-1, %eax
	je	.L19
	addl	16(%rsp,%rax,4), %r12d
.L19:
	movl	8(%rsp), %eax
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jg	.L20
	addl	$1, %r13d
	cmpl	%r13d, 4(%rsp)
	jg	.L18
.L17:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
	movq	472(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L65
	addq	$480, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L23:
	.cfi_restore_state
	xorl	%r12d, %r12d
	jmp	.L17
.L65:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.long	2147483647
	.set	.LC3,.LC2
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, const char *argv[])
{
  int h, w;
  int c[10][10];
  
  scanf("%d %d", &h, &w);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  int d[10];
  for (int i = 0; i < 10; i++) d[i] = INT_MAX;
  d[1] = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
	if (d[j] != INT_MAX && d[i] > d[j] + c[i][j]) {
	  d[i] = d[j] + c[i][j];
	  update = true;
	}
      }
    }
    if (!update) break;
  }

  int ans = 0, a;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &a);
      if (a != -1) ans += d[a];
    }
  }

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

  return 0;
}

2 4
0 9 9 9 9 9 9 9 9 9
9 0 9 9 9 9 9 9 9 9
9 9 0 9 9 9 9 9 9 9
9 9 9 0 2 9 9 9 9 9
9 9 9 9 0 9 9 9 9 2
9 9 9 9 9 0 9 9 9 9
9 9 9 9 9 9 0 9 9 9
9 9 9 9 9 9 9 0 9 9
9 9 9 9 2 9 9 9 0 9
9 2 9 9 9 9 9 9 9 0
-1 -1 -1 -1
8 1 1 8
 3 5
0 4 3 6 2 7 2 5 3 3
4 0 5 3 7 5 3 7 2 7
5 7 0 7 2 9 3 2 9 1
3 6 2 0 2 7 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 3 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
3 5 2 6 1
2 5 3 2 1
6 9 2 5 6
 5 5
0 999 999 999 999 999 999 999 999 999
999 0 999 999 999 999 999 999 999 999
999 999 0 999 999 999 999 999 999 999
999 999 999 0 999 999 999 999 999 999
999 999 999 999 0 999 999 999 999 999
999 999 999 999 999 0 999 999 999 999
999 999 999 999 999 999 0 999 999 999
999 999 999 999 999 999 999 0 999 1330
999 999 999 999 999 999 999 999 0 999
999 999 999 999 999 999 999 999 999 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
 5 5
0 999 999 999 999 999 999 999 999 999
999 0 999 999 999 999 999 999 999 999
999 999 0 999 999 999 999 999 999 999
999 334 999 0 999 999 999 999 999 999
999 999 999 999 0 999 999 999 999 999
999 999 999 999 999 0 999 577 999 999
999 999 999 999 117 999 0 999 999 999
999 999 999 999 999 999 999 0 999 1330
999 999 999 999 999 999 999 999 0 999
999 999 999 999 999 999 999 999 999 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 0 1 1 1
1 1 1 1 1
 3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 7
5 7 0 7 2 9 1 2 9 1
3 6 2 0 2 7 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 0 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
0 5 2 6 1
2 5 3 2 1
6 9 2 5 6
 2 4
0 9 9 9 9 9 9 9 13 9
9 0 9 9 9 9 9 9 9 9
9 9 0 9 9 9 9 9 9 9
9 9 9 0 2 9 9 9 9 9
9 9 9 9 0 9 9 9 9 2
9 9 9 9 15 0 9 9 9 9
9 9 9 9 9 9 0 9 9 9
9 9 9 9 9 2 9 0 9 9
9 9 9 5 2 9 9 9 0 9
9 2 9 9 9 9 2 9 9 0
-1 -1 -1 -1
0 1 1 8
 3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 7
5 7 0 7 2 9 1 2 9 0
3 6 2 0 2 7 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 0 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
0 5 2 6 1
2 5 3 2 1
6 9 2 5 6
 5 5
0 999 999 999 999 999 999 999 999 999
999 0 999 999 999 999 999 999 999 999
999 999 0 999 999 999 999 999 999 999
999 334 999 0 999 999 999 999 999 999
999 999 999 999 0 999 999 202 999 999
999 999 999 999 999 0 999 577 999 999
999 999 999 999 117 999 0 999 999 999
999 999 999 999 999 999 999 0 999 1330
999 999 999 999 999 999 999 999 0 999
999 999 999 999 999 999 999 999 999 0
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 0 1 1 1
1 0 1 1 1
 2 4
0 9 9 9 9 9 9 9 13 9
9 0 9 9 9 9 9 9 9 9
9 9 0 9 9 9 9 9 9 9
9 9 9 0 2 9 9 9 9 9
9 9 9 9 0 9 9 9 9 1
9 9 9 15 15 0 9 9 9 9
9 9 9 9 9 9 0 9 9 9
9 9 9 9 9 2 9 0 9 9
9 9 9 5 2 9 9 9 0 9
9 2 9 9 9 9 2 9 9 0
-1 -1 -1 -1
0 1 1 8
 3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 11
5 7 0 7 2 9 1 2 9 0
3 6 2 0 2 7 6 4 2 3
3 5 7 4 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 0 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
0 5 2 6 1
2 5 3 2 1
6 9 2 6 6

12
 47
 0
 999
 44
 15
 36
 1998
 14
 35

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD 1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, const char *argv[])
{
  int h, w;
  int c[10][10];
  
  scanf("%d %d", &h, &w);
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  int d[10];
  for (int i = 0; i < 10; i++) d[i] = INT_MAX;
  d[1] = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
	if (d[j] != INT_MAX && d[i] > d[j] + c[i][j]) {
	  d[i] = d[j] + c[i][j];
	  update = true;
	}
      }
    }
    if (!update) break;
  }

  int ans = 0, a;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      scanf("%d", &a);
      if (a != -1) ans += d[a];
    }
  }

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

  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$528, %rsp
	movl	%edi, -516(%rbp)
	movq	%rsi, -528(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-504(%rbp), %rdx
	leaq	-508(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -496(%rbp)
	jmp	.L2
.L5:
	movl	$0, -492(%rbp)
	jmp	.L3
.L4:
	leaq	-416(%rbp), %rcx
	movl	-492(%rbp), %eax
	movslq	%eax, %rsi
	movl	-496(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -492(%rbp)
.L3:
	cmpl	$9, -492(%rbp)
	jle	.L4
	addl	$1, -496(%rbp)
.L2:
	cmpl	$9, -496(%rbp)
	jle	.L5
	movl	$0, -488(%rbp)
	jmp	.L6
.L7:
	movl	-488(%rbp), %eax
	cltq
	movl	$2147483647, -464(%rbp,%rax,4)
	addl	$1, -488(%rbp)
.L6:
	cmpl	$9, -488(%rbp)
	jle	.L7
	movl	$0, -460(%rbp)
.L15:
	movb	$0, -509(%rbp)
	movl	$0, -484(%rbp)
	jmp	.L8
.L12:
	movl	$0, -480(%rbp)
	jmp	.L9
.L11:
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %eax
	cmpl	$2147483647, %eax
	je	.L10
	movl	-484(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %ecx
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %esi
	movl	-480(%rbp), %eax
	movslq	%eax, %rdi
	movl	-484(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	movl	-416(%rbp,%rax,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L10
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %ecx
	movl	-480(%rbp), %eax
	movslq	%eax, %rsi
	movl	-484(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	movl	-416(%rbp,%rax,4), %eax
	leal	(%rcx,%rax), %edx
	movl	-484(%rbp), %eax
	cltq
	movl	%edx, -464(%rbp,%rax,4)
	movb	$1, -509(%rbp)
.L10:
	addl	$1, -480(%rbp)
.L9:
	cmpl	$9, -480(%rbp)
	jle	.L11
	addl	$1, -484(%rbp)
.L8:
	cmpl	$9, -484(%rbp)
	jle	.L12
	movzbl	-509(%rbp), %eax
	xorl	$1, %eax
	testb	%al, %al
	jne	.L24
	jmp	.L15
.L24:
	nop
	movl	$0, -476(%rbp)
	movl	$0, -472(%rbp)
	jmp	.L16
.L20:
	movl	$0, -468(%rbp)
	jmp	.L17
.L19:
	leaq	-500(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-500(%rbp), %eax
	cmpl	$-1, %eax
	je	.L18
	movl	-500(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %eax
	addl	%eax, -476(%rbp)
.L18:
	addl	$1, -468(%rbp)
.L17:
	movl	-504(%rbp), %eax
	cmpl	%eax, -468(%rbp)
	jl	.L19
	addl	$1, -472(%rbp)
.L16:
	movl	-508(%rbp), %eax
	cmpl	%eax, -472(%rbp)
	jl	.L20
	movl	-476(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$528, %rsp
	movl	%edi, -516(%rbp)
	movq	%rsi, -528(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-504(%rbp), %rdx
	leaq	-508(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -496(%rbp)
	jmp	.L2
.L5:
	movl	$0, -492(%rbp)
	jmp	.L3
.L4:
	leaq	-416(%rbp), %rcx
	movl	-492(%rbp), %eax
	movslq	%eax, %rsi
	movl	-496(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -492(%rbp)
.L3:
	cmpl	$9, -492(%rbp)
	jle	.L4
	addl	$1, -496(%rbp)
.L2:
	cmpl	$9, -496(%rbp)
	jle	.L5
	movl	$0, -488(%rbp)
	jmp	.L6
.L7:
	movl	-488(%rbp), %eax
	cltq
	movl	$2147483647, -464(%rbp,%rax,4)
	addl	$1, -488(%rbp)
.L6:
	cmpl	$9, -488(%rbp)
	jle	.L7
	movl	$0, -460(%rbp)
.L15:
	movb	$0, -509(%rbp)
	movl	$0, -484(%rbp)
	jmp	.L8
.L12:
	movl	$0, -480(%rbp)
	jmp	.L9
.L11:
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %eax
	cmpl	$2147483647, %eax
	je	.L10
	movl	-484(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %ecx
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %esi
	movl	-480(%rbp), %eax
	movslq	%eax, %rdi
	movl	-484(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	movl	-416(%rbp,%rax,4), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L10
	movl	-480(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %ecx
	movl	-480(%rbp), %eax
	movslq	%eax, %rsi
	movl	-484(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	movl	-416(%rbp,%rax,4), %eax
	leal	(%rcx,%rax), %edx
	movl	-484(%rbp), %eax
	cltq
	movl	%edx, -464(%rbp,%rax,4)
	movb	$1, -509(%rbp)
.L10:
	addl	$1, -480(%rbp)
.L9:
	cmpl	$9, -480(%rbp)
	jle	.L11
	addl	$1, -484(%rbp)
.L8:
	cmpl	$9, -484(%rbp)
	jle	.L12
	movzbl	-509(%rbp), %eax
	xorl	$1, %eax
	testb	%al, %al
	jne	.L24
	jmp	.L15
.L24:
	nop
	movl	$0, -476(%rbp)
	movl	$0, -472(%rbp)
	jmp	.L16
.L20:
	movl	$0, -468(%rbp)
	jmp	.L17
.L19:
	leaq	-500(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-500(%rbp), %eax
	cmpl	$-1, %eax
	je	.L18
	movl	-500(%rbp), %eax
	cltq
	movl	-464(%rbp,%rax,4), %eax
	addl	%eax, -476(%rbp)
.L18:
	addl	$1, -468(%rbp)
.L17:
	movl	-504(%rbp), %eax
	cmpl	%eax, -468(%rbp)
	jl	.L19
	addl	$1, -472(%rbp)
.L16:
	movl	-508(%rbp), %eax
	cmpl	%eax, -472(%rbp)
	jl	.L20
	movl	-476(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
