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>

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  int c[100];
  const int f=10;
  int i,j,k;
  for(i=0;i<f*f;i++) scanf("%d",c+i);
  for(k=0;k<f;k++){
    for(i=0;i<f;i++){
      for(j=0;j<f;j++){
	c[i*f+j]=MIN(c[i*f+j],c[i*f+k]+c[k*f+j]);
      }
    }
  }
  int ans=0;
  for(i=0;i<h*w;i++){
    int a;
    scanf("%d",&a);
    if(a<0) continue;
    ans+=c[a*f+1];
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  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	run
	.type	run, @function
run:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-444(%rbp), %rdx
	leaq	-448(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$10, -420(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L2
.L3:
	movl	-436(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-416(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -436(%rbp)
.L2:
	movl	-420(%rbp), %eax
	imull	%eax, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L3
	movl	$0, -428(%rbp)
	jmp	.L4
.L9:
	movl	$0, -436(%rbp)
	jmp	.L5
.L8:
	movl	$0, -432(%rbp)
	jmp	.L6
.L7:
	movl	-436(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %edx
	movl	-428(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movl	-428(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %ecx
	movl	-432(%rbp), %eax
	addl	%ecx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-436(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %ecx
	movl	-432(%rbp), %eax
	addl	%ecx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	-436(%rbp), %ecx
	movl	%ecx, %esi
	imull	-420(%rbp), %esi
	movl	-432(%rbp), %ecx
	addl	%esi, %ecx
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -432(%rbp)
.L6:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L7
	addl	$1, -436(%rbp)
.L5:
	movl	-436(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L8
	addl	$1, -428(%rbp)
.L4:
	movl	-428(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L9
	movl	$0, -424(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L10
.L13:
	leaq	-440(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-440(%rbp), %eax
	testl	%eax, %eax
	js	.L15
	movl	-440(%rbp), %eax
	imull	-420(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	addl	%eax, -424(%rbp)
	jmp	.L12
.L15:
	nop
.L12:
	addl	$1, -436(%rbp)
.L10:
	movl	-448(%rbp), %edx
	movl	-444(%rbp), %eax
	imull	%edx, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L13
	movl	-424(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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"
.LC2:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	leaq	16(%rsp), %r12
	leaq	416(%rsp), %rbx
	movq	%r12, %r13
	call	__isoc99_scanf@PLT
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r13
	jne	.L2
	movq	%r12, %rcx
	movq	%r12, %r8
	xorl	%edi, %edi
.L3:
	movq	%r12, %rax
	movq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L4:
	movl	(%rax), %r9d
	movl	(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	4(%rax), %r9d
	movl	%esi, (%rax)
	movl	4(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	8(%rax), %r9d
	movl	%esi, 4(%rax)
	movl	8(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	12(%rax), %r9d
	movl	%esi, 8(%rax)
	movl	12(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	16(%rax), %r9d
	movl	%esi, 12(%rax)
	movl	16(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	20(%rax), %r9d
	movl	%esi, 16(%rax)
	movl	20(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	24(%rax), %r9d
	movl	%esi, 20(%rax)
	movl	24(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	28(%rax), %r9d
	movl	%esi, 24(%rax)
	movl	28(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	%esi, 28(%rax)
	movl	32(%rcx), %esi
	movl	32(%rax), %r9d
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	36(%rax), %r9d
	movl	%esi, 32(%rax)
	movl	36(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	addq	$40, %rax
	addq	$40, %rdx
	movl	%esi, -4(%rax)
	cmpq	%rbx, %rax
	jne	.L4
	addl	$1, %edi
	addq	$4, %r8
	addq	$40, %rcx
	cmpl	$10, %edi
	jne	.L3
	movl	8(%rsp), %eax
	imull	4(%rsp), %eax
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
	leaq	12(%rsp), %rbx
	testl	%eax, %eax
	jle	.L6
.L5:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	js	.L7
	leal	(%rax,%rax,4), %eax
	leal	1(%rax,%rax), %eax
	cltq
	addl	16(%rsp,%rax,4), %r12d
.L7:
	movl	4(%rsp), %eax
	imull	8(%rsp), %eax
	addl	$1, %r13d
	cmpl	%r13d, %eax
	jg	.L5
.L6:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$440, %rsp
	.cfi_def_cfa_offset 480
	movq	%fs:40, %rax
	movq	%rax, 424(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	leaq	4(%rsp), %rsi
	leaq	16(%rsp), %r12
	leaq	416(%rsp), %rbx
	movq	%r12, %r13
	call	__isoc99_scanf@PLT
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %r13
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r13
	jne	.L2
	movq	%r12, %rcx
	movq	%r12, %r8
	xorl	%edi, %edi
.L3:
	movq	%r12, %rax
	movq	%r8, %rdx
	.p2align 4,,10
	.p2align 3
.L4:
	movl	(%rax), %r9d
	movl	(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	4(%rax), %r9d
	movl	%esi, (%rax)
	movl	4(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	8(%rax), %r9d
	movl	%esi, 4(%rax)
	movl	8(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	12(%rax), %r9d
	movl	%esi, 8(%rax)
	movl	12(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	16(%rax), %r9d
	movl	%esi, 12(%rax)
	movl	16(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	20(%rax), %r9d
	movl	%esi, 16(%rax)
	movl	20(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	24(%rax), %r9d
	movl	%esi, 20(%rax)
	movl	24(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	28(%rax), %r9d
	movl	%esi, 24(%rax)
	movl	28(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	%esi, 28(%rax)
	movl	32(%rcx), %esi
	movl	32(%rax), %r9d
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	movl	36(%rax), %r9d
	movl	%esi, 32(%rax)
	movl	36(%rcx), %esi
	addl	(%rdx), %esi
	cmpl	%r9d, %esi
	cmovg	%r9d, %esi
	addq	$40, %rax
	addq	$40, %rdx
	movl	%esi, -4(%rax)
	cmpq	%rbx, %rax
	jne	.L4
	addl	$1, %edi
	addq	$4, %r8
	addq	$40, %rcx
	cmpl	$10, %edi
	jne	.L3
	movl	8(%rsp), %eax
	imull	4(%rsp), %eax
	xorl	%r12d, %r12d
	xorl	%r13d, %r13d
	leaq	12(%rsp), %rbx
	testl	%eax, %eax
	jle	.L6
.L5:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	js	.L7
	leal	(%rax,%rax,4), %eax
	leal	1(%rax,%rax), %eax
	cltq
	addl	16(%rsp,%rax,4), %r12d
.L7:
	movl	4(%rsp), %eax
	imull	8(%rsp), %eax
	addl	$1, %r13d
	cmpl	%r13d, %eax
	jg	.L5
.L6:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	424(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L17
	addq	$440, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L17:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.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:

#include<stdio.h>
#include<stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  int c[100];
  const int f=10;
  int i,j,k;
  for(i=0;i<f*f;i++) scanf("%d",c+i);
  for(k=0;k<f;k++){
    for(i=0;i<f;i++){
      for(j=0;j<f;j++){
	c[i*f+j]=MIN(c[i*f+j],c[i*f+k]+c[k*f+j]);
      }
    }
  }
  int ans=0;
  for(i=0;i<h*w;i++){
    int a;
    scanf("%d",&a);
    if(a<0) continue;
    ans+=c[a*f+1];
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  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>

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  int c[100];
  const int f=10;
  int i,j,k;
  for(i=0;i<f*f;i++) scanf("%d",c+i);
  for(k=0;k<f;k++){
    for(i=0;i<f;i++){
      for(j=0;j<f;j++){
	c[i*f+j]=MIN(c[i*f+j],c[i*f+k]+c[k*f+j]);
      }
    }
  }
  int ans=0;
  for(i=0;i<h*w;i++){
    int a;
    scanf("%d",&a);
    if(a<0) continue;
    ans+=c[a*f+1];
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  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	run
	.type	run, @function
run:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-444(%rbp), %rdx
	leaq	-448(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$10, -420(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L2
.L3:
	movl	-436(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-416(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -436(%rbp)
.L2:
	movl	-420(%rbp), %eax
	imull	%eax, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L3
	movl	$0, -428(%rbp)
	jmp	.L4
.L9:
	movl	$0, -436(%rbp)
	jmp	.L5
.L8:
	movl	$0, -432(%rbp)
	jmp	.L6
.L7:
	movl	-436(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %edx
	movl	-428(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movl	-428(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %ecx
	movl	-432(%rbp), %eax
	addl	%ecx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-436(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %ecx
	movl	-432(%rbp), %eax
	addl	%ecx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	-436(%rbp), %ecx
	movl	%ecx, %esi
	imull	-420(%rbp), %esi
	movl	-432(%rbp), %ecx
	addl	%esi, %ecx
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -432(%rbp)
.L6:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L7
	addl	$1, -436(%rbp)
.L5:
	movl	-436(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L8
	addl	$1, -428(%rbp)
.L4:
	movl	-428(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L9
	movl	$0, -424(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L10
.L13:
	leaq	-440(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-440(%rbp), %eax
	testl	%eax, %eax
	js	.L15
	movl	-440(%rbp), %eax
	imull	-420(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	addl	%eax, -424(%rbp)
	jmp	.L12
.L15:
	nop
.L12:
	addl	$1, -436(%rbp)
.L10:
	movl	-448(%rbp), %edx
	movl	-444(%rbp), %eax
	imull	%edx, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L13
	movl	-424(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	run
	.type	run, @function
run:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$448, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-444(%rbp), %rdx
	leaq	-448(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$10, -420(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L2
.L3:
	movl	-436(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	-416(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -436(%rbp)
.L2:
	movl	-420(%rbp), %eax
	imull	%eax, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L3
	movl	$0, -428(%rbp)
	jmp	.L4
.L9:
	movl	$0, -436(%rbp)
	jmp	.L5
.L8:
	movl	$0, -432(%rbp)
	jmp	.L6
.L7:
	movl	-436(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %edx
	movl	-428(%rbp), %eax
	addl	%edx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %edx
	movl	-428(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %ecx
	movl	-432(%rbp), %eax
	addl	%ecx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	addl	%eax, %edx
	movl	-436(%rbp), %eax
	imull	-420(%rbp), %eax
	movl	%eax, %ecx
	movl	-432(%rbp), %eax
	addl	%ecx, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	movl	-436(%rbp), %ecx
	movl	%ecx, %esi
	imull	-420(%rbp), %esi
	movl	-432(%rbp), %ecx
	addl	%esi, %ecx
	cmpl	%eax, %edx
	cmovg	%eax, %edx
	movslq	%ecx, %rax
	movl	%edx, -416(%rbp,%rax,4)
	addl	$1, -432(%rbp)
.L6:
	movl	-432(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L7
	addl	$1, -436(%rbp)
.L5:
	movl	-436(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L8
	addl	$1, -428(%rbp)
.L4:
	movl	-428(%rbp), %eax
	cmpl	-420(%rbp), %eax
	jl	.L9
	movl	$0, -424(%rbp)
	movl	$0, -436(%rbp)
	jmp	.L10
.L13:
	leaq	-440(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-440(%rbp), %eax
	testl	%eax, %eax
	js	.L15
	movl	-440(%rbp), %eax
	imull	-420(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-416(%rbp,%rax,4), %eax
	addl	%eax, -424(%rbp)
	jmp	.L12
.L15:
	nop
.L12:
	addl	$1, -436(%rbp)
.L10:
	movl	-448(%rbp), %edx
	movl	-444(%rbp), %eax
	imull	%edx, %eax
	cmpl	%eax, -436(%rbp)
	jl	.L13
	movl	-424(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
