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

```c
// AOJ Vol-3 0300: Floppy Cube
// 2017.9.30

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

int ans;

int rot[4][31] = {
	{ 0,1,2,3,4,5,6,22,23,24,12,11,10,18,14,15,16,17,13,19,20,21,7,8,9,25,26,27,28,29,30 },
	{ 0,28,29,30,4,5,6,7,8,9,10,11,12,13,14,16,15,17,18,21,20,19,22,23,24,25,26,27,1,2,3 },
	{ 0,24,2,3,27,5,6,30,8,9,21,11,12,13,14,15,18,17,16,19,20,10,22,23,1,25,26,4,28,29,7 },
	{ 0,1,2,22,4,5,25,7,8,28,10,11,19,15,14,13,16,17,18,12,20,21,3,23,24,6,26,27,9,29,30 }};

int check(char *a)
{
	int i;
	for (i =  2; i <=  9; i++) if (a[i] != a[ 1]) return 0;
	for (i = 11; i <= 12; i++) if (a[i] != a[10]) return 0;
	for (i = 14; i <= 15; i++) if (a[i] != a[13]) return 0;
	for (i = 17; i <= 18; i++) if (a[i] != a[16]) return 0;
	for (i = 20; i <= 21; i++) if (a[i] != a[19]) return 0;
	for (i = 23; i <= 30; i++) if (a[i] != a[22]) return 0;
	return 1;
}

void dfs(char *a, int k)
{
	int i, j;
	char b[31];

	if (check(a)) { if (k < ans) ans = k; return ; }
	if (k > ans) return;
	for (i = 0; i < 4; i++) {
		for (j = 1; j <= 30; j++) b[j] = a[rot[i][j]];
		dfs(b, k+1);
	}
}

int main()
{
	int n, i, t;
	char a[31];

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 1; i <= 30; i++) scanf("%d", &t), a[i] = t;
		if (check(a)) puts("0");
		else {
			ans = 8;
			dfs(a, 0);
			printf("%d\n", ans);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	ans
	.bss
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.zero	4
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 496
rot:
	.long	0
	.long	1
	.long	2
	.long	3
	.long	4
	.long	5
	.long	6
	.long	22
	.long	23
	.long	24
	.long	12
	.long	11
	.long	10
	.long	18
	.long	14
	.long	15
	.long	16
	.long	17
	.long	13
	.long	19
	.long	20
	.long	21
	.long	7
	.long	8
	.long	9
	.long	25
	.long	26
	.long	27
	.long	28
	.long	29
	.long	30
	.long	0
	.long	28
	.long	29
	.long	30
	.long	4
	.long	5
	.long	6
	.long	7
	.long	8
	.long	9
	.long	10
	.long	11
	.long	12
	.long	13
	.long	14
	.long	16
	.long	15
	.long	17
	.long	18
	.long	21
	.long	20
	.long	19
	.long	22
	.long	23
	.long	24
	.long	25
	.long	26
	.long	27
	.long	1
	.long	2
	.long	3
	.long	0
	.long	24
	.long	2
	.long	3
	.long	27
	.long	5
	.long	6
	.long	30
	.long	8
	.long	9
	.long	21
	.long	11
	.long	12
	.long	13
	.long	14
	.long	15
	.long	18
	.long	17
	.long	16
	.long	19
	.long	20
	.long	10
	.long	22
	.long	23
	.long	1
	.long	25
	.long	26
	.long	4
	.long	28
	.long	29
	.long	7
	.long	0
	.long	1
	.long	2
	.long	22
	.long	4
	.long	5
	.long	25
	.long	7
	.long	8
	.long	28
	.long	10
	.long	11
	.long	19
	.long	15
	.long	14
	.long	13
	.long	16
	.long	17
	.long	18
	.long	12
	.long	20
	.long	21
	.long	3
	.long	23
	.long	24
	.long	6
	.long	26
	.long	27
	.long	9
	.long	29
	.long	30
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$2, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L3
	movl	$0, %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	cmpl	$9, -4(%rbp)
	jle	.L5
	movl	$11, -4(%rbp)
	jmp	.L6
.L8:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$10, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L7
	movl	$0, %eax
	jmp	.L4
.L7:
	addl	$1, -4(%rbp)
.L6:
	cmpl	$12, -4(%rbp)
	jle	.L8
	movl	$14, -4(%rbp)
	jmp	.L9
.L11:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$13, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L10
	movl	$0, %eax
	jmp	.L4
.L10:
	addl	$1, -4(%rbp)
.L9:
	cmpl	$15, -4(%rbp)
	jle	.L11
	movl	$17, -4(%rbp)
	jmp	.L12
.L14:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$16, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L13
	movl	$0, %eax
	jmp	.L4
.L13:
	addl	$1, -4(%rbp)
.L12:
	cmpl	$18, -4(%rbp)
	jle	.L14
	movl	$20, -4(%rbp)
	jmp	.L15
.L17:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$19, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L16
	movl	$0, %eax
	jmp	.L4
.L16:
	addl	$1, -4(%rbp)
.L15:
	cmpl	$21, -4(%rbp)
	jle	.L17
	movl	$23, -4(%rbp)
	jmp	.L18
.L20:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$22, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L19
	movl	$0, %eax
	jmp	.L4
.L19:
	addl	$1, -4(%rbp)
.L18:
	cmpl	$30, -4(%rbp)
	jle	.L20
	movl	$1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB1:
	.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	%rdi, -72(%rbp)
	movl	%esi, -76(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-72(%rbp), %rax
	movq	%rax, %rdi
	call	check
	testl	%eax, %eax
	je	.L22
	movl	ans(%rip), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L32
	movl	-76(%rbp), %eax
	movl	%eax, ans(%rip)
	jmp	.L32
.L22:
	movl	ans(%rip), %eax
	cmpl	%eax, -76(%rbp)
	jg	.L33
	movl	$0, -56(%rbp)
	jmp	.L26
.L29:
	movl	$1, -52(%rbp)
	jmp	.L27
.L28:
	movl	-52(%rbp), %eax
	movslq	%eax, %rcx
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$5, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	addl	$1, -52(%rbp)
.L27:
	cmpl	$30, -52(%rbp)
	jle	.L28
	movl	-76(%rbp), %eax
	leal	1(%rax), %edx
	leaq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	dfs
	addl	$1, -56(%rbp)
.L26:
	cmpl	$3, -56(%rbp)
	jle	.L29
	jmp	.L21
.L32:
	nop
	jmp	.L21
.L33:
	nop
.L21:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L35
.L39:
	movl	$1, -52(%rbp)
	jmp	.L36
.L37:
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-56(%rbp), %eax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	addl	$1, -52(%rbp)
.L36:
	cmpl	$30, -52(%rbp)
	jle	.L37
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	check
	testl	%eax, %eax
	je	.L38
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L35
.L38:
	movl	$8, ans(%rip)
	leaq	-48(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	dfs
	movl	ans(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	movl	-60(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -60(%rbp)
	testl	%eax, %eax
	jg	.L39
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	check
	.type	check, @function
check:
.LFB35:
	.cfi_startproc
	endbr64
	movzbl	1(%rdi), %eax
	cmpb	2(%rdi), %al
	jne	.L25
	cmpb	3(%rdi), %al
	jne	.L25
	cmpb	4(%rdi), %al
	jne	.L25
	cmpb	5(%rdi), %al
	jne	.L25
	cmpb	6(%rdi), %al
	jne	.L25
	cmpb	7(%rdi), %al
	jne	.L25
	cmpb	8(%rdi), %al
	jne	.L25
	cmpb	%al, 9(%rdi)
	jne	.L25
	movzbl	10(%rdi), %eax
	cmpb	%al, 11(%rdi)
	jne	.L25
	cmpb	12(%rdi), %al
	jne	.L25
	movzbl	13(%rdi), %eax
	cmpb	%al, 14(%rdi)
	jne	.L25
	cmpb	15(%rdi), %al
	jne	.L25
	movzbl	16(%rdi), %eax
	cmpb	%al, 17(%rdi)
	jne	.L25
	cmpb	18(%rdi), %al
	jne	.L25
	movzbl	19(%rdi), %eax
	cmpb	%al, 20(%rdi)
	jne	.L25
	cmpb	21(%rdi), %al
	jne	.L25
	movzbl	22(%rdi), %eax
	cmpb	23(%rdi), %al
	jne	.L25
	cmpb	24(%rdi), %al
	jne	.L25
	cmpb	25(%rdi), %al
	jne	.L25
	cmpb	26(%rdi), %al
	jne	.L25
	cmpb	27(%rdi), %al
	jne	.L25
	cmpb	%al, 28(%rdi)
	jne	.L25
	cmpb	%al, 29(%rdi)
	jne	.L25
	cmpb	%al, 30(%rdi)
	sete	%al
	movzbl	%al, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	check, .-check
	.p2align 4
	.type	dfs.part.0, @function
dfs.part.0:
.LFB39:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	leal	1(%rsi), %edi
	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	$264, %rsp
	.cfi_def_cfa_offset 320
	movl	%esi, 52(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 248(%rsp)
	xorl	%eax, %eax
	leaq	80(%rsp), %rax
	movl	%edi, 48(%rsp)
	leaq	rot(%rip), %rdi
	movq	%rax, 32(%rsp)
	movl	%esi, %eax
	addl	$5, %eax
	movq	%rdi, (%rsp)
	movl	%eax, 44(%rsp)
.L28:
	movq	(%rsp), %rcx
	movq	32(%rsp), %rsi
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	(%rcx,%rax,4), %rdx
	movzbl	(%r15,%rdx), %edx
	movb	%dl, (%rsi,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L29
	movq	32(%rsp), %rdi
	call	check
	movl	ans(%rip), %esi
	testl	%eax, %eax
	jne	.L64
	cmpl	%esi, 48(%rsp)
	jg	.L31
	movl	52(%rsp), %eax
	movq	%r15, 72(%rsp)
	leaq	112(%rsp), %r14
	leaq	rot(%rip), %r13
	movq	%r13, %r15
	leal	2(%rax), %edi
	addl	$3, %eax
	movl	%edi, 28(%rsp)
	movl	%eax, 24(%rsp)
.L32:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L33:
	movslq	(%r15,%rax,4), %rdx
	movzbl	80(%rsp,%rdx), %edx
	movb	%dl, (%r14,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L33
	movq	%r14, %rdi
	call	check
	testl	%eax, %eax
	jne	.L65
	cmpl	%esi, 28(%rsp)
	jg	.L35
	movl	52(%rsp), %eax
	leaq	144(%rsp), %r12
	leaq	rot(%rip), %r8
	movq	%r15, 56(%rsp)
	leaq	176(%rsp), %r13
	movq	%r14, 64(%rsp)
	movq	%r12, %r15
	movq	%r8, %r14
	addl	$4, %eax
	movq	%r13, %r12
	movl	%eax, 40(%rsp)
.L36:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	(%r14,%rax,4), %rdx
	movzbl	112(%rsp,%rdx), %edx
	movb	%dl, (%r15,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L37
	movq	%r15, %rdi
	call	check
	testl	%eax, %eax
	jne	.L66
	cmpl	%esi, 24(%rsp)
	jg	.L39
	movq	%r14, 8(%rsp)
	movl	40(%rsp), %r13d
	leaq	rot(%rip), %rbp
	movq	%r15, 16(%rsp)
	movl	44(%rsp), %ebx
.L40:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	0(%rbp,%rax,4), %rdx
	movzbl	144(%rsp,%rdx), %edx
	movb	%dl, (%r12,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L41
	movq	%r12, %rdi
	call	check
	testl	%eax, %eax
	jne	.L67
	leaq	rot(%rip), %r15
	leaq	208(%rsp), %r14
	cmpl	%esi, %r13d
	jg	.L43
.L44:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L45:
	movslq	(%r15,%rax,4), %rdx
	movzbl	176(%rsp,%rdx), %edx
	movb	%dl, (%r14,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L45
	movq	%r14, %rdi
	call	check
	testl	%eax, %eax
	jne	.L68
	cmpl	%esi, %ebx
	jg	.L47
	movl	%ebx, %esi
	call	dfs.part.0
	.p2align 4,,10
	.p2align 3
.L47:
	addq	$124, %r15
	leaq	496+rot(%rip), %rax
	cmpq	%r15, %rax
	je	.L43
	movl	ans(%rip), %esi
	jmp	.L44
.L67:
	cmpl	%esi, %r13d
	jge	.L43
	movl	%r13d, ans(%rip)
	.p2align 4,,10
	.p2align 3
.L43:
	addq	$124, %rbp
	leaq	496+rot(%rip), %rax
	cmpq	%rbp, %rax
	je	.L60
	movl	ans(%rip), %esi
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L68:
	cmpl	%esi, %ebx
	jge	.L47
	movl	%ebx, ans(%rip)
	jmp	.L47
.L60:
	movq	8(%rsp), %r14
	movq	16(%rsp), %r15
.L39:
	addq	$124, %r14
	leaq	496+rot(%rip), %rax
	cmpq	%r14, %rax
	je	.L61
	movl	ans(%rip), %esi
	jmp	.L36
.L61:
	movq	56(%rsp), %r15
	movq	64(%rsp), %r14
.L35:
	addq	$124, %r15
	leaq	496+rot(%rip), %rax
	cmpq	%r15, %rax
	je	.L62
	movl	ans(%rip), %esi
	jmp	.L32
.L66:
	movl	24(%rsp), %eax
	cmpl	%esi, %eax
	jge	.L39
	movl	%eax, ans(%rip)
	jmp	.L39
.L62:
	movq	72(%rsp), %r15
.L31:
	addq	$124, (%rsp)
	movq	(%rsp), %rax
	leaq	496+rot(%rip), %rdi
	cmpq	%rax, %rdi
	jne	.L28
	movq	248(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L69
	addq	$264, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L65:
	.cfi_restore_state
	movl	28(%rsp), %eax
	cmpl	%esi, %eax
	jge	.L35
	movl	%eax, ans(%rip)
	jmp	.L35
.L64:
	movl	48(%rsp), %eax
	cmpl	%esi, %eax
	jge	.L31
	movl	%eax, ans(%rip)
	jmp	.L31
.L69:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	dfs.part.0, .-dfs.part.0
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB36:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	check
	movl	%eax, %r8d
	movl	ans(%rip), %eax
	testl	%r8d, %r8d
	jne	.L74
	cmpl	%esi, %eax
	jl	.L70
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	jmp	dfs.part.0
.L74:
	.cfi_restore_state
	cmpl	%esi, %eax
	jle	.L70
	movl	%esi, ans(%rip)
.L70:
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jle	.L85
	leaq	33(%rsp), %rax
	leaq	63(%rsp), %r12
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rbp
	leaq	32(%rsp), %r14
	leaq	64(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L76:
	movq	8(%rsp), %r15
	.p2align 4,,10
	.p2align 3
.L77:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movb	%al, -1(%r15)
	cmpq	%r12, %r15
	jne	.L77
	movq	%r14, %rdi
	call	check
	movl	%eax, %edx
	testl	%eax, %eax
	je	.L78
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L79:
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jg	.L76
.L85:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L93
	addq	$120, %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
	.p2align 4,,10
	.p2align 3
.L78:
	.cfi_restore_state
	movl	$8, ans(%rip)
	leaq	rot(%rip), %r15
	call	check
	testl	%eax, %eax
	jne	.L94
.L81:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L83:
	movslq	(%r15,%rax,4), %rdx
	movzbl	32(%rsp,%rdx), %edx
	movb	%dl, 0(%r13,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L83
	movl	$1, %esi
	movq	%r13, %rdi
	addq	$124, %r15
	call	dfs
	leaq	496+rot(%rip), %rax
	cmpq	%r15, %rax
	jne	.L81
	movl	ans(%rip), %edx
.L82:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L79
.L94:
	movl	$0, ans(%rip)
	jmp	.L82
.L93:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 496
rot:
	.long	0
	.long	1
	.long	2
	.long	3
	.long	4
	.long	5
	.long	6
	.long	22
	.long	23
	.long	24
	.long	12
	.long	11
	.long	10
	.long	18
	.long	14
	.long	15
	.long	16
	.long	17
	.long	13
	.long	19
	.long	20
	.long	21
	.long	7
	.long	8
	.long	9
	.long	25
	.long	26
	.long	27
	.long	28
	.long	29
	.long	30
	.long	0
	.long	28
	.long	29
	.long	30
	.long	4
	.long	5
	.long	6
	.long	7
	.long	8
	.long	9
	.long	10
	.long	11
	.long	12
	.long	13
	.long	14
	.long	16
	.long	15
	.long	17
	.long	18
	.long	21
	.long	20
	.long	19
	.long	22
	.long	23
	.long	24
	.long	25
	.long	26
	.long	27
	.long	1
	.long	2
	.long	3
	.long	0
	.long	24
	.long	2
	.long	3
	.long	27
	.long	5
	.long	6
	.long	30
	.long	8
	.long	9
	.long	21
	.long	11
	.long	12
	.long	13
	.long	14
	.long	15
	.long	18
	.long	17
	.long	16
	.long	19
	.long	20
	.long	10
	.long	22
	.long	23
	.long	1
	.long	25
	.long	26
	.long	4
	.long	28
	.long	29
	.long	7
	.long	0
	.long	1
	.long	2
	.long	22
	.long	4
	.long	5
	.long	25
	.long	7
	.long	8
	.long	28
	.long	10
	.long	11
	.long	19
	.long	15
	.long	14
	.long	13
	.long	16
	.long	17
	.long	18
	.long	12
	.long	20
	.long	21
	.long	3
	.long	23
	.long	24
	.long	6
	.long	26
	.long	27
	.long	9
	.long	29
	.long	30
	.globl	ans
	.bss
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	check
	.type	check, @function
check:
.LFB35:
	.cfi_startproc
	endbr64
	movzbl	1(%rdi), %eax
	cmpb	2(%rdi), %al
	jne	.L25
	cmpb	3(%rdi), %al
	jne	.L25
	cmpb	4(%rdi), %al
	jne	.L25
	cmpb	5(%rdi), %al
	jne	.L25
	cmpb	6(%rdi), %al
	jne	.L25
	cmpb	7(%rdi), %al
	jne	.L25
	cmpb	8(%rdi), %al
	jne	.L25
	cmpb	%al, 9(%rdi)
	jne	.L25
	movzbl	10(%rdi), %eax
	cmpb	%al, 11(%rdi)
	jne	.L25
	cmpb	12(%rdi), %al
	jne	.L25
	movzbl	13(%rdi), %eax
	cmpb	%al, 14(%rdi)
	jne	.L25
	cmpb	15(%rdi), %al
	jne	.L25
	movzbl	16(%rdi), %eax
	cmpb	%al, 17(%rdi)
	jne	.L25
	cmpb	18(%rdi), %al
	jne	.L25
	movzbl	19(%rdi), %eax
	cmpb	%al, 20(%rdi)
	jne	.L25
	cmpb	21(%rdi), %al
	jne	.L25
	movzbl	22(%rdi), %eax
	cmpb	23(%rdi), %al
	jne	.L25
	cmpb	24(%rdi), %al
	jne	.L25
	cmpb	25(%rdi), %al
	jne	.L25
	cmpb	26(%rdi), %al
	jne	.L25
	cmpb	27(%rdi), %al
	jne	.L25
	cmpb	%al, 28(%rdi)
	jne	.L25
	cmpb	%al, 29(%rdi)
	jne	.L25
	cmpb	%al, 30(%rdi)
	sete	%al
	movzbl	%al, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L25:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	check, .-check
	.p2align 4
	.type	dfs.part.0, @function
dfs.part.0:
.LFB39:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movq	%rdi, %r15
	leal	1(%rsi), %edi
	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	$264, %rsp
	.cfi_def_cfa_offset 320
	movl	%esi, 52(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 248(%rsp)
	xorl	%eax, %eax
	leaq	80(%rsp), %rax
	movl	%edi, 48(%rsp)
	leaq	rot(%rip), %rdi
	movq	%rax, 32(%rsp)
	movl	%esi, %eax
	addl	$5, %eax
	movq	%rdi, (%rsp)
	movl	%eax, 44(%rsp)
.L28:
	movq	(%rsp), %rcx
	movq	32(%rsp), %rsi
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	(%rcx,%rax,4), %rdx
	movzbl	(%r15,%rdx), %edx
	movb	%dl, (%rsi,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L29
	movq	32(%rsp), %rdi
	call	check
	movl	ans(%rip), %esi
	testl	%eax, %eax
	jne	.L64
	cmpl	%esi, 48(%rsp)
	jg	.L31
	movl	52(%rsp), %eax
	movq	%r15, 72(%rsp)
	leaq	112(%rsp), %r14
	leaq	rot(%rip), %r13
	movq	%r13, %r15
	leal	2(%rax), %edi
	addl	$3, %eax
	movl	%edi, 28(%rsp)
	movl	%eax, 24(%rsp)
.L32:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L33:
	movslq	(%r15,%rax,4), %rdx
	movzbl	80(%rsp,%rdx), %edx
	movb	%dl, (%r14,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L33
	movq	%r14, %rdi
	call	check
	testl	%eax, %eax
	jne	.L65
	cmpl	%esi, 28(%rsp)
	jg	.L35
	movl	52(%rsp), %eax
	leaq	144(%rsp), %r12
	leaq	rot(%rip), %r8
	movq	%r15, 56(%rsp)
	leaq	176(%rsp), %r13
	movq	%r14, 64(%rsp)
	movq	%r12, %r15
	movq	%r8, %r14
	addl	$4, %eax
	movq	%r13, %r12
	movl	%eax, 40(%rsp)
.L36:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	(%r14,%rax,4), %rdx
	movzbl	112(%rsp,%rdx), %edx
	movb	%dl, (%r15,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L37
	movq	%r15, %rdi
	call	check
	testl	%eax, %eax
	jne	.L66
	cmpl	%esi, 24(%rsp)
	jg	.L39
	movq	%r14, 8(%rsp)
	movl	40(%rsp), %r13d
	leaq	rot(%rip), %rbp
	movq	%r15, 16(%rsp)
	movl	44(%rsp), %ebx
.L40:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L41:
	movslq	0(%rbp,%rax,4), %rdx
	movzbl	144(%rsp,%rdx), %edx
	movb	%dl, (%r12,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L41
	movq	%r12, %rdi
	call	check
	testl	%eax, %eax
	jne	.L67
	leaq	rot(%rip), %r15
	leaq	208(%rsp), %r14
	cmpl	%esi, %r13d
	jg	.L43
.L44:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L45:
	movslq	(%r15,%rax,4), %rdx
	movzbl	176(%rsp,%rdx), %edx
	movb	%dl, (%r14,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L45
	movq	%r14, %rdi
	call	check
	testl	%eax, %eax
	jne	.L68
	cmpl	%esi, %ebx
	jg	.L47
	movl	%ebx, %esi
	call	dfs.part.0
	.p2align 4,,10
	.p2align 3
.L47:
	addq	$124, %r15
	leaq	496+rot(%rip), %rax
	cmpq	%r15, %rax
	je	.L43
	movl	ans(%rip), %esi
	jmp	.L44
.L67:
	cmpl	%esi, %r13d
	jge	.L43
	movl	%r13d, ans(%rip)
	.p2align 4,,10
	.p2align 3
.L43:
	addq	$124, %rbp
	leaq	496+rot(%rip), %rax
	cmpq	%rbp, %rax
	je	.L60
	movl	ans(%rip), %esi
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L68:
	cmpl	%esi, %ebx
	jge	.L47
	movl	%ebx, ans(%rip)
	jmp	.L47
.L60:
	movq	8(%rsp), %r14
	movq	16(%rsp), %r15
.L39:
	addq	$124, %r14
	leaq	496+rot(%rip), %rax
	cmpq	%r14, %rax
	je	.L61
	movl	ans(%rip), %esi
	jmp	.L36
.L61:
	movq	56(%rsp), %r15
	movq	64(%rsp), %r14
.L35:
	addq	$124, %r15
	leaq	496+rot(%rip), %rax
	cmpq	%r15, %rax
	je	.L62
	movl	ans(%rip), %esi
	jmp	.L32
.L66:
	movl	24(%rsp), %eax
	cmpl	%esi, %eax
	jge	.L39
	movl	%eax, ans(%rip)
	jmp	.L39
.L62:
	movq	72(%rsp), %r15
.L31:
	addq	$124, (%rsp)
	movq	(%rsp), %rax
	leaq	496+rot(%rip), %rdi
	cmpq	%rax, %rdi
	jne	.L28
	movq	248(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L69
	addq	$264, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L65:
	.cfi_restore_state
	movl	28(%rsp), %eax
	cmpl	%esi, %eax
	jge	.L35
	movl	%eax, ans(%rip)
	jmp	.L35
.L64:
	movl	48(%rsp), %eax
	cmpl	%esi, %eax
	jge	.L31
	movl	%eax, ans(%rip)
	jmp	.L31
.L69:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	dfs.part.0, .-dfs.part.0
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB36:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	check
	movl	%eax, %r8d
	movl	ans(%rip), %eax
	testl	%r8d, %r8d
	jne	.L74
	cmpl	%esi, %eax
	jl	.L70
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	jmp	dfs.part.0
.L74:
	.cfi_restore_state
	cmpl	%esi, %eax
	jle	.L70
	movl	%esi, ans(%rip)
.L70:
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE36:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	leaq	.LC0(%rip), %rbx
	movq	%rbx, %rdi
	subq	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jle	.L85
	leaq	33(%rsp), %rax
	leaq	63(%rsp), %r12
	movq	%rax, 8(%rsp)
	leaq	28(%rsp), %rbp
	leaq	32(%rsp), %r14
	leaq	64(%rsp), %r13
	.p2align 4,,10
	.p2align 3
.L76:
	movq	8(%rsp), %r15
	.p2align 4,,10
	.p2align 3
.L77:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movb	%al, -1(%r15)
	cmpq	%r12, %r15
	jne	.L77
	movq	%r14, %rdi
	call	check
	movl	%eax, %edx
	testl	%eax, %eax
	je	.L78
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L79:
	movl	24(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 24(%rsp)
	testl	%eax, %eax
	jg	.L76
.L85:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L93
	addq	$120, %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
	.p2align 4,,10
	.p2align 3
.L78:
	.cfi_restore_state
	movl	$8, ans(%rip)
	leaq	rot(%rip), %r15
	call	check
	testl	%eax, %eax
	jne	.L94
.L81:
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L83:
	movslq	(%r15,%rax,4), %rdx
	movzbl	32(%rsp,%rdx), %edx
	movb	%dl, 0(%r13,%rax)
	addq	$1, %rax
	cmpq	$31, %rax
	jne	.L83
	movl	$1, %esi
	movq	%r13, %rdi
	addq	$124, %r15
	call	dfs
	leaq	496+rot(%rip), %rax
	cmpq	%r15, %rax
	jne	.L81
	movl	ans(%rip), %edx
.L82:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L79
.L94:
	movl	$0, ans(%rip)
	jmp	.L82
.L93:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 496
rot:
	.long	0
	.long	1
	.long	2
	.long	3
	.long	4
	.long	5
	.long	6
	.long	22
	.long	23
	.long	24
	.long	12
	.long	11
	.long	10
	.long	18
	.long	14
	.long	15
	.long	16
	.long	17
	.long	13
	.long	19
	.long	20
	.long	21
	.long	7
	.long	8
	.long	9
	.long	25
	.long	26
	.long	27
	.long	28
	.long	29
	.long	30
	.long	0
	.long	28
	.long	29
	.long	30
	.long	4
	.long	5
	.long	6
	.long	7
	.long	8
	.long	9
	.long	10
	.long	11
	.long	12
	.long	13
	.long	14
	.long	16
	.long	15
	.long	17
	.long	18
	.long	21
	.long	20
	.long	19
	.long	22
	.long	23
	.long	24
	.long	25
	.long	26
	.long	27
	.long	1
	.long	2
	.long	3
	.long	0
	.long	24
	.long	2
	.long	3
	.long	27
	.long	5
	.long	6
	.long	30
	.long	8
	.long	9
	.long	21
	.long	11
	.long	12
	.long	13
	.long	14
	.long	15
	.long	18
	.long	17
	.long	16
	.long	19
	.long	20
	.long	10
	.long	22
	.long	23
	.long	1
	.long	25
	.long	26
	.long	4
	.long	28
	.long	29
	.long	7
	.long	0
	.long	1
	.long	2
	.long	22
	.long	4
	.long	5
	.long	25
	.long	7
	.long	8
	.long	28
	.long	10
	.long	11
	.long	19
	.long	15
	.long	14
	.long	13
	.long	16
	.long	17
	.long	18
	.long	12
	.long	20
	.long	21
	.long	3
	.long	23
	.long	24
	.long	6
	.long	26
	.long	27
	.long	9
	.long	29
	.long	30
	.globl	ans
	.bss
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.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 Vol-3 0300: Floppy Cube
// 2017.9.30

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

int ans;

int rot[4][31] = {
	{ 0,1,2,3,4,5,6,22,23,24,12,11,10,18,14,15,16,17,13,19,20,21,7,8,9,25,26,27,28,29,30 },
	{ 0,28,29,30,4,5,6,7,8,9,10,11,12,13,14,16,15,17,18,21,20,19,22,23,24,25,26,27,1,2,3 },
	{ 0,24,2,3,27,5,6,30,8,9,21,11,12,13,14,15,18,17,16,19,20,10,22,23,1,25,26,4,28,29,7 },
	{ 0,1,2,22,4,5,25,7,8,28,10,11,19,15,14,13,16,17,18,12,20,21,3,23,24,6,26,27,9,29,30 }};

int check(char *a)
{
	int i;
	for (i =  2; i <=  9; i++) if (a[i] != a[ 1]) return 0;
	for (i = 11; i <= 12; i++) if (a[i] != a[10]) return 0;
	for (i = 14; i <= 15; i++) if (a[i] != a[13]) return 0;
	for (i = 17; i <= 18; i++) if (a[i] != a[16]) return 0;
	for (i = 20; i <= 21; i++) if (a[i] != a[19]) return 0;
	for (i = 23; i <= 30; i++) if (a[i] != a[22]) return 0;
	return 1;
}

void dfs(char *a, int k)
{
	int i, j;
	char b[31];

	if (check(a)) { if (k < ans) ans = k; return ; }
	if (k > ans) return;
	for (i = 0; i < 4; i++) {
		for (j = 1; j <= 30; j++) b[j] = a[rot[i][j]];
		dfs(b, k+1);
	}
}

int main()
{
	int n, i, t;
	char a[31];

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 1; i <= 30; i++) scanf("%d", &t), a[i] = t;
		if (check(a)) puts("0");
		else {
			ans = 8;
			dfs(a, 0);
			printf("%d\n", ans);
		}
	}
	return 0;
}
4
1 1 1 1 1 1 1 1 1 2 2 2 4 4 4 6 6 6 5 5 5 3 3 3 3 3 3 3 3 3
3 3 3 1 1 1 1 1 1 2 2 2 4 4 6 4 6 6 5 5 5 3 3 3 3 3 3 1 1 1
3 3 3 1 1 3 1 1 1 2 2 5 6 4 4 4 6 6 2 5 5 3 3 3 1 3 3 1 1 1
1 3 1 3 1 3 3 1 3 2 2 2 6 4 4 6 6 4 5 5 5 1 3 1 1 3 1 3 1 3

0
1
2
7

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

```c
// AOJ Vol-3 0300: Floppy Cube
// 2017.9.30

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

int ans;

int rot[4][31] = {
	{ 0,1,2,3,4,5,6,22,23,24,12,11,10,18,14,15,16,17,13,19,20,21,7,8,9,25,26,27,28,29,30 },
	{ 0,28,29,30,4,5,6,7,8,9,10,11,12,13,14,16,15,17,18,21,20,19,22,23,24,25,26,27,1,2,3 },
	{ 0,24,2,3,27,5,6,30,8,9,21,11,12,13,14,15,18,17,16,19,20,10,22,23,1,25,26,4,28,29,7 },
	{ 0,1,2,22,4,5,25,7,8,28,10,11,19,15,14,13,16,17,18,12,20,21,3,23,24,6,26,27,9,29,30 }};

int check(char *a)
{
	int i;
	for (i =  2; i <=  9; i++) if (a[i] != a[ 1]) return 0;
	for (i = 11; i <= 12; i++) if (a[i] != a[10]) return 0;
	for (i = 14; i <= 15; i++) if (a[i] != a[13]) return 0;
	for (i = 17; i <= 18; i++) if (a[i] != a[16]) return 0;
	for (i = 20; i <= 21; i++) if (a[i] != a[19]) return 0;
	for (i = 23; i <= 30; i++) if (a[i] != a[22]) return 0;
	return 1;
}

void dfs(char *a, int k)
{
	int i, j;
	char b[31];

	if (check(a)) { if (k < ans) ans = k; return ; }
	if (k > ans) return;
	for (i = 0; i < 4; i++) {
		for (j = 1; j <= 30; j++) b[j] = a[rot[i][j]];
		dfs(b, k+1);
	}
}

int main()
{
	int n, i, t;
	char a[31];

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 1; i <= 30; i++) scanf("%d", &t), a[i] = t;
		if (check(a)) puts("0");
		else {
			ans = 8;
			dfs(a, 0);
			printf("%d\n", ans);
		}
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	ans
	.bss
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.zero	4
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 496
rot:
	.long	0
	.long	1
	.long	2
	.long	3
	.long	4
	.long	5
	.long	6
	.long	22
	.long	23
	.long	24
	.long	12
	.long	11
	.long	10
	.long	18
	.long	14
	.long	15
	.long	16
	.long	17
	.long	13
	.long	19
	.long	20
	.long	21
	.long	7
	.long	8
	.long	9
	.long	25
	.long	26
	.long	27
	.long	28
	.long	29
	.long	30
	.long	0
	.long	28
	.long	29
	.long	30
	.long	4
	.long	5
	.long	6
	.long	7
	.long	8
	.long	9
	.long	10
	.long	11
	.long	12
	.long	13
	.long	14
	.long	16
	.long	15
	.long	17
	.long	18
	.long	21
	.long	20
	.long	19
	.long	22
	.long	23
	.long	24
	.long	25
	.long	26
	.long	27
	.long	1
	.long	2
	.long	3
	.long	0
	.long	24
	.long	2
	.long	3
	.long	27
	.long	5
	.long	6
	.long	30
	.long	8
	.long	9
	.long	21
	.long	11
	.long	12
	.long	13
	.long	14
	.long	15
	.long	18
	.long	17
	.long	16
	.long	19
	.long	20
	.long	10
	.long	22
	.long	23
	.long	1
	.long	25
	.long	26
	.long	4
	.long	28
	.long	29
	.long	7
	.long	0
	.long	1
	.long	2
	.long	22
	.long	4
	.long	5
	.long	25
	.long	7
	.long	8
	.long	28
	.long	10
	.long	11
	.long	19
	.long	15
	.long	14
	.long	13
	.long	16
	.long	17
	.long	18
	.long	12
	.long	20
	.long	21
	.long	3
	.long	23
	.long	24
	.long	6
	.long	26
	.long	27
	.long	9
	.long	29
	.long	30
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$2, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L3
	movl	$0, %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	cmpl	$9, -4(%rbp)
	jle	.L5
	movl	$11, -4(%rbp)
	jmp	.L6
.L8:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$10, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L7
	movl	$0, %eax
	jmp	.L4
.L7:
	addl	$1, -4(%rbp)
.L6:
	cmpl	$12, -4(%rbp)
	jle	.L8
	movl	$14, -4(%rbp)
	jmp	.L9
.L11:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$13, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L10
	movl	$0, %eax
	jmp	.L4
.L10:
	addl	$1, -4(%rbp)
.L9:
	cmpl	$15, -4(%rbp)
	jle	.L11
	movl	$17, -4(%rbp)
	jmp	.L12
.L14:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$16, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L13
	movl	$0, %eax
	jmp	.L4
.L13:
	addl	$1, -4(%rbp)
.L12:
	cmpl	$18, -4(%rbp)
	jle	.L14
	movl	$20, -4(%rbp)
	jmp	.L15
.L17:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$19, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L16
	movl	$0, %eax
	jmp	.L4
.L16:
	addl	$1, -4(%rbp)
.L15:
	cmpl	$21, -4(%rbp)
	jle	.L17
	movl	$23, -4(%rbp)
	jmp	.L18
.L20:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$22, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L19
	movl	$0, %eax
	jmp	.L4
.L19:
	addl	$1, -4(%rbp)
.L18:
	cmpl	$30, -4(%rbp)
	jle	.L20
	movl	$1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB1:
	.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	%rdi, -72(%rbp)
	movl	%esi, -76(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-72(%rbp), %rax
	movq	%rax, %rdi
	call	check
	testl	%eax, %eax
	je	.L22
	movl	ans(%rip), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L32
	movl	-76(%rbp), %eax
	movl	%eax, ans(%rip)
	jmp	.L32
.L22:
	movl	ans(%rip), %eax
	cmpl	%eax, -76(%rbp)
	jg	.L33
	movl	$0, -56(%rbp)
	jmp	.L26
.L29:
	movl	$1, -52(%rbp)
	jmp	.L27
.L28:
	movl	-52(%rbp), %eax
	movslq	%eax, %rcx
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$5, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	addl	$1, -52(%rbp)
.L27:
	cmpl	$30, -52(%rbp)
	jle	.L28
	movl	-76(%rbp), %eax
	leal	1(%rax), %edx
	leaq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	dfs
	addl	$1, -56(%rbp)
.L26:
	cmpl	$3, -56(%rbp)
	jle	.L29
	jmp	.L21
.L32:
	nop
	jmp	.L21
.L33:
	nop
.L21:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L35
.L39:
	movl	$1, -52(%rbp)
	jmp	.L36
.L37:
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-56(%rbp), %eax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	addl	$1, -52(%rbp)
.L36:
	cmpl	$30, -52(%rbp)
	jle	.L37
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	check
	testl	%eax, %eax
	je	.L38
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L35
.L38:
	movl	$8, ans(%rip)
	leaq	-48(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	dfs
	movl	ans(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	movl	-60(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -60(%rbp)
	testl	%eax, %eax
	jg	.L39
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	ans
	.bss
	.align 4
	.type	ans, @object
	.size	ans, 4
ans:
	.zero	4
	.globl	rot
	.data
	.align 32
	.type	rot, @object
	.size	rot, 496
rot:
	.long	0
	.long	1
	.long	2
	.long	3
	.long	4
	.long	5
	.long	6
	.long	22
	.long	23
	.long	24
	.long	12
	.long	11
	.long	10
	.long	18
	.long	14
	.long	15
	.long	16
	.long	17
	.long	13
	.long	19
	.long	20
	.long	21
	.long	7
	.long	8
	.long	9
	.long	25
	.long	26
	.long	27
	.long	28
	.long	29
	.long	30
	.long	0
	.long	28
	.long	29
	.long	30
	.long	4
	.long	5
	.long	6
	.long	7
	.long	8
	.long	9
	.long	10
	.long	11
	.long	12
	.long	13
	.long	14
	.long	16
	.long	15
	.long	17
	.long	18
	.long	21
	.long	20
	.long	19
	.long	22
	.long	23
	.long	24
	.long	25
	.long	26
	.long	27
	.long	1
	.long	2
	.long	3
	.long	0
	.long	24
	.long	2
	.long	3
	.long	27
	.long	5
	.long	6
	.long	30
	.long	8
	.long	9
	.long	21
	.long	11
	.long	12
	.long	13
	.long	14
	.long	15
	.long	18
	.long	17
	.long	16
	.long	19
	.long	20
	.long	10
	.long	22
	.long	23
	.long	1
	.long	25
	.long	26
	.long	4
	.long	28
	.long	29
	.long	7
	.long	0
	.long	1
	.long	2
	.long	22
	.long	4
	.long	5
	.long	25
	.long	7
	.long	8
	.long	28
	.long	10
	.long	11
	.long	19
	.long	15
	.long	14
	.long	13
	.long	16
	.long	17
	.long	18
	.long	12
	.long	20
	.long	21
	.long	3
	.long	23
	.long	24
	.long	6
	.long	26
	.long	27
	.long	9
	.long	29
	.long	30
	.text
	.globl	check
	.type	check, @function
check:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	$2, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$1, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L3
	movl	$0, %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	cmpl	$9, -4(%rbp)
	jle	.L5
	movl	$11, -4(%rbp)
	jmp	.L6
.L8:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$10, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L7
	movl	$0, %eax
	jmp	.L4
.L7:
	addl	$1, -4(%rbp)
.L6:
	cmpl	$12, -4(%rbp)
	jle	.L8
	movl	$14, -4(%rbp)
	jmp	.L9
.L11:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$13, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L10
	movl	$0, %eax
	jmp	.L4
.L10:
	addl	$1, -4(%rbp)
.L9:
	cmpl	$15, -4(%rbp)
	jle	.L11
	movl	$17, -4(%rbp)
	jmp	.L12
.L14:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$16, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L13
	movl	$0, %eax
	jmp	.L4
.L13:
	addl	$1, -4(%rbp)
.L12:
	cmpl	$18, -4(%rbp)
	jle	.L14
	movl	$20, -4(%rbp)
	jmp	.L15
.L17:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$19, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L16
	movl	$0, %eax
	jmp	.L4
.L16:
	addl	$1, -4(%rbp)
.L15:
	cmpl	$21, -4(%rbp)
	jle	.L17
	movl	$23, -4(%rbp)
	jmp	.L18
.L20:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	-24(%rbp), %rax
	addq	$22, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L19
	movl	$0, %eax
	jmp	.L4
.L19:
	addl	$1, -4(%rbp)
.L18:
	cmpl	$30, -4(%rbp)
	jle	.L20
	movl	$1, %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	check, .-check
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB1:
	.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	%rdi, -72(%rbp)
	movl	%esi, -76(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-72(%rbp), %rax
	movq	%rax, %rdi
	call	check
	testl	%eax, %eax
	je	.L22
	movl	ans(%rip), %eax
	cmpl	%eax, -76(%rbp)
	jge	.L32
	movl	-76(%rbp), %eax
	movl	%eax, ans(%rip)
	jmp	.L32
.L22:
	movl	ans(%rip), %eax
	cmpl	%eax, -76(%rbp)
	jg	.L33
	movl	$0, -56(%rbp)
	jmp	.L26
.L29:
	movl	$1, -52(%rbp)
	jmp	.L27
.L28:
	movl	-52(%rbp), %eax
	movslq	%eax, %rcx
	movl	-56(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$5, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	rot(%rip), %rax
	movl	(%rdx,%rax), %eax
	movslq	%eax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movl	-52(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	addl	$1, -52(%rbp)
.L27:
	cmpl	$30, -52(%rbp)
	jle	.L28
	movl	-76(%rbp), %eax
	leal	1(%rax), %edx
	leaq	-48(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	dfs
	addl	$1, -56(%rbp)
.L26:
	cmpl	$3, -56(%rbp)
	jle	.L29
	jmp	.L21
.L32:
	nop
	jmp	.L21
.L33:
	nop
.L21:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L35
.L39:
	movl	$1, -52(%rbp)
	jmp	.L36
.L37:
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-56(%rbp), %eax
	movl	%eax, %edx
	movl	-52(%rbp), %eax
	cltq
	movb	%dl, -48(%rbp,%rax)
	addl	$1, -52(%rbp)
.L36:
	cmpl	$30, -52(%rbp)
	jle	.L37
	leaq	-48(%rbp), %rax
	movq	%rax, %rdi
	call	check
	testl	%eax, %eax
	je	.L38
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L35
.L38:
	movl	$8, ans(%rip)
	leaq	-48(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	dfs
	movl	ans(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	movl	-60(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -60(%rbp)
	testl	%eax, %eax
	jg	.L39
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
