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

```c
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	face
	.data
	.align 32
	.type	face, @object
	.size	face, 784
face:
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	1
	.long	2
	.long	3
	.long	0
	.long	1
	.long	3
	.long	5
	.long	0
	.long	1
	.long	4
	.long	2
	.long	0
	.long	1
	.long	5
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	1
	.long	4
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	3
	.long	1
	.long	0
	.long	2
	.long	4
	.long	6
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	6
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	1
	.long	2
	.long	0
	.long	3
	.long	2
	.long	6
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	5
	.long	1
	.long	0
	.long	3
	.long	6
	.long	5
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	1
	.long	5
	.long	0
	.long	4
	.long	2
	.long	1
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	5
	.long	6
	.long	0
	.long	4
	.long	6
	.long	2
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	1
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	3
	.long	6
	.long	0
	.long	5
	.long	4
	.long	1
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	6
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	6
	.long	2
	.long	4
	.long	0
	.long	6
	.long	3
	.long	2
	.long	0
	.long	6
	.long	4
	.long	5
	.long	0
	.long	6
	.long	5
	.long	3
	.long	0
	.zero	12
	.globl	assign
	.bss
	.align 16
	.type	assign, @object
	.size	assign, 28
assign:
	.zero	28
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, -12(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -12(%rbp)
.L2:
	cmpl	$6, -12(%rbp)
	jle	.L3
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L4
.L9:
	leaq	-16(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -12(%rbp)
	jmp	.L5
.L8:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L6
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L6:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L7
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L7:
	addl	$1, -12(%rbp)
.L5:
	cmpl	$6, -12(%rbp)
	jle	.L8
	movl	-20(%rbp), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+face(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	4+assign(%rip), %rbx
	leaq	24(%rbx), %r12
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r12
	jne	.L2
	movq	%rbp, %rdi
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %r15
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	leaq	16(%rsp), %r14
	leaq	.LC1(%rip), %r13
	leaq	assign(%rip), %r12
	leaq	face(%rip), %rbp
	leal	-1(%rax), %edx
	leaq	.LC2(%rip), %rbx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L3
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	(%rdx,%rax,8), %rdx
	subq	%rax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	movslq	12(%rbp,%rax), %rax
.L28:
	movl	(%r12,%rax,4), %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L17
.L3:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4+assign(%rip), %ecx
	movslq	16(%rsp), %rax
	cmpl	%eax, %ecx
	jne	.L4
	movl	$1, 16(%rsp)
	movl	$1, %eax
.L4:
	movslq	20(%rsp), %rdx
	cmpl	%edx, %ecx
	jne	.L5
	movl	$1, 20(%rsp)
	movl	$1, %edx
.L5:
	movl	8+assign(%rip), %ecx
	cmpl	%ecx, %eax
	jne	.L6
	movl	$2, 16(%rsp)
	movl	$2, %eax
.L6:
	cmpl	%edx, %ecx
	jne	.L7
	movl	$2, 20(%rsp)
	movl	$2, %edx
.L7:
	movl	12+assign(%rip), %ecx
	cmpl	%eax, %ecx
	jne	.L8
	movl	$3, 16(%rsp)
	movl	$3, %eax
.L8:
	cmpl	%ecx, %edx
	jne	.L9
	movl	$3, 20(%rsp)
	movl	$3, %edx
.L9:
	movl	16+assign(%rip), %ecx
	cmpl	%eax, %ecx
	jne	.L10
	movl	$4, 16(%rsp)
	movl	$4, %eax
.L10:
	cmpl	%ecx, %edx
	jne	.L11
	movl	$4, 20(%rsp)
	movl	$4, %edx
.L11:
	movl	20+assign(%rip), %ecx
	cmpl	%ecx, %eax
	jne	.L12
	movl	$5, 16(%rsp)
	movl	$5, %eax
.L12:
	cmpl	%ecx, %edx
	jne	.L13
	movl	$5, 20(%rsp)
	movl	$5, %edx
.L13:
	movl	24+assign(%rip), %ecx
	cmpl	%ecx, %eax
	jne	.L14
	movl	$6, 16(%rsp)
	movl	$6, %eax
.L14:
	cmpl	%ecx, %edx
	jne	.L15
	leaq	0(,%rax,8), %rdx
	movl	$6, 20(%rsp)
	subq	%rax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	movslq	108(%rbp,%rax), %rax
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L17:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$40, %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
.L30:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	assign
	.bss
	.align 16
	.type	assign, @object
	.size	assign, 28
assign:
	.zero	28
	.globl	face
	.data
	.align 32
	.type	face, @object
	.size	face, 784
face:
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	1
	.long	2
	.long	3
	.long	0
	.long	1
	.long	3
	.long	5
	.long	0
	.long	1
	.long	4
	.long	2
	.long	0
	.long	1
	.long	5
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	1
	.long	4
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	3
	.long	1
	.long	0
	.long	2
	.long	4
	.long	6
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	6
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	1
	.long	2
	.long	0
	.long	3
	.long	2
	.long	6
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	5
	.long	1
	.long	0
	.long	3
	.long	6
	.long	5
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	1
	.long	5
	.long	0
	.long	4
	.long	2
	.long	1
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	5
	.long	6
	.long	0
	.long	4
	.long	6
	.long	2
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	1
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	3
	.long	6
	.long	0
	.long	5
	.long	4
	.long	1
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	6
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	6
	.long	2
	.long	4
	.long	0
	.long	6
	.long	3
	.long	2
	.long	0
	.long	6
	.long	4
	.long	5
	.long	0
	.long	6
	.long	5
	.long	3
	.long	0
	.zero	12
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	4+assign(%rip), %rbx
	leaq	24(%rbx), %r12
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$4, %rbx
	call	__isoc99_scanf@PLT
	cmpq	%rbx, %r12
	jne	.L2
	movq	%rbp, %rdi
	leaq	12(%rsp), %rsi
	leaq	20(%rsp), %r15
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	leaq	16(%rsp), %r14
	leaq	.LC1(%rip), %r13
	leaq	assign(%rip), %r12
	leaq	face(%rip), %rbp
	leal	-1(%rax), %edx
	leaq	.LC2(%rip), %rbx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	jne	.L3
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	(%rdx,%rax,8), %rdx
	subq	%rax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	movslq	12(%rbp,%rax), %rax
.L28:
	movl	(%r12,%rax,4), %edx
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	12(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 12(%rsp)
	testl	%eax, %eax
	je	.L17
.L3:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4+assign(%rip), %ecx
	movslq	16(%rsp), %rax
	cmpl	%eax, %ecx
	jne	.L4
	movl	$1, 16(%rsp)
	movl	$1, %eax
.L4:
	movslq	20(%rsp), %rdx
	cmpl	%edx, %ecx
	jne	.L5
	movl	$1, 20(%rsp)
	movl	$1, %edx
.L5:
	movl	8+assign(%rip), %ecx
	cmpl	%ecx, %eax
	jne	.L6
	movl	$2, 16(%rsp)
	movl	$2, %eax
.L6:
	cmpl	%edx, %ecx
	jne	.L7
	movl	$2, 20(%rsp)
	movl	$2, %edx
.L7:
	movl	12+assign(%rip), %ecx
	cmpl	%eax, %ecx
	jne	.L8
	movl	$3, 16(%rsp)
	movl	$3, %eax
.L8:
	cmpl	%ecx, %edx
	jne	.L9
	movl	$3, 20(%rsp)
	movl	$3, %edx
.L9:
	movl	16+assign(%rip), %ecx
	cmpl	%eax, %ecx
	jne	.L10
	movl	$4, 16(%rsp)
	movl	$4, %eax
.L10:
	cmpl	%ecx, %edx
	jne	.L11
	movl	$4, 20(%rsp)
	movl	$4, %edx
.L11:
	movl	20+assign(%rip), %ecx
	cmpl	%ecx, %eax
	jne	.L12
	movl	$5, 16(%rsp)
	movl	$5, %eax
.L12:
	cmpl	%ecx, %edx
	jne	.L13
	movl	$5, 20(%rsp)
	movl	$5, %edx
.L13:
	movl	24+assign(%rip), %ecx
	cmpl	%ecx, %eax
	jne	.L14
	movl	$6, 16(%rsp)
	movl	$6, %eax
.L14:
	cmpl	%ecx, %edx
	jne	.L15
	leaq	0(,%rax,8), %rdx
	movl	$6, 20(%rsp)
	subq	%rax, %rdx
	movq	%rdx, %rax
	salq	$4, %rax
	movslq	108(%rbp,%rax), %rax
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L17:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	addq	$40, %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
.L30:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	assign
	.bss
	.align 16
	.type	assign, @object
	.size	assign, 28
assign:
	.zero	28
	.globl	face
	.data
	.align 32
	.type	face, @object
	.size	face, 784
face:
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	1
	.long	2
	.long	3
	.long	0
	.long	1
	.long	3
	.long	5
	.long	0
	.long	1
	.long	4
	.long	2
	.long	0
	.long	1
	.long	5
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	1
	.long	4
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	3
	.long	1
	.long	0
	.long	2
	.long	4
	.long	6
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	6
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	1
	.long	2
	.long	0
	.long	3
	.long	2
	.long	6
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	5
	.long	1
	.long	0
	.long	3
	.long	6
	.long	5
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	1
	.long	5
	.long	0
	.long	4
	.long	2
	.long	1
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	5
	.long	6
	.long	0
	.long	4
	.long	6
	.long	2
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	1
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	3
	.long	6
	.long	0
	.long	5
	.long	4
	.long	1
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	6
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	6
	.long	2
	.long	4
	.long	0
	.long	6
	.long	3
	.long	2
	.long	0
	.long	6
	.long	4
	.long	5
	.long	0
	.long	6
	.long	5
	.long	3
	.long	0
	.zero	12
	.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:

#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}

1 2 3 4 5 6
3
4 5
1 3
3 2
 1 2 3 4 5 6
3
4 5
1 3
6 2
 1 2 3 4 5 6
3
4 5
2 3
6 2
 1 2 3 4 5 6
3
6 5
2 3
6 2
 1 2 3 4 5 6
3
6 3
1 3
3 2
 1 2 3 4 5 6
3
4 2
1 3
3 2
 1 2 3 4 5 6
3
4 5
2 3
4 2
 1 2 3 4 5 6
3
6 5
2 6
6 2
 1 2 3 4 5 6
3
6 4
1 3
3 2
 1 2 3 4 5 6
3
4 5
1 4
6 2

6
5
6
 6
5
4
 6
1
4
 3
1
4
 2
5
6
 1
5
6
 6
1
1
 3
3
4
 5
5
6
 6
2
4

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

```c
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	face
	.data
	.align 32
	.type	face, @object
	.size	face, 784
face:
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	1
	.long	2
	.long	3
	.long	0
	.long	1
	.long	3
	.long	5
	.long	0
	.long	1
	.long	4
	.long	2
	.long	0
	.long	1
	.long	5
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	1
	.long	4
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	3
	.long	1
	.long	0
	.long	2
	.long	4
	.long	6
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	6
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	1
	.long	2
	.long	0
	.long	3
	.long	2
	.long	6
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	5
	.long	1
	.long	0
	.long	3
	.long	6
	.long	5
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	1
	.long	5
	.long	0
	.long	4
	.long	2
	.long	1
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	5
	.long	6
	.long	0
	.long	4
	.long	6
	.long	2
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	1
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	3
	.long	6
	.long	0
	.long	5
	.long	4
	.long	1
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	6
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	6
	.long	2
	.long	4
	.long	0
	.long	6
	.long	3
	.long	2
	.long	0
	.long	6
	.long	4
	.long	5
	.long	0
	.long	6
	.long	5
	.long	3
	.long	0
	.zero	12
	.globl	assign
	.bss
	.align 16
	.type	assign, @object
	.size	assign, 28
assign:
	.zero	28
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, -12(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -12(%rbp)
.L2:
	cmpl	$6, -12(%rbp)
	jle	.L3
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L4
.L9:
	leaq	-16(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -12(%rbp)
	jmp	.L5
.L8:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L6
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L6:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L7
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L7:
	addl	$1, -12(%rbp)
.L5:
	cmpl	$6, -12(%rbp)
	jle	.L8
	movl	-20(%rbp), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+face(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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	face
	.data
	.align 32
	.type	face, @object
	.size	face, 784
face:
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	1
	.long	2
	.long	3
	.long	0
	.long	1
	.long	3
	.long	5
	.long	0
	.long	1
	.long	4
	.long	2
	.long	0
	.long	1
	.long	5
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	1
	.long	4
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	3
	.long	1
	.long	0
	.long	2
	.long	4
	.long	6
	.long	0
	.zero	12
	.long	0
	.long	2
	.long	6
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	1
	.long	2
	.long	0
	.long	3
	.long	2
	.long	6
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	3
	.long	5
	.long	1
	.long	0
	.long	3
	.long	6
	.long	5
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	1
	.long	5
	.long	0
	.long	4
	.long	2
	.long	1
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	4
	.long	5
	.long	6
	.long	0
	.long	4
	.long	6
	.long	2
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	1
	.long	3
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	3
	.long	6
	.long	0
	.long	5
	.long	4
	.long	1
	.long	0
	.zero	12
	.long	0
	.long	5
	.long	6
	.long	4
	.long	0
	.zero	12
	.long	0
	.zero	12
	.long	0
	.long	6
	.long	2
	.long	4
	.long	0
	.long	6
	.long	3
	.long	2
	.long	0
	.long	6
	.long	4
	.long	5
	.long	0
	.long	6
	.long	5
	.long	3
	.long	0
	.zero	12
	.globl	assign
	.bss
	.align 16
	.type	assign, @object
	.size	assign, 28
assign:
	.zero	28
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1, -12(%rbp)
	jmp	.L2
.L3:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -12(%rbp)
.L2:
	cmpl	$6, -12(%rbp)
	jle	.L3
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L4
.L9:
	leaq	-16(%rbp), %rdx
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -12(%rbp)
	jmp	.L5
.L8:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L6
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L6:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L7
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L7:
	addl	$1, -12(%rbp)
.L5:
	cmpl	$6, -12(%rbp)
	jle	.L8
	movl	-20(%rbp), %eax
	movl	-16(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$3, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	12+face(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	assign(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L4:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	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:
