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

```c
// AOJ 1290: Traveling Cube
// 2017.10.20 bal4u@uu

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

typedef struct { char r, c, d[3], n; int s; } Q;
Q q[100000]; int top, end;

#define RED     1		// top  r
#define MAGENTA 2		// south  m
#define BLUE    3		// east  b
#define YELLOW  4		// west  y
#define GREEN   5		// north  g
#define CYAN    6		// bottom c
#define WHITE   7		// w
#define BLACK   8       // k

char map[32][32];
char mk[32][32][6][6][6];
char seq[7];
int mv[4][2] =  {{-1,0},{0,1},{1,0},{0,-1}};
int rot[4][3] = {{2,6,3},{4,2,1},{5,1,3},{3,2,6}};
int tr['z'];

int main()
{
	int w, d, i, r, c, n, r2, c2, n2, s, ans;
	char dice[7], dice2[7];

	tr['r'] = RED, tr['m'] = MAGENTA, tr['b'] = BLUE, tr['c'] = CYAN, tr['g'] = GREEN, tr['y'] = YELLOW;
	tr['w'] = WHITE, tr['k'] = BLACK;
	while (scanf("%d%d", &w, &d) && w > 0) {
		memset(mk, 0, sizeof(mk));
		for (r = 0; r < d; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) {
				if (map[r][c] == '#') {
					q[0].r = r, q[0].c = c; map[r][c] = WHITE;
					q[0].d[0] = RED, q[0].d[1] = MAGENTA, q[0].d[2] = BLUE;
					q[0].n = 0, q[0].s = 0;
				} else map[r][c] = tr[map[r][c]];
			}
		}
		scanf("%s", seq); for (i = 0; i < 6; i++) seq[i] = tr[seq[i]];
		ans = -1; top = 0, end = 1;
		while (top < end) {
			r = q[top].r, c = q[top].c, n = q[top].n, s = q[top].s+1;
			memcpy(dice+1, q[top].d, 3); for (i = 4; i <= 6; i++) dice[i] = 7 - dice[7-i]; top++;
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= d || c2 < 0 || c2 >= w || map[r2][c2] == BLACK) continue;
				dice2[1] = dice[rot[i][0]],	dice2[2] = dice[rot[i][1]], dice2[3] = dice[rot[i][2]];
				if (map[r2][c2] == WHITE) n2 = n;
				else {
					if (dice2[1] != seq[n] || dice2[1] != map[r2][c2]) continue;
					if (n == 5) { ans = s; goto done; }
					n2 = n + 1;
				}
				if (mk[r2][c2][dice2[1]][dice2[2]][n]) continue;
				mk[r2][c2][dice2[1]][dice2[2]][n] = 1;
				q[end].r = r2, q[end].c = c2, q[end].n = n2, q[end].s = s;
				memcpy(q[end].d, dice2+1, 3); end++;
			}
		}
		if (ans < 0) puts("unreachable");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 1200000
q:
	.zero	1200000
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	end
	.align 4
	.type	end, @object
	.size	end, 4
end:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1024
map:
	.zero	1024
	.globl	mk
	.align 32
	.type	mk, @object
	.size	mk, 221184
mk:
	.zero	221184
	.globl	seq
	.type	seq, @object
	.size	seq, 7
seq:
	.zero	7
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	0
	.long	1
	.long	1
	.long	0
	.long	0
	.long	-1
	.globl	rot
	.align 32
	.type	rot, @object
	.size	rot, 48
rot:
	.long	2
	.long	6
	.long	3
	.long	4
	.long	2
	.long	1
	.long	5
	.long	1
	.long	3
	.long	3
	.long	2
	.long	6
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 488
tr:
	.zero	488
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"unreachable"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, 456+tr(%rip)
	movl	$2, 436+tr(%rip)
	movl	$3, 392+tr(%rip)
	movl	$6, 396+tr(%rip)
	movl	$5, 412+tr(%rip)
	movl	$4, 484+tr(%rip)
	movl	$7, 476+tr(%rip)
	movl	$8, 428+tr(%rip)
	jmp	.L2
.L28:
	movl	$221184, %edx
	movl	$0, %esi
	leaq	mk(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -56(%rbp)
	jmp	.L3
.L8:
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	movq	%rax, %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
	movl	$0, -52(%rbp)
	jmp	.L4
.L7:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L5
	movl	-56(%rbp), %eax
	movb	%al, q(%rip)
	movl	-52(%rbp), %eax
	movb	%al, 1+q(%rip)
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$7, (%rax)
	movb	$1, 2+q(%rip)
	movb	$2, 3+q(%rip)
	movb	$3, 4+q(%rip)
	movb	$0, 5+q(%rip)
	movl	$0, 8+q(%rip)
	jmp	.L6
.L5:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	movslq	%eax, %rcx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rcx
	leaq	map(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
.L6:
	addl	$1, -52(%rbp)
.L4:
	movl	-68(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L7
	addl	$1, -56(%rbp)
.L3:
	movl	-64(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L8
	leaq	seq(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -60(%rbp)
	jmp	.L9
.L10:
	movl	-60(%rbp), %eax
	cltq
	leaq	seq(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %ecx
	movl	-60(%rbp), %eax
	cltq
	leaq	seq(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	addl	$1, -60(%rbp)
.L9:
	cmpl	$5, -60(%rbp)
	jle	.L10
	movl	$-1, -44(%rbp)
	movl	$0, top(%rip)
	movl	$1, end(%rip)
	jmp	.L11
.L26:
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -56(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	1+q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -52(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	5+q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -40(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	2(%rax), %rcx
	leaq	-22(%rbp), %rax
	addq	$1, %rax
	movl	$3, %edx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	$4, -60(%rbp)
	jmp	.L12
.L13:
	movl	$7, %eax
	subl	-60(%rbp), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movl	%eax, %edx
	movl	$7, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	movl	-60(%rbp), %eax
	cltq
	movb	%dl, -22(%rbp,%rax)
	addl	$1, -60(%rbp)
.L12:
	cmpl	$6, -60(%rbp)
	jle	.L13
	movl	top(%rip), %eax
	addl	$1, %eax
	movl	%eax, top(%rip)
	movl	$0, -60(%rbp)
	jmp	.L14
.L25:
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -32(%rbp)
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-52(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
	cmpl	$0, -32(%rbp)
	js	.L31
	movl	-64(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L31
	cmpl	$0, -28(%rbp)
	js	.L31
	movl	-68(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L31
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$8, %al
	je	.L31
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -14(%rbp)
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -13(%rbp)
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -12(%rbp)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$7, %al
	jne	.L18
	movl	-40(%rbp), %eax
	movl	%eax, -48(%rbp)
	jmp	.L19
.L18:
	movzbl	-14(%rbp), %edx
	movl	-40(%rbp), %eax
	cltq
	leaq	seq(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	jne	.L32
	movzbl	-14(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rcx
	leaq	map(%rip), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L32
	cmpl	$5, -40(%rbp)
	jne	.L22
	movl	-36(%rbp), %eax
	movl	%eax, -44(%rbp)
	jmp	.L23
.L22:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -48(%rbp)
.L19:
	movzbl	-14(%rbp), %eax
	movsbl	%al, %eax
	movzbl	-13(%rbp), %edx
	movsbl	%dl, %edx
	movl	-40(%rbp), %ecx
	movslq	%ecx, %r8
	cltq
	movslq	%edx, %rdi
	movl	-32(%rbp), %edx
	movslq	%edx, %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movq	%rax, %rdx
	salq	$3, %rdx
	addq	%rax, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, %rdx
	movq	%rdi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	addq	%rax, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$3, %rax
	leaq	(%rdi,%rax), %rsi
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$8, %rax
	addq	%rsi, %rax
	leaq	(%rax,%r8), %rdx
	leaq	mk(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L33
	movzbl	-14(%rbp), %eax
	movsbl	%al, %eax
	movzbl	-13(%rbp), %edx
	movsbl	%dl, %edx
	movl	-40(%rbp), %ecx
	movslq	%ecx, %r8
	cltq
	movslq	%edx, %rdi
	movl	-32(%rbp), %edx
	movslq	%edx, %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movq	%rax, %rdx
	salq	$3, %rdx
	addq	%rax, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, %rdx
	movq	%rdi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	addq	%rax, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$3, %rax
	leaq	(%rdi,%rax), %rsi
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$8, %rax
	addq	%rsi, %rax
	leaq	(%rax,%r8), %rdx
	leaq	mk(%rip), %rax
	addq	%rdx, %rax
	movb	$1, (%rax)
	movl	end(%rip), %eax
	movl	-32(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movl	-28(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	1+q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movl	-48(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	5+q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+q(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	leaq	-15(%rbp), %rcx
	addq	$1, %rcx
	movl	end(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	addq	$2, %rax
	movl	$3, %edx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	end(%rip), %eax
	addl	$1, %eax
	movl	%eax, end(%rip)
	jmp	.L17
.L31:
	nop
	jmp	.L17
.L32:
	nop
	jmp	.L17
.L33:
	nop
.L17:
	addl	$1, -60(%rbp)
.L14:
	cmpl	$3, -60(%rbp)
	jle	.L25
.L11:
	movl	top(%rip), %edx
	movl	end(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	cmpl	$0, -44(%rbp)
	jns	.L34
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L2
.L34:
	nop
.L23:
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L27
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jg	.L28
.L27:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"unreachable"
.LC4:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movq	.LC0(%rip), %rax
	movb	%r13b, 14(%rsp)
	movl	$1, 456+tr(%rip)
	movq	%rax, 392+tr(%rip)
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	32(%rsp), %rax
	movl	$2, 436+tr(%rip)
	movl	$5, 412+tr(%rip)
	movl	$4, 484+tr(%rip)
	movl	$7, 476+tr(%rip)
	movl	$8, 428+tr(%rip)
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L33
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.L33
	movl	$221184, %edx
	xorl	%esi, %esi
	leaq	mk(%rip), %rdi
	xorl	%ebp, %ebp
	call	memset@PLT
	movl	36(%rsp), %edx
	leaq	map(%rip), %r12
	leaq	tr(%rip), %rbx
	testl	%edx, %edx
	jle	.L13
	movzbl	14(%rsp), %r13d
	movzbl	15(%rsp), %r14d
	.p2align 4,,10
	.p2align 3
.L12:
	movq	%r12, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %esi
	movq	%r12, %rax
	xorl	%edi, %edi
	xorl	%ecx, %ecx
	movl	%ebp, %r8d
	testl	%esi, %esi
	jle	.L6
	.p2align 4,,10
	.p2align 3
.L5:
	movsbq	(%rax), %rdx
	cmpb	$35, %dl
	je	.L73
	movl	(%rbx,%rdx,4), %edx
	addl	$1, %ecx
	addq	$1, %rax
	movb	%dl, -1(%rax)
	cmpl	%esi, %ecx
	jne	.L5
	testb	%dil, %dil
	je	.L6
.L9:
	movl	$0, 8+q(%rip)
	movl	$197121, 2+q(%rip)
	movb	%r14b, 1+q(%rip)
	movb	%r13b, q(%rip)
.L6:
	addl	$1, %ebp
	addq	$32, %r12
	cmpl	%ebp, 36(%rsp)
	jg	.L12
	movb	%r13b, 14(%rsp)
	movb	%r14b, 15(%rsp)
.L13:
	leaq	.LC1(%rip), %rdi
	leaq	seq(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movsbq	seq(%rip), %rdx
	xorl	%eax, %eax
	movl	$1, end(%rip)
	leaq	43(%rsp), %r9
	movl	$7, %edi
	movb	(%rbx,%rdx,4), %al
	movsbq	1+seq(%rip), %rdx
	movl	(%rbx,%rdx,4), %ecx
	movsbq	2+seq(%rip), %rdx
	movb	%cl, %ah
	movzbl	(%rbx,%rdx,4), %ecx
	movsbq	3+seq(%rip), %rdx
	movzwl	%ax, %eax
	movzbl	(%rbx,%rdx,4), %edx
	sall	$16, %ecx
	orl	%ecx, %eax
	sall	$24, %edx
	orl	%edx, %eax
	movsbq	4+seq(%rip), %rdx
	movl	%eax, seq(%rip)
	xorl	%eax, %eax
	movb	(%rbx,%rdx,4), %al
	movsbq	5+seq(%rip), %rdx
	movzwl	(%rbx,%rdx,4), %ecx
	leaq	2+q(%rip), %rdx
	movb	%cl, %ah
	xorl	%ecx, %ecx
	movw	%ax, 4+seq(%rip)
	movl	4+mv(%rip), %eax
	movl	%ecx, (%rsp)
	movl	%eax, 8(%rsp)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%r8d, %r11
	leaq	seq(%rip), %rcx
	cmpb	%bpl, (%rcx,%r11)
	jne	.L16
	cmpb	%r13b, %bpl
	je	.L74
	.p2align 4,,10
	.p2align 3
.L16:
	movl	12+mv(%rip), %ebx
	movl	%eax, %r10d
	addl	8+mv(%rip), %r10d
	js	.L21
	addl	%esi, %ebx
	cmpl	%r10d, 36(%rsp)
	jle	.L21
	testl	%ebx, %ebx
	js	.L21
	cmpl	%ebx, 32(%rsp)
	jle	.L21
	movslq	%r10d, %r15
	leaq	map(%rip), %rcx
	movslq	%ebx, %r14
	movq	%r15, %r11
	salq	$5, %r11
	addq	%rcx, %r11
	movzbl	(%r11,%r14), %r13d
	cmpb	$8, %r13b
	je	.L21
	movslq	12+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %rbp
	movslq	16+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %r12
	movslq	20+rot(%rip), %r11
	movb	%bpl, 50(%rsp)
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%r11b, 52(%rsp)
	cmpb	$7, %r13b
	je	.L75
	movslq	%r8d, %r11
	leaq	seq(%rip), %rcx
	cmpb	%bpl, (%rcx,%r11)
	jne	.L21
	cmpb	%r13b, %bpl
	je	.L76
	.p2align 4,,10
	.p2align 3
.L21:
	movl	20+mv(%rip), %ebx
	movl	%eax, %r10d
	addl	16+mv(%rip), %r10d
	js	.L25
	addl	%esi, %ebx
	cmpl	36(%rsp), %r10d
	jge	.L25
	testl	%ebx, %ebx
	js	.L25
	cmpl	%ebx, 32(%rsp)
	jle	.L25
	movslq	%r10d, %r14
	leaq	map(%rip), %rcx
	movslq	%ebx, %r15
	movq	%r14, %r11
	salq	$5, %r11
	addq	%rcx, %r11
	movzbl	(%r11,%r15), %r13d
	cmpb	$8, %r13b
	je	.L25
	movslq	24+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %rbp
	movslq	28+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %r12
	movslq	32+rot(%rip), %r11
	movb	%bpl, 50(%rsp)
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%r11b, 52(%rsp)
	cmpb	$7, %r13b
	je	.L77
	movslq	%r8d, %r11
	leaq	seq(%rip), %rcx
	cmpb	%bpl, (%rcx,%r11)
	jne	.L25
	cmpb	%bpl, %r13b
	je	.L78
	.p2align 4,,10
	.p2align 3
.L25:
	movl	28+mv(%rip), %ebx
	addl	24+mv(%rip), %eax
	js	.L28
	addl	%esi, %ebx
	cmpl	%eax, 36(%rsp)
	jle	.L28
	testl	%ebx, %ebx
	js	.L28
	cmpl	%ebx, 32(%rsp)
	jle	.L28
	movslq	%eax, %r10
	leaq	map(%rip), %rcx
	movslq	%ebx, %rbp
	movq	%r10, %rsi
	salq	$5, %rsi
	addq	%rcx, %rsi
	movzbl	(%rsi,%rbp), %r13d
	cmpb	$8, %r13b
	je	.L28
	movslq	40+rot(%rip), %r11
	movslq	36+rot(%rip), %rsi
	movsbq	42(%rsp,%r11), %r12
	movslq	44+rot(%rip), %r11
	movsbq	42(%rsp,%rsi), %rsi
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%sil, 50(%rsp)
	movb	%r11b, 52(%rsp)
	movslq	%r8d, %r11
	cmpb	$7, %r13b
	je	.L30
	leaq	seq(%rip), %rcx
	cmpb	%sil, (%rcx,%r11)
	jne	.L28
	cmpb	%sil, %r13b
	je	.L79
	.p2align 4,,10
	.p2align 3
.L28:
	movl	(%rsp), %eax
	addq	$12, %rdx
	cmpl	end(%rip), %eax
	jge	.L80
.L4:
	movzwl	(%rdx), %r15d
	movzbl	2(%rdx), %r11d
	movl	%edi, %r12d
	xorl	%r10d, %r10d
	movl	6(%rdx), %ecx
	addl	$1, (%rsp)
	movl	%r15d, %ebx
	movb	%r11b, 2(%r9)
	subl	%r11d, %r12d
	movl	%edi, %r11d
	movzbl	%bh, %ebp
	addl	$1, %ecx
	movb	%r12b, %r10b
	movsbl	-2(%rdx), %eax
	subl	%ebp, %r11d
	movsbl	-1(%rdx), %esi
	movsbl	3(%rdx), %r8d
	movl	%ecx, 4(%rsp)
	movl	%r11d, %ebx
	movl	%r10d, %ecx
	movl	%edi, %r10d
	movw	%r15w, (%r9)
	movb	%bl, %ch
	movl	(%rsp), %ebx
	subl	%r15d, %r10d
	movb	%r10b, 48(%rsp)
	movl	%eax, %r10d
	movl	%ebx, top(%rip)
	leaq	mv(%rip), %rbx
	movw	%cx, 46(%rsp)
	addl	(%rbx), %r10d
	js	.L16
	movl	8(%rsp), %ecx
	leal	(%rsi,%rcx), %ebx
	cmpl	%r10d, 36(%rsp)
	jle	.L16
	testl	%ebx, %ebx
	js	.L16
	cmpl	%ebx, 32(%rsp)
	jle	.L16
	movslq	%r10d, %r15
	leaq	map(%rip), %rcx
	movslq	%ebx, %r14
	movq	%r15, %r11
	salq	$5, %r11
	addq	%rcx, %r11
	movzbl	(%r11,%r14), %r13d
	cmpb	$8, %r13b
	je	.L16
	movslq	rot(%rip), %r11
	movsbq	42(%rsp,%r11), %rbp
	movslq	4+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %r12
	movslq	8+rot(%rip), %r11
	movb	%bpl, 50(%rsp)
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%r11b, 52(%rsp)
	cmpb	$7, %r13b
	jne	.L15
	movl	%r8d, %r13d
	movslq	%r8d, %r11
.L18:
	leaq	(%r12,%r12,2), %r12
	leaq	0(%rbp,%rbp,8), %rbp
	addq	%r12, %r12
	leaq	mk(%rip), %rcx
	leaq	(%r12,%rbp,4), %rbp
	leaq	(%r14,%r14,2), %r12
	leaq	(%r12,%r12,8), %r12
	leaq	0(%rbp,%r12,8), %rbp
	leaq	(%r15,%r15,2), %r12
	leaq	(%r12,%r12,8), %r12
	salq	$8, %r12
	addq	%r12, %rbp
	addq	%rcx, %rbp
	addq	%rbp, %r11
	cmpb	$0, (%r11)
	jne	.L16
	movb	$1, (%r11)
	movslq	end(%rip), %r11
	leaq	(%r11,%r11,2), %r12
	movq	%r11, %r14
	xorl	%r11d, %r11d
	movb	%r10b, %r11b
	leaq	0(,%r12,4), %rbp
	addl	$1, %r14d
	movl	%r11d, %ecx
	movb	%bl, %ch
	leaq	q(%rip), %rbx
	movw	%cx, (%rbx,%r12,4)
	movl	4(%rsp), %ecx
	leaq	(%rbx,%rbp), %r10
	movzwl	50(%rsp), %r11d
	movb	%r13b, 5(%r10)
	movl	%ecx, 8(%r10)
	leaq	2(%rbx,%rbp), %r10
	movw	%r11w, (%r10)
	movzbl	52(%rsp), %r11d
	movl	%r14d, end(%rip)
	movb	%r11b, 2(%r10)
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L73:
	movl	%ecx, %r14d
	addl	$1, %ecx
	movb	$7, (%rax)
	movl	%r8d, %r13d
	addq	$1, %rax
	cmpl	%esi, %ecx
	je	.L9
	movl	$1, %edi
	jmp	.L5
.L79:
	cmpl	$5, %r8d
	je	.L17
	addl	$1, %r8d
.L30:
	leaq	(%rsi,%rsi,8), %r13
	leaq	(%r12,%r12,2), %rsi
	addq	%rsi, %rsi
	leaq	(%r10,%r10,2), %r10
	leaq	mk(%rip), %rcx
	leaq	(%rsi,%r13,4), %r12
	leaq	0(%rbp,%rbp,2), %rsi
	leaq	(%rsi,%rsi,8), %rsi
	leaq	(%r10,%r10,8), %r10
	salq	$8, %r10
	leaq	(%r12,%rsi,8), %rsi
	addq	%r10, %rsi
	addq	%rcx, %rsi
	addq	%r11, %rsi
	cmpb	$0, (%rsi)
	jne	.L28
	movslq	end(%rip), %r10
	movl	4(%rsp), %ecx
	movb	$1, (%rsi)
	addq	$12, %rdx
	leaq	(%r10,%r10,2), %rbp
	movq	%r10, %rsi
	xorl	%r10d, %r10d
	movb	%al, %r10b
	leaq	0(,%rbp,4), %r11
	addl	$1, %esi
	movl	%r10d, %eax
	movb	%bl, %ah
	leaq	q(%rip), %rbx
	movw	%ax, (%rbx,%rbp,4)
	leaq	(%rbx,%r11), %rax
	movb	%r8b, 5(%rax)
	movzwl	50(%rsp), %r8d
	movl	%ecx, 8(%rax)
	leaq	2(%rbx,%r11), %rax
	movw	%r8w, (%rax)
	movzbl	52(%rsp), %r8d
	movl	%esi, end(%rip)
	movb	%r8b, 2(%rax)
	movl	(%rsp), %eax
	cmpl	end(%rip), %eax
	jl	.L4
	.p2align 4,,10
	.p2align 3
.L80:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L75:
	movl	%r8d, %r13d
	movslq	%r8d, %r11
.L22:
	leaq	(%r12,%r12,2), %r12
	leaq	0(%rbp,%rbp,8), %rbp
	addq	%r12, %r12
	leaq	mk(%rip), %rcx
	leaq	(%r12,%rbp,4), %rbp
	leaq	(%r14,%r14,2), %r12
	leaq	(%r12,%r12,8), %r12
	leaq	0(%rbp,%r12,8), %rbp
	leaq	(%r15,%r15,2), %r12
	leaq	(%r12,%r12,8), %r12
	salq	$8, %r12
	addq	%r12, %rbp
	addq	%rcx, %rbp
	addq	%rbp, %r11
	cmpb	$0, (%r11)
	jne	.L21
	movb	$1, (%r11)
	movslq	end(%rip), %r11
	leaq	(%r11,%r11,2), %r12
	movq	%r11, %r14
	xorl	%r11d, %r11d
	movb	%r10b, %r11b
	leaq	0(,%r12,4), %rbp
	addl	$1, %r14d
	movl	%r11d, %ecx
	movb	%bl, %ch
	leaq	q(%rip), %rbx
	movw	%cx, (%rbx,%r12,4)
	movl	4(%rsp), %ecx
	leaq	(%rbx,%rbp), %r10
	movzwl	50(%rsp), %r11d
	movb	%r13b, 5(%r10)
	movl	%ecx, 8(%r10)
	leaq	2(%rbx,%rbp), %r10
	movw	%r11w, (%r10)
	movzbl	52(%rsp), %r11d
	movl	%r14d, end(%rip)
	movb	%r11b, 2(%r10)
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L77:
	movl	%r8d, %r13d
	movslq	%r8d, %r11
.L26:
	leaq	(%r12,%r12,2), %r12
	leaq	0(%rbp,%rbp,8), %rbp
	addq	%r12, %r12
	leaq	mk(%rip), %rcx
	leaq	(%r12,%rbp,4), %rbp
	leaq	(%r15,%r15,2), %r12
	leaq	(%r12,%r12,8), %r12
	leaq	0(%rbp,%r12,8), %rbp
	leaq	(%r14,%r14,2), %r12
	leaq	(%r12,%r12,8), %r12
	salq	$8, %r12
	addq	%r12, %rbp
	addq	%rcx, %rbp
	addq	%rbp, %r11
	cmpb	$0, (%r11)
	jne	.L25
	movb	$1, (%r11)
	movslq	end(%rip), %r11
	leaq	(%r11,%r11,2), %r12
	movq	%r11, %r14
	xorl	%r11d, %r11d
	movb	%r10b, %r11b
	leaq	0(,%r12,4), %rbp
	addl	$1, %r14d
	movl	%r11d, %ecx
	movb	%bl, %ch
	leaq	q(%rip), %rbx
	movw	%cx, (%rbx,%r12,4)
	movl	4(%rsp), %ecx
	leaq	(%rbx,%rbp), %r10
	movzwl	50(%rsp), %r11d
	movb	%r13b, 5(%r10)
	movl	%ecx, 8(%r10)
	leaq	2(%rbx,%rbp), %r10
	movw	%r11w, (%r10)
	movzbl	52(%rsp), %r11d
	movl	%r14d, end(%rip)
	movb	%r11b, 2(%r10)
	jmp	.L25
.L74:
	cmpl	$5, %r8d
	je	.L17
	leal	1(%r8), %r13d
	jmp	.L18
.L76:
	cmpl	$5, %r8d
	je	.L17
	leal	1(%r8), %r13d
	jmp	.L22
.L78:
	cmpl	$5, %r8d
	je	.L17
	leal	1(%r8), %r13d
	jmp	.L26
.L33:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L81
	addq	$72, %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
.L17:
	.cfi_restore_state
	movl	4(%rsp), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L81:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 488
tr:
	.zero	488
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 48
rot:
	.long	2
	.long	6
	.long	3
	.long	4
	.long	2
	.long	1
	.long	5
	.long	1
	.long	3
	.long	3
	.long	2
	.long	6
	.globl	mv
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	0
	.long	1
	.long	1
	.long	0
	.long	0
	.long	-1
	.globl	seq
	.bss
	.align 4
	.type	seq, @object
	.size	seq, 7
seq:
	.zero	7
	.globl	mk
	.align 32
	.type	mk, @object
	.size	mk, 221184
mk:
	.zero	221184
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1024
map:
	.zero	1024
	.globl	end
	.align 4
	.type	end, @object
	.size	end, 4
end:
	.zero	4
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 1200000
q:
	.zero	1200000
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	3
	.long	6
	.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
.LC1:
	.string	"%s"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"unreachable"
.LC4:
	.string	"%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB35:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	movq	.LC0(%rip), %rax
	movb	%r13b, 14(%rsp)
	movl	$1, 456+tr(%rip)
	movq	%rax, 392+tr(%rip)
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
	leaq	32(%rsp), %rax
	movl	$2, 436+tr(%rip)
	movl	$5, 412+tr(%rip)
	movl	$4, 484+tr(%rip)
	movl	$7, 476+tr(%rip)
	movl	$8, 428+tr(%rip)
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC4(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L33
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.L33
	movl	$221184, %edx
	xorl	%esi, %esi
	leaq	mk(%rip), %rdi
	xorl	%ebp, %ebp
	call	memset@PLT
	movl	36(%rsp), %edx
	leaq	map(%rip), %r12
	leaq	tr(%rip), %rbx
	testl	%edx, %edx
	jle	.L13
	movzbl	14(%rsp), %r13d
	movzbl	15(%rsp), %r14d
	.p2align 4,,10
	.p2align 3
.L12:
	movq	%r12, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %esi
	movq	%r12, %rax
	xorl	%edi, %edi
	xorl	%ecx, %ecx
	movl	%ebp, %r8d
	testl	%esi, %esi
	jle	.L6
	.p2align 4,,10
	.p2align 3
.L5:
	movsbq	(%rax), %rdx
	cmpb	$35, %dl
	je	.L73
	movl	(%rbx,%rdx,4), %edx
	addl	$1, %ecx
	addq	$1, %rax
	movb	%dl, -1(%rax)
	cmpl	%esi, %ecx
	jne	.L5
	testb	%dil, %dil
	je	.L6
.L9:
	movl	$0, 8+q(%rip)
	movl	$197121, 2+q(%rip)
	movb	%r14b, 1+q(%rip)
	movb	%r13b, q(%rip)
.L6:
	addl	$1, %ebp
	addq	$32, %r12
	cmpl	%ebp, 36(%rsp)
	jg	.L12
	movb	%r13b, 14(%rsp)
	movb	%r14b, 15(%rsp)
.L13:
	leaq	.LC1(%rip), %rdi
	leaq	seq(%rip), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movsbq	seq(%rip), %rdx
	xorl	%eax, %eax
	movl	$1, end(%rip)
	leaq	43(%rsp), %r9
	movl	$7, %edi
	movb	(%rbx,%rdx,4), %al
	movsbq	1+seq(%rip), %rdx
	movl	(%rbx,%rdx,4), %ecx
	movsbq	2+seq(%rip), %rdx
	movb	%cl, %ah
	movzbl	(%rbx,%rdx,4), %ecx
	movsbq	3+seq(%rip), %rdx
	movzwl	%ax, %eax
	movzbl	(%rbx,%rdx,4), %edx
	sall	$16, %ecx
	orl	%ecx, %eax
	sall	$24, %edx
	orl	%edx, %eax
	movsbq	4+seq(%rip), %rdx
	movl	%eax, seq(%rip)
	xorl	%eax, %eax
	movb	(%rbx,%rdx,4), %al
	movsbq	5+seq(%rip), %rdx
	movzwl	(%rbx,%rdx,4), %ecx
	leaq	2+q(%rip), %rdx
	movb	%cl, %ah
	xorl	%ecx, %ecx
	movw	%ax, 4+seq(%rip)
	movl	4+mv(%rip), %eax
	movl	%ecx, (%rsp)
	movl	%eax, 8(%rsp)
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%r8d, %r11
	leaq	seq(%rip), %rcx
	cmpb	%bpl, (%rcx,%r11)
	jne	.L16
	cmpb	%r13b, %bpl
	je	.L74
	.p2align 4,,10
	.p2align 3
.L16:
	movl	12+mv(%rip), %ebx
	movl	%eax, %r10d
	addl	8+mv(%rip), %r10d
	js	.L21
	addl	%esi, %ebx
	cmpl	%r10d, 36(%rsp)
	jle	.L21
	testl	%ebx, %ebx
	js	.L21
	cmpl	%ebx, 32(%rsp)
	jle	.L21
	movslq	%r10d, %r15
	leaq	map(%rip), %rcx
	movslq	%ebx, %r14
	movq	%r15, %r11
	salq	$5, %r11
	addq	%rcx, %r11
	movzbl	(%r11,%r14), %r13d
	cmpb	$8, %r13b
	je	.L21
	movslq	12+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %rbp
	movslq	16+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %r12
	movslq	20+rot(%rip), %r11
	movb	%bpl, 50(%rsp)
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%r11b, 52(%rsp)
	cmpb	$7, %r13b
	je	.L75
	movslq	%r8d, %r11
	leaq	seq(%rip), %rcx
	cmpb	%bpl, (%rcx,%r11)
	jne	.L21
	cmpb	%r13b, %bpl
	je	.L76
	.p2align 4,,10
	.p2align 3
.L21:
	movl	20+mv(%rip), %ebx
	movl	%eax, %r10d
	addl	16+mv(%rip), %r10d
	js	.L25
	addl	%esi, %ebx
	cmpl	36(%rsp), %r10d
	jge	.L25
	testl	%ebx, %ebx
	js	.L25
	cmpl	%ebx, 32(%rsp)
	jle	.L25
	movslq	%r10d, %r14
	leaq	map(%rip), %rcx
	movslq	%ebx, %r15
	movq	%r14, %r11
	salq	$5, %r11
	addq	%rcx, %r11
	movzbl	(%r11,%r15), %r13d
	cmpb	$8, %r13b
	je	.L25
	movslq	24+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %rbp
	movslq	28+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %r12
	movslq	32+rot(%rip), %r11
	movb	%bpl, 50(%rsp)
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%r11b, 52(%rsp)
	cmpb	$7, %r13b
	je	.L77
	movslq	%r8d, %r11
	leaq	seq(%rip), %rcx
	cmpb	%bpl, (%rcx,%r11)
	jne	.L25
	cmpb	%bpl, %r13b
	je	.L78
	.p2align 4,,10
	.p2align 3
.L25:
	movl	28+mv(%rip), %ebx
	addl	24+mv(%rip), %eax
	js	.L28
	addl	%esi, %ebx
	cmpl	%eax, 36(%rsp)
	jle	.L28
	testl	%ebx, %ebx
	js	.L28
	cmpl	%ebx, 32(%rsp)
	jle	.L28
	movslq	%eax, %r10
	leaq	map(%rip), %rcx
	movslq	%ebx, %rbp
	movq	%r10, %rsi
	salq	$5, %rsi
	addq	%rcx, %rsi
	movzbl	(%rsi,%rbp), %r13d
	cmpb	$8, %r13b
	je	.L28
	movslq	40+rot(%rip), %r11
	movslq	36+rot(%rip), %rsi
	movsbq	42(%rsp,%r11), %r12
	movslq	44+rot(%rip), %r11
	movsbq	42(%rsp,%rsi), %rsi
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%sil, 50(%rsp)
	movb	%r11b, 52(%rsp)
	movslq	%r8d, %r11
	cmpb	$7, %r13b
	je	.L30
	leaq	seq(%rip), %rcx
	cmpb	%sil, (%rcx,%r11)
	jne	.L28
	cmpb	%sil, %r13b
	je	.L79
	.p2align 4,,10
	.p2align 3
.L28:
	movl	(%rsp), %eax
	addq	$12, %rdx
	cmpl	end(%rip), %eax
	jge	.L80
.L4:
	movzwl	(%rdx), %r15d
	movzbl	2(%rdx), %r11d
	movl	%edi, %r12d
	xorl	%r10d, %r10d
	movl	6(%rdx), %ecx
	addl	$1, (%rsp)
	movl	%r15d, %ebx
	movb	%r11b, 2(%r9)
	subl	%r11d, %r12d
	movl	%edi, %r11d
	movzbl	%bh, %ebp
	addl	$1, %ecx
	movb	%r12b, %r10b
	movsbl	-2(%rdx), %eax
	subl	%ebp, %r11d
	movsbl	-1(%rdx), %esi
	movsbl	3(%rdx), %r8d
	movl	%ecx, 4(%rsp)
	movl	%r11d, %ebx
	movl	%r10d, %ecx
	movl	%edi, %r10d
	movw	%r15w, (%r9)
	movb	%bl, %ch
	movl	(%rsp), %ebx
	subl	%r15d, %r10d
	movb	%r10b, 48(%rsp)
	movl	%eax, %r10d
	movl	%ebx, top(%rip)
	leaq	mv(%rip), %rbx
	movw	%cx, 46(%rsp)
	addl	(%rbx), %r10d
	js	.L16
	movl	8(%rsp), %ecx
	leal	(%rsi,%rcx), %ebx
	cmpl	%r10d, 36(%rsp)
	jle	.L16
	testl	%ebx, %ebx
	js	.L16
	cmpl	%ebx, 32(%rsp)
	jle	.L16
	movslq	%r10d, %r15
	leaq	map(%rip), %rcx
	movslq	%ebx, %r14
	movq	%r15, %r11
	salq	$5, %r11
	addq	%rcx, %r11
	movzbl	(%r11,%r14), %r13d
	cmpb	$8, %r13b
	je	.L16
	movslq	rot(%rip), %r11
	movsbq	42(%rsp,%r11), %rbp
	movslq	4+rot(%rip), %r11
	movsbq	42(%rsp,%r11), %r12
	movslq	8+rot(%rip), %r11
	movb	%bpl, 50(%rsp)
	movzbl	42(%rsp,%r11), %r11d
	movb	%r12b, 51(%rsp)
	movb	%r11b, 52(%rsp)
	cmpb	$7, %r13b
	jne	.L15
	movl	%r8d, %r13d
	movslq	%r8d, %r11
.L18:
	leaq	(%r12,%r12,2), %r12
	leaq	0(%rbp,%rbp,8), %rbp
	addq	%r12, %r12
	leaq	mk(%rip), %rcx
	leaq	(%r12,%rbp,4), %rbp
	leaq	(%r14,%r14,2), %r12
	leaq	(%r12,%r12,8), %r12
	leaq	0(%rbp,%r12,8), %rbp
	leaq	(%r15,%r15,2), %r12
	leaq	(%r12,%r12,8), %r12
	salq	$8, %r12
	addq	%r12, %rbp
	addq	%rcx, %rbp
	addq	%rbp, %r11
	cmpb	$0, (%r11)
	jne	.L16
	movb	$1, (%r11)
	movslq	end(%rip), %r11
	leaq	(%r11,%r11,2), %r12
	movq	%r11, %r14
	xorl	%r11d, %r11d
	movb	%r10b, %r11b
	leaq	0(,%r12,4), %rbp
	addl	$1, %r14d
	movl	%r11d, %ecx
	movb	%bl, %ch
	leaq	q(%rip), %rbx
	movw	%cx, (%rbx,%r12,4)
	movl	4(%rsp), %ecx
	leaq	(%rbx,%rbp), %r10
	movzwl	50(%rsp), %r11d
	movb	%r13b, 5(%r10)
	movl	%ecx, 8(%r10)
	leaq	2(%rbx,%rbp), %r10
	movw	%r11w, (%r10)
	movzbl	52(%rsp), %r11d
	movl	%r14d, end(%rip)
	movb	%r11b, 2(%r10)
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L73:
	movl	%ecx, %r14d
	addl	$1, %ecx
	movb	$7, (%rax)
	movl	%r8d, %r13d
	addq	$1, %rax
	cmpl	%esi, %ecx
	je	.L9
	movl	$1, %edi
	jmp	.L5
.L79:
	cmpl	$5, %r8d
	je	.L17
	addl	$1, %r8d
.L30:
	leaq	(%rsi,%rsi,8), %r13
	leaq	(%r12,%r12,2), %rsi
	addq	%rsi, %rsi
	leaq	(%r10,%r10,2), %r10
	leaq	mk(%rip), %rcx
	leaq	(%rsi,%r13,4), %r12
	leaq	0(%rbp,%rbp,2), %rsi
	leaq	(%rsi,%rsi,8), %rsi
	leaq	(%r10,%r10,8), %r10
	salq	$8, %r10
	leaq	(%r12,%rsi,8), %rsi
	addq	%r10, %rsi
	addq	%rcx, %rsi
	addq	%r11, %rsi
	cmpb	$0, (%rsi)
	jne	.L28
	movslq	end(%rip), %r10
	movl	4(%rsp), %ecx
	movb	$1, (%rsi)
	addq	$12, %rdx
	leaq	(%r10,%r10,2), %rbp
	movq	%r10, %rsi
	xorl	%r10d, %r10d
	movb	%al, %r10b
	leaq	0(,%rbp,4), %r11
	addl	$1, %esi
	movl	%r10d, %eax
	movb	%bl, %ah
	leaq	q(%rip), %rbx
	movw	%ax, (%rbx,%rbp,4)
	leaq	(%rbx,%r11), %rax
	movb	%r8b, 5(%rax)
	movzwl	50(%rsp), %r8d
	movl	%ecx, 8(%rax)
	leaq	2(%rbx,%r11), %rax
	movw	%r8w, (%rax)
	movzbl	52(%rsp), %r8d
	movl	%esi, end(%rip)
	movb	%r8b, 2(%rax)
	movl	(%rsp), %eax
	cmpl	end(%rip), %eax
	jl	.L4
	.p2align 4,,10
	.p2align 3
.L80:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L75:
	movl	%r8d, %r13d
	movslq	%r8d, %r11
.L22:
	leaq	(%r12,%r12,2), %r12
	leaq	0(%rbp,%rbp,8), %rbp
	addq	%r12, %r12
	leaq	mk(%rip), %rcx
	leaq	(%r12,%rbp,4), %rbp
	leaq	(%r14,%r14,2), %r12
	leaq	(%r12,%r12,8), %r12
	leaq	0(%rbp,%r12,8), %rbp
	leaq	(%r15,%r15,2), %r12
	leaq	(%r12,%r12,8), %r12
	salq	$8, %r12
	addq	%r12, %rbp
	addq	%rcx, %rbp
	addq	%rbp, %r11
	cmpb	$0, (%r11)
	jne	.L21
	movb	$1, (%r11)
	movslq	end(%rip), %r11
	leaq	(%r11,%r11,2), %r12
	movq	%r11, %r14
	xorl	%r11d, %r11d
	movb	%r10b, %r11b
	leaq	0(,%r12,4), %rbp
	addl	$1, %r14d
	movl	%r11d, %ecx
	movb	%bl, %ch
	leaq	q(%rip), %rbx
	movw	%cx, (%rbx,%r12,4)
	movl	4(%rsp), %ecx
	leaq	(%rbx,%rbp), %r10
	movzwl	50(%rsp), %r11d
	movb	%r13b, 5(%r10)
	movl	%ecx, 8(%r10)
	leaq	2(%rbx,%rbp), %r10
	movw	%r11w, (%r10)
	movzbl	52(%rsp), %r11d
	movl	%r14d, end(%rip)
	movb	%r11b, 2(%r10)
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L77:
	movl	%r8d, %r13d
	movslq	%r8d, %r11
.L26:
	leaq	(%r12,%r12,2), %r12
	leaq	0(%rbp,%rbp,8), %rbp
	addq	%r12, %r12
	leaq	mk(%rip), %rcx
	leaq	(%r12,%rbp,4), %rbp
	leaq	(%r15,%r15,2), %r12
	leaq	(%r12,%r12,8), %r12
	leaq	0(%rbp,%r12,8), %rbp
	leaq	(%r14,%r14,2), %r12
	leaq	(%r12,%r12,8), %r12
	salq	$8, %r12
	addq	%r12, %rbp
	addq	%rcx, %rbp
	addq	%rbp, %r11
	cmpb	$0, (%r11)
	jne	.L25
	movb	$1, (%r11)
	movslq	end(%rip), %r11
	leaq	(%r11,%r11,2), %r12
	movq	%r11, %r14
	xorl	%r11d, %r11d
	movb	%r10b, %r11b
	leaq	0(,%r12,4), %rbp
	addl	$1, %r14d
	movl	%r11d, %ecx
	movb	%bl, %ch
	leaq	q(%rip), %rbx
	movw	%cx, (%rbx,%r12,4)
	movl	4(%rsp), %ecx
	leaq	(%rbx,%rbp), %r10
	movzwl	50(%rsp), %r11d
	movb	%r13b, 5(%r10)
	movl	%ecx, 8(%r10)
	leaq	2(%rbx,%rbp), %r10
	movw	%r11w, (%r10)
	movzbl	52(%rsp), %r11d
	movl	%r14d, end(%rip)
	movb	%r11b, 2(%r10)
	jmp	.L25
.L74:
	cmpl	$5, %r8d
	je	.L17
	leal	1(%r8), %r13d
	jmp	.L18
.L76:
	cmpl	$5, %r8d
	je	.L17
	leal	1(%r8), %r13d
	jmp	.L22
.L78:
	cmpl	$5, %r8d
	je	.L17
	leal	1(%r8), %r13d
	jmp	.L26
.L33:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L81
	addq	$72, %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
.L17:
	.cfi_restore_state
	movl	4(%rsp), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
.L81:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE35:
	.size	main, .-main
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 488
tr:
	.zero	488
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 48
rot:
	.long	2
	.long	6
	.long	3
	.long	4
	.long	2
	.long	1
	.long	5
	.long	1
	.long	3
	.long	3
	.long	2
	.long	6
	.globl	mv
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	0
	.long	1
	.long	1
	.long	0
	.long	0
	.long	-1
	.globl	seq
	.bss
	.align 4
	.type	seq, @object
	.size	seq, 7
seq:
	.zero	7
	.globl	mk
	.align 32
	.type	mk, @object
	.size	mk, 221184
mk:
	.zero	221184
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1024
map:
	.zero	1024
	.globl	end
	.align 4
	.type	end, @object
	.size	end, 4
end:
	.zero	4
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 1200000
q:
	.zero	1200000
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	3
	.long	6
	.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 1290: Traveling Cube
// 2017.10.20 bal4u@uu

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

typedef struct { char r, c, d[3], n; int s; } Q;
Q q[100000]; int top, end;

#define RED     1		// top  r
#define MAGENTA 2		// south  m
#define BLUE    3		// east  b
#define YELLOW  4		// west  y
#define GREEN   5		// north  g
#define CYAN    6		// bottom c
#define WHITE   7		// w
#define BLACK   8       // k

char map[32][32];
char mk[32][32][6][6][6];
char seq[7];
int mv[4][2] =  {{-1,0},{0,1},{1,0},{0,-1}};
int rot[4][3] = {{2,6,3},{4,2,1},{5,1,3},{3,2,6}};
int tr['z'];

int main()
{
	int w, d, i, r, c, n, r2, c2, n2, s, ans;
	char dice[7], dice2[7];

	tr['r'] = RED, tr['m'] = MAGENTA, tr['b'] = BLUE, tr['c'] = CYAN, tr['g'] = GREEN, tr['y'] = YELLOW;
	tr['w'] = WHITE, tr['k'] = BLACK;
	while (scanf("%d%d", &w, &d) && w > 0) {
		memset(mk, 0, sizeof(mk));
		for (r = 0; r < d; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) {
				if (map[r][c] == '#') {
					q[0].r = r, q[0].c = c; map[r][c] = WHITE;
					q[0].d[0] = RED, q[0].d[1] = MAGENTA, q[0].d[2] = BLUE;
					q[0].n = 0, q[0].s = 0;
				} else map[r][c] = tr[map[r][c]];
			}
		}
		scanf("%s", seq); for (i = 0; i < 6; i++) seq[i] = tr[seq[i]];
		ans = -1; top = 0, end = 1;
		while (top < end) {
			r = q[top].r, c = q[top].c, n = q[top].n, s = q[top].s+1;
			memcpy(dice+1, q[top].d, 3); for (i = 4; i <= 6; i++) dice[i] = 7 - dice[7-i]; top++;
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= d || c2 < 0 || c2 >= w || map[r2][c2] == BLACK) continue;
				dice2[1] = dice[rot[i][0]],	dice2[2] = dice[rot[i][1]], dice2[3] = dice[rot[i][2]];
				if (map[r2][c2] == WHITE) n2 = n;
				else {
					if (dice2[1] != seq[n] || dice2[1] != map[r2][c2]) continue;
					if (n == 5) { ans = s; goto done; }
					n2 = n + 1;
				}
				if (mk[r2][c2][dice2[1]][dice2[2]][n]) continue;
				mk[r2][c2][dice2[1]][dice2[2]][n] = 1;
				q[end].r = r2, q[end].c = c2, q[end].n = n2, q[end].s = s;
				memcpy(q[end].d, dice2+1, 3); end++;
			}
		}
		if (ans < 0) puts("unreachable");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0;
}
10 5
kkkkkwwwww
w#wwwrwwww
wwwwbgwwww
kwwmcwwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kcmyrgbwwk
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwkk
kcmyrgbwwk
kwwwwwwwwk
cnyrgb
0 0
 10 5
kkkkkwwwww
w#wwwrwwww
wwwwbgwwww
kwwmcwwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kwwbgrymck
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwkk
kcmyrgbwwk
kwwwwwwwwk
cnyrgb
0 0
 10 5
kkkkkwwwww
w#wwwrwwww
wwwwbgwwww
kwwmwcwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kwwbgrymck
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kkwkkkkkwk
kcmyrgbwwk
kwwwwwwwwk
cnyrgb
0 0
 10 5
kkkkkwwwww
w#wwwrwwww
wwwwbgwwww
kwwmcwwwkk
kkwywwwkkk
ymcbgr
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kcmyrgbwwk
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwkk
kcmyrgbwwk
kwwwwwwwwk
cnyrgb
0 0
 10 5
kkkkkwwwww
w#wwwrwwww
wwwwbgwwww
kwwnwcwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kwwbgrymck
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kkwkkkkkwk
kcmyrgbwwk
kwwwwwwwwk
cnyrgb
0 0
 10 5
kkkkkwwwww
wwwwrwww#w
wwwwbgwwww
kwwmcwwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kcmyrgbwwk
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwkk
kcmyrgbwwk
kwwwwwwwwk
cmyrgb
0 0
 10 5
kkkkkwwwww
w#wwwrwwww
wwwwbgwwww
kwwmcwwwkk
kkkwwwywkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kwwbgrymck
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kkwkkkkkwk
kcmyrgbwwk
kwwwwwwwwk
cnyrgb
0 0
 10 5
kkkkkwwwwx
w#wwwrwwww
wwwwbgwwww
kwwmcwwwkk
kkwywwwkkk
rgycmb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kcmyrgbwwk
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwkk
kbmyrgbwwk
kwwwwwwwwk
cmrygb
0 0
 10 5
kkkkkwwwwx
w#wwwrwwww
wwwwbgwwww
kwwmcwwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwwk
kcgyrmbwwk
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkkkkkkk
kwkkkkkwkk
kbmyrgbwwk
kwwwwwwwwk
cmrygb
0 0
 10 5
kkkkkwwwwx
w#wwwrwwww
wwwwwgwwbw
kwwmcwwwkk
kkwywwwkkk
rgbcmy
10 5
kkkkkkkklk
k#kkkkkkkk
kwkkkkkwwk
kcmyrgbwwk
kwwwwwwwwk
cmyrgb
10 5
kkkkkkkkkk
k#kkjkkkkk
kwkkkkkwkk
kbmyrgbwwk
kwwwwwwwwk
cmyrgb
0 0

9
49
unreachable
 9
unreachable
unreachable
 15
unreachable
unreachable
 14
49
unreachable
 unreachable
unreachable
unreachable
 unreachable
49
unreachable
 18
unreachable
unreachable
 24
49
unreachable
 9
71
unreachable
 17
49
unreachable

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

```c
// AOJ 1290: Traveling Cube
// 2017.10.20 bal4u@uu

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

typedef struct { char r, c, d[3], n; int s; } Q;
Q q[100000]; int top, end;

#define RED     1		// top  r
#define MAGENTA 2		// south  m
#define BLUE    3		// east  b
#define YELLOW  4		// west  y
#define GREEN   5		// north  g
#define CYAN    6		// bottom c
#define WHITE   7		// w
#define BLACK   8       // k

char map[32][32];
char mk[32][32][6][6][6];
char seq[7];
int mv[4][2] =  {{-1,0},{0,1},{1,0},{0,-1}};
int rot[4][3] = {{2,6,3},{4,2,1},{5,1,3},{3,2,6}};
int tr['z'];

int main()
{
	int w, d, i, r, c, n, r2, c2, n2, s, ans;
	char dice[7], dice2[7];

	tr['r'] = RED, tr['m'] = MAGENTA, tr['b'] = BLUE, tr['c'] = CYAN, tr['g'] = GREEN, tr['y'] = YELLOW;
	tr['w'] = WHITE, tr['k'] = BLACK;
	while (scanf("%d%d", &w, &d) && w > 0) {
		memset(mk, 0, sizeof(mk));
		for (r = 0; r < d; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < w; c++) {
				if (map[r][c] == '#') {
					q[0].r = r, q[0].c = c; map[r][c] = WHITE;
					q[0].d[0] = RED, q[0].d[1] = MAGENTA, q[0].d[2] = BLUE;
					q[0].n = 0, q[0].s = 0;
				} else map[r][c] = tr[map[r][c]];
			}
		}
		scanf("%s", seq); for (i = 0; i < 6; i++) seq[i] = tr[seq[i]];
		ans = -1; top = 0, end = 1;
		while (top < end) {
			r = q[top].r, c = q[top].c, n = q[top].n, s = q[top].s+1;
			memcpy(dice+1, q[top].d, 3); for (i = 4; i <= 6; i++) dice[i] = 7 - dice[7-i]; top++;
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= d || c2 < 0 || c2 >= w || map[r2][c2] == BLACK) continue;
				dice2[1] = dice[rot[i][0]],	dice2[2] = dice[rot[i][1]], dice2[3] = dice[rot[i][2]];
				if (map[r2][c2] == WHITE) n2 = n;
				else {
					if (dice2[1] != seq[n] || dice2[1] != map[r2][c2]) continue;
					if (n == 5) { ans = s; goto done; }
					n2 = n + 1;
				}
				if (mk[r2][c2][dice2[1]][dice2[2]][n]) continue;
				mk[r2][c2][dice2[1]][dice2[2]][n] = 1;
				q[end].r = r2, q[end].c = c2, q[end].n = n2, q[end].s = s;
				memcpy(q[end].d, dice2+1, 3); end++;
			}
		}
		if (ans < 0) puts("unreachable");
		else {
done:		printf("%d\n", ans);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 1200000
q:
	.zero	1200000
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	end
	.align 4
	.type	end, @object
	.size	end, 4
end:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1024
map:
	.zero	1024
	.globl	mk
	.align 32
	.type	mk, @object
	.size	mk, 221184
mk:
	.zero	221184
	.globl	seq
	.type	seq, @object
	.size	seq, 7
seq:
	.zero	7
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	0
	.long	1
	.long	1
	.long	0
	.long	0
	.long	-1
	.globl	rot
	.align 32
	.type	rot, @object
	.size	rot, 48
rot:
	.long	2
	.long	6
	.long	3
	.long	4
	.long	2
	.long	1
	.long	5
	.long	1
	.long	3
	.long	3
	.long	2
	.long	6
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 488
tr:
	.zero	488
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"unreachable"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, 456+tr(%rip)
	movl	$2, 436+tr(%rip)
	movl	$3, 392+tr(%rip)
	movl	$6, 396+tr(%rip)
	movl	$5, 412+tr(%rip)
	movl	$4, 484+tr(%rip)
	movl	$7, 476+tr(%rip)
	movl	$8, 428+tr(%rip)
	jmp	.L2
.L28:
	movl	$221184, %edx
	movl	$0, %esi
	leaq	mk(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -56(%rbp)
	jmp	.L3
.L8:
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	movq	%rax, %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
	movl	$0, -52(%rbp)
	jmp	.L4
.L7:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L5
	movl	-56(%rbp), %eax
	movb	%al, q(%rip)
	movl	-52(%rbp), %eax
	movb	%al, 1+q(%rip)
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$7, (%rax)
	movb	$1, 2+q(%rip)
	movb	$2, 3+q(%rip)
	movb	$3, 4+q(%rip)
	movb	$0, 5+q(%rip)
	movl	$0, 8+q(%rip)
	jmp	.L6
.L5:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	movslq	%eax, %rcx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rcx
	leaq	map(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
.L6:
	addl	$1, -52(%rbp)
.L4:
	movl	-68(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L7
	addl	$1, -56(%rbp)
.L3:
	movl	-64(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L8
	leaq	seq(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -60(%rbp)
	jmp	.L9
.L10:
	movl	-60(%rbp), %eax
	cltq
	leaq	seq(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %ecx
	movl	-60(%rbp), %eax
	cltq
	leaq	seq(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	addl	$1, -60(%rbp)
.L9:
	cmpl	$5, -60(%rbp)
	jle	.L10
	movl	$-1, -44(%rbp)
	movl	$0, top(%rip)
	movl	$1, end(%rip)
	jmp	.L11
.L26:
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -56(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	1+q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -52(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	5+q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -40(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	2(%rax), %rcx
	leaq	-22(%rbp), %rax
	addq	$1, %rax
	movl	$3, %edx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	$4, -60(%rbp)
	jmp	.L12
.L13:
	movl	$7, %eax
	subl	-60(%rbp), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movl	%eax, %edx
	movl	$7, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	movl	-60(%rbp), %eax
	cltq
	movb	%dl, -22(%rbp,%rax)
	addl	$1, -60(%rbp)
.L12:
	cmpl	$6, -60(%rbp)
	jle	.L13
	movl	top(%rip), %eax
	addl	$1, %eax
	movl	%eax, top(%rip)
	movl	$0, -60(%rbp)
	jmp	.L14
.L25:
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -32(%rbp)
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-52(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
	cmpl	$0, -32(%rbp)
	js	.L31
	movl	-64(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L31
	cmpl	$0, -28(%rbp)
	js	.L31
	movl	-68(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L31
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$8, %al
	je	.L31
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -14(%rbp)
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -13(%rbp)
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -12(%rbp)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$7, %al
	jne	.L18
	movl	-40(%rbp), %eax
	movl	%eax, -48(%rbp)
	jmp	.L19
.L18:
	movzbl	-14(%rbp), %edx
	movl	-40(%rbp), %eax
	cltq
	leaq	seq(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	jne	.L32
	movzbl	-14(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rcx
	leaq	map(%rip), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L32
	cmpl	$5, -40(%rbp)
	jne	.L22
	movl	-36(%rbp), %eax
	movl	%eax, -44(%rbp)
	jmp	.L23
.L22:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -48(%rbp)
.L19:
	movzbl	-14(%rbp), %eax
	movsbl	%al, %eax
	movzbl	-13(%rbp), %edx
	movsbl	%dl, %edx
	movl	-40(%rbp), %ecx
	movslq	%ecx, %r8
	cltq
	movslq	%edx, %rdi
	movl	-32(%rbp), %edx
	movslq	%edx, %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movq	%rax, %rdx
	salq	$3, %rdx
	addq	%rax, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, %rdx
	movq	%rdi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	addq	%rax, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$3, %rax
	leaq	(%rdi,%rax), %rsi
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$8, %rax
	addq	%rsi, %rax
	leaq	(%rax,%r8), %rdx
	leaq	mk(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L33
	movzbl	-14(%rbp), %eax
	movsbl	%al, %eax
	movzbl	-13(%rbp), %edx
	movsbl	%dl, %edx
	movl	-40(%rbp), %ecx
	movslq	%ecx, %r8
	cltq
	movslq	%edx, %rdi
	movl	-32(%rbp), %edx
	movslq	%edx, %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movq	%rax, %rdx
	salq	$3, %rdx
	addq	%rax, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, %rdx
	movq	%rdi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	addq	%rax, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$3, %rax
	leaq	(%rdi,%rax), %rsi
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$8, %rax
	addq	%rsi, %rax
	leaq	(%rax,%r8), %rdx
	leaq	mk(%rip), %rax
	addq	%rdx, %rax
	movb	$1, (%rax)
	movl	end(%rip), %eax
	movl	-32(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movl	-28(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	1+q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movl	-48(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	5+q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+q(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	leaq	-15(%rbp), %rcx
	addq	$1, %rcx
	movl	end(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	addq	$2, %rax
	movl	$3, %edx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	end(%rip), %eax
	addl	$1, %eax
	movl	%eax, end(%rip)
	jmp	.L17
.L31:
	nop
	jmp	.L17
.L32:
	nop
	jmp	.L17
.L33:
	nop
.L17:
	addl	$1, -60(%rbp)
.L14:
	cmpl	$3, -60(%rbp)
	jle	.L25
.L11:
	movl	top(%rip), %edx
	movl	end(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	cmpl	$0, -44(%rbp)
	jns	.L34
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L2
.L34:
	nop
.L23:
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L27
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jg	.L28
.L27:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 1200000
q:
	.zero	1200000
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	end
	.align 4
	.type	end, @object
	.size	end, 4
end:
	.zero	4
	.globl	map
	.align 32
	.type	map, @object
	.size	map, 1024
map:
	.zero	1024
	.globl	mk
	.align 32
	.type	mk, @object
	.size	mk, 221184
mk:
	.zero	221184
	.globl	seq
	.type	seq, @object
	.size	seq, 7
seq:
	.zero	7
	.globl	mv
	.data
	.align 32
	.type	mv, @object
	.size	mv, 32
mv:
	.long	-1
	.long	0
	.long	0
	.long	1
	.long	1
	.long	0
	.long	0
	.long	-1
	.globl	rot
	.align 32
	.type	rot, @object
	.size	rot, 48
rot:
	.long	2
	.long	6
	.long	3
	.long	4
	.long	2
	.long	1
	.long	5
	.long	1
	.long	3
	.long	3
	.long	2
	.long	6
	.globl	tr
	.bss
	.align 32
	.type	tr, @object
	.size	tr, 488
tr:
	.zero	488
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"unreachable"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, 456+tr(%rip)
	movl	$2, 436+tr(%rip)
	movl	$3, 392+tr(%rip)
	movl	$6, 396+tr(%rip)
	movl	$5, 412+tr(%rip)
	movl	$4, 484+tr(%rip)
	movl	$7, 476+tr(%rip)
	movl	$8, 428+tr(%rip)
	jmp	.L2
.L28:
	movl	$221184, %edx
	movl	$0, %esi
	leaq	mk(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -56(%rbp)
	jmp	.L3
.L8:
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	movq	%rax, %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
	movl	$0, -52(%rbp)
	jmp	.L4
.L7:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$35, %al
	jne	.L5
	movl	-56(%rbp), %eax
	movb	%al, q(%rip)
	movl	-52(%rbp), %eax
	movb	%al, 1+q(%rip)
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movb	$7, (%rax)
	movb	$1, 2+q(%rip)
	movb	$2, 3+q(%rip)
	movb	$3, 4+q(%rip)
	movb	$0, 5+q(%rip)
	movl	$0, 8+q(%rip)
	jmp	.L6
.L5:
	movl	-52(%rbp), %eax
	movslq	%eax, %rdx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	movslq	%eax, %rcx
	movl	-56(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rcx
	leaq	map(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
.L6:
	addl	$1, -52(%rbp)
.L4:
	movl	-68(%rbp), %eax
	cmpl	%eax, -52(%rbp)
	jl	.L7
	addl	$1, -56(%rbp)
.L3:
	movl	-64(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L8
	leaq	seq(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -60(%rbp)
	jmp	.L9
.L10:
	movl	-60(%rbp), %eax
	cltq
	leaq	seq(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tr(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %ecx
	movl	-60(%rbp), %eax
	cltq
	leaq	seq(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	addl	$1, -60(%rbp)
.L9:
	cmpl	$5, -60(%rbp)
	jle	.L10
	movl	$-1, -44(%rbp)
	movl	$0, top(%rip)
	movl	$1, end(%rip)
	jmp	.L11
.L26:
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -56(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	1+q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -52(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	5+q(%rip), %rax
	movzbl	(%rdx,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, -40(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	top(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	leaq	2(%rax), %rcx
	leaq	-22(%rbp), %rax
	addq	$1, %rax
	movl	$3, %edx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	$4, -60(%rbp)
	jmp	.L12
.L13:
	movl	$7, %eax
	subl	-60(%rbp), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movl	%eax, %edx
	movl	$7, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	movl	-60(%rbp), %eax
	cltq
	movb	%dl, -22(%rbp,%rax)
	addl	$1, -60(%rbp)
.L12:
	cmpl	$6, -60(%rbp)
	jle	.L13
	movl	top(%rip), %eax
	addl	$1, %eax
	movl	%eax, top(%rip)
	movl	$0, -60(%rbp)
	jmp	.L14
.L25:
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-56(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -32(%rbp)
	movl	-60(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+mv(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-52(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -28(%rbp)
	cmpl	$0, -32(%rbp)
	js	.L31
	movl	-64(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jge	.L31
	cmpl	$0, -28(%rbp)
	js	.L31
	movl	-68(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jge	.L31
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$8, %al
	je	.L31
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -14(%rbp)
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -13(%rbp)
	movl	-60(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	movzbl	-22(%rbp,%rax), %eax
	movb	%al, -12(%rbp)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rdx
	leaq	map(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$7, %al
	jne	.L18
	movl	-40(%rbp), %eax
	movl	%eax, -48(%rbp)
	jmp	.L19
.L18:
	movzbl	-14(%rbp), %edx
	movl	-40(%rbp), %eax
	cltq
	leaq	seq(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	cmpb	%al, %dl
	jne	.L32
	movzbl	-14(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%eax, %rcx
	movl	-32(%rbp), %eax
	cltq
	salq	$5, %rax
	addq	%rax, %rcx
	leaq	map(%rip), %rax
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	jne	.L32
	cmpl	$5, -40(%rbp)
	jne	.L22
	movl	-36(%rbp), %eax
	movl	%eax, -44(%rbp)
	jmp	.L23
.L22:
	movl	-40(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -48(%rbp)
.L19:
	movzbl	-14(%rbp), %eax
	movsbl	%al, %eax
	movzbl	-13(%rbp), %edx
	movsbl	%dl, %edx
	movl	-40(%rbp), %ecx
	movslq	%ecx, %r8
	cltq
	movslq	%edx, %rdi
	movl	-32(%rbp), %edx
	movslq	%edx, %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movq	%rax, %rdx
	salq	$3, %rdx
	addq	%rax, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, %rdx
	movq	%rdi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	addq	%rax, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$3, %rax
	leaq	(%rdi,%rax), %rsi
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$8, %rax
	addq	%rsi, %rax
	leaq	(%rax,%r8), %rdx
	leaq	mk(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	testb	%al, %al
	jne	.L33
	movzbl	-14(%rbp), %eax
	movsbl	%al, %eax
	movzbl	-13(%rbp), %edx
	movsbl	%dl, %edx
	movl	-40(%rbp), %ecx
	movslq	%ecx, %r8
	cltq
	movslq	%edx, %rdi
	movl	-32(%rbp), %edx
	movslq	%edx, %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rsi
	movq	%rax, %rdx
	salq	$3, %rdx
	addq	%rax, %rdx
	leaq	0(,%rdx,4), %rax
	movq	%rax, %rdx
	movq	%rdi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	addq	%rax, %rax
	leaq	(%rdx,%rax), %rdi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$3, %rax
	leaq	(%rdi,%rax), %rsi
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rdx
	addq	%rdx, %rax
	salq	$8, %rax
	addq	%rsi, %rax
	leaq	(%rax,%r8), %rdx
	leaq	mk(%rip), %rax
	addq	%rdx, %rax
	movb	$1, (%rax)
	movl	end(%rip), %eax
	movl	-32(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movl	-28(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	1+q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movl	-48(%rbp), %edx
	movl	%edx, %ecx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	5+q(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	end(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+q(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	leaq	-15(%rbp), %rcx
	addq	$1, %rcx
	movl	end(%rip), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	leaq	q(%rip), %rdx
	addq	%rdx, %rax
	addq	$2, %rax
	movl	$3, %edx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	memcpy@PLT
	movl	end(%rip), %eax
	addl	$1, %eax
	movl	%eax, end(%rip)
	jmp	.L17
.L31:
	nop
	jmp	.L17
.L32:
	nop
	jmp	.L17
.L33:
	nop
.L17:
	addl	$1, -60(%rbp)
.L14:
	cmpl	$3, -60(%rbp)
	jle	.L25
.L11:
	movl	top(%rip), %edx
	movl	end(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	cmpl	$0, -44(%rbp)
	jns	.L34
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L2
.L34:
	nop
.L23:
	movl	-44(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-64(%rbp), %rdx
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L27
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jg	.L28
.L27:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
