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>
#include<limits.h>

#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int Q[N], M[N][N], color[N], d[N], n, f=1, c=1;

void Enqueue(int n){
  Q[f] = n;
  f++;
  if(f == N) f=1;
}

int Dequeue(){
  int x = c;
  c++;
  if(c == N) c=1;
  return Q[x];
}

void BFS(int s){
  int i, u;
  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(f != c){
    u = Dequeue();
    for(i = 1; i <= n; i++){
      if(color[i] == WHITE && M[u][i] == 1){
	color[i] = GRAY;
	d[i] = d[u] + 1;
	Enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

int main(){
  int i, j, k, x, s, m;
  for(i=1; i < n; i++){
    for(j=1; j < n; j++) M[i][j] = 0;
  }
  scanf("%d",&n);
  for(i=1; i <= n; i++){
    scanf("%d%d", &m, &k);
    if(i == 1) s = 1;
    for(j=0; j < k; j++){
      scanf("%d",&x);
      M[m][x] = 1;
    }
  }
  BFS(s);
  for(i=1; i <= n; i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40804
M:
	.zero	40804
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	d
	.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	f
	.data
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.long	1
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.long	1
	.text
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB0:
	.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	f(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	f(%rip), %eax
	addl	$1, %eax
	movl	%eax, f(%rip)
	movl	f(%rip), %eax
	cmpl	$101, %eax
	jne	.L3
	movl	$1, f(%rip)
.L3:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	Enqueue, .-Enqueue
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	c(%rip), %eax
	movl	%eax, -4(%rbp)
	movl	c(%rip), %eax
	addl	$1, %eax
	movl	%eax, c(%rip)
	movl	c(%rip), %eax
	cmpl	$101, %eax
	jne	.L5
	movl	$1, c(%rip)
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Dequeue, .-Dequeue
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L9
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	jmp	.L10
.L14:
	movl	$0, %eax
	call	Dequeue
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L11
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L12
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%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	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L12
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
.L12:
	addl	$1, -8(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L13
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
.L10:
	movl	f(%rip), %edx
	movl	c(%rip), %eax
	cmpl	%eax, %edx
	jne	.L14
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	BFS, .-BFS
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.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, -20(%rbp)
	jmp	.L16
.L19:
	movl	$1, -16(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%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	M(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L18
	addl	$1, -20(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -20(%rbp)
	jmp	.L20
.L24:
	leaq	-32(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, -20(%rbp)
	jne	.L21
	movl	$1, -12(%rbp)
.L21:
	movl	$0, -16(%rbp)
	jmp	.L22
.L23:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-28(%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	M(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L22:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L23
	addl	$1, -20(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L24
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	BFS
	movl	$1, -20(%rbp)
	jmp	.L25
.L26:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L26
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB23:
	.cfi_startproc
	endbr64
	movslq	f(%rip), %rcx
	leaq	Q(%rip), %rax
	movl	$1, %edx
	movl	%edi, (%rax,%rcx,4)
	cmpl	$100, %ecx
	leal	1(%rcx), %eax
	cmove	%edx, %eax
	movl	%eax, f(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	Enqueue, .-Enqueue
	.p2align 4
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	c(%rip), %rax
	movl	$1, %ecx
	cmpl	$100, %eax
	leal	1(%rax), %edx
	cmove	%ecx, %edx
	movl	%edx, c(%rip)
	leaq	Q(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.cfi_endproc
.LFE24:
	.size	Dequeue, .-Dequeue
	.p2align 4
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	n(%rip), %ebx
	testl	%ebx, %ebx
	jle	.L12
	movslq	%ebx, %r13
	xorl	%esi, %esi
	leaq	4+color(%rip), %rdi
	salq	$2, %r13
	movq	%r13, %rdx
	call	memset@PLT
	movq	%r13, %rdx
	movl	$255, %esi
	leaq	4+d(%rip), %rdi
	call	memset@PLT
.L12:
	movslq	f(%rip), %rdx
	movslq	%r12d, %rax
	leaq	color(%rip), %rcx
	leaq	d(%rip), %r11
	movl	$1, (%rcx,%rax,4)
	leaq	Q(%rip), %rbp
	movl	$0, (%r11,%rax,4)
	movq	%rdx, %rax
	movl	%r12d, 0(%rbp,%rdx,4)
	leal	1(%rdx), %edx
	cmpl	$100, %eax
	je	.L10
	movl	%edx, f(%rip)
.L11:
	movslq	c(%rip), %rax
	xorl	%r9d, %r9d
	movl	$1, %r12d
	leal	1(%rbx), %esi
	leaq	M(%rip), %r13
	cmpl	%eax, %edx
	je	.L8
	.p2align 4,,10
	.p2align 3
.L13:
	leal	1(%rax), %r10d
	cmpl	$100, %eax
	movslq	0(%rbp,%rax,4), %r8
	cmove	%r12d, %r10d
	testl	%ebx, %ebx
	jle	.L16
	imulq	$404, %r8, %rdi
	movl	$1, %eax
	addq	%r13, %rdi
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%rcx,%rax,4), %r14d
	testl	%r14d, %r14d
	jne	.L17
	cmpl	$1, (%rdi,%rax,4)
	jne	.L17
	movl	(%r11,%r8,4), %r14d
	movl	$1, (%rcx,%rax,4)
	leal	1(%r14), %r9d
	movl	$1, %r14d
	movl	%r9d, (%r11,%rax,4)
	movslq	%edx, %r9
	addl	$1, %edx
	cmpl	$101, %edx
	movl	%eax, 0(%rbp,%r9,4)
	movl	$1, %r9d
	cmove	%r14d, %edx
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L18
.L16:
	movl	$2, (%rcx,%r8,4)
	cmpl	%edx, %r10d
	je	.L32
	movslq	%r10d, %rax
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%r10d, c(%rip)
	testb	%r9b, %r9b
	je	.L8
	movl	%r10d, f(%rip)
.L8:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	movl	$1, f(%rip)
	movl	$1, %edx
	jmp	.L11
	.cfi_endproc
.LFE25:
	.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:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jle	.L34
	subl	$2, %eax
	leaq	408+M(%rip), %rcx
	imulq	$404, %rax, %rbx
	leaq	404(%rcx), %rdx
	leaq	4(,%rax,4), %rbp
	addq	%rdx, %rbx
	.p2align 4,,10
	.p2align 3
.L35:
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$404, %rcx
	cmpq	%rbx, %rcx
	jne	.L35
.L34:
	leaq	.LC0(%rip), %rbp
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L36
	leaq	36(%rsp), %rax
	movl	$1, %r13d
	leaq	28(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	M(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L39:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	jle	.L37
	xorl	%r14d, %r14d
	leaq	32(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L38:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	36(%rsp), %rax
	movslq	32(%rsp), %rsi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rax
	addq	%rsi, %rax
	movl	$1, (%r12,%rax,4)
	cmpl	%r14d, 28(%rsp)
	jg	.L38
.L37:
	addl	$1, %r13d
	cmpl	%r13d, n(%rip)
	jge	.L39
.L36:
	movl	$1, %edi
	call	BFS
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L40
	movl	$1, %ebx
	leaq	d(%rip), %r12
	leaq	.LC2(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L41:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L41
.L40:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	addq	$56, %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
.L48:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	c
	.data
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.long	1
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.long	1
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40804
M:
	.zero	40804
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.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	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB23:
	.cfi_startproc
	endbr64
	movslq	f(%rip), %rcx
	leaq	Q(%rip), %rax
	movl	$1, %edx
	movl	%edi, (%rax,%rcx,4)
	cmpl	$100, %ecx
	leal	1(%rcx), %eax
	cmove	%edx, %eax
	movl	%eax, f(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	Enqueue, .-Enqueue
	.p2align 4
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	c(%rip), %rax
	movl	$1, %ecx
	cmpl	$100, %eax
	leal	1(%rax), %edx
	cmove	%ecx, %edx
	movl	%edx, c(%rip)
	leaq	Q(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.cfi_endproc
.LFE24:
	.size	Dequeue, .-Dequeue
	.p2align 4
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	n(%rip), %ebx
	testl	%ebx, %ebx
	jle	.L12
	movslq	%ebx, %r13
	xorl	%esi, %esi
	leaq	4+color(%rip), %rdi
	salq	$2, %r13
	movq	%r13, %rdx
	call	memset@PLT
	movq	%r13, %rdx
	movl	$255, %esi
	leaq	4+d(%rip), %rdi
	call	memset@PLT
.L12:
	movslq	f(%rip), %rdx
	movslq	%r12d, %rax
	leaq	color(%rip), %rcx
	leaq	d(%rip), %r11
	movl	$1, (%rcx,%rax,4)
	leaq	Q(%rip), %rbp
	movl	$0, (%r11,%rax,4)
	movq	%rdx, %rax
	movl	%r12d, 0(%rbp,%rdx,4)
	leal	1(%rdx), %edx
	cmpl	$100, %eax
	je	.L10
	movl	%edx, f(%rip)
.L11:
	movslq	c(%rip), %rax
	xorl	%r9d, %r9d
	movl	$1, %r12d
	leal	1(%rbx), %esi
	leaq	M(%rip), %r13
	cmpl	%eax, %edx
	je	.L8
	.p2align 4,,10
	.p2align 3
.L13:
	leal	1(%rax), %r10d
	cmpl	$100, %eax
	movslq	0(%rbp,%rax,4), %r8
	cmove	%r12d, %r10d
	testl	%ebx, %ebx
	jle	.L16
	imulq	$404, %r8, %rdi
	movl	$1, %eax
	addq	%r13, %rdi
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%rcx,%rax,4), %r14d
	testl	%r14d, %r14d
	jne	.L17
	cmpl	$1, (%rdi,%rax,4)
	jne	.L17
	movl	(%r11,%r8,4), %r14d
	movl	$1, (%rcx,%rax,4)
	leal	1(%r14), %r9d
	movl	$1, %r14d
	movl	%r9d, (%r11,%rax,4)
	movslq	%edx, %r9
	addl	$1, %edx
	cmpl	$101, %edx
	movl	%eax, 0(%rbp,%r9,4)
	movl	$1, %r9d
	cmove	%r14d, %edx
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L18
.L16:
	movl	$2, (%rcx,%r8,4)
	cmpl	%edx, %r10d
	je	.L32
	movslq	%r10d, %rax
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%r10d, c(%rip)
	testb	%r9b, %r9b
	je	.L8
	movl	%r10d, f(%rip)
.L8:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	movl	$1, f(%rip)
	movl	$1, %edx
	jmp	.L11
	.cfi_endproc
.LFE25:
	.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:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	movl	n(%rip), %eax
	cmpl	$1, %eax
	jle	.L34
	subl	$2, %eax
	leaq	408+M(%rip), %rcx
	imulq	$404, %rax, %rbx
	leaq	404(%rcx), %rdx
	leaq	4(,%rax,4), %rbp
	addq	%rdx, %rbx
	.p2align 4,,10
	.p2align 3
.L35:
	movq	%rcx, %rdi
	movq	%rbp, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$404, %rcx
	cmpq	%rbx, %rcx
	jne	.L35
.L34:
	leaq	.LC0(%rip), %rbp
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L36
	leaq	36(%rsp), %rax
	movl	$1, %r13d
	leaq	28(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	M(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L39:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	jle	.L37
	xorl	%r14d, %r14d
	leaq	32(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L38:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	36(%rsp), %rax
	movslq	32(%rsp), %rsi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rax
	addq	%rsi, %rax
	movl	$1, (%r12,%rax,4)
	cmpl	%r14d, 28(%rsp)
	jg	.L38
.L37:
	addl	$1, %r13d
	cmpl	%r13d, n(%rip)
	jge	.L39
.L36:
	movl	$1, %edi
	call	BFS
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L40
	movl	$1, %ebx
	leaq	d(%rip), %r12
	leaq	.LC2(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L41:
	movl	(%r12,%rbx,4), %ecx
	movl	%ebx, %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L41
.L40:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L48
	addq	$56, %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
.L48:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	c
	.data
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.long	1
	.globl	f
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.long	1
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 404
d:
	.zero	404
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40804
M:
	.zero	40804
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.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>
#include<limits.h>

#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int Q[N], M[N][N], color[N], d[N], n, f=1, c=1;

void Enqueue(int n){
  Q[f] = n;
  f++;
  if(f == N) f=1;
}

int Dequeue(){
  int x = c;
  c++;
  if(c == N) c=1;
  return Q[x];
}

void BFS(int s){
  int i, u;
  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(f != c){
    u = Dequeue();
    for(i = 1; i <= n; i++){
      if(color[i] == WHITE && M[u][i] == 1){
	color[i] = GRAY;
	d[i] = d[u] + 1;
	Enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

int main(){
  int i, j, k, x, s, m;
  for(i=1; i < n; i++){
    for(j=1; j < n; j++) M[i][j] = 0;
  }
  scanf("%d",&n);
  for(i=1; i <= n; i++){
    scanf("%d%d", &m, &k);
    if(i == 1) s = 1;
    for(j=0; j < k; j++){
      scanf("%d",&x);
      M[m][x] = 1;
    }
  }
  BFS(s);
  for(i=1; i <= n; i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}
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
2 2
3 -1
4 1
 1 0
2 -1
3 1
4 1
 1 0
2 -1
3 1
4 -1
 1 0
2 1
3 -1
4 2

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>
#include<limits.h>

#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int Q[N], M[N][N], color[N], d[N], n, f=1, c=1;

void Enqueue(int n){
  Q[f] = n;
  f++;
  if(f == N) f=1;
}

int Dequeue(){
  int x = c;
  c++;
  if(c == N) c=1;
  return Q[x];
}

void BFS(int s){
  int i, u;
  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  Enqueue(s);
  while(f != c){
    u = Dequeue();
    for(i = 1; i <= n; i++){
      if(color[i] == WHITE && M[u][i] == 1){
	color[i] = GRAY;
	d[i] = d[u] + 1;
	Enqueue(i);
      }
    }
    color[u] = BLACK;
  }
}

int main(){
  int i, j, k, x, s, m;
  for(i=1; i < n; i++){
    for(j=1; j < n; j++) M[i][j] = 0;
  }
  scanf("%d",&n);
  for(i=1; i <= n; i++){
    scanf("%d%d", &m, &k);
    if(i == 1) s = 1;
    for(j=0; j < k; j++){
      scanf("%d",&x);
      M[m][x] = 1;
    }
  }
  BFS(s);
  for(i=1; i <= n; i++){
    printf("%d %d\n", i, d[i]);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40804
M:
	.zero	40804
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	d
	.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	f
	.data
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.long	1
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.long	1
	.text
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB0:
	.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	f(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	f(%rip), %eax
	addl	$1, %eax
	movl	%eax, f(%rip)
	movl	f(%rip), %eax
	cmpl	$101, %eax
	jne	.L3
	movl	$1, f(%rip)
.L3:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	Enqueue, .-Enqueue
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	c(%rip), %eax
	movl	%eax, -4(%rbp)
	movl	c(%rip), %eax
	addl	$1, %eax
	movl	%eax, c(%rip)
	movl	c(%rip), %eax
	cmpl	$101, %eax
	jne	.L5
	movl	$1, c(%rip)
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Dequeue, .-Dequeue
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L9
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	jmp	.L10
.L14:
	movl	$0, %eax
	call	Dequeue
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L11
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L12
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%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	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L12
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
.L12:
	addl	$1, -8(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L13
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
.L10:
	movl	f(%rip), %edx
	movl	c(%rip), %eax
	cmpl	%eax, %edx
	jne	.L14
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	BFS, .-BFS
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.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, -20(%rbp)
	jmp	.L16
.L19:
	movl	$1, -16(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%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	M(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L18
	addl	$1, -20(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -20(%rbp)
	jmp	.L20
.L24:
	leaq	-32(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, -20(%rbp)
	jne	.L21
	movl	$1, -12(%rbp)
.L21:
	movl	$0, -16(%rbp)
	jmp	.L22
.L23:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-28(%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	M(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L22:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L23
	addl	$1, -20(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L24
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	BFS
	movl	$1, -20(%rbp)
	jmp	.L25
.L26:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L26
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	M
	.align 32
	.type	M, @object
	.size	M, 40804
M:
	.zero	40804
	.globl	color
	.align 32
	.type	color, @object
	.size	color, 404
color:
	.zero	404
	.globl	d
	.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	f
	.data
	.align 4
	.type	f, @object
	.size	f, 4
f:
	.long	1
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.long	1
	.text
	.globl	Enqueue
	.type	Enqueue, @function
Enqueue:
.LFB0:
	.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	f(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	f(%rip), %eax
	addl	$1, %eax
	movl	%eax, f(%rip)
	movl	f(%rip), %eax
	cmpl	$101, %eax
	jne	.L3
	movl	$1, f(%rip)
.L3:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	Enqueue, .-Enqueue
	.globl	Dequeue
	.type	Dequeue, @function
Dequeue:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	c(%rip), %eax
	movl	%eax, -4(%rbp)
	movl	c(%rip), %eax
	addl	$1, %eax
	movl	%eax, c(%rip)
	movl	c(%rip), %eax
	cmpl	$101, %eax
	jne	.L5
	movl	$1, c(%rip)
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Dequeue, .-Dequeue
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$24, %rsp
	movl	%edi, -20(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$-1, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L9
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
	jmp	.L10
.L14:
	movl	$0, %eax
	call	Dequeue
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L11
.L13:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L12
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%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	M(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jne	.L12
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	Enqueue
.L12:
	addl	$1, -8(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L13
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	color(%rip), %rax
	movl	$2, (%rdx,%rax)
.L10:
	movl	f(%rip), %edx
	movl	c(%rip), %eax
	cmpl	%eax, %edx
	jne	.L14
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	BFS, .-BFS
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.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, -20(%rbp)
	jmp	.L16
.L19:
	movl	$1, -16(%rbp)
	jmp	.L17
.L18:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%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	M(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L18
	addl	$1, -20(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L19
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -20(%rbp)
	jmp	.L20
.L24:
	leaq	-32(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, -20(%rbp)
	jne	.L21
	movl	$1, -12(%rbp)
.L21:
	movl	$0, -16(%rbp)
	jmp	.L22
.L23:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	-28(%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	M(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L22:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L23
	addl	$1, -20(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L24
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	BFS
	movl	$1, -20(%rbp)
	jmp	.L25
.L26:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L25:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L26
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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:
