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>
#define INF -1
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define MAX 101
void BFS();
int Dequeue();
void Enqueue(int );
int G[MAX][MAX];
int Q[MAX],head=0,tail=0;
int vertex[MAX],edge[MAX];
int color[MAX];
int time,n;
int d[MAX];  /*頂点からの距離*/
int main() 
{
 int i,j;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 scanf("%d%d",&vertex[i],&edge[i]);
 	for(j=1;j<=edge[i];j++)
 	{
		scanf("%d",&G[vertex[i]][j]);
 	}
 }
 BFS(vertex[1]);
 for(i=1;i<=n;i++) printf("%d %d\n",vertex[i],d[vertex[i]]);
 return 0;
}

void BFS(int s)
{
 int i,empty,u,v;
 for(i=1;i<=n;i++)
 {
 	color[i] = WHITE;
 	d[i] = INF;
 }
 color[s] = GRAY;
 d[s] = 0;
 empty = 0;
 Enqueue(s);
 empty++;
 while( empty != 0)
 {
	u = Dequeue();
	empty--;
	for(i=1;i<=edge[u];i++)
	{
		v = G[u][i];
		if(color[v] == WHITE)
		{
			color[v] = GRAY;
			d[v] = d[u]+1;
			Enqueue(v);
			empty++;
		}
	}
 }
 color[u] = BLACK;
}

int Dequeue()
{
 if(head == MAX) head = 0;
 return Q[head++];
}

void Enqueue(int value)
{
 if(tail == MAX) tail =0;
 Q[tail++] = value;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	G
	.bss
	.align 32
	.type	G, @object
	.size	G, 40804
G:
	.zero	40804
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 404
vertex:
	.zero	404
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 404
edge:
	.zero	404
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %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	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -8(%rbp)
	jmp	.L2
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	vertex(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -4(%rbp)
	jmp	.L3
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L4
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L5
	movl	4+vertex(%rip), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	BFS
	movl	$1, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	vertex(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L7
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L10
.L11:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L11
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -12(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	addl	$1, -12(%rbp)
	jmp	.L12
.L16:
	movl	$0, %eax
	call	Dequeue
	movl	%eax, -8(%rbp)
	subl	$1, -12(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L13
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L14
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	addl	$1, -12(%rbp)
.L14:
	addl	$1, -16(%rbp)
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L15
.L12:
	cmpl	$0, -12(%rbp)
	jne	.L16
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	BFS, .-BFS
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	head(%rip), %eax
	cmpl	$101, %eax
	jne	.L18
	movl	$0, head(%rip)
.L18:
	movl	head(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Dequeue, .-Dequeue
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	tail(%rip), %eax
	cmpl	$101, %eax
	jne	.L21
	movl	$0, tail(%rip)
.L21:
	movl	tail(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Enqueue, .-Enqueue
	.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	BFS
	.type	BFS, @function
BFS:
.LFB24:
	.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
	movl	%edi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movslq	n(%rip), %rax
	testl	%eax, %eax
	jle	.L5
	leaq	0(,%rax,4), %r12
	xorl	%esi, %esi
	leaq	4+color(%rip), %rdi
	movq	%r12, %rdx
	call	memset@PLT
	movq	%r12, %rdx
	movl	$255, %esi
	leaq	4+d(%rip), %rdi
	call	memset@PLT
.L5:
	movslq	%ebx, %rax
	leaq	color(%rip), %r9
	leaq	d(%rip), %rbp
	movl	$2, (%r9,%rax,4)
	movl	$0, 0(%rbp,%rax,4)
	movslq	tail(%rip), %rax
	leal	1(%rax), %r8d
	cmpl	$101, %eax
	jne	.L3
	movl	$1, %r8d
	xorl	%eax, %eax
.L3:
	leaq	Q(%rip), %r12
	movl	%r8d, tail(%rip)
	xorl	%edi, %edi
	movl	$1, %r10d
	movl	%ebx, (%r12,%rax,4)
	movl	head(%rip), %r13d
	leaq	edge(%rip), %r14
	leaq	G(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$101, %r13d
	je	.L14
	movslq	%r13d, %rax
	addl	$1, %r13d
.L6:
	movslq	(%r12,%rax,4), %r11
	subl	$1, %r10d
	movl	(%r14,%r11,4), %ecx
	testl	%ecx, %ecx
	jle	.L7
	leaq	(%r11,%r11,4), %rdx
	subl	$1, %ecx
	leaq	8+G(%rip), %rbx
	imulq	$404, %r11, %rax
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%r11,%rdx,4), %rdx
	addq	%rcx, %rdx
	leaq	4(%r15,%rax), %rax
	leaq	(%rbx,%rdx,4), %rbx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L24:
	movslq	%r8d, %rdx
	addl	$1, %r8d
.L9:
	movl	%esi, (%r12,%rdx,4)
	addl	$1, %r10d
	movl	%edi, 0(%rbp,%rcx,4)
	movl	$1, %edi
.L8:
	addq	$4, %rax
	cmpq	%rbx, %rax
	je	.L7
.L10:
	movslq	(%rax), %rcx
	movslq	(%r9,%rcx,4), %rdx
	movq	%rcx, %rsi
	testl	%edx, %edx
	jne	.L8
	movl	0(%rbp,%r11,4), %edi
	movl	$2, (%r9,%rcx,4)
	addl	$1, %edi
	cmpl	$101, %r8d
	jne	.L24
	movl	$1, %r8d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	testl	%r10d, %r10d
	jne	.L11
	movl	%r13d, head(%rip)
	testb	%dil, %dil
	je	.L12
	movl	%r8d, tail(%rip)
.L12:
	movl	$1, (%r9,%r11,4)
	addq	$8, %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
	.p2align 4,,10
	.p2align 3
.L14:
	.cfi_restore_state
	movl	$1, %r13d
	xorl	%eax, %eax
	jmp	.L6
	.cfi_endproc
.LFE24:
	.size	BFS, .-BFS
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %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
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	$1, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	G(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	leaq	4+vertex(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	4+edge(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L31
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	movl	$1, %r15d
	testl	%eax, %eax
	jle	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	0(%rbp), %rax
	movq	%r12, %rdi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rax
	addq	%r15, %rax
	addq	$1, %r15
	leaq	0(%r13,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	%r15d, (%rbx)
	jge	.L29
.L32:
	addl	$1, %r14d
	addq	$4, %rbp
	addq	$4, %rbx
	cmpl	%r14d, n(%rip)
	jge	.L30
.L31:
	movl	4+vertex(%rip), %edi
	xorl	%eax, %eax
	movl	$1, %ebx
	leaq	vertex(%rip), %r13
	leaq	d(%rip), %r12
	leaq	.LC2(%rip), %rbp
	call	BFS
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.L41
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	0(%r13,%rbx,4), %rax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	movl	(%r12,%rax,4), %ecx
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L27
.L41:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	head(%rip), %rax
	leal	1(%rax), %edx
	cmpl	$101, %eax
	jne	.L45
	movl	$1, %edx
	xorl	%eax, %eax
.L45:
	movl	%edx, head(%rip)
	leaq	Q(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.cfi_endproc
.LFE25:
	.size	Dequeue, .-Dequeue
	.p2align 4
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB26:
	.cfi_startproc
	endbr64
	movslq	tail(%rip), %rax
	leal	1(%rax), %edx
	cmpl	$101, %eax
	jne	.L48
	movl	$1, %edx
	xorl	%eax, %eax
.L48:
	movl	%edx, tail(%rip)
	leaq	Q(%rip), %rdx
	movl	%edi, (%rdx,%rax,4)
	ret
	.cfi_endproc
.LFE26:
	.size	Enqueue, .-Enqueue
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 404
edge:
	.zero	404
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 404
vertex:
	.zero	404
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	G
	.align 32
	.type	G, @object
	.size	G, 40804
G:
	.zero	40804
	.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	BFS
	.type	BFS, @function
BFS:
.LFB24:
	.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
	movl	%edi, %ebx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movslq	n(%rip), %rax
	testl	%eax, %eax
	jle	.L5
	leaq	0(,%rax,4), %r12
	xorl	%esi, %esi
	leaq	4+color(%rip), %rdi
	movq	%r12, %rdx
	call	memset@PLT
	movq	%r12, %rdx
	movl	$255, %esi
	leaq	4+d(%rip), %rdi
	call	memset@PLT
.L5:
	movslq	%ebx, %rax
	leaq	color(%rip), %r9
	leaq	d(%rip), %rbp
	movl	$2, (%r9,%rax,4)
	movl	$0, 0(%rbp,%rax,4)
	movslq	tail(%rip), %rax
	leal	1(%rax), %r8d
	cmpl	$101, %eax
	jne	.L3
	movl	$1, %r8d
	xorl	%eax, %eax
.L3:
	leaq	Q(%rip), %r12
	movl	%r8d, tail(%rip)
	xorl	%edi, %edi
	movl	$1, %r10d
	movl	%ebx, (%r12,%rax,4)
	movl	head(%rip), %r13d
	leaq	edge(%rip), %r14
	leaq	G(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	$101, %r13d
	je	.L14
	movslq	%r13d, %rax
	addl	$1, %r13d
.L6:
	movslq	(%r12,%rax,4), %r11
	subl	$1, %r10d
	movl	(%r14,%r11,4), %ecx
	testl	%ecx, %ecx
	jle	.L7
	leaq	(%r11,%r11,4), %rdx
	subl	$1, %ecx
	leaq	8+G(%rip), %rbx
	imulq	$404, %r11, %rax
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%r11,%rdx,4), %rdx
	addq	%rcx, %rdx
	leaq	4(%r15,%rax), %rax
	leaq	(%rbx,%rdx,4), %rbx
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L24:
	movslq	%r8d, %rdx
	addl	$1, %r8d
.L9:
	movl	%esi, (%r12,%rdx,4)
	addl	$1, %r10d
	movl	%edi, 0(%rbp,%rcx,4)
	movl	$1, %edi
.L8:
	addq	$4, %rax
	cmpq	%rbx, %rax
	je	.L7
.L10:
	movslq	(%rax), %rcx
	movslq	(%r9,%rcx,4), %rdx
	movq	%rcx, %rsi
	testl	%edx, %edx
	jne	.L8
	movl	0(%rbp,%r11,4), %edi
	movl	$2, (%r9,%rcx,4)
	addl	$1, %edi
	cmpl	$101, %r8d
	jne	.L24
	movl	$1, %r8d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	testl	%r10d, %r10d
	jne	.L11
	movl	%r13d, head(%rip)
	testb	%dil, %dil
	je	.L12
	movl	%r8d, tail(%rip)
.L12:
	movl	$1, (%r9,%r11,4)
	addq	$8, %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
	.p2align 4,,10
	.p2align 3
.L14:
	.cfi_restore_state
	movl	$1, %r13d
	xorl	%eax, %eax
	jmp	.L6
	.cfi_endproc
.LFE24:
	.size	BFS, .-BFS
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %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
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	$1, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	G(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	leaq	4+vertex(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	4+edge(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L31
	.p2align 4,,10
	.p2align 3
.L30:
	movq	%rbx, %rdx
	movq	%rbp, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%rbx), %eax
	movl	$1, %r15d
	testl	%eax, %eax
	jle	.L32
	.p2align 4,,10
	.p2align 3
.L29:
	movslq	0(%rbp), %rax
	movq	%r12, %rdi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rax
	addq	%r15, %rax
	addq	$1, %r15
	leaq	0(%r13,%rax,4), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	%r15d, (%rbx)
	jge	.L29
.L32:
	addl	$1, %r14d
	addq	$4, %rbp
	addq	$4, %rbx
	cmpl	%r14d, n(%rip)
	jge	.L30
.L31:
	movl	4+vertex(%rip), %edi
	xorl	%eax, %eax
	movl	$1, %ebx
	leaq	vertex(%rip), %r13
	leaq	d(%rip), %r12
	leaq	.LC2(%rip), %rbp
	call	BFS
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.L41
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	0(%r13,%rbx,4), %rax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	movl	(%r12,%rax,4), %ecx
	movq	%rax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L27
.L41:
	addq	$8, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	head(%rip), %rax
	leal	1(%rax), %edx
	cmpl	$101, %eax
	jne	.L45
	movl	$1, %edx
	xorl	%eax, %eax
.L45:
	movl	%edx, head(%rip)
	leaq	Q(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.cfi_endproc
.LFE25:
	.size	Dequeue, .-Dequeue
	.p2align 4
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB26:
	.cfi_startproc
	endbr64
	movslq	tail(%rip), %rax
	leal	1(%rax), %edx
	cmpl	$101, %eax
	jne	.L48
	movl	$1, %edx
	xorl	%eax, %eax
.L48:
	movl	%edx, tail(%rip)
	leaq	Q(%rip), %rdx
	movl	%edi, (%rdx,%rax,4)
	ret
	.cfi_endproc
.LFE26:
	.size	Enqueue, .-Enqueue
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 404
edge:
	.zero	404
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 404
vertex:
	.zero	404
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	G
	.align 32
	.type	G, @object
	.size	G, 40804
G:
	.zero	40804
	.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>
#define INF -1
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define MAX 101
void BFS();
int Dequeue();
void Enqueue(int );
int G[MAX][MAX];
int Q[MAX],head=0,tail=0;
int vertex[MAX],edge[MAX];
int color[MAX];
int time,n;
int d[MAX];  /*頂点からの距離*/
int main() 
{
 int i,j;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 scanf("%d%d",&vertex[i],&edge[i]);
 	for(j=1;j<=edge[i];j++)
 	{
		scanf("%d",&G[vertex[i]][j]);
 	}
 }
 BFS(vertex[1]);
 for(i=1;i<=n;i++) printf("%d %d\n",vertex[i],d[vertex[i]]);
 return 0;
}

void BFS(int s)
{
 int i,empty,u,v;
 for(i=1;i<=n;i++)
 {
 	color[i] = WHITE;
 	d[i] = INF;
 }
 color[s] = GRAY;
 d[s] = 0;
 empty = 0;
 Enqueue(s);
 empty++;
 while( empty != 0)
 {
	u = Dequeue();
	empty--;
	for(i=1;i<=edge[u];i++)
	{
		v = G[u][i];
		if(color[v] == WHITE)
		{
			color[v] = GRAY;
			d[v] = d[u]+1;
			Enqueue(v);
			empty++;
		}
	}
 }
 color[u] = BLACK;
}

int Dequeue()
{
 if(head == MAX) head = 0;
 return Q[head++];
}

void Enqueue(int value)
{
 if(tail == MAX) tail =0;
 Q[tail++] = value;
}
4
1 2 1 4
2 1 4
3 0
4 1 3
 4
1 2 1 4
2 1 4
3 0
4 1 4
 4
1 2 2 4
2 1 4
3 0
4 1 1
 4
1 2 2 4
2 1 1
3 0
4 1 3
 4
1 2 1 1
2 1 4
3 0
4 1 4
 4
1 2 2 1
2 1 1
3 0
4 1 3
 4
1 2 1 4
3 1 4
3 0
4 1 2
 4
1 2 3 4
4 1 4
3 -1
3 1 0
 4
1 2 1 3
0 1 1
4 0
4 1 1
 4
1 2 2 1
2 1 4
3 0
3 1 0

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

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>
#define INF -1
#define WHITE 0
#define BLACK 1
#define GRAY 2
#define MAX 101
void BFS();
int Dequeue();
void Enqueue(int );
int G[MAX][MAX];
int Q[MAX],head=0,tail=0;
int vertex[MAX],edge[MAX];
int color[MAX];
int time,n;
int d[MAX];  /*頂点からの距離*/
int main() 
{
 int i,j;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 scanf("%d%d",&vertex[i],&edge[i]);
 	for(j=1;j<=edge[i];j++)
 	{
		scanf("%d",&G[vertex[i]][j]);
 	}
 }
 BFS(vertex[1]);
 for(i=1;i<=n;i++) printf("%d %d\n",vertex[i],d[vertex[i]]);
 return 0;
}

void BFS(int s)
{
 int i,empty,u,v;
 for(i=1;i<=n;i++)
 {
 	color[i] = WHITE;
 	d[i] = INF;
 }
 color[s] = GRAY;
 d[s] = 0;
 empty = 0;
 Enqueue(s);
 empty++;
 while( empty != 0)
 {
	u = Dequeue();
	empty--;
	for(i=1;i<=edge[u];i++)
	{
		v = G[u][i];
		if(color[v] == WHITE)
		{
			color[v] = GRAY;
			d[v] = d[u]+1;
			Enqueue(v);
			empty++;
		}
	}
 }
 color[u] = BLACK;
}

int Dequeue()
{
 if(head == MAX) head = 0;
 return Q[head++];
}

void Enqueue(int value)
{
 if(tail == MAX) tail =0;
 Q[tail++] = value;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	G
	.bss
	.align 32
	.type	G, @object
	.size	G, 40804
G:
	.zero	40804
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 404
vertex:
	.zero	404
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 404
edge:
	.zero	404
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %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	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -8(%rbp)
	jmp	.L2
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	vertex(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -4(%rbp)
	jmp	.L3
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L4
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L5
	movl	4+vertex(%rip), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	BFS
	movl	$1, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	vertex(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L7
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L10
.L11:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L11
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -12(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	addl	$1, -12(%rbp)
	jmp	.L12
.L16:
	movl	$0, %eax
	call	Dequeue
	movl	%eax, -8(%rbp)
	subl	$1, -12(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L13
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L14
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	addl	$1, -12(%rbp)
.L14:
	addl	$1, -16(%rbp)
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L15
.L12:
	cmpl	$0, -12(%rbp)
	jne	.L16
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	BFS, .-BFS
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	head(%rip), %eax
	cmpl	$101, %eax
	jne	.L18
	movl	$0, head(%rip)
.L18:
	movl	head(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Dequeue, .-Dequeue
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	tail(%rip), %eax
	cmpl	$101, %eax
	jne	.L21
	movl	$0, tail(%rip)
.L21:
	movl	tail(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Enqueue, .-Enqueue
	.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	G
	.bss
	.align 32
	.type	G, @object
	.size	G, 40804
G:
	.zero	40804
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	vertex
	.align 32
	.type	vertex, @object
	.size	vertex, 404
vertex:
	.zero	404
	.globl	edge
	.align 32
	.type	edge, @object
	.size	edge, 404
edge:
	.zero	404
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	time
	.align 4
	.type	time, @object
	.size	time, 4
time:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %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	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -8(%rbp)
	jmp	.L2
.L5:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	addq	%rax, %rdx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	vertex(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -4(%rbp)
	jmp	.L3
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L3:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -4(%rbp)
	jle	.L4
	addl	$1, -8(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L5
	movl	4+vertex(%rip), %eax
	movl	%eax, %edi
	movl	$0, %eax
	call	BFS
	movl	$1, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vertex(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	vertex(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L7
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L10
.L11:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L11
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$0, -12(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	addl	$1, -12(%rbp)
	jmp	.L12
.L16:
	movl	$0, %eax
	call	Dequeue
	movl	%eax, -8(%rbp)
	subl	$1, -12(%rbp)
	movl	$1, -16(%rbp)
	jmp	.L13
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L14
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	addl	$1, -12(%rbp)
.L14:
	addl	$1, -16(%rbp)
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	edge(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L15
.L12:
	cmpl	$0, -12(%rbp)
	jne	.L16
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	BFS, .-BFS
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	head(%rip), %eax
	cmpl	$101, %eax
	jne	.L18
	movl	$0, head(%rip)
.L18:
	movl	head(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Dequeue, .-Dequeue
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	tail(%rip), %eax
	cmpl	$101, %eax
	jne	.L21
	movl	$0, tail(%rip)
.L21:
	movl	tail(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	Enqueue, .-Enqueue
	.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:
