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

```c
// AOJ 2299:   Tiles are Colorful
// 2017.12.10

#include <stdio.h>
#include <string.h>

int m, n, k;
char map[501][503];
int mv[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};
int rpos[26], cpos[26];
int sr[501], sc[501];

int calc()
{
	int r, c, i, r2, c2, a, ans = 0;
	for (r = 0; r < m; r++) for (c = 0; c < n; c++) 
		if ((sr[c] + sc[r]) && map[r][c] == '.' ) {
			memset(rpos, -1, sizeof(rpos));

		    for (i = 0; i < 4; i++) {
				if (!sr[c]) { if (i < 2) continue; }
				if (!sc[r]) { if (i > 2) continue; }

				r2 = r, c2 = c;
				while (1) {
					r2 += mv[i][0], c2 += mv[i][1];
					if (r2 < 0 || r2 >= m || c2 < 0 || c2 >= n) break;
					if (map[r2][c2] == '.') continue;

	                a = map[r2][c2]-'A';
					if (rpos[a] >= 0) {
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
						r2 = rpos[a], c2 = cpos[a];
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
	                    ans += 2, k -= 2;
						if (!k) return ans;
					} else rpos[a] = r2, cpos[a] = c2;
					break;
				}
            }
        }

	return ans;
}

int main()
{
	int r, c, t, k, ans;
	char buf[10];

    fgets(buf, 10, stdin);
	sscanf(buf, "%d%d", &m, &n);
	for (k = 0, r = 0; r < m; r++) {
		fgets(map[r], 503, stdin);
		for (c = 0; c < n; c++) {
			if (map[r][c] != '.') k++, sr[c]++, sc[r]++;
		}
	}
	ans = 0;
	do t = calc(), ans += t;
	while (t && k);
	printf("%d\n", ans);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 252003
map:
	.zero	252003
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	rpos
	.bss
	.align 32
	.type	rpos, @object
	.size	rpos, 104
rpos:
	.zero	104
	.globl	cpos
	.align 32
	.type	cpos, @object
	.size	cpos, 104
cpos:
	.zero	104
	.globl	sr
	.align 32
	.type	sr, @object
	.size	sr, 2004
sr:
	.zero	2004
	.globl	sc
	.align 32
	.type	sc, @object
	.size	sc, 2004
sc:
	.zero	2004
	.text
	.globl	calc
	.type	calc, @function
calc:
.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
	movl	$0, -8(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L2
.L17:
	movl	$0, -24(%rbp)
	jmp	.L3
.L16:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	testl	%eax, %eax
	je	.L4
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-28(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	jne	.L4
	movl	$104, %edx
	movl	$-1, %esi
	leaq	rpos(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -20(%rbp)
	jmp	.L5
.L15:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L6
	cmpl	$1, -20(%rbp)
	jle	.L19
.L6:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L8
	cmpl	$2, -20(%rbp)
	jg	.L20
.L8:
	movl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
.L14:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+mv(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	js	.L7
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L7
	cmpl	$0, -12(%rbp)
	js	.L7
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L7
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	je	.L21
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	subl	$65, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L11
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$2, -8(%rbp)
	movl	k(%rip), %eax
	subl	$2, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	testl	%eax, %eax
	jne	.L22
	movl	-8(%rbp), %eax
	jmp	.L13
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rpos(%rip), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	cpos(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L22
.L21:
	nop
	jmp	.L14
.L19:
	nop
	jmp	.L7
.L20:
	nop
	jmp	.L7
.L22:
	nop
.L7:
	addl	$1, -20(%rbp)
.L5:
	cmpl	$3, -20(%rbp)
	jle	.L15
.L4:
	addl	$1, -24(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	addl	$1, -28(%rbp)
.L2:
	movl	m(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L17
	movl	-8(%rbp), %eax
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-18(%rbp), %rax
	movl	$10, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-18(%rbp), %rax
	leaq	n(%rip), %rdx
	movq	%rdx, %rcx
	leaq	m(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -32(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L24
.L28:
	movq	stdin(%rip), %rax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$503, %rdx, %rdx
	leaq	map(%rip), %rcx
	addq	%rdx, %rcx
	movq	%rax, %rdx
	movl	$503, %esi
	movq	%rcx, %rdi
	call	fgets@PLT
	movl	$0, -36(%rbp)
	jmp	.L25
.L27:
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	je	.L26
	addl	$1, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L26:
	addl	$1, -36(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L27
	addl	$1, -40(%rbp)
.L24:
	movl	m(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L28
	movl	$0, -28(%rbp)
.L30:
	movl	$0, %eax
	call	calc
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	addl	%eax, -28(%rbp)
	cmpl	$0, -24(%rbp)
	je	.L29
	cmpl	$0, -32(%rbp)
	jne	.L30
.L29:
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	m(%rip), %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%eax, -52(%rsp)
	testl	%eax, %eax
	jle	.L21
	movl	n(%rip), %eax
	movl	$0, -24(%rsp)
	xorl	%r14d, %r14d
	leaq	sc(%rip), %r12
	leaq	map(%rip), %rbp
	leaq	sr(%rip), %r15
	movq	%r12, %rbx
	movl	%eax, -48(%rsp)
	movq	%rbp, %r11
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	-48(%rsp), %r10
	xorl	%r13d, %r13d
	testl	%r10d, %r10d
	jle	.L20
	movl	%r14d, %r12d
	movq	%r11, %r14
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%r15,%r13,4), %edx
	movl	%r13d, %eax
	movl	%edx, %edi
	addl	(%rbx), %edi
	je	.L4
	cmpb	$46, (%r14,%r13)
	je	.L56
.L4:
	addq	$1, %r13
	cmpq	%r13, %r10
	jne	.L18
	movq	%r14, %r11
	movl	%r12d, %r14d
.L20:
	addl	$1, %r14d
	addq	$4, %rbx
	addq	$503, %r11
	cmpl	-52(%rsp), %r14d
	jne	.L3
.L1:
	movl	-24(%rsp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L56:
	.cfi_restore_state
	movl	k(%rip), %esi
	pcmpeqd	%xmm0, %xmm0
	leaq	1(%r13), %rcx
	xorl	%ebp, %ebp
	movq	%rcx, -40(%rsp)
	movl	%ebp, %ecx
	movq	$-1, 96+rpos(%rip)
	movl	%esi, -44(%rsp)
	movb	$0, -18(%rsp)
	movq	%r14, -32(%rsp)
	movaps	%xmm0, rpos(%rip)
	movaps	%xmm0, 16+rpos(%rip)
	movaps	%xmm0, 32+rpos(%rip)
	movaps	%xmm0, 48+rpos(%rip)
	movaps	%xmm0, 64+rpos(%rip)
	movaps	%xmm0, 80+rpos(%rip)
	testl	%edx, %edx
	jne	.L22
.L58:
	cmpl	$1, %ebp
	jle	.L5
.L22:
	movl	(%rbx), %edx
	testl	%edx, %edx
	jne	.L7
	cmpl	$3, %ecx
	je	.L15
.L7:
	leaq	mv(%rip), %rsi
	movl	(%rsi,%rbp,8), %r9d
	addq	$4, %rsi
	movl	(%rsi,%rbp,8), %edx
	cmpl	$1, %edx
	jne	.L57
	movslq	%r9d, %r8
	leal	(%r9,%r12), %edx
	leaq	map(%rip), %rsi
	movl	%eax, %edi
	imulq	$503, %r8, %r8
	movslq	%edx, %rdx
	imulq	$503, %rdx, %rdx
	addq	-40(%rsp), %rdx
	addq	%rsi, %rdx
	movl	%r12d, %esi
	leaq	1(%r8), %r11
	negq	%r8
.L12:
	addl	%r9d, %esi
	addl	$1, %edi
	cmpl	-48(%rsp), %edi
	setge	%cl
	cmpl	%esi, -52(%rsp)
	setle	%r14b
	orb	%r14b, %cl
	jne	.L5
	testl	%esi, %esi
	js	.L5
	addq	%r11, %rdx
	movsbl	-1(%rdx,%r8), %ecx
	cmpb	$46, %cl
	je	.L12
.L11:
	subl	$65, %ecx
	leaq	rpos(%rip), %rdx
	movslq	%ecx, %rcx
	movslq	(%rdx,%rcx,4), %rdx
	testl	%edx, %edx
	js	.L13
	movslq	%esi, %rsi
	leaq	map(%rip), %r9
	movslq	%edi, %rdi
	addl	$2, -24(%rsp)
	imulq	$503, %rsi, %r8
	subl	$1, (%r15,%rdi,4)
	addq	%r9, %r8
	movb	$46, (%r8,%rdi)
	leaq	sc(%rip), %rdi
	subl	$1, (%rdi,%rsi,4)
	leaq	cpos(%rip), %rsi
	movslq	(%rsi,%rcx,4), %rcx
	imulq	$503, %rdx, %rsi
	subl	$1, (%rdi,%rdx,4)
	subl	$1, (%r15,%rcx,4)
	addq	%r9, %rsi
	subl	$2, -44(%rsp)
	movb	$46, (%rsi,%rcx)
	je	.L14
	movb	$1, -18(%rsp)
.L5:
	addq	$1, %rbp
	cmpq	$4, %rbp
	je	.L15
	movl	(%r15,%r13,4), %edx
	movl	%ebp, %ecx
	testl	%edx, %edx
	je	.L58
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L15:
	cmpb	$0, -18(%rsp)
	movq	-32(%rsp), %r14
	je	.L4
	movl	-44(%rsp), %eax
	movl	%eax, k(%rip)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L13:
	leaq	rpos(%rip), %rdx
	movl	%esi, (%rdx,%rcx,4)
	leaq	cpos(%rip), %rsi
	movl	%edi, (%rsi,%rcx,4)
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L57:
	movslq	%r9d, %rcx
	leal	(%r9,%r12), %r8d
	movslq	%edx, %r11
	movl	%eax, %edi
	imulq	$503, %rcx, %r14
	movslq	%r8d, %r8
	leal	(%rdx,%rax), %ecx
	imulq	$503, %r8, %r8
	movslq	%ecx, %rcx
	leaq	(%r14,%r11), %rsi
	negq	%r11
	movq	%rsi, -16(%rsp)
	addq	%rcx, %r8
	leaq	map(%rip), %rsi
	addq	%rsi, %r8
	movl	%r12d, %esi
.L10:
	addl	%r9d, %esi
	addl	%edx, %edi
	movl	%esi, %ecx
	orl	%edi, %ecx
	shrl	$31, %ecx
	cmpl	-52(%rsp), %esi
	setge	-17(%rsp)
	orb	-17(%rsp), %cl
	jne	.L5
	cmpl	-48(%rsp), %edi
	jge	.L5
	addq	-16(%rsp), %r8
	movq	%r8, %rcx
	subq	%r14, %rcx
	movsbl	(%rcx,%r11), %ecx
	cmpb	$46, %cl
	jne	.L11
	jmp	.L10
.L14:
	movl	$0, k(%rip)
	movl	-24(%rsp), %eax
	popq	%rbx
	.cfi_remember_state
	.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
.L21:
	.cfi_restore_state
	movl	$0, -24(%rsp)
	jmp	.L1
	.cfi_endproc
.LFE35:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$10, %esi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	14(%rsp), %rbp
	movq	%rbp, %rdi
	call	fgets@PLT
	leaq	n(%rip), %rcx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	leaq	m(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L60
	leaq	map(%rip), %r13
	leaq	sc(%rip), %rbx
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	leaq	4+sr(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L64:
	movq	stdin(%rip), %rdx
	movl	$503, %esi
	movq	%r13, %rdi
	call	fgets@PLT
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.L61
	subl	$1, %edx
	leaq	sr(%rip), %rax
	leaq	(%r12,%rdx,4), %rcx
	movq	%r13, %rdx
	.p2align 4,,10
	.p2align 3
.L63:
	cmpb	$46, (%rdx)
	je	.L62
	addl	$1, (%rax)
	addl	$1, %ebp
	addl	$1, (%rbx)
.L62:
	addq	$4, %rax
	addq	$1, %rdx
	cmpq	%rcx, %rax
	jne	.L63
.L61:
	addl	$1, %r14d
	addq	$503, %r13
	addq	$4, %rbx
	cmpl	%r14d, m(%rip)
	jg	.L64
	testl	%ebp, %ebp
	setne	%bl
	xorl	%r12d, %r12d
	jmp	.L65
	.p2align 4,,10
	.p2align 3
.L77:
	testb	%bl, %bl
	je	.L67
.L65:
	xorl	%eax, %eax
	call	calc
	addl	%eax, %r12d
	testl	%eax, %eax
	jne	.L77
.L67:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L78
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	xorl	%eax, %eax
	call	calc
	movl	%eax, %r12d
	jmp	.L67
.L78:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	sc
	.bss
	.align 32
	.type	sc, @object
	.size	sc, 2004
sc:
	.zero	2004
	.globl	sr
	.align 32
	.type	sr, @object
	.size	sr, 2004
sr:
	.zero	2004
	.globl	cpos
	.align 32
	.type	cpos, @object
	.size	cpos, 104
cpos:
	.zero	104
	.globl	rpos
	.align 32
	.type	rpos, @object
	.size	rpos, 104
rpos:
	.zero	104
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	map
	.bss
	.align 32
	.type	map, @object
	.size	map, 252003
map:
	.zero	252003
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.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	calc
	.type	calc, @function
calc:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	m(%rip), %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%eax, -52(%rsp)
	testl	%eax, %eax
	jle	.L21
	movl	n(%rip), %eax
	movl	$0, -24(%rsp)
	xorl	%r14d, %r14d
	leaq	sc(%rip), %r12
	leaq	map(%rip), %rbp
	leaq	sr(%rip), %r15
	movq	%r12, %rbx
	movl	%eax, -48(%rsp)
	movq	%rbp, %r11
	.p2align 4,,10
	.p2align 3
.L3:
	movslq	-48(%rsp), %r10
	xorl	%r13d, %r13d
	testl	%r10d, %r10d
	jle	.L20
	movl	%r14d, %r12d
	movq	%r11, %r14
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%r15,%r13,4), %edx
	movl	%r13d, %eax
	movl	%edx, %edi
	addl	(%rbx), %edi
	je	.L4
	cmpb	$46, (%r14,%r13)
	je	.L56
.L4:
	addq	$1, %r13
	cmpq	%r13, %r10
	jne	.L18
	movq	%r14, %r11
	movl	%r12d, %r14d
.L20:
	addl	$1, %r14d
	addq	$4, %rbx
	addq	$503, %r11
	cmpl	-52(%rsp), %r14d
	jne	.L3
.L1:
	movl	-24(%rsp), %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L56:
	.cfi_restore_state
	movl	k(%rip), %esi
	pcmpeqd	%xmm0, %xmm0
	leaq	1(%r13), %rcx
	xorl	%ebp, %ebp
	movq	%rcx, -40(%rsp)
	movl	%ebp, %ecx
	movq	$-1, 96+rpos(%rip)
	movl	%esi, -44(%rsp)
	movb	$0, -18(%rsp)
	movq	%r14, -32(%rsp)
	movaps	%xmm0, rpos(%rip)
	movaps	%xmm0, 16+rpos(%rip)
	movaps	%xmm0, 32+rpos(%rip)
	movaps	%xmm0, 48+rpos(%rip)
	movaps	%xmm0, 64+rpos(%rip)
	movaps	%xmm0, 80+rpos(%rip)
	testl	%edx, %edx
	jne	.L22
.L58:
	cmpl	$1, %ebp
	jle	.L5
.L22:
	movl	(%rbx), %edx
	testl	%edx, %edx
	jne	.L7
	cmpl	$3, %ecx
	je	.L15
.L7:
	leaq	mv(%rip), %rsi
	movl	(%rsi,%rbp,8), %r9d
	addq	$4, %rsi
	movl	(%rsi,%rbp,8), %edx
	cmpl	$1, %edx
	jne	.L57
	movslq	%r9d, %r8
	leal	(%r9,%r12), %edx
	leaq	map(%rip), %rsi
	movl	%eax, %edi
	imulq	$503, %r8, %r8
	movslq	%edx, %rdx
	imulq	$503, %rdx, %rdx
	addq	-40(%rsp), %rdx
	addq	%rsi, %rdx
	movl	%r12d, %esi
	leaq	1(%r8), %r11
	negq	%r8
.L12:
	addl	%r9d, %esi
	addl	$1, %edi
	cmpl	-48(%rsp), %edi
	setge	%cl
	cmpl	%esi, -52(%rsp)
	setle	%r14b
	orb	%r14b, %cl
	jne	.L5
	testl	%esi, %esi
	js	.L5
	addq	%r11, %rdx
	movsbl	-1(%rdx,%r8), %ecx
	cmpb	$46, %cl
	je	.L12
.L11:
	subl	$65, %ecx
	leaq	rpos(%rip), %rdx
	movslq	%ecx, %rcx
	movslq	(%rdx,%rcx,4), %rdx
	testl	%edx, %edx
	js	.L13
	movslq	%esi, %rsi
	leaq	map(%rip), %r9
	movslq	%edi, %rdi
	addl	$2, -24(%rsp)
	imulq	$503, %rsi, %r8
	subl	$1, (%r15,%rdi,4)
	addq	%r9, %r8
	movb	$46, (%r8,%rdi)
	leaq	sc(%rip), %rdi
	subl	$1, (%rdi,%rsi,4)
	leaq	cpos(%rip), %rsi
	movslq	(%rsi,%rcx,4), %rcx
	imulq	$503, %rdx, %rsi
	subl	$1, (%rdi,%rdx,4)
	subl	$1, (%r15,%rcx,4)
	addq	%r9, %rsi
	subl	$2, -44(%rsp)
	movb	$46, (%rsi,%rcx)
	je	.L14
	movb	$1, -18(%rsp)
.L5:
	addq	$1, %rbp
	cmpq	$4, %rbp
	je	.L15
	movl	(%r15,%r13,4), %edx
	movl	%ebp, %ecx
	testl	%edx, %edx
	je	.L58
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L15:
	cmpb	$0, -18(%rsp)
	movq	-32(%rsp), %r14
	je	.L4
	movl	-44(%rsp), %eax
	movl	%eax, k(%rip)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L13:
	leaq	rpos(%rip), %rdx
	movl	%esi, (%rdx,%rcx,4)
	leaq	cpos(%rip), %rsi
	movl	%edi, (%rsi,%rcx,4)
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L57:
	movslq	%r9d, %rcx
	leal	(%r9,%r12), %r8d
	movslq	%edx, %r11
	movl	%eax, %edi
	imulq	$503, %rcx, %r14
	movslq	%r8d, %r8
	leal	(%rdx,%rax), %ecx
	imulq	$503, %r8, %r8
	movslq	%ecx, %rcx
	leaq	(%r14,%r11), %rsi
	negq	%r11
	movq	%rsi, -16(%rsp)
	addq	%rcx, %r8
	leaq	map(%rip), %rsi
	addq	%rsi, %r8
	movl	%r12d, %esi
.L10:
	addl	%r9d, %esi
	addl	%edx, %edi
	movl	%esi, %ecx
	orl	%edi, %ecx
	shrl	$31, %ecx
	cmpl	-52(%rsp), %esi
	setge	-17(%rsp)
	orb	-17(%rsp), %cl
	jne	.L5
	cmpl	-48(%rsp), %edi
	jge	.L5
	addq	-16(%rsp), %r8
	movq	%r8, %rcx
	subq	%r14, %rcx
	movsbl	(%rcx,%r11), %ecx
	cmpb	$46, %cl
	jne	.L11
	jmp	.L10
.L14:
	movl	$0, k(%rip)
	movl	-24(%rsp), %eax
	popq	%rbx
	.cfi_remember_state
	.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
.L21:
	.cfi_restore_state
	movl	$0, -24(%rsp)
	jmp	.L1
	.cfi_endproc
.LFE35:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$10, %esi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	stdin(%rip), %rdx
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	14(%rsp), %rbp
	movq	%rbp, %rdi
	call	fgets@PLT
	leaq	n(%rip), %rcx
	movq	%rbp, %rdi
	xorl	%eax, %eax
	leaq	m(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movl	m(%rip), %eax
	testl	%eax, %eax
	jle	.L60
	leaq	map(%rip), %r13
	leaq	sc(%rip), %rbx
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	leaq	4+sr(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L64:
	movq	stdin(%rip), %rdx
	movl	$503, %esi
	movq	%r13, %rdi
	call	fgets@PLT
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.L61
	subl	$1, %edx
	leaq	sr(%rip), %rax
	leaq	(%r12,%rdx,4), %rcx
	movq	%r13, %rdx
	.p2align 4,,10
	.p2align 3
.L63:
	cmpb	$46, (%rdx)
	je	.L62
	addl	$1, (%rax)
	addl	$1, %ebp
	addl	$1, (%rbx)
.L62:
	addq	$4, %rax
	addq	$1, %rdx
	cmpq	%rcx, %rax
	jne	.L63
.L61:
	addl	$1, %r14d
	addq	$503, %r13
	addq	$4, %rbx
	cmpl	%r14d, m(%rip)
	jg	.L64
	testl	%ebp, %ebp
	setne	%bl
	xorl	%r12d, %r12d
	jmp	.L65
	.p2align 4,,10
	.p2align 3
.L77:
	testb	%bl, %bl
	je	.L67
.L65:
	xorl	%eax, %eax
	call	calc
	addl	%eax, %r12d
	testl	%eax, %eax
	jne	.L77
.L67:
	xorl	%eax, %eax
	movl	%r12d, %edx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L78
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	xorl	%eax, %eax
	call	calc
	movl	%eax, %r12d
	jmp	.L67
.L78:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	sc
	.bss
	.align 32
	.type	sc, @object
	.size	sc, 2004
sc:
	.zero	2004
	.globl	sr
	.align 32
	.type	sr, @object
	.size	sr, 2004
sr:
	.zero	2004
	.globl	cpos
	.align 32
	.type	cpos, @object
	.size	cpos, 104
cpos:
	.zero	104
	.globl	rpos
	.align 32
	.type	rpos, @object
	.size	rpos, 104
rpos:
	.zero	104
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	map
	.bss
	.align 32
	.type	map, @object
	.size	map, 252003
map:
	.zero	252003
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	m
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.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:

// AOJ 2299:   Tiles are Colorful
// 2017.12.10

#include <stdio.h>
#include <string.h>

int m, n, k;
char map[501][503];
int mv[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};
int rpos[26], cpos[26];
int sr[501], sc[501];

int calc()
{
	int r, c, i, r2, c2, a, ans = 0;
	for (r = 0; r < m; r++) for (c = 0; c < n; c++) 
		if ((sr[c] + sc[r]) && map[r][c] == '.' ) {
			memset(rpos, -1, sizeof(rpos));

		    for (i = 0; i < 4; i++) {
				if (!sr[c]) { if (i < 2) continue; }
				if (!sc[r]) { if (i > 2) continue; }

				r2 = r, c2 = c;
				while (1) {
					r2 += mv[i][0], c2 += mv[i][1];
					if (r2 < 0 || r2 >= m || c2 < 0 || c2 >= n) break;
					if (map[r2][c2] == '.') continue;

	                a = map[r2][c2]-'A';
					if (rpos[a] >= 0) {
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
						r2 = rpos[a], c2 = cpos[a];
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
	                    ans += 2, k -= 2;
						if (!k) return ans;
					} else rpos[a] = r2, cpos[a] = c2;
					break;
				}
            }
        }

	return ans;
}

int main()
{
	int r, c, t, k, ans;
	char buf[10];

    fgets(buf, 10, stdin);
	sscanf(buf, "%d%d", &m, &n);
	for (k = 0, r = 0; r < m; r++) {
		fgets(map[r], 503, stdin);
		for (c = 0; c < n; c++) {
			if (map[r][c] != '.') k++, sr[c]++, sc[r]++;
		}
	}
	ans = 0;
	do t = calc(), ans += t;
	while (t && k);
	printf("%d\n", ans);
	return 0;
}
5 7
NBTUUOR
QT.SZRQ
SANAGIP
LMDGZBM
KLKIODP
 5 0
NBTUUOR
QT.SZRQ
PIGANAS
LMDGZBM
PDOIKKL
 5 7
OUTUBOR
QT.SZRQ
SANAGIP
LMDGZBM
KLKIODP
 5 7
NBTUUOR
QT.SZSQ
ASNAGIP
MBYGDML
KKLIODP
 3 7
NUTUBOR
RT.SZQQ
RANCGIP
MLZGDMB
LDOIKPK
 5 7
NUTUBOR
QT.SZRQ
SANAGIP
LMDGZBM
LKKIODP
 5 7
NUTUBOR
QT.SZRQ
TANAGIP
LMDGZBM
LKKIODP
 3 7
NUTUBOR
ST.SZQQ
RANCGIP
MLZGDMB
LCOIKPK
 5 7
NBTUUOR
QT.SZRQ
SANAGIP
LMDGZBM
LKKIODP
 5 3
NBTUUOR
QT.SZRQ
SANAGIP
LMDGZBM
LKKIODP

2
 0
 4
 14
 6
 30
 26
 8
 2
 2

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

```c
// AOJ 2299:   Tiles are Colorful
// 2017.12.10

#include <stdio.h>
#include <string.h>

int m, n, k;
char map[501][503];
int mv[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};
int rpos[26], cpos[26];
int sr[501], sc[501];

int calc()
{
	int r, c, i, r2, c2, a, ans = 0;
	for (r = 0; r < m; r++) for (c = 0; c < n; c++) 
		if ((sr[c] + sc[r]) && map[r][c] == '.' ) {
			memset(rpos, -1, sizeof(rpos));

		    for (i = 0; i < 4; i++) {
				if (!sr[c]) { if (i < 2) continue; }
				if (!sc[r]) { if (i > 2) continue; }

				r2 = r, c2 = c;
				while (1) {
					r2 += mv[i][0], c2 += mv[i][1];
					if (r2 < 0 || r2 >= m || c2 < 0 || c2 >= n) break;
					if (map[r2][c2] == '.') continue;

	                a = map[r2][c2]-'A';
					if (rpos[a] >= 0) {
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
						r2 = rpos[a], c2 = cpos[a];
	                    map[r2][c2] = '.', sr[c2]--, sc[r2]--;
	                    ans += 2, k -= 2;
						if (!k) return ans;
					} else rpos[a] = r2, cpos[a] = c2;
					break;
				}
            }
        }

	return ans;
}

int main()
{
	int r, c, t, k, ans;
	char buf[10];

    fgets(buf, 10, stdin);
	sscanf(buf, "%d%d", &m, &n);
	for (k = 0, r = 0; r < m; r++) {
		fgets(map[r], 503, stdin);
		for (c = 0; c < n; c++) {
			if (map[r][c] != '.') k++, sr[c]++, sc[r]++;
		}
	}
	ans = 0;
	do t = calc(), ans += t;
	while (t && k);
	printf("%d\n", ans);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 252003
map:
	.zero	252003
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	rpos
	.bss
	.align 32
	.type	rpos, @object
	.size	rpos, 104
rpos:
	.zero	104
	.globl	cpos
	.align 32
	.type	cpos, @object
	.size	cpos, 104
cpos:
	.zero	104
	.globl	sr
	.align 32
	.type	sr, @object
	.size	sr, 2004
sr:
	.zero	2004
	.globl	sc
	.align 32
	.type	sc, @object
	.size	sc, 2004
sc:
	.zero	2004
	.text
	.globl	calc
	.type	calc, @function
calc:
.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
	movl	$0, -8(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L2
.L17:
	movl	$0, -24(%rbp)
	jmp	.L3
.L16:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	testl	%eax, %eax
	je	.L4
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-28(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	jne	.L4
	movl	$104, %edx
	movl	$-1, %esi
	leaq	rpos(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -20(%rbp)
	jmp	.L5
.L15:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L6
	cmpl	$1, -20(%rbp)
	jle	.L19
.L6:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L8
	cmpl	$2, -20(%rbp)
	jg	.L20
.L8:
	movl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
.L14:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+mv(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	js	.L7
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L7
	cmpl	$0, -12(%rbp)
	js	.L7
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L7
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	je	.L21
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	subl	$65, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L11
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$2, -8(%rbp)
	movl	k(%rip), %eax
	subl	$2, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	testl	%eax, %eax
	jne	.L22
	movl	-8(%rbp), %eax
	jmp	.L13
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rpos(%rip), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	cpos(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L22
.L21:
	nop
	jmp	.L14
.L19:
	nop
	jmp	.L7
.L20:
	nop
	jmp	.L7
.L22:
	nop
.L7:
	addl	$1, -20(%rbp)
.L5:
	cmpl	$3, -20(%rbp)
	jle	.L15
.L4:
	addl	$1, -24(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	addl	$1, -28(%rbp)
.L2:
	movl	m(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L17
	movl	-8(%rbp), %eax
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-18(%rbp), %rax
	movl	$10, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-18(%rbp), %rax
	leaq	n(%rip), %rdx
	movq	%rdx, %rcx
	leaq	m(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -32(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L24
.L28:
	movq	stdin(%rip), %rax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$503, %rdx, %rdx
	leaq	map(%rip), %rcx
	addq	%rdx, %rcx
	movq	%rax, %rdx
	movl	$503, %esi
	movq	%rcx, %rdi
	call	fgets@PLT
	movl	$0, -36(%rbp)
	jmp	.L25
.L27:
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	je	.L26
	addl	$1, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L26:
	addl	$1, -36(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L27
	addl	$1, -40(%rbp)
.L24:
	movl	m(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L28
	movl	$0, -28(%rbp)
.L30:
	movl	$0, %eax
	call	calc
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	addl	%eax, -28(%rbp)
	cmpl	$0, -24(%rbp)
	je	.L29
	cmpl	$0, -32(%rbp)
	jne	.L30
.L29:
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	m
	.bss
	.align 4
	.type	m, @object
	.size	m, 4
m:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 252003
map:
	.zero	252003
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	1
	.long	0
	.long	0
	.long	1
	.long	0
	.long	-1
	.globl	rpos
	.bss
	.align 32
	.type	rpos, @object
	.size	rpos, 104
rpos:
	.zero	104
	.globl	cpos
	.align 32
	.type	cpos, @object
	.size	cpos, 104
cpos:
	.zero	104
	.globl	sr
	.align 32
	.type	sr, @object
	.size	sr, 2004
sr:
	.zero	2004
	.globl	sc
	.align 32
	.type	sc, @object
	.size	sc, 2004
sc:
	.zero	2004
	.text
	.globl	calc
	.type	calc, @function
calc:
.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
	movl	$0, -8(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L2
.L17:
	movl	$0, -24(%rbp)
	jmp	.L3
.L16:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	testl	%eax, %eax
	je	.L4
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-28(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	jne	.L4
	movl	$104, %edx
	movl	$-1, %esi
	leaq	rpos(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -20(%rbp)
	jmp	.L5
.L15:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L6
	cmpl	$1, -20(%rbp)
	jle	.L19
.L6:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L8
	cmpl	$2, -20(%rbp)
	jg	.L20
.L8:
	movl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
.L14:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -16(%rbp)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+mv(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	js	.L7
	movl	m(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L7
	cmpl	$0, -12(%rbp)
	js	.L7
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L7
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	je	.L21
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	subl	$65, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	js	.L11
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	rpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -16(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	cpos(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$46, (%rax)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$2, -8(%rbp)
	movl	k(%rip), %eax
	subl	$2, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	testl	%eax, %eax
	jne	.L22
	movl	-8(%rbp), %eax
	jmp	.L13
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	rpos(%rip), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	cpos(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L22
.L21:
	nop
	jmp	.L14
.L19:
	nop
	jmp	.L7
.L20:
	nop
	jmp	.L7
.L22:
	nop
.L7:
	addl	$1, -20(%rbp)
.L5:
	cmpl	$3, -20(%rbp)
	jle	.L15
.L4:
	addl	$1, -24(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L16
	addl	$1, -28(%rbp)
.L2:
	movl	m(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L17
	movl	-8(%rbp), %eax
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rdx
	leaq	-18(%rbp), %rax
	movl	$10, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-18(%rbp), %rax
	leaq	n(%rip), %rdx
	movq	%rdx, %rcx
	leaq	m(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -32(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L24
.L28:
	movq	stdin(%rip), %rax
	movl	-40(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$503, %rdx, %rdx
	leaq	map(%rip), %rcx
	addq	%rdx, %rcx
	movq	%rax, %rdx
	movl	$503, %esi
	movq	%rcx, %rdi
	call	fgets@PLT
	movl	$0, -36(%rbp)
	jmp	.L25
.L27:
	movl	-36(%rbp), %eax
	movslq	%eax, %rdx
	movl	-40(%rbp), %eax
	cltq
	imulq	$503, %rax, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$46, %al
	je	.L26
	addl	$1, -32(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sr(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L26:
	addl	$1, -36(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L27
	addl	$1, -40(%rbp)
.L24:
	movl	m(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L28
	movl	$0, -28(%rbp)
.L30:
	movl	$0, %eax
	call	calc
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	addl	%eax, -28(%rbp)
	cmpl	$0, -24(%rbp)
	je	.L29
	cmpl	$0, -32(%rbp)
	jne	.L30
.L29:
	movl	-28(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
