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 N 101
#define WHITE -4
#define GRAY -3
#define BLACK -2
#define INF -1

typedef struct{
  int Adj[N];
  int k;
  int color;
  int d;
  int id;
}Node;

Node node[N];
int head, tail, n, Q[N];

void enqueue(int x){
  Q[tail] = x;
  if(tail == n)
    tail = 0;
  else
    tail++;
}

int dequeue(void){
  int y;
  y = Q[head];
  if(head == n)
    head = 0;
  else
    head++;
  return y;
}

void BFS(){
  int i, u;
  for(i = 1;i < n+1;i++){
    node[i].color = WHITE;
    node[i].d = INF;
  }
  node[1].color = GRAY;
  node[1].d = 0;
  head = tail = 0;
  enqueue(node[1].id);
  while(head != tail){
    u = dequeue();
    for(i = 0;i < node[u].k;i++){
      if(node[node[u].Adj[i]].color == WHITE){
	node[node[u].Adj[i]].color = GRAY;
	node[node[u].Adj[i]].d = node[u].d + 1;
	enqueue(node[u].Adj[i]);
      }
    }
    node[u].color = BLACK;
  }
}
  

int main(){
  int i, j, l;
  scanf("%d", &n);
  for(i = 1;i < n+1;i++){
    scanf("%d%d", &node[i].id, &node[i].k);
    for(j = 0;j < node[i].k;j++)
      scanf("%d", &node[i].Adj[j]);   
  }
    BFS();
  for(i = 1;i < n+1;i++)
    printf("%d %d\n", i, node[i].d);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	node
	.bss
	.align 32
	.type	node, @object
	.size	node, 42420
node:
	.zero	42420
	.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	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.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	tail(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	tail(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jne	.L2
	movl	$0, tail(%rip)
	jmp	.L4
.L2:
	movl	tail(%rip), %eax
	addl	$1, %eax
	movl	%eax, tail(%rip)
.L4:
	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	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	head(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jne	.L6
	movl	$0, head(%rip)
	jmp	.L7
.L6:
	movl	head(%rip), %eax
	addl	$1, %eax
	movl	%eax, head(%rip)
.L7:
	movl	-4(%rbp), %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	$16, %rsp
	movl	$1, -8(%rbp)
	jmp	.L10
.L11:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-4, (%rax,%rdx)
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	$-1, (%rax,%rdx)
	addl	$1, -8(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L11
	movl	$-3, 828+node(%rip)
	movl	$0, 832+node(%rip)
	movl	$0, tail(%rip)
	movl	tail(%rip), %eax
	movl	%eax, head(%rip)
	movl	836+node(%rip), %eax
	movl	%eax, %edi
	call	enqueue
	jmp	.L12
.L16:
	call	dequeue
	movl	%eax, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L15:
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	$-4, %eax
	jne	.L14
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-3, (%rax,%rdx)
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	(%rax,%rdx), %ecx
	movl	-8(%rbp), %eax
	movslq	%eax, %rsi
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %ecx
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	enqueue
.L14:
	addl	$1, -8(%rbp)
.L13:
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	404+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L15
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-2, (%rax,%rdx)
.L12:
	movl	head(%rip), %edx
	movl	tail(%rip), %eax
	cmpl	%eax, %edx
	jne	.L16
	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	$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	.L18
.L21:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	400(%rax), %rdx
	leaq	node(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	416(%rax), %rcx
	leaq	node(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L19
.L20:
	movl	-4(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%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)
.L19:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	404+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L20
	addl	$1, -8(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L21
	movl	$0, %eax
	call	BFS
	movl	$1, -8(%rbp)
	jmp	.L22
.L23:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	(%rax,%rdx), %edx
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L22:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L23
	movl	$0, %eax
	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	tail(%rip), %rcx
	leaq	Q(%rip), %rdx
	movl	%edi, (%rdx,%rcx,4)
	xorl	%edx, %edx
	cmpl	n(%rip), %ecx
	je	.L2
	leal	1(%rcx), %edx
.L2:
	movl	%edx, tail(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	enqueue, .-enqueue
	.p2align 4
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	head(%rip), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rdx,%rcx,4), %r8d
	xorl	%edx, %edx
	cmpl	n(%rip), %ecx
	je	.L6
	leal	1(%rcx), %edx
.L6:
	movl	%edx, head(%rip)
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	dequeue, .-dequeue
	.p2align 4
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB25:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r11d
	testl	%r11d, %r11d
	jle	.L9
	cmpl	$1, %r11d
	je	.L22
	movl	%r11d, %edx
	leaq	828+node(%rip), %rax
	shrl	%edx
	leaq	840(%rax), %rcx
	subl	$1, %edx
	imulq	$840, %rdx, %rdx
	addq	%rcx, %rdx
	.p2align 4,,10
	.p2align 3
.L11:
	movq	$-4, (%rax)
	addq	$840, %rax
	movq	$-4, -420(%rax)
	cmpq	%rdx, %rax
	jne	.L11
	movl	%r11d, %eax
	orl	$1, %eax
	testb	$1, %r11b
	je	.L12
.L10:
	cltq
	movq	.LC0(%rip), %rcx
	leaq	8+node(%rip), %rdx
	imulq	$420, %rax, %rax
	movq	%rcx, 400(%rdx,%rax)
.L12:
	movq	.LC1(%rip), %rax
	movslq	836+node(%rip), %rdi
	movq	%rax, 828+node(%rip)
	movl	%edi, Q(%rip)
.L13:
	leaq	node(%rip), %r8
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$1, %esi
	xorl	%r10d, %r10d
	movl	$1, tail(%rip)
	leaq	4(%r8), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	Q(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	%r11d, %r10d
	leal	1(%r10), %eax
	cmove	%r13d, %eax
	imulq	$420, %rdi, %rdx
	movl	%eax, %r10d
	addq	%r8, %rdx
	movl	404(%rdx), %ecx
	testl	%ecx, %ecx
	jle	.L16
	leaq	(%rdi,%rdi,2), %rax
	subl	$1, %ecx
	movq	%rdx, %rbp
	leaq	(%rdi,%rax,4), %rax
	leaq	(%rdi,%rax,8), %rax
	addq	%rcx, %rax
	leaq	(%r14,%rax,4), %r9
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$4, %rdx
	cmpq	%r9, %rdx
	je	.L16
.L18:
	movslq	(%rdx), %rax
	movq	%rax, %rcx
	imulq	$420, %rax, %rax
	addq	%r8, %rax
	cmpl	$-4, 408(%rax)
	jne	.L17
	movl	412(%rbp), %r12d
	movl	$-3, 408(%rax)
	addl	$1, %r12d
	movl	%r12d, 412(%rax)
	movslq	%esi, %rax
	movl	%ecx, (%rbx,%rax,4)
	cmpl	%esi, %r11d
	je	.L24
	addq	$4, %rdx
	addl	$1, %esi
	movl	$1, %r12d
	cmpq	%r9, %rdx
	jne	.L18
	.p2align 4,,10
	.p2align 3
.L16:
	imulq	$420, %rdi, %rdi
	movl	$-2, 408(%r8,%rdi)
	cmpl	%r10d, %esi
	je	.L19
	movslq	%r10d, %rax
	movslq	(%rbx,%rax,4), %rdi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L24:
	movl	$1, %r12d
	xorl	%esi, %esi
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%esi, head(%rip)
	testb	%r12b, %r12b
	je	.L8
	movl	%esi, tail(%rip)
.L8:
	popq	%rbx
	.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
.L9:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	movq	.LC1(%rip), %rax
	movslq	836+node(%rip), %rdi
	movl	$0, tail(%rip)
	movl	$0, head(%rip)
	movq	%rax, 828+node(%rip)
	movl	%edi, Q(%rip)
	jne	.L13
	ret
.L22:
	movl	$1, %eax
	jmp	.L10
	.cfi_endproc
.LFE25:
	.size	BFS, .-BFS
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
.LC4:
	.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
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %r15
	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	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	leaq	824+node(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L39
	.p2align 4,,10
	.p2align 3
.L38:
	leaq	12(%r12), %rsi
	movq	%r12, %rdx
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%r12), %eax
	leaq	-404(%r12), %rbp
	xorl	%ebx, %ebx
	testl	%eax, %eax
	jle	.L41
	.p2align 4,,10
	.p2align 3
.L40:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, (%r12)
	jg	.L40
.L41:
	addq	$1, %r14
	addq	$420, %r12
	cmpl	%r14d, n(%rip)
	jge	.L38
.L39:
	xorl	%eax, %eax
	leaq	832+node(%rip), %rbp
	movl	$1, %ebx
	call	BFS
	movl	n(%rip), %edx
	leaq	.LC4(%rip), %r12
	testl	%edx, %edx
	jle	.L49
	.p2align 4,,10
	.p2align 3
.L42:
	movl	0(%rbp), %ecx
	movl	%ebx, %edx
	xorl	%eax, %eax
	movq	%r12, %rsi
	movl	$1, %edi
	addl	$1, %ebx
	addq	$420, %rbp
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L42
.L49:
	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
.LFE26:
	.size	main, .-main
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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	node
	.align 32
	.type	node, @object
	.size	node, 42420
node:
	.zero	42420
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-4
	.long	-1
	.align 8
.LC1:
	.long	-3
	.long	0
	.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	tail(%rip), %rcx
	leaq	Q(%rip), %rdx
	movl	%edi, (%rdx,%rcx,4)
	xorl	%edx, %edx
	cmpl	n(%rip), %ecx
	je	.L2
	leal	1(%rcx), %edx
.L2:
	movl	%edx, tail(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	enqueue, .-enqueue
	.p2align 4
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB24:
	.cfi_startproc
	endbr64
	movslq	head(%rip), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rdx,%rcx,4), %r8d
	xorl	%edx, %edx
	cmpl	n(%rip), %ecx
	je	.L6
	leal	1(%rcx), %edx
.L6:
	movl	%edx, head(%rip)
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	dequeue, .-dequeue
	.p2align 4
	.globl	BFS
	.type	BFS, @function
BFS:
.LFB25:
	.cfi_startproc
	endbr64
	movl	n(%rip), %r11d
	testl	%r11d, %r11d
	jle	.L9
	cmpl	$1, %r11d
	je	.L22
	movl	%r11d, %edx
	leaq	828+node(%rip), %rax
	shrl	%edx
	leaq	840(%rax), %rcx
	subl	$1, %edx
	imulq	$840, %rdx, %rdx
	addq	%rcx, %rdx
	.p2align 4,,10
	.p2align 3
.L11:
	movq	$-4, (%rax)
	addq	$840, %rax
	movq	$-4, -420(%rax)
	cmpq	%rdx, %rax
	jne	.L11
	movl	%r11d, %eax
	orl	$1, %eax
	testb	$1, %r11b
	je	.L12
.L10:
	cltq
	movq	.LC0(%rip), %rcx
	leaq	8+node(%rip), %rdx
	imulq	$420, %rax, %rax
	movq	%rcx, 400(%rdx,%rax)
.L12:
	movq	.LC1(%rip), %rax
	movslq	836+node(%rip), %rdi
	movq	%rax, 828+node(%rip)
	movl	%edi, Q(%rip)
.L13:
	leaq	node(%rip), %r8
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$1, %esi
	xorl	%r10d, %r10d
	movl	$1, tail(%rip)
	leaq	4(%r8), %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	xorl	%r12d, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	Q(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L20:
	cmpl	%r11d, %r10d
	leal	1(%r10), %eax
	cmove	%r13d, %eax
	imulq	$420, %rdi, %rdx
	movl	%eax, %r10d
	addq	%r8, %rdx
	movl	404(%rdx), %ecx
	testl	%ecx, %ecx
	jle	.L16
	leaq	(%rdi,%rdi,2), %rax
	subl	$1, %ecx
	movq	%rdx, %rbp
	leaq	(%rdi,%rax,4), %rax
	leaq	(%rdi,%rax,8), %rax
	addq	%rcx, %rax
	leaq	(%r14,%rax,4), %r9
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L17:
	addq	$4, %rdx
	cmpq	%r9, %rdx
	je	.L16
.L18:
	movslq	(%rdx), %rax
	movq	%rax, %rcx
	imulq	$420, %rax, %rax
	addq	%r8, %rax
	cmpl	$-4, 408(%rax)
	jne	.L17
	movl	412(%rbp), %r12d
	movl	$-3, 408(%rax)
	addl	$1, %r12d
	movl	%r12d, 412(%rax)
	movslq	%esi, %rax
	movl	%ecx, (%rbx,%rax,4)
	cmpl	%esi, %r11d
	je	.L24
	addq	$4, %rdx
	addl	$1, %esi
	movl	$1, %r12d
	cmpq	%r9, %rdx
	jne	.L18
	.p2align 4,,10
	.p2align 3
.L16:
	imulq	$420, %rdi, %rdi
	movl	$-2, 408(%r8,%rdi)
	cmpl	%r10d, %esi
	je	.L19
	movslq	%r10d, %rax
	movslq	(%rbx,%rax,4), %rdi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L24:
	movl	$1, %r12d
	xorl	%esi, %esi
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L19:
	movl	%esi, head(%rip)
	testb	%r12b, %r12b
	je	.L8
	movl	%esi, tail(%rip)
.L8:
	popq	%rbx
	.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
.L9:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	movq	.LC1(%rip), %rax
	movslq	836+node(%rip), %rdi
	movl	$0, tail(%rip)
	movl	$0, head(%rip)
	movq	%rax, 828+node(%rip)
	movl	%edi, Q(%rip)
	jne	.L13
	ret
.L22:
	movl	$1, %eax
	jmp	.L10
	.cfi_endproc
.LFE25:
	.size	BFS, .-BFS
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
.LC4:
	.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
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC3(%rip), %r15
	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	.LC2(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	leaq	824+node(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L39
	.p2align 4,,10
	.p2align 3
.L38:
	leaq	12(%r12), %rsi
	movq	%r12, %rdx
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	(%r12), %eax
	leaq	-404(%r12), %rbp
	xorl	%ebx, %ebx
	testl	%eax, %eax
	jle	.L41
	.p2align 4,,10
	.p2align 3
.L40:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %rbp
	cmpl	%ebx, (%r12)
	jg	.L40
.L41:
	addq	$1, %r14
	addq	$420, %r12
	cmpl	%r14d, n(%rip)
	jge	.L38
.L39:
	xorl	%eax, %eax
	leaq	832+node(%rip), %rbp
	movl	$1, %ebx
	call	BFS
	movl	n(%rip), %edx
	leaq	.LC4(%rip), %r12
	testl	%edx, %edx
	jle	.L49
	.p2align 4,,10
	.p2align 3
.L42:
	movl	0(%rbp), %ecx
	movl	%ebx, %edx
	xorl	%eax, %eax
	movq	%r12, %rsi
	movl	$1, %edi
	addl	$1, %ebx
	addq	$420, %rbp
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jge	.L42
.L49:
	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
.LFE26:
	.size	main, .-main
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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	node
	.align 32
	.type	node, @object
	.size	node, 42420
node:
	.zero	42420
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-4
	.long	-1
	.align 8
.LC1:
	.long	-3
	.long	0
	.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 N 101
#define WHITE -4
#define GRAY -3
#define BLACK -2
#define INF -1

typedef struct{
  int Adj[N];
  int k;
  int color;
  int d;
  int id;
}Node;

Node node[N];
int head, tail, n, Q[N];

void enqueue(int x){
  Q[tail] = x;
  if(tail == n)
    tail = 0;
  else
    tail++;
}

int dequeue(void){
  int y;
  y = Q[head];
  if(head == n)
    head = 0;
  else
    head++;
  return y;
}

void BFS(){
  int i, u;
  for(i = 1;i < n+1;i++){
    node[i].color = WHITE;
    node[i].d = INF;
  }
  node[1].color = GRAY;
  node[1].d = 0;
  head = tail = 0;
  enqueue(node[1].id);
  while(head != tail){
    u = dequeue();
    for(i = 0;i < node[u].k;i++){
      if(node[node[u].Adj[i]].color == WHITE){
	node[node[u].Adj[i]].color = GRAY;
	node[node[u].Adj[i]].d = node[u].d + 1;
	enqueue(node[u].Adj[i]);
      }
    }
    node[u].color = BLACK;
  }
}
  

int main(){
  int i, j, l;
  scanf("%d", &n);
  for(i = 1;i < n+1;i++){
    scanf("%d%d", &node[i].id, &node[i].k);
    for(j = 0;j < node[i].k;j++)
      scanf("%d", &node[i].Adj[j]);   
  }
    BFS();
  for(i = 1;i < n+1;i++)
    printf("%d %d\n", i, node[i].d);
  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>
#define N 101
#define WHITE -4
#define GRAY -3
#define BLACK -2
#define INF -1

typedef struct{
  int Adj[N];
  int k;
  int color;
  int d;
  int id;
}Node;

Node node[N];
int head, tail, n, Q[N];

void enqueue(int x){
  Q[tail] = x;
  if(tail == n)
    tail = 0;
  else
    tail++;
}

int dequeue(void){
  int y;
  y = Q[head];
  if(head == n)
    head = 0;
  else
    head++;
  return y;
}

void BFS(){
  int i, u;
  for(i = 1;i < n+1;i++){
    node[i].color = WHITE;
    node[i].d = INF;
  }
  node[1].color = GRAY;
  node[1].d = 0;
  head = tail = 0;
  enqueue(node[1].id);
  while(head != tail){
    u = dequeue();
    for(i = 0;i < node[u].k;i++){
      if(node[node[u].Adj[i]].color == WHITE){
	node[node[u].Adj[i]].color = GRAY;
	node[node[u].Adj[i]].d = node[u].d + 1;
	enqueue(node[u].Adj[i]);
      }
    }
    node[u].color = BLACK;
  }
}
  

int main(){
  int i, j, l;
  scanf("%d", &n);
  for(i = 1;i < n+1;i++){
    scanf("%d%d", &node[i].id, &node[i].k);
    for(j = 0;j < node[i].k;j++)
      scanf("%d", &node[i].Adj[j]);   
  }
    BFS();
  for(i = 1;i < n+1;i++)
    printf("%d %d\n", i, node[i].d);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	node
	.bss
	.align 32
	.type	node, @object
	.size	node, 42420
node:
	.zero	42420
	.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	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.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	tail(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	tail(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jne	.L2
	movl	$0, tail(%rip)
	jmp	.L4
.L2:
	movl	tail(%rip), %eax
	addl	$1, %eax
	movl	%eax, tail(%rip)
.L4:
	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	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	head(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jne	.L6
	movl	$0, head(%rip)
	jmp	.L7
.L6:
	movl	head(%rip), %eax
	addl	$1, %eax
	movl	%eax, head(%rip)
.L7:
	movl	-4(%rbp), %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	$16, %rsp
	movl	$1, -8(%rbp)
	jmp	.L10
.L11:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-4, (%rax,%rdx)
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	$-1, (%rax,%rdx)
	addl	$1, -8(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L11
	movl	$-3, 828+node(%rip)
	movl	$0, 832+node(%rip)
	movl	$0, tail(%rip)
	movl	tail(%rip), %eax
	movl	%eax, head(%rip)
	movl	836+node(%rip), %eax
	movl	%eax, %edi
	call	enqueue
	jmp	.L12
.L16:
	call	dequeue
	movl	%eax, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L15:
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	$-4, %eax
	jne	.L14
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-3, (%rax,%rdx)
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	(%rax,%rdx), %ecx
	movl	-8(%rbp), %eax
	movslq	%eax, %rsi
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %ecx
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	enqueue
.L14:
	addl	$1, -8(%rbp)
.L13:
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	404+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L15
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-2, (%rax,%rdx)
.L12:
	movl	head(%rip), %edx
	movl	tail(%rip), %eax
	cmpl	%eax, %edx
	jne	.L16
	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	$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	.L18
.L21:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	400(%rax), %rdx
	leaq	node(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	416(%rax), %rcx
	leaq	node(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L19
.L20:
	movl	-4(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%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)
.L19:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	404+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L20
	addl	$1, -8(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L21
	movl	$0, %eax
	call	BFS
	movl	$1, -8(%rbp)
	jmp	.L22
.L23:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	(%rax,%rdx), %edx
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L22:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L23
	movl	$0, %eax
	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	node
	.bss
	.align 32
	.type	node, @object
	.size	node, 42420
node:
	.zero	42420
	.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	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 404
Q:
	.zero	404
	.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	tail(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	Q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	tail(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jne	.L2
	movl	$0, tail(%rip)
	jmp	.L4
.L2:
	movl	tail(%rip), %eax
	addl	$1, %eax
	movl	%eax, tail(%rip)
.L4:
	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	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	head(%rip), %edx
	movl	n(%rip), %eax
	cmpl	%eax, %edx
	jne	.L6
	movl	$0, head(%rip)
	jmp	.L7
.L6:
	movl	head(%rip), %eax
	addl	$1, %eax
	movl	%eax, head(%rip)
.L7:
	movl	-4(%rbp), %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	$16, %rsp
	movl	$1, -8(%rbp)
	jmp	.L10
.L11:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-4, (%rax,%rdx)
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	$-1, (%rax,%rdx)
	addl	$1, -8(%rbp)
.L10:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L11
	movl	$-3, 828+node(%rip)
	movl	$0, 832+node(%rip)
	movl	$0, tail(%rip)
	movl	tail(%rip), %eax
	movl	%eax, head(%rip)
	movl	836+node(%rip), %eax
	movl	%eax, %edi
	call	enqueue
	jmp	.L12
.L16:
	call	dequeue
	movl	%eax, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L15:
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	$-4, %eax
	jne	.L14
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-3, (%rax,%rdx)
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	(%rax,%rdx), %ecx
	movl	-8(%rbp), %eax
	movslq	%eax, %rsi
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %ecx
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	%ecx, (%rax,%rdx)
	movl	-8(%rbp), %eax
	movslq	%eax, %rcx
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	enqueue
.L14:
	addl	$1, -8(%rbp)
.L13:
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	404+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L15
	movl	-4(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	408+node(%rip), %rdx
	movl	$-2, (%rax,%rdx)
.L12:
	movl	head(%rip), %edx
	movl	tail(%rip), %eax
	cmpl	%eax, %edx
	jne	.L16
	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	$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	.L18
.L21:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	400(%rax), %rdx
	leaq	node(%rip), %rax
	addq	%rdx, %rax
	leaq	4(%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	416(%rax), %rcx
	leaq	node(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L19
.L20:
	movl	-4(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	salq	$3, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	node(%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)
.L19:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	404+node(%rip), %rdx
	movl	(%rax,%rdx), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L20
	addl	$1, -8(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L21
	movl	$0, %eax
	call	BFS
	movl	$1, -8(%rbp)
	jmp	.L22
.L23:
	movl	-8(%rbp), %eax
	cltq
	imulq	$420, %rax, %rax
	leaq	412+node(%rip), %rdx
	movl	(%rax,%rdx), %edx
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -8(%rbp)
.L22:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L23
	movl	$0, %eax
	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:
