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

```c
#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}*p,x,y,g,d,v,f,o,l,r,f0;main(){for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	W
	.bss
	.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	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	DP
	.align 32
	.type	DP, @object
	.size	DP, 2040000
DP:
	.zero	2040000
	.text
	.globl	CalcO
	.type	CalcO, @function
CalcO:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	testl	%eax, %eax
	jle	.L3
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	addl	%eax, -4(%rbp)
.L3:
	cmpl	$0, -4(%rbp)
	jle	.L4
	movl	m(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	jmp	.L6
.L4:
	movl	$0, %eax
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	CalcO, .-CalcO
	.globl	CalcF
	.type	CalcF, @function
CalcF:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	testl	%eax, %eax
	jns	.L8
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	jmp	.L10
.L8:
	movl	-4(%rbp), %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	CalcF, .-CalcF
	.globl	Walk
	.type	Walk, @function
Walk:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	%r8d, -36(%rbp)
	movl	%r9d, -40(%rbp)
	movl	-32(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%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
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%rsi,%rax), %rcx
	movl	-36(%rbp), %eax
	cltq
	imulq	$10000, %rax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L13
	movq	-8(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
.L13:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Walk, .-Walk
	.globl	Dig
	.type	Dig, @function
Dig:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -12(%rbp)
	movl	%esi, -16(%rbp)
	movl	%edx, -20(%rbp)
	movl	%ecx, -24(%rbp)
	movl	%r8d, -28(%rbp)
	movl	%r9d, -32(%rbp)
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %ecx
	movl	-32(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	CalcF
	movl	%eax, %ebx
	movl	-28(%rbp), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	movl	%ecx, %edi
	movl	$0, %eax
	call	CalcO
	movl	%eax, %edi
	movl	-24(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-16(%rbp), %esi
	movl	-12(%rbp), %eax
	movl	%ebx, %r9d
	movl	%edi, %r8d
	movl	%eax, %edi
	movl	$0, %eax
	call	Walk
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Dig, .-Dig
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	g
	.align 4
	.type	g, @object
	.size	g, 4
g:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.zero	4
	.globl	o
	.align 4
	.type	o, @object
	.size	o, 4
o:
	.zero	4
	.globl	l
	.align 4
	.type	l, @object
	.size	l, 4
l:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	f0
	.align 4
	.type	f0, @object
	.size	f0, 4
f0:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"NA\n"
.LC3:
	.string	"%d%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	jmp	.L16
.L54:
	movl	$0, y(%rip)
	jmp	.L17
.L20:
	movl	$0, x(%rip)
	jmp	.L18
.L19:
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rcx
	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	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L18:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L17:
	movl	y(%rip), %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jl	.L20
	movl	f0(%rip), %eax
	addl	$1, %eax
	movl	%eax, f0(%rip)
	movl	o(%rip), %eax
	cmpl	$1, %eax
	jle	.L21
	movl	$0, x(%rip)
	jmp	.L22
.L23:
	movl	x(%rip), %r12d
	movl	f0(%rip), %ebx
	movl	x(%rip), %eax
	movl	o(%rip), %edx
	leal	-1(%rdx), %ecx
	movl	$0, %edx
	movl	%eax, %esi
	movl	%ecx, %edi
	movl	$0, %eax
	call	CalcO
	movl	%eax, %r13d
	movl	x(%rip), %r15d
	movl	x(%rip), %r14d
	movl	x(%rip), %eax
	movl	%eax, -52(%rbp)
	movl	$0, %edx
	movl	%r12d, %esi
	movl	%ebx, %edi
	movl	$0, %eax
	call	CalcF
	movl	%eax, %edx
	movslq	-52(%rbp), %r8
	movslq	%r15d, %rsi
	movslq	%r14d, %rcx
	movslq	%r13d, %rdi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	imulq	$10000, %rdi, %rsi
	addq	%rax, %rsi
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	addq	%r8, %rax
	leaq	0(,%rax,4), %rcx
	leaq	DP(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L22:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L23
.L21:
	movl	$0, y(%rip)
	jmp	.L24
.L45:
	movl	$0, g(%rip)
	jmp	.L25
.L44:
	movl	m(%rip), %eax
	movl	%eax, o(%rip)
	jmp	.L26
.L43:
	movl	$0, d(%rip)
	jmp	.L27
.L42:
	movl	$0, l(%rip)
	jmp	.L28
.L41:
	movl	$0, v(%rip)
	jmp	.L29
.L40:
	movl	l(%rip), %edx
	movl	g(%rip), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
	movl	o(%rip), %edi
	movl	y(%rip), %esi
	movl	d(%rip), %eax
	testl	%eax, %eax
	je	.L30
	movl	l(%rip), %edx
	movl	v(%rip), %eax
	addl	%edx, %eax
	jmp	.L31
.L30:
	movl	r(%rip), %eax
	movl	v(%rip), %edx
	subl	%edx, %eax
.L31:
	movl	%eax, x(%rip)
	movl	x(%rip), %eax
	movl	l(%rip), %ecx
	movl	r(%rip), %edx
	movslq	%edx, %r8
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%r8,%rax), %rcx
	movslq	%edi, %rax
	imulq	$10000, %rax, %rdx
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, f(%rip)
	movl	f(%rip), %eax
	testl	%eax, %eax
	je	.L32
	movq	p(%rip), %rax
	movl	$0, (%rax)
	movl	f(%rip), %r8d
	movl	o(%rip), %edi
	movl	x(%rip), %ecx
	movl	x(%rip), %edx
	movl	y(%rip), %eax
	leal	1(%rax), %esi
	movl	x(%rip), %eax
	movl	%r8d, %r9d
	movl	%edi, %r8d
	movl	%eax, %edi
	movl	$0, %eax
	call	Dig
	movl	x(%rip), %eax
	testl	%eax, %eax
	je	.L36
	movl	x(%rip), %edx
	movl	l(%rip), %eax
	cmpl	%eax, %edx
	jle	.L34
	movl	f(%rip), %r8d
	movl	o(%rip), %eax
	leal	-1(%rax), %r10d
	movl	r(%rip), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	-1(%rsi), %edi
	movl	%r8d, %r9d
	movl	%r10d, %r8d
	movl	%eax, %esi
	movl	$0, %eax
	call	Walk
	jmp	.L36
.L34:
	movl	f(%rip), %r9d
	movl	o(%rip), %r8d
	movl	r(%rip), %edx
	movl	x(%rip), %eax
	leal	-1(%rax), %esi
	movl	y(%rip), %eax
	movl	x(%rip), %ecx
	leal	-1(%rcx), %edi
	movl	%edx, %ecx
	movl	%esi, %edx
	movl	%eax, %esi
	movl	$0, %eax
	call	Dig
.L36:
	movl	W(%rip), %eax
	leal	-1(%rax), %edx
	movl	x(%rip), %eax
	cmpl	%eax, %edx
	jle	.L32
	movl	x(%rip), %edx
	movl	r(%rip), %eax
	cmpl	%eax, %edx
	jge	.L38
	movl	f(%rip), %r8d
	movl	o(%rip), %eax
	leal	-1(%rax), %r10d
	movl	r(%rip), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	1(%rsi), %edi
	movl	%r8d, %r9d
	movl	%r10d, %r8d
	movl	%eax, %esi
	movl	$0, %eax
	call	Walk
	jmp	.L32
.L38:
	movl	f(%rip), %r9d
	movl	o(%rip), %r8d
	movl	x(%rip), %eax
	leal	1(%rax), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	1(%rsi), %edi
	movl	%eax, %esi
	movl	$0, %eax
	call	Dig
.L32:
	movl	v(%rip), %eax
	addl	$1, %eax
	movl	%eax, v(%rip)
.L29:
	movl	g(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jge	.L40
	movl	l(%rip), %eax
	addl	$1, %eax
	movl	%eax, l(%rip)
.L28:
	movl	W(%rip), %eax
	movl	g(%rip), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	l(%rip), %eax
	cmpl	%eax, %edx
	jg	.L41
	movl	d(%rip), %eax
	addl	$1, %eax
	movl	%eax, d(%rip)
.L27:
	movl	d(%rip), %eax
	cmpl	$1, %eax
	jle	.L42
	movl	o(%rip), %eax
	subl	$1, %eax
	movl	%eax, o(%rip)
.L26:
	movl	o(%rip), %eax
	cmpl	$1, %eax
	jg	.L43
	movl	g(%rip), %eax
	addl	$1, %eax
	movl	%eax, g(%rip)
.L25:
	movl	g(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L44
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L24:
	movl	H(%rip), %eax
	leal	-1(%rax), %edx
	movl	y(%rip), %eax
	cmpl	%eax, %edx
	jg	.L45
	movl	$0, f(%rip)
	movl	$0, x(%rip)
	jmp	.L46
.L51:
	movl	$0, o(%rip)
	jmp	.L47
.L50:
	movl	o(%rip), %eax
	leal	1(%rax), %edi
	movl	H(%rip), %eax
	leal	-1(%rax), %esi
	movl	x(%rip), %eax
	movl	x(%rip), %ecx
	movl	x(%rip), %edx
	movslq	%edx, %r8
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%r8,%rax), %rcx
	movslq	%edi, %rax
	imulq	$10000, %rax, %rdx
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	(%rax), %edx
	movl	f(%rip), %eax
	cmpl	%eax, %edx
	jle	.L49
	movq	p(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, f(%rip)
.L49:
	movq	p(%rip), %rax
	movl	$0, (%rax)
	movl	o(%rip), %eax
	addl	$1, %eax
	movl	%eax, o(%rip)
.L47:
	movl	o(%rip), %edx
	movl	m(%rip), %eax
	cmpl	%eax, %edx
	jl	.L50
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L46:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L51
	movl	f0(%rip), %eax
	movl	f(%rip), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	f(%rip), %eax
	testl	%eax, %eax
	je	.L52
	leaq	.LC1(%rip), %rax
	jmp	.L53
.L52:
	leaq	.LC2(%rip), %rax
.L53:
	movl	%edx, %esi
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	movl	$80000, %edx
	movl	%eax, %esi
	leaq	DP(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
.L16:
	leaq	o(%rip), %r9
	leaq	m(%rip), %r8
	leaq	f0(%rip), %rax
	movq	%rax, %rcx
	leaq	H(%rip), %rax
	movq	%rax, %rdx
	leaq	W(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	W(%rip), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L54
	movl	$0, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.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
	.p2align 4
	.globl	CalcO
	.type	CalcO, @function
CalcO:
.LFB0:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	leaq	(%rsi,%rsi,4), %rax
	leaq	(%rdx,%rax,2), %rdx
	leaq	c(%rip), %rax
	movl	(%rax,%rdx,4), %eax
	leal	(%rdi,%rax), %edx
	testl	%eax, %eax
	cmovg	%edx, %edi
	xorl	%eax, %eax
	testl	%edi, %edi
	jle	.L1
	movl	m(%rip), %eax
	cmpl	%eax, %edi
	cmovle	%edi, %eax
.L1:
	ret
	.cfi_endproc
.LFE0:
	.size	CalcO, .-CalcO
	.p2align 4
	.globl	CalcF
	.type	CalcF, @function
CalcF:
.LFB1:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movl	%edi, %eax
	leaq	(%rsi,%rsi,4), %rcx
	leaq	(%rdx,%rcx,2), %rcx
	leaq	c(%rip), %rdx
	movl	(%rdx,%rcx,4), %edx
	leal	(%rdi,%rdx), %ecx
	testl	%edx, %edx
	cmovs	%ecx, %eax
	ret
	.cfi_endproc
.LFE1:
	.size	CalcF, .-CalcF
	.p2align 4
	.globl	Walk
	.type	Walk, @function
Walk:
.LFB2:
	.cfi_startproc
	endbr64
	movslq	%r8d, %r8
	movslq	%edi, %rdi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	imulq	$10000, %r8, %r8
	leaq	(%rdi,%rdi,4), %rax
	movslq	%ecx, %rcx
	imulq	$1000, %rsi, %rsi
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rdx,4), %rdx
	leaq	DP(%rip), %r10
	leaq	(%r8,%rax,4), %rax
	addq	%rsi, %rax
	leaq	(%rax,%rdx,2), %rax
	addq	%rcx, %rax
	cmpl	%r9d, (%r10,%rax,4)
	jge	.L9
	movl	%r9d, (%r10,%rax,4)
.L9:
	ret
	.cfi_endproc
.LFE2:
	.size	Walk, .-Walk
	.p2align 4
	.globl	Dig
	.type	Dig, @function
Dig:
.LFB3:
	.cfi_startproc
	endbr64
	movl	%edi, %r10d
	movslq	%esi, %rdi
	movl	%edx, %esi
	subl	$1, %r8d
	movslq	%r10d, %rdx
	leaq	(%rdx,%rdx,4), %rax
	leaq	(%rdi,%rax,2), %r10
	leaq	c(%rip), %rax
	movl	(%rax,%r10,4), %eax
	testl	%eax, %eax
	js	.L16
	addl	%eax, %r8d
.L12:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	jle	.L13
	movl	m(%rip), %eax
	cmpl	%eax, %r8d
	cmovle	%r8d, %eax
.L13:
	cltq
	leaq	(%rdx,%rdx,4), %rdx
	movslq	%ecx, %r10
	imulq	$10000, %rax, %rax
	leaq	(%rdx,%rdx,4), %rdx
	movslq	%esi, %rcx
	imulq	$1000, %rdi, %rdi
	leaq	DP(%rip), %r8
	leaq	(%rax,%rdx,4), %rax
	leaq	(%rcx,%rcx,4), %rdx
	addq	%rdi, %rax
	leaq	(%rax,%rdx,2), %rax
	addq	%r10, %rax
	cmpl	%r9d, (%r8,%rax,4)
	jge	.L14
	movl	%r9d, (%r8,%rax,4)
.L14:
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	addl	%eax, %r9d
	jmp	.L12
	.cfi_endproc
.LFE3:
	.size	Dig, .-Dig
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"NA\n"
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d%d%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%r13d, %r10d
	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
	leaq	DP(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rbx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
.L18:
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	leaq	o(%rip), %r9
	movl	%r10d, (%rsp)
	leaq	m(%rip), %r8
	leaq	f0(%rip), %rcx
	leaq	H(%rip), %rdx
	leaq	W(%rip), %rsi
	call	scanf@PLT
	movl	W(%rip), %edi
	movl	(%rsp), %r10d
	imull	%edi, %eax
	movl	%edi, 116(%rsp)
	testl	%eax, %eax
	je	.L155
	movl	$0, y(%rip)
	movl	H(%rip), %esi
	testl	%esi, %esi
	jle	.L19
	movl	%edi, %ecx
	xorl	%eax, %eax
	leaq	c(%rip), %rbx
	movl	%r10d, %r14d
	leaq	.LC2(%rip), %r13
.L22:
	movl	$0, x(%rip)
	testl	%ecx, %ecx
	jle	.L20
	xorl	%edx, %edx
	jmp	.L23
.L21:
	movl	y(%rip), %eax
.L23:
	movslq	%edx, %rdx
	cltq
	movq	%r13, %rdi
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rax,%rdx,2), %rax
	leaq	(%rbx,%rax,4), %rsi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	movl	W(%rip), %ecx
	leal	1(%rax), %edx
	movl	%edx, x(%rip)
	cmpl	%ecx, %edx
	jl	.L21
	movl	y(%rip), %eax
	movl	H(%rip), %esi
	addl	$1, %eax
	movl	%eax, y(%rip)
	cmpl	%esi, %eax
	jl	.L22
	movl	%ecx, 116(%rsp)
	movl	%r14d, %r10d
.L19:
	movl	f0(%rip), %eax
	movl	o(%rip), %edx
	leal	1(%rax), %ebx
	movl	%ebx, 112(%rsp)
	movl	%ebx, f0(%rip)
	cmpl	$1, %edx
	jle	.L27
	movl	116(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L27
	movl	m(%rip), %eax
	subl	$1, %edx
	movl	c(%rip), %edi
	cmpl	%eax, %edx
	movl	%eax, %ecx
	cmovle	%edx, %ecx
	testl	%edi, %edi
	jle	.L156
	addl	%edx, %edi
	movl	%ebx, %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L31:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$1, 116(%rsp)
	movl	%r8d, (%r12,%rdi)
	je	.L27
	movl	40+c(%rip), %edi
	testl	%edi, %edi
	jle	.L157
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L34:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$2, 116(%rsp)
	movl	%r8d, 444(%r12,%rdi)
	je	.L27
	movl	80+c(%rip), %edi
	testl	%edi, %edi
	jle	.L158
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L36:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$3, 116(%rsp)
	movl	%r8d, 888(%r12,%rdi)
	je	.L27
	movl	120+c(%rip), %edi
	testl	%edi, %edi
	jle	.L159
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L38:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$4, 116(%rsp)
	movl	%r8d, 1332(%r12,%rdi)
	je	.L27
	movl	160+c(%rip), %edi
	testl	%edi, %edi
	jle	.L160
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L40:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$5, 116(%rsp)
	movl	%r8d, 1776(%r12,%rdi)
	je	.L27
	movl	200+c(%rip), %edi
	testl	%edi, %edi
	jle	.L161
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L42:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$6, 116(%rsp)
	movl	%r8d, 2220(%r12,%rdi)
	je	.L27
	movl	240+c(%rip), %edi
	testl	%edi, %edi
	jle	.L162
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L44:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$7, 116(%rsp)
	movl	%r8d, 2664(%r12,%rdi)
	je	.L27
	movl	280+c(%rip), %edi
	testl	%edi, %edi
	jle	.L163
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L46:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$8, 116(%rsp)
	movl	%r8d, 3108(%r12,%rdi)
	je	.L27
	movl	320+c(%rip), %edi
	testl	%edi, %edi
	jle	.L164
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L48:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$9, 116(%rsp)
	movl	%r8d, 3552(%r12,%rdi)
	je	.L27
	movl	360+c(%rip), %r8d
	movl	112(%rsp), %ebx
	leal	(%rbx,%r8), %edi
	testl	%r8d, %r8d
	jle	.L50
	addl	%r8d, %edx
	movl	%ebx, %edi
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
.L50:
	movslq	%ecx, %rax
	imulq	$40000, %rax, %rax
	movl	%edi, 3996(%r12,%rax)
	jmp	.L27
.L155:
	addq	$168, %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
.L20:
	.cfi_restore_state
	movl	%ecx, 116(%rsp)
	movl	%r14d, %r10d
.L154:
	addl	$1, %eax
	cmpl	%esi, %eax
	jl	.L154
	movl	f0(%rip), %eax
	addl	$1, %eax
	movl	%eax, 112(%rsp)
	movl	%eax, f0(%rip)
.L27:
	movl	$0, y(%rip)
	leal	-1(%rsi), %eax
	movl	%eax, 132(%rsp)
	testl	%eax, %eax
	jle	.L52
	movslq	m(%rip), %rax
	movslq	116(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	movl	$0, 128(%rsp)
	xorl	%edx, %edx
	movl	%eax, 12(%rsp)
	imulq	$10000, %rax, %rax
	movq	%rdi, 152(%rsp)
	movq	%rax, 144(%rsp)
	movq	%rdi, %rax
	subl	$1, %eax
	movl	%eax, 64(%rsp)
.L75:
	movl	128(%rsp), %edi
	movl	116(%rsp), %r8d
	movslq	%edi, %rax
	addl	$1, %edi
	movl	%edi, 128(%rsp)
	testl	%r8d, %r8d
	jle	.L92
	movq	%rax, 104(%rsp)
	imulq	$1000, %rax, %r14
	movslq	%edi, %rax
	movq	%rax, 24(%rsp)
	imulq	$4000, %rax, %rax
	movq	$0, (%rsp)
	movq	%rax, 32(%rsp)
.L74:
	movl	12(%rsp), %eax
	cmpl	$1, %eax
	jle	.L93
	movq	(%rsp), %rdx
	movl	116(%rsp), %ecx
	movl	%eax, 8(%rsp)
	subl	%edx, %ecx
	leal	1(%rdx), %eax
	movl	%edx, 96(%rsp)
	movl	%ecx, 68(%rsp)
	movq	144(%rsp), %rcx
	movl	%eax, 100(%rsp)
	movq	%rcx, 80(%rsp)
.L73:
	movl	8(%rsp), %edi
	xorl	%r13d, %r13d
	movq	%r14, %r11
	movl	%r13d, %r15d
	movslq	%edi, %rax
	subl	$1, %edi
	movq	%rax, 120(%rsp)
	movslq	%edi, %rax
	imulq	$10000, %rax, %rax
	movl	%edi, 8(%rsp)
	movq	%rax, 56(%rsp)
	.p2align 4,,10
	.p2align 3
.L72:
	imulq	$10000, 120(%rsp), %rax
	xorl	%r13d, %r13d
	movq	%rax, 72(%rsp)
	.p2align 4,,10
	.p2align 3
.L71:
	leaq	0(%r13,%r13,4), %rax
	movq	%r13, 16(%rsp)
	movl	%r13d, %r10d
	xorl	%edx, %edx
	addq	%rax, %rax
	movq	72(%rsp), %r14
	movq	%rax, 48(%rsp)
	movl	96(%rsp), %eax
	leal	(%rax,%r13), %r8d
	movq	(%rsp), %rax
	movl	%r8d, 92(%rsp)
	movslq	%r8d, %r9
	addq	%r13, %rax
	movq	%rax, 40(%rsp)
	movslq	%r13d, %rax
	leaq	(%rax,%rax,4), %rdi
	addq	%rdi, %rdi
	jmp	.L70
	.p2align 4,,10
	.p2align 3
.L58:
	addl	$1, %edx
	cmpl	(%rsp), %edx
	jg	.L165
.L70:
	movl	%r8d, %eax
	leal	(%rdx,%r10), %ecx
	subl	%edx, %eax
	testl	%r15d, %r15d
	cmovne	%ecx, %eax
	movslq	%eax, %rcx
	leaq	(%rcx,%rcx,4), %rbp
	leaq	0(%rbp,%rbp,4), %rsi
	leaq	(%r14,%rsi,4), %rbx
	addq	%r11, %rbx
	addq	%rdi, %rbx
	addq	%r9, %rbx
	movl	(%r12,%rbx,4), %esi
	testl	%esi, %esi
	je	.L58
	movl	$0, (%r12,%rbx,4)
	movq	24(%rsp), %rbx
	leaq	(%rbx,%rbp,2), %rbx
	leaq	c(%rip), %rbp
	movl	0(%rbp,%rbx,4), %r13d
	movl	8(%rsp), %ebx
	movl	%esi, %ebp
	addl	%r13d, %ebx
	testl	%r13d, %r13d
	jns	.L60
	movl	8(%rsp), %ebx
	leal	0(%r13,%rsi), %ebp
.L60:
	movl	12(%rsp), %r13d
	cmpl	%ebx, %r13d
	cmovle	%r13d, %ebx
	imulq	$444, %rcx, %r13
	addq	32(%rsp), %r13
	movslq	%ebx, %rbx
	imulq	$40000, %rbx, %rbx
	addq	%rbx, %r13
	addq	%r12, %r13
	cmpl	%ebp, 0(%r13)
	jge	.L61
	movl	%ebp, 0(%r13)
.L61:
	testl	%eax, %eax
	je	.L62
	leal	-1(%rax), %ebx
	movslq	%ebx, %rbx
	cmpl	16(%rsp), %eax
	jle	.L63
	movq	56(%rsp), %rbp
	leaq	(%rbx,%rbx,4), %rbx
	leaq	(%rbx,%rbx,4), %rbx
	leaq	0(%rbp,%rbx,4), %rbx
	addq	%r11, %rbx
	addq	%rdi, %rbx
	addq	%r9, %rbx
	cmpl	%esi, (%r12,%rbx,4)
	jge	.L62
	movl	%esi, (%r12,%rbx,4)
	.p2align 4,,10
	.p2align 3
.L62:
	cmpl	%eax, 64(%rsp)
	jle	.L58
	leal	1(%rax), %ebx
	cmpl	%eax, %r8d
	movslq	%ebx, %rax
	jle	.L67
	movq	56(%rsp), %rbx
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rbx,%rax,4), %rax
	addq	%r11, %rax
	addq	%rdi, %rax
	addq	%r9, %rax
	cmpl	%esi, (%r12,%rax,4)
	jge	.L58
	movl	%esi, (%r12,%rax,4)
	addl	$1, %edx
	cmpl	(%rsp), %edx
	jle	.L70
	.p2align 4,,10
	.p2align 3
.L165:
	leaq	(%rcx,%rcx,4), %rdx
	movq	16(%rsp), %r13
	movq	48(%rsp), %rax
	leaq	(%rdx,%rdx,4), %rdx
	addq	40(%rsp), %rax
	addq	80(%rsp), %rax
	leaq	(%rax,%rdx,4), %rax
	movl	100(%rsp), %r10d
	addq	$1, %r13
	leaq	(%r12,%rax,4), %rbp
	cmpl	%r13d, 68(%rsp)
	jg	.L71
	movl	68(%rsp), %edi
	movl	$1, %eax
	testl	%edi, %edi
	cmovg	%edi, %eax
	cmpl	$1, %r15d
	je	.L166
	movl	$1, %r15d
	jmp	.L72
	.p2align 4,,10
	.p2align 3
.L63:
	movq	104(%rsp), %r13
	leaq	(%rbx,%rbx,4), %rbp
	movl	%esi, 88(%rsp)
	leaq	0(%r13,%rbp,2), %rbp
	leaq	c(%rip), %r13
	movl	0(%r13,%rbp,4), %r13d
	movl	8(%rsp), %ebp
	addl	%r13d, %ebp
	testl	%r13d, %r13d
	jns	.L65
	addl	%esi, %r13d
	movl	8(%rsp), %ebp
	movl	%r13d, 88(%rsp)
.L65:
	movl	12(%rsp), %r13d
	cmpl	%ebp, %r13d
	cmovle	%r13d, %ebp
	imulq	$110, %rbx, %rbx
	movslq	%ebp, %rbp
	imulq	$10000, %rbp, %rbp
	addq	%r11, %rbp
	addq	%rbx, %rbp
	movl	88(%rsp), %ebx
	addq	%r9, %rbp
	cmpl	(%r12,%rbp,4), %ebx
	jle	.L62
	movl	%ebx, (%r12,%rbp,4)
	jmp	.L62
	.p2align 4,,10
	.p2align 3
.L67:
	movq	104(%rsp), %rbp
	leaq	(%rax,%rax,4), %rbx
	movl	8(%rsp), %r13d
	leaq	0(%rbp,%rbx,2), %rbx
	leaq	c(%rip), %rbp
	movl	0(%rbp,%rbx,4), %ebp
	leal	0(%rbp,%r13), %ebx
	testl	%ebp, %ebp
	jns	.L69
	addl	%ebp, %esi
	movl	%r13d, %ebx
.L69:
	movl	12(%rsp), %ebp
	cmpl	%ebx, %ebp
	cmovle	%ebp, %ebx
	leaq	(%rax,%rax,4), %rbp
	leaq	0(%rbp,%rbp,4), %rbp
	movslq	%ebx, %rbx
	imulq	$10000, %rbx, %rbx
	leaq	(%rbx,%rbp,4), %rbx
	addq	%r11, %rbx
	addq	%rdi, %rbx
	addq	%rax, %rbx
	cmpl	%esi, (%r12,%rbx,4)
	jge	.L58
	movl	%esi, (%r12,%rbx,4)
	jmp	.L58
.L166:
	subq	$10000, 80(%rsp)
	movl	%eax, %r15d
	movq	%r11, %r14
	cmpl	$1, 8(%rsp)
	jne	.L73
	movl	$1, %esi
	movl	$1, %edx
.L54:
	addq	$1, (%rsp)
	movq	(%rsp), %rax
	cmpq	152(%rsp), %rax
	jne	.L74
	movl	116(%rsp), %eax
	movl	$1, %ecx
	jmp	.L53
.L162:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L44
.L161:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L42
.L160:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L40
.L159:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L38
.L158:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L36
.L157:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L34
.L156:
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L31
.L92:
	xorl	%eax, %eax
.L53:
	addq	$1000, 144(%rsp)
	movl	128(%rsp), %ebx
	cmpl	%ebx, 132(%rsp)
	jne	.L75
	movl	%eax, g(%rip)
	movl	132(%rsp), %eax
	movl	%eax, y(%rip)
	testb	%sil, %sil
	je	.L76
	movl	$2, d(%rip)
	movl	%r15d, l(%rip)
	movl	%r10d, v(%rip)
.L76:
	testb	%dl, %dl
	je	.L77
	movl	92(%rsp), %eax
	movl	%eax, r(%rip)
	testb	%cl, %cl
	je	.L78
.L89:
	movl	8(%rsp), %eax
	movl	%eax, o(%rip)
	testb	%dl, %dl
	je	.L52
.L78:
	movq	%rbp, p(%rip)
.L52:
	movl	116(%rsp), %ebx
	leaq	.LC1(%rip), %rdi
	movl	$0, f(%rip)
	movl	$0, x(%rip)
	testl	%ebx, %ebx
	jle	.L80
	movslq	m(%rip), %rdi
	leaq	444+DP(%rip), %rdx
	movl	$40000, %r9d
	xorl	%r8d, %r8d
	movslq	132(%rsp), %rsi
	movq	%rdi, %rcx
	imulq	$40000, %rdi, %rdi
	imulq	$4000, %rsi, %rsi
	addq	%rdi, %rdx
	subq	%rdi, %r9
	addq	%rsi, %rdx
	leaq	(%rsi,%rdi), %rax
	leal	-1(%rbx), %esi
	movq	%r9, %r11
	imulq	$444, %rsi, %rsi
	addq	%r12, %rax
	leal	1(%rcx), %ebx
	leaq	(%rdx,%rsi), %r13
	xorl	%edx, %edx
	xorl	%esi, %esi
.L84:
	testl	%ecx, %ecx
	jle	.L96
	leaq	(%r11,%rax), %rsi
	movl	$1, %edi
.L83:
	movl	(%rsi), %r9d
	cmpl	%edx, %r9d
	jle	.L82
	movl	%r9d, %edx
	movl	$1, %r8d
.L82:
	addq	$1, %rdi
	movl	$0, (%rsi)
	addq	$40000, %rsi
	cmpq	%rbx, %rdi
	jne	.L83
	movq	%rax, 136(%rsp)
	addq	$444, %rax
	movl	%ecx, %edi
	movl	$1, %esi
	cmpq	%rax, %r13
	jne	.L84
.L167:
	movl	116(%rsp), %eax
	movl	%edi, o(%rip)
	movl	%eax, x(%rip)
	testb	%r8b, %r8b
	je	.L85
	subl	%edx, 112(%rsp)
	movl	%edx, f(%rip)
	testb	%sil, %sil
	je	.L86
	movq	136(%rsp), %rax
	movq	%rax, p(%rip)
.L86:
	testl	%edx, %edx
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %rax
	cmove	%rax, %rdi
.L80:
	movl	112(%rsp), %esi
	xorl	%eax, %eax
	movl	%r10d, (%rsp)
	call	printf@PLT
	xorl	%esi, %esi
	movl	$80000, %edx
	movq	%r12, %rdi
	testl	%eax, %eax
	sete	%sil
	call	memset@PLT
	movl	(%rsp), %r10d
	jmp	.L18
.L96:
	addq	$444, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r13
	jne	.L84
	jmp	.L167
.L85:
	leaq	.LC1(%rip), %rdi
	testb	%sil, %sil
	je	.L80
	movq	136(%rsp), %rax
	movq	%rax, p(%rip)
	jmp	.L80
.L93:
	movl	%eax, 8(%rsp)
	jmp	.L54
.L77:
	testb	%cl, %cl
	jne	.L89
	jmp	.L52
.L164:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L48
.L163:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L46
	.cfi_endproc
.LFE4:
	.size	main, .-main
	.globl	f0
	.bss
	.align 4
	.type	f0, @object
	.size	f0, 4
f0:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	l
	.align 4
	.type	l, @object
	.size	l, 4
l:
	.zero	4
	.globl	o
	.align 4
	.type	o, @object
	.size	o, 4
o:
	.zero	4
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	g
	.align 4
	.type	g, @object
	.size	g, 4
g:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	p
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	DP
	.align 32
	.type	DP, @object
	.size	DP, 2040000
DP:
	.zero	2040000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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
	.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
	.p2align 4
	.globl	CalcO
	.type	CalcO, @function
CalcO:
.LFB0:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	leaq	(%rsi,%rsi,4), %rax
	leaq	(%rdx,%rax,2), %rdx
	leaq	c(%rip), %rax
	movl	(%rax,%rdx,4), %eax
	leal	(%rdi,%rax), %edx
	testl	%eax, %eax
	cmovg	%edx, %edi
	xorl	%eax, %eax
	testl	%edi, %edi
	jle	.L1
	movl	m(%rip), %eax
	cmpl	%eax, %edi
	cmovle	%edi, %eax
.L1:
	ret
	.cfi_endproc
.LFE0:
	.size	CalcO, .-CalcO
	.p2align 4
	.globl	CalcF
	.type	CalcF, @function
CalcF:
.LFB1:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	movl	%edi, %eax
	leaq	(%rsi,%rsi,4), %rcx
	leaq	(%rdx,%rcx,2), %rcx
	leaq	c(%rip), %rdx
	movl	(%rdx,%rcx,4), %edx
	leal	(%rdi,%rdx), %ecx
	testl	%edx, %edx
	cmovs	%ecx, %eax
	ret
	.cfi_endproc
.LFE1:
	.size	CalcF, .-CalcF
	.p2align 4
	.globl	Walk
	.type	Walk, @function
Walk:
.LFB2:
	.cfi_startproc
	endbr64
	movslq	%r8d, %r8
	movslq	%edi, %rdi
	movslq	%esi, %rsi
	movslq	%edx, %rdx
	imulq	$10000, %r8, %r8
	leaq	(%rdi,%rdi,4), %rax
	movslq	%ecx, %rcx
	imulq	$1000, %rsi, %rsi
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rdx,4), %rdx
	leaq	DP(%rip), %r10
	leaq	(%r8,%rax,4), %rax
	addq	%rsi, %rax
	leaq	(%rax,%rdx,2), %rax
	addq	%rcx, %rax
	cmpl	%r9d, (%r10,%rax,4)
	jge	.L9
	movl	%r9d, (%r10,%rax,4)
.L9:
	ret
	.cfi_endproc
.LFE2:
	.size	Walk, .-Walk
	.p2align 4
	.globl	Dig
	.type	Dig, @function
Dig:
.LFB3:
	.cfi_startproc
	endbr64
	movl	%edi, %r10d
	movslq	%esi, %rdi
	movl	%edx, %esi
	subl	$1, %r8d
	movslq	%r10d, %rdx
	leaq	(%rdx,%rdx,4), %rax
	leaq	(%rdi,%rax,2), %r10
	leaq	c(%rip), %rax
	movl	(%rax,%r10,4), %eax
	testl	%eax, %eax
	js	.L16
	addl	%eax, %r8d
.L12:
	xorl	%eax, %eax
	testl	%r8d, %r8d
	jle	.L13
	movl	m(%rip), %eax
	cmpl	%eax, %r8d
	cmovle	%r8d, %eax
.L13:
	cltq
	leaq	(%rdx,%rdx,4), %rdx
	movslq	%ecx, %r10
	imulq	$10000, %rax, %rax
	leaq	(%rdx,%rdx,4), %rdx
	movslq	%esi, %rcx
	imulq	$1000, %rdi, %rdi
	leaq	DP(%rip), %r8
	leaq	(%rax,%rdx,4), %rax
	leaq	(%rcx,%rcx,4), %rdx
	addq	%rdi, %rax
	leaq	(%rax,%rdx,2), %rax
	addq	%r10, %rax
	cmpl	%r9d, (%r8,%rax,4)
	jge	.L14
	movl	%r9d, (%r8,%rax,4)
.L14:
	ret
	.p2align 4,,10
	.p2align 3
.L16:
	addl	%eax, %r9d
	jmp	.L12
	.cfi_endproc
.LFE3:
	.size	Dig, .-Dig
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
.LC1:
	.string	"NA\n"
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d%d%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%r13d, %r10d
	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
	leaq	DP(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rbx, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
.L18:
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	leaq	o(%rip), %r9
	movl	%r10d, (%rsp)
	leaq	m(%rip), %r8
	leaq	f0(%rip), %rcx
	leaq	H(%rip), %rdx
	leaq	W(%rip), %rsi
	call	scanf@PLT
	movl	W(%rip), %edi
	movl	(%rsp), %r10d
	imull	%edi, %eax
	movl	%edi, 116(%rsp)
	testl	%eax, %eax
	je	.L155
	movl	$0, y(%rip)
	movl	H(%rip), %esi
	testl	%esi, %esi
	jle	.L19
	movl	%edi, %ecx
	xorl	%eax, %eax
	leaq	c(%rip), %rbx
	movl	%r10d, %r14d
	leaq	.LC2(%rip), %r13
.L22:
	movl	$0, x(%rip)
	testl	%ecx, %ecx
	jle	.L20
	xorl	%edx, %edx
	jmp	.L23
.L21:
	movl	y(%rip), %eax
.L23:
	movslq	%edx, %rdx
	cltq
	movq	%r13, %rdi
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rax,%rdx,2), %rax
	leaq	(%rbx,%rax,4), %rsi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	movl	W(%rip), %ecx
	leal	1(%rax), %edx
	movl	%edx, x(%rip)
	cmpl	%ecx, %edx
	jl	.L21
	movl	y(%rip), %eax
	movl	H(%rip), %esi
	addl	$1, %eax
	movl	%eax, y(%rip)
	cmpl	%esi, %eax
	jl	.L22
	movl	%ecx, 116(%rsp)
	movl	%r14d, %r10d
.L19:
	movl	f0(%rip), %eax
	movl	o(%rip), %edx
	leal	1(%rax), %ebx
	movl	%ebx, 112(%rsp)
	movl	%ebx, f0(%rip)
	cmpl	$1, %edx
	jle	.L27
	movl	116(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L27
	movl	m(%rip), %eax
	subl	$1, %edx
	movl	c(%rip), %edi
	cmpl	%eax, %edx
	movl	%eax, %ecx
	cmovle	%edx, %ecx
	testl	%edi, %edi
	jle	.L156
	addl	%edx, %edi
	movl	%ebx, %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L31:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$1, 116(%rsp)
	movl	%r8d, (%r12,%rdi)
	je	.L27
	movl	40+c(%rip), %edi
	testl	%edi, %edi
	jle	.L157
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L34:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$2, 116(%rsp)
	movl	%r8d, 444(%r12,%rdi)
	je	.L27
	movl	80+c(%rip), %edi
	testl	%edi, %edi
	jle	.L158
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L36:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$3, 116(%rsp)
	movl	%r8d, 888(%r12,%rdi)
	je	.L27
	movl	120+c(%rip), %edi
	testl	%edi, %edi
	jle	.L159
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L38:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$4, 116(%rsp)
	movl	%r8d, 1332(%r12,%rdi)
	je	.L27
	movl	160+c(%rip), %edi
	testl	%edi, %edi
	jle	.L160
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L40:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$5, 116(%rsp)
	movl	%r8d, 1776(%r12,%rdi)
	je	.L27
	movl	200+c(%rip), %edi
	testl	%edi, %edi
	jle	.L161
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L42:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$6, 116(%rsp)
	movl	%r8d, 2220(%r12,%rdi)
	je	.L27
	movl	240+c(%rip), %edi
	testl	%edi, %edi
	jle	.L162
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L44:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$7, 116(%rsp)
	movl	%r8d, 2664(%r12,%rdi)
	je	.L27
	movl	280+c(%rip), %edi
	testl	%edi, %edi
	jle	.L163
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L46:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$8, 116(%rsp)
	movl	%r8d, 3108(%r12,%rdi)
	je	.L27
	movl	320+c(%rip), %edi
	testl	%edi, %edi
	jle	.L164
	addl	%edx, %edi
	movl	112(%rsp), %r8d
	cmpl	%eax, %edi
	cmovg	%eax, %edi
.L48:
	movslq	%edi, %rdi
	imulq	$40000, %rdi, %rdi
	cmpl	$9, 116(%rsp)
	movl	%r8d, 3552(%r12,%rdi)
	je	.L27
	movl	360+c(%rip), %r8d
	movl	112(%rsp), %ebx
	leal	(%rbx,%r8), %edi
	testl	%r8d, %r8d
	jle	.L50
	addl	%r8d, %edx
	movl	%ebx, %edi
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, %ecx
.L50:
	movslq	%ecx, %rax
	imulq	$40000, %rax, %rax
	movl	%edi, 3996(%r12,%rax)
	jmp	.L27
.L155:
	addq	$168, %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
.L20:
	.cfi_restore_state
	movl	%ecx, 116(%rsp)
	movl	%r14d, %r10d
.L154:
	addl	$1, %eax
	cmpl	%esi, %eax
	jl	.L154
	movl	f0(%rip), %eax
	addl	$1, %eax
	movl	%eax, 112(%rsp)
	movl	%eax, f0(%rip)
.L27:
	movl	$0, y(%rip)
	leal	-1(%rsi), %eax
	movl	%eax, 132(%rsp)
	testl	%eax, %eax
	jle	.L52
	movslq	m(%rip), %rax
	movslq	116(%rsp), %rdi
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	movl	$0, 128(%rsp)
	xorl	%edx, %edx
	movl	%eax, 12(%rsp)
	imulq	$10000, %rax, %rax
	movq	%rdi, 152(%rsp)
	movq	%rax, 144(%rsp)
	movq	%rdi, %rax
	subl	$1, %eax
	movl	%eax, 64(%rsp)
.L75:
	movl	128(%rsp), %edi
	movl	116(%rsp), %r8d
	movslq	%edi, %rax
	addl	$1, %edi
	movl	%edi, 128(%rsp)
	testl	%r8d, %r8d
	jle	.L92
	movq	%rax, 104(%rsp)
	imulq	$1000, %rax, %r14
	movslq	%edi, %rax
	movq	%rax, 24(%rsp)
	imulq	$4000, %rax, %rax
	movq	$0, (%rsp)
	movq	%rax, 32(%rsp)
.L74:
	movl	12(%rsp), %eax
	cmpl	$1, %eax
	jle	.L93
	movq	(%rsp), %rdx
	movl	116(%rsp), %ecx
	movl	%eax, 8(%rsp)
	subl	%edx, %ecx
	leal	1(%rdx), %eax
	movl	%edx, 96(%rsp)
	movl	%ecx, 68(%rsp)
	movq	144(%rsp), %rcx
	movl	%eax, 100(%rsp)
	movq	%rcx, 80(%rsp)
.L73:
	movl	8(%rsp), %edi
	xorl	%r13d, %r13d
	movq	%r14, %r11
	movl	%r13d, %r15d
	movslq	%edi, %rax
	subl	$1, %edi
	movq	%rax, 120(%rsp)
	movslq	%edi, %rax
	imulq	$10000, %rax, %rax
	movl	%edi, 8(%rsp)
	movq	%rax, 56(%rsp)
	.p2align 4,,10
	.p2align 3
.L72:
	imulq	$10000, 120(%rsp), %rax
	xorl	%r13d, %r13d
	movq	%rax, 72(%rsp)
	.p2align 4,,10
	.p2align 3
.L71:
	leaq	0(%r13,%r13,4), %rax
	movq	%r13, 16(%rsp)
	movl	%r13d, %r10d
	xorl	%edx, %edx
	addq	%rax, %rax
	movq	72(%rsp), %r14
	movq	%rax, 48(%rsp)
	movl	96(%rsp), %eax
	leal	(%rax,%r13), %r8d
	movq	(%rsp), %rax
	movl	%r8d, 92(%rsp)
	movslq	%r8d, %r9
	addq	%r13, %rax
	movq	%rax, 40(%rsp)
	movslq	%r13d, %rax
	leaq	(%rax,%rax,4), %rdi
	addq	%rdi, %rdi
	jmp	.L70
	.p2align 4,,10
	.p2align 3
.L58:
	addl	$1, %edx
	cmpl	(%rsp), %edx
	jg	.L165
.L70:
	movl	%r8d, %eax
	leal	(%rdx,%r10), %ecx
	subl	%edx, %eax
	testl	%r15d, %r15d
	cmovne	%ecx, %eax
	movslq	%eax, %rcx
	leaq	(%rcx,%rcx,4), %rbp
	leaq	0(%rbp,%rbp,4), %rsi
	leaq	(%r14,%rsi,4), %rbx
	addq	%r11, %rbx
	addq	%rdi, %rbx
	addq	%r9, %rbx
	movl	(%r12,%rbx,4), %esi
	testl	%esi, %esi
	je	.L58
	movl	$0, (%r12,%rbx,4)
	movq	24(%rsp), %rbx
	leaq	(%rbx,%rbp,2), %rbx
	leaq	c(%rip), %rbp
	movl	0(%rbp,%rbx,4), %r13d
	movl	8(%rsp), %ebx
	movl	%esi, %ebp
	addl	%r13d, %ebx
	testl	%r13d, %r13d
	jns	.L60
	movl	8(%rsp), %ebx
	leal	0(%r13,%rsi), %ebp
.L60:
	movl	12(%rsp), %r13d
	cmpl	%ebx, %r13d
	cmovle	%r13d, %ebx
	imulq	$444, %rcx, %r13
	addq	32(%rsp), %r13
	movslq	%ebx, %rbx
	imulq	$40000, %rbx, %rbx
	addq	%rbx, %r13
	addq	%r12, %r13
	cmpl	%ebp, 0(%r13)
	jge	.L61
	movl	%ebp, 0(%r13)
.L61:
	testl	%eax, %eax
	je	.L62
	leal	-1(%rax), %ebx
	movslq	%ebx, %rbx
	cmpl	16(%rsp), %eax
	jle	.L63
	movq	56(%rsp), %rbp
	leaq	(%rbx,%rbx,4), %rbx
	leaq	(%rbx,%rbx,4), %rbx
	leaq	0(%rbp,%rbx,4), %rbx
	addq	%r11, %rbx
	addq	%rdi, %rbx
	addq	%r9, %rbx
	cmpl	%esi, (%r12,%rbx,4)
	jge	.L62
	movl	%esi, (%r12,%rbx,4)
	.p2align 4,,10
	.p2align 3
.L62:
	cmpl	%eax, 64(%rsp)
	jle	.L58
	leal	1(%rax), %ebx
	cmpl	%eax, %r8d
	movslq	%ebx, %rax
	jle	.L67
	movq	56(%rsp), %rbx
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rbx,%rax,4), %rax
	addq	%r11, %rax
	addq	%rdi, %rax
	addq	%r9, %rax
	cmpl	%esi, (%r12,%rax,4)
	jge	.L58
	movl	%esi, (%r12,%rax,4)
	addl	$1, %edx
	cmpl	(%rsp), %edx
	jle	.L70
	.p2align 4,,10
	.p2align 3
.L165:
	leaq	(%rcx,%rcx,4), %rdx
	movq	16(%rsp), %r13
	movq	48(%rsp), %rax
	leaq	(%rdx,%rdx,4), %rdx
	addq	40(%rsp), %rax
	addq	80(%rsp), %rax
	leaq	(%rax,%rdx,4), %rax
	movl	100(%rsp), %r10d
	addq	$1, %r13
	leaq	(%r12,%rax,4), %rbp
	cmpl	%r13d, 68(%rsp)
	jg	.L71
	movl	68(%rsp), %edi
	movl	$1, %eax
	testl	%edi, %edi
	cmovg	%edi, %eax
	cmpl	$1, %r15d
	je	.L166
	movl	$1, %r15d
	jmp	.L72
	.p2align 4,,10
	.p2align 3
.L63:
	movq	104(%rsp), %r13
	leaq	(%rbx,%rbx,4), %rbp
	movl	%esi, 88(%rsp)
	leaq	0(%r13,%rbp,2), %rbp
	leaq	c(%rip), %r13
	movl	0(%r13,%rbp,4), %r13d
	movl	8(%rsp), %ebp
	addl	%r13d, %ebp
	testl	%r13d, %r13d
	jns	.L65
	addl	%esi, %r13d
	movl	8(%rsp), %ebp
	movl	%r13d, 88(%rsp)
.L65:
	movl	12(%rsp), %r13d
	cmpl	%ebp, %r13d
	cmovle	%r13d, %ebp
	imulq	$110, %rbx, %rbx
	movslq	%ebp, %rbp
	imulq	$10000, %rbp, %rbp
	addq	%r11, %rbp
	addq	%rbx, %rbp
	movl	88(%rsp), %ebx
	addq	%r9, %rbp
	cmpl	(%r12,%rbp,4), %ebx
	jle	.L62
	movl	%ebx, (%r12,%rbp,4)
	jmp	.L62
	.p2align 4,,10
	.p2align 3
.L67:
	movq	104(%rsp), %rbp
	leaq	(%rax,%rax,4), %rbx
	movl	8(%rsp), %r13d
	leaq	0(%rbp,%rbx,2), %rbx
	leaq	c(%rip), %rbp
	movl	0(%rbp,%rbx,4), %ebp
	leal	0(%rbp,%r13), %ebx
	testl	%ebp, %ebp
	jns	.L69
	addl	%ebp, %esi
	movl	%r13d, %ebx
.L69:
	movl	12(%rsp), %ebp
	cmpl	%ebx, %ebp
	cmovle	%ebp, %ebx
	leaq	(%rax,%rax,4), %rbp
	leaq	0(%rbp,%rbp,4), %rbp
	movslq	%ebx, %rbx
	imulq	$10000, %rbx, %rbx
	leaq	(%rbx,%rbp,4), %rbx
	addq	%r11, %rbx
	addq	%rdi, %rbx
	addq	%rax, %rbx
	cmpl	%esi, (%r12,%rbx,4)
	jge	.L58
	movl	%esi, (%r12,%rbx,4)
	jmp	.L58
.L166:
	subq	$10000, 80(%rsp)
	movl	%eax, %r15d
	movq	%r11, %r14
	cmpl	$1, 8(%rsp)
	jne	.L73
	movl	$1, %esi
	movl	$1, %edx
.L54:
	addq	$1, (%rsp)
	movq	(%rsp), %rax
	cmpq	152(%rsp), %rax
	jne	.L74
	movl	116(%rsp), %eax
	movl	$1, %ecx
	jmp	.L53
.L162:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L44
.L161:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L42
.L160:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L40
.L159:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L38
.L158:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L36
.L157:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L34
.L156:
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L31
.L92:
	xorl	%eax, %eax
.L53:
	addq	$1000, 144(%rsp)
	movl	128(%rsp), %ebx
	cmpl	%ebx, 132(%rsp)
	jne	.L75
	movl	%eax, g(%rip)
	movl	132(%rsp), %eax
	movl	%eax, y(%rip)
	testb	%sil, %sil
	je	.L76
	movl	$2, d(%rip)
	movl	%r15d, l(%rip)
	movl	%r10d, v(%rip)
.L76:
	testb	%dl, %dl
	je	.L77
	movl	92(%rsp), %eax
	movl	%eax, r(%rip)
	testb	%cl, %cl
	je	.L78
.L89:
	movl	8(%rsp), %eax
	movl	%eax, o(%rip)
	testb	%dl, %dl
	je	.L52
.L78:
	movq	%rbp, p(%rip)
.L52:
	movl	116(%rsp), %ebx
	leaq	.LC1(%rip), %rdi
	movl	$0, f(%rip)
	movl	$0, x(%rip)
	testl	%ebx, %ebx
	jle	.L80
	movslq	m(%rip), %rdi
	leaq	444+DP(%rip), %rdx
	movl	$40000, %r9d
	xorl	%r8d, %r8d
	movslq	132(%rsp), %rsi
	movq	%rdi, %rcx
	imulq	$40000, %rdi, %rdi
	imulq	$4000, %rsi, %rsi
	addq	%rdi, %rdx
	subq	%rdi, %r9
	addq	%rsi, %rdx
	leaq	(%rsi,%rdi), %rax
	leal	-1(%rbx), %esi
	movq	%r9, %r11
	imulq	$444, %rsi, %rsi
	addq	%r12, %rax
	leal	1(%rcx), %ebx
	leaq	(%rdx,%rsi), %r13
	xorl	%edx, %edx
	xorl	%esi, %esi
.L84:
	testl	%ecx, %ecx
	jle	.L96
	leaq	(%r11,%rax), %rsi
	movl	$1, %edi
.L83:
	movl	(%rsi), %r9d
	cmpl	%edx, %r9d
	jle	.L82
	movl	%r9d, %edx
	movl	$1, %r8d
.L82:
	addq	$1, %rdi
	movl	$0, (%rsi)
	addq	$40000, %rsi
	cmpq	%rbx, %rdi
	jne	.L83
	movq	%rax, 136(%rsp)
	addq	$444, %rax
	movl	%ecx, %edi
	movl	$1, %esi
	cmpq	%rax, %r13
	jne	.L84
.L167:
	movl	116(%rsp), %eax
	movl	%edi, o(%rip)
	movl	%eax, x(%rip)
	testb	%r8b, %r8b
	je	.L85
	subl	%edx, 112(%rsp)
	movl	%edx, f(%rip)
	testb	%sil, %sil
	je	.L86
	movq	136(%rsp), %rax
	movq	%rax, p(%rip)
.L86:
	testl	%edx, %edx
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %rax
	cmove	%rax, %rdi
.L80:
	movl	112(%rsp), %esi
	xorl	%eax, %eax
	movl	%r10d, (%rsp)
	call	printf@PLT
	xorl	%esi, %esi
	movl	$80000, %edx
	movq	%r12, %rdi
	testl	%eax, %eax
	sete	%sil
	call	memset@PLT
	movl	(%rsp), %r10d
	jmp	.L18
.L96:
	addq	$444, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r13
	jne	.L84
	jmp	.L167
.L85:
	leaq	.LC1(%rip), %rdi
	testb	%sil, %sil
	je	.L80
	movq	136(%rsp), %rax
	movq	%rax, p(%rip)
	jmp	.L80
.L93:
	movl	%eax, 8(%rsp)
	jmp	.L54
.L77:
	testb	%cl, %cl
	jne	.L89
	jmp	.L52
.L164:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L48
.L163:
	movl	112(%rsp), %ebx
	leal	(%rbx,%rdi), %r8d
	movl	%ecx, %edi
	jmp	.L46
	.cfi_endproc
.LFE4:
	.size	main, .-main
	.globl	f0
	.bss
	.align 4
	.type	f0, @object
	.size	f0, 4
f0:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	l
	.align 4
	.type	l, @object
	.size	l, 4
l:
	.zero	4
	.globl	o
	.align 4
	.type	o, @object
	.size	o, 4
o:
	.zero	4
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	g
	.align 4
	.type	g, @object
	.size	g, 4
g:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	p
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	DP
	.align 32
	.type	DP, @object
	.size	DP, 2040000
DP:
	.zero	2040000
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.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
	.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:

#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}*p,x,y,g,d,v,f,o,l,r,f0;main(){for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -6
-250 -10 -20 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -6
-250 -10 -32 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-20 -79 -20
3 3
110 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -12
-250 -10 -32 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 19 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -20
-250 -10 -20 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 0 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -6
-250 -10 -20 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-20 -79 -20
3 3
110 3 3
-100 -20 -30
-100 -20 2
-100 -20 -14
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -12
-250 -10 -32 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -18 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -6
-250 -10 -20 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-117 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 19 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-127 -20 -20
4 5
1500 5 4
-10 -380 -250 -312
-90 2 -144 8
-250 -130 -330 -120
-120 -40 -50 -20
-250 -10 -20 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
6 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 10 3
-100 -20 -100
-20 -20 -20
-8 -79 -20
3 3
110 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-120 -40 -50 -6
-250 -10 -32 -150
0 0
 3 3
100 10 10
-100 -20 -100
-100 -20 -100
-100 -20 -100
3 3
100 10 10
-100 -20 -100
-100 -20 -20
-100 -60 -20
3 3
100 19 3
-100 -20 -100
-20 -20 -20
-20 -100 -20
3 3
100 3 3
-100 -20 -30
-100 -20 2
-100 -20 -20
4 5
1500 5 4
-10 -380 -250 -250
-90 2 -80 8
-250 -130 -330 -120
-122 -40 -50 -8
-250 -10 -20 -150
0 0

60
80
NA
50
376
 60
80
NA
50
388
 60
80
NA
50
394
 60
80
NA
50
390
 60
80
NA
50
NA
 60
80
NA
44
394
 58
80
NA
50
376
 60
80
NA
50
454
 60
40
NA
50
388
 60
80
NA
50
378

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

```c
#define rep(i,n)for(i=0;i<n;i++)
W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}*p,x,y,g,d,v,f,o,l,r,f0;main(){for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	W
	.bss
	.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	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	DP
	.align 32
	.type	DP, @object
	.size	DP, 2040000
DP:
	.zero	2040000
	.text
	.globl	CalcO
	.type	CalcO, @function
CalcO:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	testl	%eax, %eax
	jle	.L3
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	addl	%eax, -4(%rbp)
.L3:
	cmpl	$0, -4(%rbp)
	jle	.L4
	movl	m(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	jmp	.L6
.L4:
	movl	$0, %eax
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	CalcO, .-CalcO
	.globl	CalcF
	.type	CalcF, @function
CalcF:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	testl	%eax, %eax
	jns	.L8
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	jmp	.L10
.L8:
	movl	-4(%rbp), %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	CalcF, .-CalcF
	.globl	Walk
	.type	Walk, @function
Walk:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	%r8d, -36(%rbp)
	movl	%r9d, -40(%rbp)
	movl	-32(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%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
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%rsi,%rax), %rcx
	movl	-36(%rbp), %eax
	cltq
	imulq	$10000, %rax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L13
	movq	-8(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
.L13:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Walk, .-Walk
	.globl	Dig
	.type	Dig, @function
Dig:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -12(%rbp)
	movl	%esi, -16(%rbp)
	movl	%edx, -20(%rbp)
	movl	%ecx, -24(%rbp)
	movl	%r8d, -28(%rbp)
	movl	%r9d, -32(%rbp)
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %ecx
	movl	-32(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	CalcF
	movl	%eax, %ebx
	movl	-28(%rbp), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	movl	%ecx, %edi
	movl	$0, %eax
	call	CalcO
	movl	%eax, %edi
	movl	-24(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-16(%rbp), %esi
	movl	-12(%rbp), %eax
	movl	%ebx, %r9d
	movl	%edi, %r8d
	movl	%eax, %edi
	movl	$0, %eax
	call	Walk
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Dig, .-Dig
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	g
	.align 4
	.type	g, @object
	.size	g, 4
g:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.zero	4
	.globl	o
	.align 4
	.type	o, @object
	.size	o, 4
o:
	.zero	4
	.globl	l
	.align 4
	.type	l, @object
	.size	l, 4
l:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	f0
	.align 4
	.type	f0, @object
	.size	f0, 4
f0:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"NA\n"
.LC3:
	.string	"%d%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	jmp	.L16
.L54:
	movl	$0, y(%rip)
	jmp	.L17
.L20:
	movl	$0, x(%rip)
	jmp	.L18
.L19:
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rcx
	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	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L18:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L17:
	movl	y(%rip), %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jl	.L20
	movl	f0(%rip), %eax
	addl	$1, %eax
	movl	%eax, f0(%rip)
	movl	o(%rip), %eax
	cmpl	$1, %eax
	jle	.L21
	movl	$0, x(%rip)
	jmp	.L22
.L23:
	movl	x(%rip), %r12d
	movl	f0(%rip), %ebx
	movl	x(%rip), %eax
	movl	o(%rip), %edx
	leal	-1(%rdx), %ecx
	movl	$0, %edx
	movl	%eax, %esi
	movl	%ecx, %edi
	movl	$0, %eax
	call	CalcO
	movl	%eax, %r13d
	movl	x(%rip), %r15d
	movl	x(%rip), %r14d
	movl	x(%rip), %eax
	movl	%eax, -52(%rbp)
	movl	$0, %edx
	movl	%r12d, %esi
	movl	%ebx, %edi
	movl	$0, %eax
	call	CalcF
	movl	%eax, %edx
	movslq	-52(%rbp), %r8
	movslq	%r15d, %rsi
	movslq	%r14d, %rcx
	movslq	%r13d, %rdi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	imulq	$10000, %rdi, %rsi
	addq	%rax, %rsi
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	addq	%r8, %rax
	leaq	0(,%rax,4), %rcx
	leaq	DP(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L22:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L23
.L21:
	movl	$0, y(%rip)
	jmp	.L24
.L45:
	movl	$0, g(%rip)
	jmp	.L25
.L44:
	movl	m(%rip), %eax
	movl	%eax, o(%rip)
	jmp	.L26
.L43:
	movl	$0, d(%rip)
	jmp	.L27
.L42:
	movl	$0, l(%rip)
	jmp	.L28
.L41:
	movl	$0, v(%rip)
	jmp	.L29
.L40:
	movl	l(%rip), %edx
	movl	g(%rip), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
	movl	o(%rip), %edi
	movl	y(%rip), %esi
	movl	d(%rip), %eax
	testl	%eax, %eax
	je	.L30
	movl	l(%rip), %edx
	movl	v(%rip), %eax
	addl	%edx, %eax
	jmp	.L31
.L30:
	movl	r(%rip), %eax
	movl	v(%rip), %edx
	subl	%edx, %eax
.L31:
	movl	%eax, x(%rip)
	movl	x(%rip), %eax
	movl	l(%rip), %ecx
	movl	r(%rip), %edx
	movslq	%edx, %r8
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%r8,%rax), %rcx
	movslq	%edi, %rax
	imulq	$10000, %rax, %rdx
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, f(%rip)
	movl	f(%rip), %eax
	testl	%eax, %eax
	je	.L32
	movq	p(%rip), %rax
	movl	$0, (%rax)
	movl	f(%rip), %r8d
	movl	o(%rip), %edi
	movl	x(%rip), %ecx
	movl	x(%rip), %edx
	movl	y(%rip), %eax
	leal	1(%rax), %esi
	movl	x(%rip), %eax
	movl	%r8d, %r9d
	movl	%edi, %r8d
	movl	%eax, %edi
	movl	$0, %eax
	call	Dig
	movl	x(%rip), %eax
	testl	%eax, %eax
	je	.L36
	movl	x(%rip), %edx
	movl	l(%rip), %eax
	cmpl	%eax, %edx
	jle	.L34
	movl	f(%rip), %r8d
	movl	o(%rip), %eax
	leal	-1(%rax), %r10d
	movl	r(%rip), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	-1(%rsi), %edi
	movl	%r8d, %r9d
	movl	%r10d, %r8d
	movl	%eax, %esi
	movl	$0, %eax
	call	Walk
	jmp	.L36
.L34:
	movl	f(%rip), %r9d
	movl	o(%rip), %r8d
	movl	r(%rip), %edx
	movl	x(%rip), %eax
	leal	-1(%rax), %esi
	movl	y(%rip), %eax
	movl	x(%rip), %ecx
	leal	-1(%rcx), %edi
	movl	%edx, %ecx
	movl	%esi, %edx
	movl	%eax, %esi
	movl	$0, %eax
	call	Dig
.L36:
	movl	W(%rip), %eax
	leal	-1(%rax), %edx
	movl	x(%rip), %eax
	cmpl	%eax, %edx
	jle	.L32
	movl	x(%rip), %edx
	movl	r(%rip), %eax
	cmpl	%eax, %edx
	jge	.L38
	movl	f(%rip), %r8d
	movl	o(%rip), %eax
	leal	-1(%rax), %r10d
	movl	r(%rip), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	1(%rsi), %edi
	movl	%r8d, %r9d
	movl	%r10d, %r8d
	movl	%eax, %esi
	movl	$0, %eax
	call	Walk
	jmp	.L32
.L38:
	movl	f(%rip), %r9d
	movl	o(%rip), %r8d
	movl	x(%rip), %eax
	leal	1(%rax), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	1(%rsi), %edi
	movl	%eax, %esi
	movl	$0, %eax
	call	Dig
.L32:
	movl	v(%rip), %eax
	addl	$1, %eax
	movl	%eax, v(%rip)
.L29:
	movl	g(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jge	.L40
	movl	l(%rip), %eax
	addl	$1, %eax
	movl	%eax, l(%rip)
.L28:
	movl	W(%rip), %eax
	movl	g(%rip), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	l(%rip), %eax
	cmpl	%eax, %edx
	jg	.L41
	movl	d(%rip), %eax
	addl	$1, %eax
	movl	%eax, d(%rip)
.L27:
	movl	d(%rip), %eax
	cmpl	$1, %eax
	jle	.L42
	movl	o(%rip), %eax
	subl	$1, %eax
	movl	%eax, o(%rip)
.L26:
	movl	o(%rip), %eax
	cmpl	$1, %eax
	jg	.L43
	movl	g(%rip), %eax
	addl	$1, %eax
	movl	%eax, g(%rip)
.L25:
	movl	g(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L44
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L24:
	movl	H(%rip), %eax
	leal	-1(%rax), %edx
	movl	y(%rip), %eax
	cmpl	%eax, %edx
	jg	.L45
	movl	$0, f(%rip)
	movl	$0, x(%rip)
	jmp	.L46
.L51:
	movl	$0, o(%rip)
	jmp	.L47
.L50:
	movl	o(%rip), %eax
	leal	1(%rax), %edi
	movl	H(%rip), %eax
	leal	-1(%rax), %esi
	movl	x(%rip), %eax
	movl	x(%rip), %ecx
	movl	x(%rip), %edx
	movslq	%edx, %r8
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%r8,%rax), %rcx
	movslq	%edi, %rax
	imulq	$10000, %rax, %rdx
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	(%rax), %edx
	movl	f(%rip), %eax
	cmpl	%eax, %edx
	jle	.L49
	movq	p(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, f(%rip)
.L49:
	movq	p(%rip), %rax
	movl	$0, (%rax)
	movl	o(%rip), %eax
	addl	$1, %eax
	movl	%eax, o(%rip)
.L47:
	movl	o(%rip), %edx
	movl	m(%rip), %eax
	cmpl	%eax, %edx
	jl	.L50
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L46:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L51
	movl	f0(%rip), %eax
	movl	f(%rip), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	f(%rip), %eax
	testl	%eax, %eax
	je	.L52
	leaq	.LC1(%rip), %rax
	jmp	.L53
.L52:
	leaq	.LC2(%rip), %rax
.L53:
	movl	%edx, %esi
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	movl	$80000, %edx
	movl	%eax, %esi
	leaq	DP(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
.L16:
	leaq	o(%rip), %r9
	leaq	m(%rip), %r8
	leaq	f0(%rip), %rax
	movq	%rax, %rcx
	leaq	H(%rip), %rax
	movq	%rax, %rdx
	leaq	W(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	W(%rip), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L54
	movl	$0, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.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	W
	.bss
	.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	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 400
c:
	.zero	400
	.globl	DP
	.align 32
	.type	DP, @object
	.size	DP, 2040000
DP:
	.zero	2040000
	.text
	.globl	CalcO
	.type	CalcO, @function
CalcO:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	testl	%eax, %eax
	jle	.L3
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	addl	%eax, -4(%rbp)
.L3:
	cmpl	$0, -4(%rbp)
	jle	.L4
	movl	m(%rip), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	jmp	.L6
.L4:
	movl	$0, %eax
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	CalcO, .-CalcO
	.globl	CalcF
	.type	CalcF, @function
CalcF:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	%edx, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %eax
	testl	%eax, %eax
	jns	.L8
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%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), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	jmp	.L10
.L8:
	movl	-4(%rbp), %eax
.L10:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	CalcF, .-CalcF
	.globl	Walk
	.type	Walk, @function
Walk:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	%r8d, -36(%rbp)
	movl	%r9d, -40(%rbp)
	movl	-32(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%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
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%rsi,%rax), %rcx
	movl	-36(%rbp), %eax
	cltq
	imulq	$10000, %rax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, -40(%rbp)
	jle	.L13
	movq	-8(%rbp), %rax
	movl	-40(%rbp), %edx
	movl	%edx, (%rax)
.L13:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Walk, .-Walk
	.globl	Dig
	.type	Dig, @function
Dig:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	movl	%edi, -12(%rbp)
	movl	%esi, -16(%rbp)
	movl	%edx, -20(%rbp)
	movl	%ecx, -24(%rbp)
	movl	%r8d, -28(%rbp)
	movl	%r9d, -32(%rbp)
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %ecx
	movl	-32(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	movl	$0, %eax
	call	CalcF
	movl	%eax, %ebx
	movl	-28(%rbp), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	movl	%ecx, %edi
	movl	$0, %eax
	call	CalcO
	movl	%eax, %edi
	movl	-24(%rbp), %ecx
	movl	-20(%rbp), %edx
	movl	-16(%rbp), %esi
	movl	-12(%rbp), %eax
	movl	%ebx, %r9d
	movl	%edi, %r8d
	movl	%eax, %edi
	movl	$0, %eax
	call	Walk
	nop
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Dig, .-Dig
	.globl	p
	.bss
	.align 8
	.type	p, @object
	.size	p, 8
p:
	.zero	8
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	g
	.align 4
	.type	g, @object
	.size	g, 4
g:
	.zero	4
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.zero	4
	.globl	o
	.align 4
	.type	o, @object
	.size	o, 4
o:
	.zero	4
	.globl	l
	.align 4
	.type	l, @object
	.size	l, 4
l:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	f0
	.align 4
	.type	f0, @object
	.size	f0, 4
f0:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"NA\n"
.LC3:
	.string	"%d%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	jmp	.L16
.L54:
	movl	$0, y(%rip)
	jmp	.L17
.L20:
	movl	$0, x(%rip)
	jmp	.L18
.L19:
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rcx
	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	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L18:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L17:
	movl	y(%rip), %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jl	.L20
	movl	f0(%rip), %eax
	addl	$1, %eax
	movl	%eax, f0(%rip)
	movl	o(%rip), %eax
	cmpl	$1, %eax
	jle	.L21
	movl	$0, x(%rip)
	jmp	.L22
.L23:
	movl	x(%rip), %r12d
	movl	f0(%rip), %ebx
	movl	x(%rip), %eax
	movl	o(%rip), %edx
	leal	-1(%rdx), %ecx
	movl	$0, %edx
	movl	%eax, %esi
	movl	%ecx, %edi
	movl	$0, %eax
	call	CalcO
	movl	%eax, %r13d
	movl	x(%rip), %r15d
	movl	x(%rip), %r14d
	movl	x(%rip), %eax
	movl	%eax, -52(%rbp)
	movl	$0, %edx
	movl	%r12d, %esi
	movl	%ebx, %edi
	movl	$0, %eax
	call	CalcF
	movl	%eax, %edx
	movslq	-52(%rbp), %r8
	movslq	%r15d, %rsi
	movslq	%r14d, %rcx
	movslq	%r13d, %rdi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	imulq	$10000, %rdi, %rsi
	addq	%rax, %rsi
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	addq	%r8, %rax
	leaq	0(,%rax,4), %rcx
	leaq	DP(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L22:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L23
.L21:
	movl	$0, y(%rip)
	jmp	.L24
.L45:
	movl	$0, g(%rip)
	jmp	.L25
.L44:
	movl	m(%rip), %eax
	movl	%eax, o(%rip)
	jmp	.L26
.L43:
	movl	$0, d(%rip)
	jmp	.L27
.L42:
	movl	$0, l(%rip)
	jmp	.L28
.L41:
	movl	$0, v(%rip)
	jmp	.L29
.L40:
	movl	l(%rip), %edx
	movl	g(%rip), %eax
	addl	%edx, %eax
	movl	%eax, r(%rip)
	movl	o(%rip), %edi
	movl	y(%rip), %esi
	movl	d(%rip), %eax
	testl	%eax, %eax
	je	.L30
	movl	l(%rip), %edx
	movl	v(%rip), %eax
	addl	%edx, %eax
	jmp	.L31
.L30:
	movl	r(%rip), %eax
	movl	v(%rip), %edx
	subl	%edx, %eax
.L31:
	movl	%eax, x(%rip)
	movl	x(%rip), %eax
	movl	l(%rip), %ecx
	movl	r(%rip), %edx
	movslq	%edx, %r8
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%r8,%rax), %rcx
	movslq	%edi, %rax
	imulq	$10000, %rax, %rdx
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, f(%rip)
	movl	f(%rip), %eax
	testl	%eax, %eax
	je	.L32
	movq	p(%rip), %rax
	movl	$0, (%rax)
	movl	f(%rip), %r8d
	movl	o(%rip), %edi
	movl	x(%rip), %ecx
	movl	x(%rip), %edx
	movl	y(%rip), %eax
	leal	1(%rax), %esi
	movl	x(%rip), %eax
	movl	%r8d, %r9d
	movl	%edi, %r8d
	movl	%eax, %edi
	movl	$0, %eax
	call	Dig
	movl	x(%rip), %eax
	testl	%eax, %eax
	je	.L36
	movl	x(%rip), %edx
	movl	l(%rip), %eax
	cmpl	%eax, %edx
	jle	.L34
	movl	f(%rip), %r8d
	movl	o(%rip), %eax
	leal	-1(%rax), %r10d
	movl	r(%rip), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	-1(%rsi), %edi
	movl	%r8d, %r9d
	movl	%r10d, %r8d
	movl	%eax, %esi
	movl	$0, %eax
	call	Walk
	jmp	.L36
.L34:
	movl	f(%rip), %r9d
	movl	o(%rip), %r8d
	movl	r(%rip), %edx
	movl	x(%rip), %eax
	leal	-1(%rax), %esi
	movl	y(%rip), %eax
	movl	x(%rip), %ecx
	leal	-1(%rcx), %edi
	movl	%edx, %ecx
	movl	%esi, %edx
	movl	%eax, %esi
	movl	$0, %eax
	call	Dig
.L36:
	movl	W(%rip), %eax
	leal	-1(%rax), %edx
	movl	x(%rip), %eax
	cmpl	%eax, %edx
	jle	.L32
	movl	x(%rip), %edx
	movl	r(%rip), %eax
	cmpl	%eax, %edx
	jge	.L38
	movl	f(%rip), %r8d
	movl	o(%rip), %eax
	leal	-1(%rax), %r10d
	movl	r(%rip), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	1(%rsi), %edi
	movl	%r8d, %r9d
	movl	%r10d, %r8d
	movl	%eax, %esi
	movl	$0, %eax
	call	Walk
	jmp	.L32
.L38:
	movl	f(%rip), %r9d
	movl	o(%rip), %r8d
	movl	x(%rip), %eax
	leal	1(%rax), %ecx
	movl	l(%rip), %edx
	movl	y(%rip), %eax
	movl	x(%rip), %esi
	leal	1(%rsi), %edi
	movl	%eax, %esi
	movl	$0, %eax
	call	Dig
.L32:
	movl	v(%rip), %eax
	addl	$1, %eax
	movl	%eax, v(%rip)
.L29:
	movl	g(%rip), %edx
	movl	v(%rip), %eax
	cmpl	%eax, %edx
	jge	.L40
	movl	l(%rip), %eax
	addl	$1, %eax
	movl	%eax, l(%rip)
.L28:
	movl	W(%rip), %eax
	movl	g(%rip), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	l(%rip), %eax
	cmpl	%eax, %edx
	jg	.L41
	movl	d(%rip), %eax
	addl	$1, %eax
	movl	%eax, d(%rip)
.L27:
	movl	d(%rip), %eax
	cmpl	$1, %eax
	jle	.L42
	movl	o(%rip), %eax
	subl	$1, %eax
	movl	%eax, o(%rip)
.L26:
	movl	o(%rip), %eax
	cmpl	$1, %eax
	jg	.L43
	movl	g(%rip), %eax
	addl	$1, %eax
	movl	%eax, g(%rip)
.L25:
	movl	g(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L44
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L24:
	movl	H(%rip), %eax
	leal	-1(%rax), %edx
	movl	y(%rip), %eax
	cmpl	%eax, %edx
	jg	.L45
	movl	$0, f(%rip)
	movl	$0, x(%rip)
	jmp	.L46
.L51:
	movl	$0, o(%rip)
	jmp	.L47
.L50:
	movl	o(%rip), %eax
	leal	1(%rax), %edi
	movl	H(%rip), %eax
	leal	-1(%rax), %esi
	movl	x(%rip), %eax
	movl	x(%rip), %ecx
	movl	x(%rip), %edx
	movslq	%edx, %r8
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rcx
	movq	%rcx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	addq	%rdx, %rdx
	addq	%rdx, %rax
	leaq	(%r8,%rax), %rcx
	movslq	%edi, %rax
	imulq	$10000, %rax, %rdx
	movslq	%esi, %rax
	imulq	$1000, %rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	DP(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, p(%rip)
	movq	p(%rip), %rax
	movl	(%rax), %edx
	movl	f(%rip), %eax
	cmpl	%eax, %edx
	jle	.L49
	movq	p(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, f(%rip)
.L49:
	movq	p(%rip), %rax
	movl	$0, (%rax)
	movl	o(%rip), %eax
	addl	$1, %eax
	movl	%eax, o(%rip)
.L47:
	movl	o(%rip), %edx
	movl	m(%rip), %eax
	cmpl	%eax, %edx
	jl	.L50
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L46:
	movl	x(%rip), %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jl	.L51
	movl	f0(%rip), %eax
	movl	f(%rip), %ecx
	subl	%ecx, %eax
	movl	%eax, %edx
	movl	f(%rip), %eax
	testl	%eax, %eax
	je	.L52
	leaq	.LC1(%rip), %rax
	jmp	.L53
.L52:
	leaq	.LC2(%rip), %rax
.L53:
	movl	%edx, %esi
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	movl	$80000, %edx
	movl	%eax, %esi
	leaq	DP(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
.L16:
	leaq	o(%rip), %r9
	leaq	m(%rip), %r8
	leaq	f0(%rip), %rax
	movq	%rax, %rcx
	leaq	H(%rip), %rax
	movq	%rax, %rdx
	leaq	W(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	W(%rip), %edx
	imull	%edx, %eax
	testl	%eax, %eax
	jne	.L54
	movl	$0, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.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:
