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

```c
// AOJ 2221 KULASIS
// 2018.3.14 bal4u

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

int N;
int map[5][5];
int dp[5][256];
int p[5] = { 0,0,60,70,80 };

int main()
{
	int i, j, k, r, c, s, ss, ans;

	scanf("%d", &N);
	while (N--) {
		memset(dp, 0, sizeof(dp));
		for (r = 0; r < 5; r++) for (c = 0; c < 5; c++) scanf("%d", &map[r][c]);
		for (i = 0; i < 256; i++) {
			dp[0][i] = 0;
			for (c = 0; c < 5; c++) if (map[0][c]) {
				s = map[0][c];
				if (c > 0) s += i >> ((c-1)<<1) & 3;
				if (c < 4) s += i >> ( c   <<1) & 3;
				if (s > 0) { s %= 4; if (s == 0) s = 4; }
				dp[0][i] += p[s];
			}
		}

		for (i = 1; i < 4; i++) for (j = 0; j < 256; j++) {
			for (k = 0; k < 256; k++) {
				ss = dp[i - 1][j];
				for (c = 0; c < 5; c++) if (map[i][c]) {
					s = map[i][c];
					if (c > 0) s += ((j >> ((c - 1) << 1)) & 3) + ((k >> ((c - 1) << 1)) & 3);
					if (c < 4) s += ((j >> (c << 1)) & 3) + ((k >> (c << 1)) & 3);
					if (s > 0) { s %= 4; if (s == 0) s = 4; }
					ss += p[s];
				}
				if (ss > dp[i][k]) dp[i][k] = ss;
			}
		}

		ans = 0;
		for (i = 0; i < 256; i++) {
			ss = dp[3][i];
			for (c = 0; c < 5; c++) if (map[4][c]) {
				s = map[4][c];
				if (c > 0) s += (i >> ((c-1)<<1)) & 3;
				if (c < 4) s += (i >> (c<<1)) & 3;
				if (s > 0) { s %= 4; if (s == 0) s = 4; }
				ss += p[s];
			}
			if (ss > ans) ans = ss;
		}
		printf("%d\n", ans);
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 100
map:
	.zero	100
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 5120
dp:
	.zero	5120
	.globl	p
	.data
	.align 16
	.type	p, @object
	.size	p, 20
p:
	.long	0
	.long	0
	.long	60
	.long	70
	.long	80
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L37:
	movl	$5120, %edx
	movl	$0, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -20(%rbp)
	jmp	.L3
.L6:
	movl	$0, -16(%rbp)
	jmp	.L4
.L5:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L4:
	cmpl	$4, -16(%rbp)
	jle	.L5
	addl	$1, -20(%rbp)
.L3:
	cmpl	$4, -20(%rbp)
	jle	.L6
	movl	$0, -32(%rbp)
	jmp	.L7
.L14:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -16(%rbp)
	jmp	.L8
.L13:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L9
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L10
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L10:
	cmpl	$3, -16(%rbp)
	jg	.L11
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L11:
	cmpl	$0, -12(%rbp)
	jle	.L12
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L12
	movl	$4, -12(%rbp)
.L12:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	addl	$1, -16(%rbp)
.L8:
	cmpl	$4, -16(%rbp)
	jle	.L13
	addl	$1, -32(%rbp)
.L7:
	cmpl	$255, -32(%rbp)
	jle	.L14
	movl	$1, -32(%rbp)
	jmp	.L15
.L27:
	movl	$0, -28(%rbp)
	jmp	.L16
.L26:
	movl	$0, -24(%rbp)
	jmp	.L17
.L25:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	salq	$8, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L18
.L23:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L20
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-28(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-24(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%esi, %eax
	addl	%eax, -12(%rbp)
.L20:
	cmpl	$3, -16(%rbp)
	jg	.L21
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-28(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-24(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%esi, %eax
	addl	%eax, -12(%rbp)
.L21:
	cmpl	$0, -12(%rbp)
	jle	.L22
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L22
	movl	$4, -12(%rbp)
.L22:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
.L19:
	addl	$1, -16(%rbp)
.L18:
	cmpl	$4, -16(%rbp)
	jle	.L23
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L24
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L24:
	addl	$1, -24(%rbp)
.L17:
	cmpl	$255, -24(%rbp)
	jle	.L25
	addl	$1, -28(%rbp)
.L16:
	cmpl	$255, -28(%rbp)
	jle	.L26
	addl	$1, -32(%rbp)
.L15:
	cmpl	$3, -32(%rbp)
	jle	.L27
	movl	$0, -4(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L28
.L36:
	movl	-32(%rbp), %eax
	cltq
	addq	$768, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L29
.L34:
	movl	-16(%rbp), %eax
	cltq
	addq	$20, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L30
	movl	-16(%rbp), %eax
	cltq
	addq	$20, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L31
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L31:
	cmpl	$3, -16(%rbp)
	jg	.L32
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L32:
	cmpl	$0, -12(%rbp)
	jle	.L33
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L33
	movl	$4, -12(%rbp)
.L33:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
.L30:
	addl	$1, -16(%rbp)
.L29:
	cmpl	$4, -16(%rbp)
	jle	.L34
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L35
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
.L35:
	addl	$1, -32(%rbp)
.L28:
	cmpl	$255, -32(%rbp)
	jle	.L36
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L37
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %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
	leaq	dp(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	movq	%rbx, 40(%rsp)
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	je	.L114
	leaq	p(%rip), %r15
.L2:
	movq	40(%rsp), %rdi
	xorl	%eax, %eax
	movl	$640, %ecx
	xorl	%ebp, %ebp
	rep stosq
	leaq	map(%rip), %rax
	movq	%rax, 32(%rsp)
	movq	%rax, %rbx
	movq	%rax, %r13
.L3:
	leaq	20(%rbx), %r12
.L4:
	movq	%rbx, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r12
	jne	.L4
	addq	$5, %rbp
	cmpq	$25, %rbp
	je	.L5
	movq	%r12, %rbx
	jmp	.L3
.L5:
	movq	40(%rsp), %rdi
	xorl	%eax, %eax
	movl	$128, %ecx
	movl	0(%r13), %r11d
	movl	4+map(%rip), %r10d
	movl	8+map(%rip), %r9d
	movl	$4, %ebx
	rep stosq
	leaq	dp(%rip), %rax
	movl	12+map(%rip), %r8d
	movl	16+map(%rip), %esi
	movq	%rax, 40(%rsp)
	movq	%rax, %rdi
.L29:
	xorl	%eax, %eax
	testl	%r11d, %r11d
	je	.L6
	movl	%ecx, %eax
	andl	$3, %eax
	addl	%r11d, %eax
	testl	%eax, %eax
	jle	.L8
	andl	$3, %eax
	cmove	%ebx, %eax
.L8:
	cltq
	movl	(%r15,%rax,4), %eax
	movl	%eax, (%rdi)
.L6:
	testl	%r10d, %r10d
	je	.L10
	movl	%ecx, %ebp
	movl	%ecx, %edx
	andl	$3, %ebp
	sarl	$2, %edx
	addl	%r10d, %ebp
	andl	$3, %edx
	addl	%ebp, %edx
	testl	%edx, %edx
	jle	.L11
	andl	$3, %edx
	cmove	%ebx, %edx
.L11:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L10:
	testl	%r9d, %r9d
	je	.L15
	movl	%ecx, %ebp
	movl	%ecx, %edx
	sarl	$2, %ebp
	sarl	$4, %edx
	andl	$3, %ebp
	andl	$3, %edx
	addl	%r9d, %ebp
	addl	%ebp, %edx
	testl	%edx, %edx
	jle	.L16
	andl	$3, %edx
	cmove	%ebx, %edx
.L16:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L15:
	testl	%r8d, %r8d
	je	.L20
	movl	%ecx, %ebp
	movl	%ecx, %edx
	sarl	$4, %ebp
	sarl	$6, %edx
	andl	$3, %ebp
	addl	%r8d, %ebp
	addl	%ebp, %edx
	testl	%edx, %edx
	jle	.L21
	andl	$3, %edx
	cmove	%ebx, %edx
.L21:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L20:
	testl	%esi, %esi
	je	.L25
	movl	%ecx, %edx
	sarl	$6, %edx
	addl	%esi, %edx
	testl	%edx, %edx
	jle	.L26
	andl	$3, %edx
	cmove	%ebx, %edx
.L26:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L25:
	addl	$1, %ecx
	addq	$4, %rdi
	cmpl	$256, %ecx
	jne	.L29
	leaq	1024+dp(%rip), %r14
	movl	$4, %r13d
.L30:
	movq	32(%rsp), %rax
	movl	$0, 28(%rsp)
	movl	20(%rax), %r10d
	movl	24(%rax), %r9d
	movl	28(%rax), %r8d
	movl	32(%rax), %ebp
	movl	36(%rax), %r12d
	leaq	-1024(%r14), %rax
	movq	%rax, 8(%rsp)
.L58:
	movl	28(%rsp), %eax
	movl	%eax, %ebx
	movl	%eax, %r11d
	movl	%eax, %esi
	andl	$3, %eax
	movl	%eax, 24(%rsp)
	sarl	$6, %esi
	sarl	$2, %ebx
	sarl	$4, %r11d
	movl	%esi, 20(%rsp)
	andl	$3, %ebx
	xorl	%esi, %esi
	andl	$3, %r11d
	.p2align 4,,10
	.p2align 3
.L55:
	movq	8(%rsp), %rdx
	movl	%esi, %eax
	movl	(%rdx), %edx
	testl	%r10d, %r10d
	je	.L31
	movl	%esi, %ecx
	andl	$3, %ecx
	addl	24(%rsp), %ecx
	addl	%r10d, %ecx
	testl	%ecx, %ecx
	jle	.L33
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L33:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L31:
	testl	%r9d, %r9d
	je	.L35
	movl	%eax, %ecx
	movl	%eax, %edi
	sarl	$2, %ecx
	andl	$3, %edi
	addl	24(%rsp), %edi
	andl	$3, %ecx
	addl	%r9d, %edi
	addl	%ebx, %ecx
	addl	%edi, %ecx
	testl	%ecx, %ecx
	jle	.L36
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L36:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L35:
	testl	%r8d, %r8d
	je	.L40
	movl	%eax, %edi
	movl	%eax, %ecx
	sarl	$2, %edi
	sarl	$4, %ecx
	andl	$3, %edi
	andl	$3, %ecx
	addl	%ebx, %edi
	addl	%r11d, %ecx
	addl	%r8d, %edi
	addl	%edi, %ecx
	testl	%ecx, %ecx
	jle	.L41
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L41:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L40:
	testl	%ebp, %ebp
	je	.L45
	movl	%eax, %edi
	movl	%eax, %ecx
	sarl	$4, %edi
	sarl	$6, %ecx
	addl	20(%rsp), %ecx
	andl	$3, %edi
	addl	%r11d, %edi
	addl	%ebp, %edi
	addl	%edi, %ecx
	testl	%ecx, %ecx
	jle	.L46
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L46:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L45:
	testl	%r12d, %r12d
	je	.L50
	sarl	$6, %eax
	addl	20(%rsp), %eax
	addl	%r12d, %eax
	testl	%eax, %eax
	jle	.L51
	andl	$3, %eax
	cmove	%r13d, %eax
.L51:
	cltq
	addl	(%r15,%rax,4), %edx
.L50:
	cmpl	%edx, (%r14,%rsi,4)
	jge	.L54
	movl	%edx, (%r14,%rsi,4)
.L54:
	addq	$1, %rsi
	cmpq	$256, %rsi
	jne	.L55
	addl	$1, 28(%rsp)
	movl	28(%rsp), %eax
	addq	$4, 8(%rsp)
	cmpl	$256, %eax
	jne	.L58
	addq	$20, 32(%rsp)
	movq	32(%rsp), %rax
	leaq	60+map(%rip), %rbx
	addq	$1024, %r14
	cmpq	%rbx, %rax
	jne	.L30
	movl	80+map(%rip), %ebx
	movl	84+map(%rip), %r11d
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	movl	88+map(%rip), %r10d
	movl	96+map(%rip), %edi
	movl	$4, %esi
	movl	92+map(%rip), %r9d
.L82:
	leaq	3072+dp(%rip), %rdx
	movl	%ecx, %eax
	movl	(%rdx,%rcx,4), %edx
	testl	%ebx, %ebx
	je	.L59
	movl	%ecx, %ebp
	andl	$3, %ebp
	addl	%ebx, %ebp
	testl	%ebp, %ebp
	jle	.L61
	andl	$3, %ebp
	cmove	%esi, %ebp
.L61:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L59:
	testl	%r11d, %r11d
	je	.L63
	movl	%eax, %r12d
	movl	%eax, %ebp
	andl	$3, %r12d
	sarl	$2, %ebp
	addl	%r11d, %r12d
	andl	$3, %ebp
	addl	%r12d, %ebp
	testl	%ebp, %ebp
	jle	.L64
	andl	$3, %ebp
	cmove	%esi, %ebp
.L64:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L63:
	testl	%r10d, %r10d
	je	.L68
	movl	%eax, %r12d
	movl	%eax, %ebp
	sarl	$2, %r12d
	sarl	$4, %ebp
	andl	$3, %r12d
	andl	$3, %ebp
	addl	%r10d, %r12d
	addl	%r12d, %ebp
	testl	%ebp, %ebp
	jle	.L69
	andl	$3, %ebp
	cmove	%esi, %ebp
.L69:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L68:
	testl	%r9d, %r9d
	je	.L73
	movl	%eax, %r12d
	movl	%eax, %ebp
	sarl	$4, %r12d
	sarl	$6, %ebp
	andl	$3, %r12d
	addl	%r9d, %r12d
	addl	%r12d, %ebp
	testl	%ebp, %ebp
	jle	.L74
	andl	$3, %ebp
	cmove	%esi, %ebp
.L74:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L73:
	testl	%edi, %edi
	je	.L78
	sarl	$6, %eax
	addl	%edi, %eax
	testl	%eax, %eax
	jle	.L79
	andl	$3, %eax
	cmove	%esi, %eax
.L79:
	cltq
	addl	(%r15,%rax,4), %edx
.L78:
	cmpl	%edx, %r8d
	cmovl	%edx, %r8d
	addq	$1, %rcx
	cmpq	$256, %rcx
	jne	.L82
	movl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L2
.L114:
	addq	$56, %rsp
	.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
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	p
	.data
	.align 16
	.type	p, @object
	.size	p, 20
p:
	.long	0
	.long	0
	.long	60
	.long	70
	.long	80
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 5120
dp:
	.zero	5120
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 100
map:
	.zero	100
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	N(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %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
	leaq	dp(%rip), %rbx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	movq	%rbx, 40(%rsp)
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	je	.L114
	leaq	p(%rip), %r15
.L2:
	movq	40(%rsp), %rdi
	xorl	%eax, %eax
	movl	$640, %ecx
	xorl	%ebp, %ebp
	rep stosq
	leaq	map(%rip), %rax
	movq	%rax, 32(%rsp)
	movq	%rax, %rbx
	movq	%rax, %r13
.L3:
	leaq	20(%rbx), %r12
.L4:
	movq	%rbx, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r12
	jne	.L4
	addq	$5, %rbp
	cmpq	$25, %rbp
	je	.L5
	movq	%r12, %rbx
	jmp	.L3
.L5:
	movq	40(%rsp), %rdi
	xorl	%eax, %eax
	movl	$128, %ecx
	movl	0(%r13), %r11d
	movl	4+map(%rip), %r10d
	movl	8+map(%rip), %r9d
	movl	$4, %ebx
	rep stosq
	leaq	dp(%rip), %rax
	movl	12+map(%rip), %r8d
	movl	16+map(%rip), %esi
	movq	%rax, 40(%rsp)
	movq	%rax, %rdi
.L29:
	xorl	%eax, %eax
	testl	%r11d, %r11d
	je	.L6
	movl	%ecx, %eax
	andl	$3, %eax
	addl	%r11d, %eax
	testl	%eax, %eax
	jle	.L8
	andl	$3, %eax
	cmove	%ebx, %eax
.L8:
	cltq
	movl	(%r15,%rax,4), %eax
	movl	%eax, (%rdi)
.L6:
	testl	%r10d, %r10d
	je	.L10
	movl	%ecx, %ebp
	movl	%ecx, %edx
	andl	$3, %ebp
	sarl	$2, %edx
	addl	%r10d, %ebp
	andl	$3, %edx
	addl	%ebp, %edx
	testl	%edx, %edx
	jle	.L11
	andl	$3, %edx
	cmove	%ebx, %edx
.L11:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L10:
	testl	%r9d, %r9d
	je	.L15
	movl	%ecx, %ebp
	movl	%ecx, %edx
	sarl	$2, %ebp
	sarl	$4, %edx
	andl	$3, %ebp
	andl	$3, %edx
	addl	%r9d, %ebp
	addl	%ebp, %edx
	testl	%edx, %edx
	jle	.L16
	andl	$3, %edx
	cmove	%ebx, %edx
.L16:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L15:
	testl	%r8d, %r8d
	je	.L20
	movl	%ecx, %ebp
	movl	%ecx, %edx
	sarl	$4, %ebp
	sarl	$6, %edx
	andl	$3, %ebp
	addl	%r8d, %ebp
	addl	%ebp, %edx
	testl	%edx, %edx
	jle	.L21
	andl	$3, %edx
	cmove	%ebx, %edx
.L21:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L20:
	testl	%esi, %esi
	je	.L25
	movl	%ecx, %edx
	sarl	$6, %edx
	addl	%esi, %edx
	testl	%edx, %edx
	jle	.L26
	andl	$3, %edx
	cmove	%ebx, %edx
.L26:
	movslq	%edx, %rdx
	addl	(%r15,%rdx,4), %eax
	movl	%eax, (%rdi)
.L25:
	addl	$1, %ecx
	addq	$4, %rdi
	cmpl	$256, %ecx
	jne	.L29
	leaq	1024+dp(%rip), %r14
	movl	$4, %r13d
.L30:
	movq	32(%rsp), %rax
	movl	$0, 28(%rsp)
	movl	20(%rax), %r10d
	movl	24(%rax), %r9d
	movl	28(%rax), %r8d
	movl	32(%rax), %ebp
	movl	36(%rax), %r12d
	leaq	-1024(%r14), %rax
	movq	%rax, 8(%rsp)
.L58:
	movl	28(%rsp), %eax
	movl	%eax, %ebx
	movl	%eax, %r11d
	movl	%eax, %esi
	andl	$3, %eax
	movl	%eax, 24(%rsp)
	sarl	$6, %esi
	sarl	$2, %ebx
	sarl	$4, %r11d
	movl	%esi, 20(%rsp)
	andl	$3, %ebx
	xorl	%esi, %esi
	andl	$3, %r11d
	.p2align 4,,10
	.p2align 3
.L55:
	movq	8(%rsp), %rdx
	movl	%esi, %eax
	movl	(%rdx), %edx
	testl	%r10d, %r10d
	je	.L31
	movl	%esi, %ecx
	andl	$3, %ecx
	addl	24(%rsp), %ecx
	addl	%r10d, %ecx
	testl	%ecx, %ecx
	jle	.L33
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L33:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L31:
	testl	%r9d, %r9d
	je	.L35
	movl	%eax, %ecx
	movl	%eax, %edi
	sarl	$2, %ecx
	andl	$3, %edi
	addl	24(%rsp), %edi
	andl	$3, %ecx
	addl	%r9d, %edi
	addl	%ebx, %ecx
	addl	%edi, %ecx
	testl	%ecx, %ecx
	jle	.L36
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L36:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L35:
	testl	%r8d, %r8d
	je	.L40
	movl	%eax, %edi
	movl	%eax, %ecx
	sarl	$2, %edi
	sarl	$4, %ecx
	andl	$3, %edi
	andl	$3, %ecx
	addl	%ebx, %edi
	addl	%r11d, %ecx
	addl	%r8d, %edi
	addl	%edi, %ecx
	testl	%ecx, %ecx
	jle	.L41
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L41:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L40:
	testl	%ebp, %ebp
	je	.L45
	movl	%eax, %edi
	movl	%eax, %ecx
	sarl	$4, %edi
	sarl	$6, %ecx
	addl	20(%rsp), %ecx
	andl	$3, %edi
	addl	%r11d, %edi
	addl	%ebp, %edi
	addl	%edi, %ecx
	testl	%ecx, %ecx
	jle	.L46
	andl	$3, %ecx
	cmove	%r13d, %ecx
.L46:
	movslq	%ecx, %rcx
	addl	(%r15,%rcx,4), %edx
.L45:
	testl	%r12d, %r12d
	je	.L50
	sarl	$6, %eax
	addl	20(%rsp), %eax
	addl	%r12d, %eax
	testl	%eax, %eax
	jle	.L51
	andl	$3, %eax
	cmove	%r13d, %eax
.L51:
	cltq
	addl	(%r15,%rax,4), %edx
.L50:
	cmpl	%edx, (%r14,%rsi,4)
	jge	.L54
	movl	%edx, (%r14,%rsi,4)
.L54:
	addq	$1, %rsi
	cmpq	$256, %rsi
	jne	.L55
	addl	$1, 28(%rsp)
	movl	28(%rsp), %eax
	addq	$4, 8(%rsp)
	cmpl	$256, %eax
	jne	.L58
	addq	$20, 32(%rsp)
	movq	32(%rsp), %rax
	leaq	60+map(%rip), %rbx
	addq	$1024, %r14
	cmpq	%rbx, %rax
	jne	.L30
	movl	80+map(%rip), %ebx
	movl	84+map(%rip), %r11d
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	movl	88+map(%rip), %r10d
	movl	96+map(%rip), %edi
	movl	$4, %esi
	movl	92+map(%rip), %r9d
.L82:
	leaq	3072+dp(%rip), %rdx
	movl	%ecx, %eax
	movl	(%rdx,%rcx,4), %edx
	testl	%ebx, %ebx
	je	.L59
	movl	%ecx, %ebp
	andl	$3, %ebp
	addl	%ebx, %ebp
	testl	%ebp, %ebp
	jle	.L61
	andl	$3, %ebp
	cmove	%esi, %ebp
.L61:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L59:
	testl	%r11d, %r11d
	je	.L63
	movl	%eax, %r12d
	movl	%eax, %ebp
	andl	$3, %r12d
	sarl	$2, %ebp
	addl	%r11d, %r12d
	andl	$3, %ebp
	addl	%r12d, %ebp
	testl	%ebp, %ebp
	jle	.L64
	andl	$3, %ebp
	cmove	%esi, %ebp
.L64:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L63:
	testl	%r10d, %r10d
	je	.L68
	movl	%eax, %r12d
	movl	%eax, %ebp
	sarl	$2, %r12d
	sarl	$4, %ebp
	andl	$3, %r12d
	andl	$3, %ebp
	addl	%r10d, %r12d
	addl	%r12d, %ebp
	testl	%ebp, %ebp
	jle	.L69
	andl	$3, %ebp
	cmove	%esi, %ebp
.L69:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L68:
	testl	%r9d, %r9d
	je	.L73
	movl	%eax, %r12d
	movl	%eax, %ebp
	sarl	$4, %r12d
	sarl	$6, %ebp
	andl	$3, %r12d
	addl	%r9d, %r12d
	addl	%r12d, %ebp
	testl	%ebp, %ebp
	jle	.L74
	andl	$3, %ebp
	cmove	%esi, %ebp
.L74:
	movslq	%ebp, %rbp
	addl	(%r15,%rbp,4), %edx
.L73:
	testl	%edi, %edi
	je	.L78
	sarl	$6, %eax
	addl	%edi, %eax
	testl	%eax, %eax
	jle	.L79
	andl	$3, %eax
	cmove	%esi, %eax
.L79:
	cltq
	addl	(%r15,%rax,4), %edx
.L78:
	cmpl	%edx, %r8d
	cmovl	%edx, %r8d
	addq	$1, %rcx
	cmpq	$256, %rcx
	jne	.L82
	movl	%r8d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L2
.L114:
	addq	$56, %rsp
	.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
	.cfi_endproc
.LFE51:
	.size	main, .-main
	.globl	p
	.data
	.align 16
	.type	p, @object
	.size	p, 20
p:
	.long	0
	.long	0
	.long	60
	.long	70
	.long	80
	.globl	dp
	.bss
	.align 32
	.type	dp, @object
	.size	dp, 5120
dp:
	.zero	5120
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 100
map:
	.zero	100
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.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 2221 KULASIS
// 2018.3.14 bal4u

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

int N;
int map[5][5];
int dp[5][256];
int p[5] = { 0,0,60,70,80 };

int main()
{
	int i, j, k, r, c, s, ss, ans;

	scanf("%d", &N);
	while (N--) {
		memset(dp, 0, sizeof(dp));
		for (r = 0; r < 5; r++) for (c = 0; c < 5; c++) scanf("%d", &map[r][c]);
		for (i = 0; i < 256; i++) {
			dp[0][i] = 0;
			for (c = 0; c < 5; c++) if (map[0][c]) {
				s = map[0][c];
				if (c > 0) s += i >> ((c-1)<<1) & 3;
				if (c < 4) s += i >> ( c   <<1) & 3;
				if (s > 0) { s %= 4; if (s == 0) s = 4; }
				dp[0][i] += p[s];
			}
		}

		for (i = 1; i < 4; i++) for (j = 0; j < 256; j++) {
			for (k = 0; k < 256; k++) {
				ss = dp[i - 1][j];
				for (c = 0; c < 5; c++) if (map[i][c]) {
					s = map[i][c];
					if (c > 0) s += ((j >> ((c - 1) << 1)) & 3) + ((k >> ((c - 1) << 1)) & 3);
					if (c < 4) s += ((j >> (c << 1)) & 3) + ((k >> (c << 1)) & 3);
					if (s > 0) { s %= 4; if (s == 0) s = 4; }
					ss += p[s];
				}
				if (ss > dp[i][k]) dp[i][k] = ss;
			}
		}

		ans = 0;
		for (i = 0; i < 256; i++) {
			ss = dp[3][i];
			for (c = 0; c < 5; c++) if (map[4][c]) {
				s = map[4][c];
				if (c > 0) s += (i >> ((c-1)<<1)) & 3;
				if (c < 4) s += (i >> (c<<1)) & 3;
				if (s > 0) { s %= 4; if (s == 0) s = 4; }
				ss += p[s];
			}
			if (ss > ans) ans = ss;
		}
		printf("%d\n", ans);
	}
	return 0;
}

5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 0 1 0
0 0 1 1 1
1 1 1 1 1

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 4
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 0 1 0
0 0 1 1 1
1 1 1 1 1

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 4
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 0 1 0
0 0 1 0 1
1 1 1 1 1

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 4
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 0 1 0
0 0 1 0 1
1 1 1 1 1

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 6
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 0 1 0
0 0 1 0 1
1 1 1 1 1

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

2 3 4 3 4
3 4 3 4 3
4 3 4 3 6
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 1 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 1 1 0
0 0 1 1 1
1 1 1 1 1

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 4
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 1 1 0
0 0 1 0 1
1 1 1 1 1

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 6
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 1 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 1 1 0
0 0 1 1 1
1 1 1 1 1

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 5
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 1 1 0
0 0 1 0 1
1 1 1 1 1

0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 6
3 4 3 4 3
4 3 4 3 4

3 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0
 5

1 1 0 3 3
1 1 0 3 3
0 0 0 0 0
2 2 0 4 4
2 2 0 4 4

1 1 1 0 0
1 1 1 1 0
1 0 1 1 0
0 0 1 1 1
1 1 1 1 1

0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 0 0 0

4 3 4 3 4
3 4 3 4 3
4 3 4 3 4
3 4 3 4 3
4 3 4 3 4

2 2 2 2 2
0 0 0 2 0
2 2 0 2 0
2 2 0 2 0
0 0 0 2 0

1280
1350
0
1920
1020
 1280
1350
80
1920
1020
 1280
1270
80
1920
1020
 1280
1270
80
1940
1020
 1280
1270
80
1960
1020
 1350
1420
0
1920
1020
 1280
1340
80
1940
1020
 1350
1420
0
1930
1020
 1280
1340
80
1940
1010
 1280
1420
80
1920
1020

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

```c
// AOJ 2221 KULASIS
// 2018.3.14 bal4u

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

int N;
int map[5][5];
int dp[5][256];
int p[5] = { 0,0,60,70,80 };

int main()
{
	int i, j, k, r, c, s, ss, ans;

	scanf("%d", &N);
	while (N--) {
		memset(dp, 0, sizeof(dp));
		for (r = 0; r < 5; r++) for (c = 0; c < 5; c++) scanf("%d", &map[r][c]);
		for (i = 0; i < 256; i++) {
			dp[0][i] = 0;
			for (c = 0; c < 5; c++) if (map[0][c]) {
				s = map[0][c];
				if (c > 0) s += i >> ((c-1)<<1) & 3;
				if (c < 4) s += i >> ( c   <<1) & 3;
				if (s > 0) { s %= 4; if (s == 0) s = 4; }
				dp[0][i] += p[s];
			}
		}

		for (i = 1; i < 4; i++) for (j = 0; j < 256; j++) {
			for (k = 0; k < 256; k++) {
				ss = dp[i - 1][j];
				for (c = 0; c < 5; c++) if (map[i][c]) {
					s = map[i][c];
					if (c > 0) s += ((j >> ((c - 1) << 1)) & 3) + ((k >> ((c - 1) << 1)) & 3);
					if (c < 4) s += ((j >> (c << 1)) & 3) + ((k >> (c << 1)) & 3);
					if (s > 0) { s %= 4; if (s == 0) s = 4; }
					ss += p[s];
				}
				if (ss > dp[i][k]) dp[i][k] = ss;
			}
		}

		ans = 0;
		for (i = 0; i < 256; i++) {
			ss = dp[3][i];
			for (c = 0; c < 5; c++) if (map[4][c]) {
				s = map[4][c];
				if (c > 0) s += (i >> ((c-1)<<1)) & 3;
				if (c < 4) s += (i >> (c<<1)) & 3;
				if (s > 0) { s %= 4; if (s == 0) s = 4; }
				ss += p[s];
			}
			if (ss > ans) ans = ss;
		}
		printf("%d\n", ans);
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 100
map:
	.zero	100
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 5120
dp:
	.zero	5120
	.globl	p
	.data
	.align 16
	.type	p, @object
	.size	p, 20
p:
	.long	0
	.long	0
	.long	60
	.long	70
	.long	80
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L37:
	movl	$5120, %edx
	movl	$0, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -20(%rbp)
	jmp	.L3
.L6:
	movl	$0, -16(%rbp)
	jmp	.L4
.L5:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L4:
	cmpl	$4, -16(%rbp)
	jle	.L5
	addl	$1, -20(%rbp)
.L3:
	cmpl	$4, -20(%rbp)
	jle	.L6
	movl	$0, -32(%rbp)
	jmp	.L7
.L14:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -16(%rbp)
	jmp	.L8
.L13:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L9
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L10
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L10:
	cmpl	$3, -16(%rbp)
	jg	.L11
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L11:
	cmpl	$0, -12(%rbp)
	jle	.L12
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L12
	movl	$4, -12(%rbp)
.L12:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	addl	$1, -16(%rbp)
.L8:
	cmpl	$4, -16(%rbp)
	jle	.L13
	addl	$1, -32(%rbp)
.L7:
	cmpl	$255, -32(%rbp)
	jle	.L14
	movl	$1, -32(%rbp)
	jmp	.L15
.L27:
	movl	$0, -28(%rbp)
	jmp	.L16
.L26:
	movl	$0, -24(%rbp)
	jmp	.L17
.L25:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	salq	$8, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L18
.L23:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L20
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-28(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-24(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%esi, %eax
	addl	%eax, -12(%rbp)
.L20:
	cmpl	$3, -16(%rbp)
	jg	.L21
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-28(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-24(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%esi, %eax
	addl	%eax, -12(%rbp)
.L21:
	cmpl	$0, -12(%rbp)
	jle	.L22
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L22
	movl	$4, -12(%rbp)
.L22:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
.L19:
	addl	$1, -16(%rbp)
.L18:
	cmpl	$4, -16(%rbp)
	jle	.L23
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L24
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L24:
	addl	$1, -24(%rbp)
.L17:
	cmpl	$255, -24(%rbp)
	jle	.L25
	addl	$1, -28(%rbp)
.L16:
	cmpl	$255, -28(%rbp)
	jle	.L26
	addl	$1, -32(%rbp)
.L15:
	cmpl	$3, -32(%rbp)
	jle	.L27
	movl	$0, -4(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L28
.L36:
	movl	-32(%rbp), %eax
	cltq
	addq	$768, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L29
.L34:
	movl	-16(%rbp), %eax
	cltq
	addq	$20, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L30
	movl	-16(%rbp), %eax
	cltq
	addq	$20, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L31
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L31:
	cmpl	$3, -16(%rbp)
	jg	.L32
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L32:
	cmpl	$0, -12(%rbp)
	jle	.L33
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L33
	movl	$4, -12(%rbp)
.L33:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
.L30:
	addl	$1, -16(%rbp)
.L29:
	cmpl	$4, -16(%rbp)
	jle	.L34
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L35
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
.L35:
	addl	$1, -32(%rbp)
.L28:
	cmpl	$255, -32(%rbp)
	jle	.L36
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L37
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
val
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 100
map:
	.zero	100
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 5120
dp:
	.zero	5120
	.globl	p
	.data
	.align 16
	.type	p, @object
	.size	p, 20
p:
	.long	0
	.long	0
	.long	60
	.long	70
	.long	80
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L37:
	movl	$5120, %edx
	movl	$0, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -20(%rbp)
	jmp	.L3
.L6:
	movl	$0, -16(%rbp)
	jmp	.L4
.L5:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L4:
	cmpl	$4, -16(%rbp)
	jle	.L5
	addl	$1, -20(%rbp)
.L3:
	cmpl	$4, -20(%rbp)
	jle	.L6
	movl	$0, -32(%rbp)
	jmp	.L7
.L14:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -16(%rbp)
	jmp	.L8
.L13:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L9
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L10
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L10:
	cmpl	$3, -16(%rbp)
	jg	.L11
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L11:
	cmpl	$0, -12(%rbp)
	jle	.L12
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L12
	movl	$4, -12(%rbp)
.L12:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	addl	$1, -16(%rbp)
.L8:
	cmpl	$4, -16(%rbp)
	jle	.L13
	addl	$1, -32(%rbp)
.L7:
	cmpl	$255, -32(%rbp)
	jle	.L14
	movl	$1, -32(%rbp)
	jmp	.L15
.L27:
	movl	$0, -28(%rbp)
	jmp	.L16
.L26:
	movl	$0, -24(%rbp)
	jmp	.L17
.L25:
	movl	-32(%rbp), %eax
	leal	-1(%rax), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	salq	$8, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L18
.L23:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L19
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L20
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-28(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-24(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%esi, %eax
	addl	%eax, -12(%rbp)
.L20:
	cmpl	$3, -16(%rbp)
	jg	.L21
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-28(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-24(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%esi, %eax
	addl	%eax, -12(%rbp)
.L21:
	cmpl	$0, -12(%rbp)
	jle	.L22
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L22
	movl	$4, -12(%rbp)
.L22:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
.L19:
	addl	$1, -16(%rbp)
.L18:
	cmpl	$4, -16(%rbp)
	jle	.L23
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L24
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
.L24:
	addl	$1, -24(%rbp)
.L17:
	cmpl	$255, -24(%rbp)
	jle	.L25
	addl	$1, -28(%rbp)
.L16:
	cmpl	$255, -28(%rbp)
	jle	.L26
	addl	$1, -32(%rbp)
.L15:
	cmpl	$3, -32(%rbp)
	jle	.L27
	movl	$0, -4(%rbp)
	movl	$0, -32(%rbp)
	jmp	.L28
.L36:
	movl	-32(%rbp), %eax
	cltq
	addq	$768, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L29
.L34:
	movl	-16(%rbp), %eax
	cltq
	addq	$20, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L30
	movl	-16(%rbp), %eax
	cltq
	addq	$20, %rax
	leaq	0(,%rax,4), %rdx
	leaq	map(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -16(%rbp)
	jle	.L31
	movl	-16(%rbp), %eax
	subl	$1, %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L31:
	cmpl	$3, -16(%rbp)
	jg	.L32
	movl	-16(%rbp), %eax
	addl	%eax, %eax
	movl	-32(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$3, %eax
	addl	%eax, -12(%rbp)
.L32:
	cmpl	$0, -12(%rbp)
	jle	.L33
	movl	-12(%rbp), %eax
	cltd
	shrl	$30, %edx
	addl	%edx, %eax
	andl	$3, %eax
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	cmpl	$0, -12(%rbp)
	jne	.L33
	movl	$4, -12(%rbp)
.L33:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	p(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -8(%rbp)
.L30:
	addl	$1, -16(%rbp)
.L29:
	cmpl	$4, -16(%rbp)
	jle	.L34
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L35
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
.L35:
	addl	$1, -32(%rbp)
.L28:
	cmpl	$255, -32(%rbp)
	jle	.L36
	movl	-4(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	movl	N(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, N(%rip)
	testl	%eax, %eax
	jne	.L37
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
