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 rep(i,n)for(int(i)=0;(i)<(n);(i)++)
int c[10][10];
int H,W,A,res;
int main()
{
scanf("%d%d",&H,&W);
rep(i,10)rep(j,10)scanf("%d",&c[i][j]);
rep(k,10)rep(i,10)rep(j,10)
if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
rep(i,H)rep(j,W)
{
scanf("%d",&A);
if(A>=0)res+=c[A][1];
}
printf("%d\n",res);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	res
	.align 4
	.type	res, @object
	.size	res, 4
res:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	W(%rip), %rax
	movq	%rax, %rdx
	leaq	H(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L2
.L5:
	movl	$0, -24(%rbp)
	jmp	.L3
.L4:
	movl	-24(%rbp), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -24(%rbp)
.L3:
	cmpl	$9, -24(%rbp)
	jle	.L4
	addl	$1, -28(%rbp)
.L2:
	cmpl	$9, -28(%rbp)
	jle	.L5
	movl	$0, -20(%rbp)
	jmp	.L6
.L12:
	movl	$0, -16(%rbp)
	jmp	.L7
.L11:
	movl	$0, -12(%rbp)
	jmp	.L8
.L10:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	movslq	%eax, %rsi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L9
	movl	-20(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	addl	$1, -12(%rbp)
.L8:
	cmpl	$9, -12(%rbp)
	jle	.L10
	addl	$1, -16(%rbp)
.L7:
	cmpl	$9, -16(%rbp)
	jle	.L11
	addl	$1, -20(%rbp)
.L6:
	cmpl	$9, -20(%rbp)
	jle	.L12
	movl	$0, -8(%rbp)
	jmp	.L13
.L17:
	movl	$0, -4(%rbp)
	jmp	.L14
.L16:
	leaq	A(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	A(%rip), %eax
	testl	%eax, %eax
	js	.L15
	movl	A(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	movq	%rax, %rdx
	leaq	4+c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	res(%rip), %eax
	addl	%edx, %eax
	movl	%eax, res(%rip)
.L15:
	addl	$1, -4(%rbp)
.L14:
	movl	W(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L16
	addl	$1, -8(%rbp)
.L13:
	movl	H(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L17
	movl	res(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	W(%rip), %rdx
	leaq	H(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	c(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	40(%r12), %r13
	leaq	440(%r12), %r14
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC1(%rip), %rbx
	call	__isoc99_scanf@PLT
.L2:
	leaq	-40(%r13), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addq	$4, %rbp
	call	__isoc99_scanf@PLT
	cmpq	%r13, %rbp
	jne	.L3
	leaq	40(%rbp), %r13
	cmpq	%r14, %r13
	jne	.L2
	leaq	400+c(%rip), %r8
	leaq	-400(%r8), %r9
	movq	%r9, %rbp
	movq	%r9, %rcx
.L16:
	movq	%r9, %rsi
	movq	%r12, %rax
	.p2align 4,,10
	.p2align 3
.L15:
	movl	(%rsi), %edx
	movl	(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, (%rax)
	jle	.L5
	movl	%edi, (%rax)
	movl	(%rsi), %edx
.L5:
	movl	4(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 4(%rax)
	jle	.L6
	movl	%edi, 4(%rax)
	movl	(%rsi), %edx
.L6:
	movl	8(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 8(%rax)
	jle	.L7
	movl	%edi, 8(%rax)
	movl	(%rsi), %edx
.L7:
	movl	12(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 12(%rax)
	jle	.L8
	movl	%edi, 12(%rax)
	movl	(%rsi), %edx
.L8:
	movl	16(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 16(%rax)
	jle	.L9
	movl	%edi, 16(%rax)
	movl	(%rsi), %edx
.L9:
	movl	20(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 20(%rax)
	jle	.L10
	movl	%edi, 20(%rax)
	movl	(%rsi), %edx
.L10:
	movl	24(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 24(%rax)
	jle	.L11
	movl	%edi, 24(%rax)
	movl	(%rsi), %edx
.L11:
	movl	28(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 28(%rax)
	jle	.L12
	movl	%edi, 28(%rax)
	movl	(%rsi), %edx
.L12:
	movl	32(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 32(%rax)
	jle	.L13
	movl	%edi, 32(%rax)
	movl	(%rsi), %edx
.L13:
	addl	36(%rcx), %edx
	cmpl	%edx, 36(%rax)
	jle	.L14
	movl	%edx, 36(%rax)
.L14:
	addq	$40, %rax
	addq	$40, %rsi
	cmpq	%r8, %rax
	jne	.L15
	addq	$40, %rcx
	addq	$4, %r9
	cmpq	%rax, %rcx
	jne	.L16
	movl	H(%rip), %eax
	testl	%eax, %eax
	jle	.L17
	movl	W(%rip), %eax
	xorl	%r13d, %r13d
	leaq	A(%rip), %r12
.L18:
	testl	%eax, %eax
	jle	.L17
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	A(%rip), %rax
	testl	%eax, %eax
	js	.L19
	leaq	(%rax,%rax,4), %rax
	addl	$1, %r14d
	movl	4(%rbp,%rax,8), %eax
	addl	%eax, res(%rip)
	movl	W(%rip), %eax
	cmpl	%r14d, %eax
	jg	.L22
	addl	$1, %r13d
	cmpl	%r13d, H(%rip)
	jg	.L18
.L17:
	movl	res(%rip), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	movl	W(%rip), %eax
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jg	.L22
	addl	$1, %r13d
	cmpl	%r13d, H(%rip)
	jg	.L18
	jmp	.L17
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	res
	.bss
	.align 4
	.type	res, @object
	.size	res, 4
res:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	W(%rip), %rdx
	leaq	H(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	leaq	c(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	leaq	40(%r12), %r13
	leaq	440(%r12), %r14
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	.LC1(%rip), %rbx
	call	__isoc99_scanf@PLT
.L2:
	leaq	-40(%r13), %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addq	$4, %rbp
	call	__isoc99_scanf@PLT
	cmpq	%r13, %rbp
	jne	.L3
	leaq	40(%rbp), %r13
	cmpq	%r14, %r13
	jne	.L2
	leaq	400+c(%rip), %r8
	leaq	-400(%r8), %r9
	movq	%r9, %rbp
	movq	%r9, %rcx
.L16:
	movq	%r9, %rsi
	movq	%r12, %rax
	.p2align 4,,10
	.p2align 3
.L15:
	movl	(%rsi), %edx
	movl	(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, (%rax)
	jle	.L5
	movl	%edi, (%rax)
	movl	(%rsi), %edx
.L5:
	movl	4(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 4(%rax)
	jle	.L6
	movl	%edi, 4(%rax)
	movl	(%rsi), %edx
.L6:
	movl	8(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 8(%rax)
	jle	.L7
	movl	%edi, 8(%rax)
	movl	(%rsi), %edx
.L7:
	movl	12(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 12(%rax)
	jle	.L8
	movl	%edi, 12(%rax)
	movl	(%rsi), %edx
.L8:
	movl	16(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 16(%rax)
	jle	.L9
	movl	%edi, 16(%rax)
	movl	(%rsi), %edx
.L9:
	movl	20(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 20(%rax)
	jle	.L10
	movl	%edi, 20(%rax)
	movl	(%rsi), %edx
.L10:
	movl	24(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 24(%rax)
	jle	.L11
	movl	%edi, 24(%rax)
	movl	(%rsi), %edx
.L11:
	movl	28(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 28(%rax)
	jle	.L12
	movl	%edi, 28(%rax)
	movl	(%rsi), %edx
.L12:
	movl	32(%rcx), %edi
	addl	%edx, %edi
	cmpl	%edi, 32(%rax)
	jle	.L13
	movl	%edi, 32(%rax)
	movl	(%rsi), %edx
.L13:
	addl	36(%rcx), %edx
	cmpl	%edx, 36(%rax)
	jle	.L14
	movl	%edx, 36(%rax)
.L14:
	addq	$40, %rax
	addq	$40, %rsi
	cmpq	%r8, %rax
	jne	.L15
	addq	$40, %rcx
	addq	$4, %r9
	cmpq	%rax, %rcx
	jne	.L16
	movl	H(%rip), %eax
	testl	%eax, %eax
	jle	.L17
	movl	W(%rip), %eax
	xorl	%r13d, %r13d
	leaq	A(%rip), %r12
.L18:
	testl	%eax, %eax
	jle	.L17
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	A(%rip), %rax
	testl	%eax, %eax
	js	.L19
	leaq	(%rax,%rax,4), %rax
	addl	$1, %r14d
	movl	4(%rbp,%rax,8), %eax
	addl	%eax, res(%rip)
	movl	W(%rip), %eax
	cmpl	%r14d, %eax
	jg	.L22
	addl	$1, %r13d
	cmpl	%r13d, H(%rip)
	jg	.L18
.L17:
	movl	res(%rip), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	movl	W(%rip), %eax
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jg	.L22
	addl	$1, %r13d
	cmpl	%r13d, H(%rip)
	jg	.L18
	jmp	.L17
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	res
	.bss
	.align 4
	.type	res, @object
	.size	res, 4
res:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.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 rep(i,n)for(int(i)=0;(i)<(n);(i)++)
int c[10][10];
int H,W,A,res;
int main()
{
scanf("%d%d",&H,&W);
rep(i,10)rep(j,10)scanf("%d",&c[i][j]);
rep(k,10)rep(i,10)rep(j,10)
if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
rep(i,H)rep(j,W)
{
scanf("%d",&A);
if(A>=0)res+=c[A][1];
}
printf("%d\n",res);
}

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>
#define rep(i,n)for(int(i)=0;(i)<(n);(i)++)
int c[10][10];
int H,W,A,res;
int main()
{
scanf("%d%d",&H,&W);
rep(i,10)rep(j,10)scanf("%d",&c[i][j]);
rep(k,10)rep(i,10)rep(j,10)
if(c[i][j]>c[i][k]+c[k][j])c[i][j]=c[i][k]+c[k][j];
rep(i,H)rep(j,W)
{
scanf("%d",&A);
if(A>=0)res+=c[A][1];
}
printf("%d\n",res);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	res
	.align 4
	.type	res, @object
	.size	res, 4
res:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	W(%rip), %rax
	movq	%rax, %rdx
	leaq	H(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L2
.L5:
	movl	$0, -24(%rbp)
	jmp	.L3
.L4:
	movl	-24(%rbp), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -24(%rbp)
.L3:
	cmpl	$9, -24(%rbp)
	jle	.L4
	addl	$1, -28(%rbp)
.L2:
	cmpl	$9, -28(%rbp)
	jle	.L5
	movl	$0, -20(%rbp)
	jmp	.L6
.L12:
	movl	$0, -16(%rbp)
	jmp	.L7
.L11:
	movl	$0, -12(%rbp)
	jmp	.L8
.L10:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	movslq	%eax, %rsi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L9
	movl	-20(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	addl	$1, -12(%rbp)
.L8:
	cmpl	$9, -12(%rbp)
	jle	.L10
	addl	$1, -16(%rbp)
.L7:
	cmpl	$9, -16(%rbp)
	jle	.L11
	addl	$1, -20(%rbp)
.L6:
	cmpl	$9, -20(%rbp)
	jle	.L12
	movl	$0, -8(%rbp)
	jmp	.L13
.L17:
	movl	$0, -4(%rbp)
	jmp	.L14
.L16:
	leaq	A(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	A(%rip), %eax
	testl	%eax, %eax
	js	.L15
	movl	A(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	movq	%rax, %rdx
	leaq	4+c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	res(%rip), %eax
	addl	%edx, %eax
	movl	%eax, res(%rip)
.L15:
	addl	$1, -4(%rbp)
.L14:
	movl	W(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L16
	addl	$1, -8(%rbp)
.L13:
	movl	H(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L17
	movl	res(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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
	.globl	c
	.bss
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	res
	.align 4
	.type	res, @object
	.size	res, 4
res:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	W(%rip), %rax
	movq	%rax, %rdx
	leaq	H(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L2
.L5:
	movl	$0, -24(%rbp)
	jmp	.L3
.L4:
	movl	-24(%rbp), %eax
	movslq	%eax, %rcx
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -24(%rbp)
.L3:
	cmpl	$9, -24(%rbp)
	jle	.L4
	addl	$1, -28(%rbp)
.L2:
	cmpl	$9, -28(%rbp)
	jle	.L5
	movl	$0, -20(%rbp)
	jmp	.L6
.L12:
	movl	$0, -16(%rbp)
	jmp	.L7
.L11:
	movl	$0, -12(%rbp)
	jmp	.L8
.L10:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-20(%rbp), %eax
	movslq	%eax, %rsi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	jle	.L9
	movl	-20(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	c(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	addl	$1, -12(%rbp)
.L8:
	cmpl	$9, -12(%rbp)
	jle	.L10
	addl	$1, -16(%rbp)
.L7:
	cmpl	$9, -16(%rbp)
	jle	.L11
	addl	$1, -20(%rbp)
.L6:
	cmpl	$9, -20(%rbp)
	jle	.L12
	movl	$0, -8(%rbp)
	jmp	.L13
.L17:
	movl	$0, -4(%rbp)
	jmp	.L14
.L16:
	leaq	A(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	A(%rip), %eax
	testl	%eax, %eax
	js	.L15
	movl	A(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	movq	%rax, %rdx
	leaq	4+c(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	res(%rip), %eax
	addl	%edx, %eax
	movl	%eax, res(%rip)
.L15:
	addl	$1, -4(%rbp)
.L14:
	movl	W(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L16
	addl	$1, -8(%rbp)
.L13:
	movl	H(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L17
	movl	res(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	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:
