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 100
#define INFTY (1<<21)
#define LEN 1000


int Q[LEN];
int head, tail;
int n, G[N][N], d[N];

void enqueue(int x){
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;
}

void dequeue(){
  int x = Q[head];
  head = ( head + 1 ) % LEN;
}

void bfs(int s){
  int i, u, v;

  enqueue(s);

  for( i = 0 ; i < n ; i++ ) d[i] = INFTY;
  d[s] = 0;

  while( head != tail ){
    u = Q[head];
    dequeue();
    for( v = 0 ; v < n ; v++ ){
      if( G[u][v] == 0 ) continue;
      if( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }

  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n",i+1,((d[i]==INFTY) ? (-1) : d[i]));
  }
}

int main(){
  int i, j, u, k ,v;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      G[i][j] = 0;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    u--;
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }
  
  bfs(0);
  return 0;

}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 4000
Q:
	.zero	4000
	.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	G
	.align 32
	.type	G, @object
	.size	G, 40000
G:
	.zero	40000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.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), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	imulq	$274877907, %rax, %rax
	shrq	$32, %rax
	sarl	$6, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, tail(%rip)
	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), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	imulq	$274877907, %rax, %rax
	shrq	$32, %rax
	sarl	$6, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, head(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dequeue, .-dequeue
	.section	.rodata
.LC0:
	.string	"%d %d\n"
	.text
	.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	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	enqueue
	movl	$0, -12(%rbp)
	jmp	.L4
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$2097152, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L5
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	jmp	.L6
.L12:
	movl	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	$0, %eax
	call	dequeue
	movl	$0, -8(%rbp)
	jmp	.L7
.L11:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L17
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	jne	.L18
	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
	jmp	.L9
.L17:
	nop
	jmp	.L9
.L18:
	nop
.L9:
	addl	$1, -8(%rbp)
.L7:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
.L6:
	movl	head(%rip), %edx
	movl	tail(%rip), %eax
	cmpl	%eax, %edx
	jne	.L12
	movl	$0, -12(%rbp)
	jmp	.L13
.L16:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	je	.L14
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L15
.L14:
	movl	$-1, %eax
.L15:
	movl	-12(%rbp), %edx
	leal	1(%rdx), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -12(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	bfs, .-bfs
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
	.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
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L20
.L23:
	movl	$0, -12(%rbp)
	jmp	.L21
.L22:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L22
	addl	$1, -16(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L23
	movl	$0, -16(%rbp)
	jmp	.L24
.L27:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -28(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L25
.L26:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	-28(%rbp), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L25:
	movl	-24(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L26
	addl	$1, -16(%rbp)
.L24:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L27
	movl	$0, %edi
	call	bfs
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	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), %rax
	movq	%rcx, %rdx
	movl	%edi, (%rax,%rcx,4)
	addl	$1, %edx
	movslq	%edx, %rax
	movl	%edx, %ecx
	imulq	$274877907, %rax, %rax
	sarl	$31, %ecx
	sarq	$38, %rax
	subl	%ecx, %eax
	imull	$1000, %eax, %eax
	subl	%eax, %edx
	movl	%edx, tail(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	enqueue, .-enqueue
	.p2align 4
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB24:
	.cfi_startproc
	endbr64
	movl	head(%rip), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	movl	%edx, %ecx
	imulq	$274877907, %rax, %rax
	sarl	$31, %ecx
	sarq	$38, %rax
	subl	%ecx, %eax
	imull	$1000, %eax, %eax
	subl	%eax, %edx
	movl	%edx, head(%rip)
	ret
	.cfi_endproc
.LFE24:
	.size	dequeue, .-dequeue
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d %d\n"
	.text
	.p2align 4
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	tail(%rip), %rdx
	leaq	Q(%rip), %r10
	movl	head(%rip), %esi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	n(%rip), %r11d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdx, %rax
	movl	%edi, (%r10,%rdx,4)
	addl	$1, %eax
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movslq	%eax, %rdx
	movl	%eax, %ecx
	imulq	$274877907, %rdx, %rdx
	sarl	$31, %ecx
	sarq	$38, %rdx
	subl	%ecx, %edx
	imull	$1000, %edx, %ecx
	subl	%ecx, %eax
	movl	%eax, tail(%rip)
	movl	%eax, %edx
	testl	%r11d, %r11d
	jle	.L5
	leal	-1(%r11), %eax
	cmpl	$2, %eax
	jbe	.L20
	movl	%r11d, %ecx
	leaq	d(%rip), %r8
	movdqa	.LC0(%rip), %xmm0
	shrl	$2, %ecx
	leaq	16(%r8), %r9
	movq	%r8, %rax
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%r9, %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rcx, %rax
	jne	.L7
	movl	%r11d, %eax
	andl	$-4, %eax
	testb	$3, %r11b
	je	.L8
.L6:
	movslq	%eax, %rcx
	movl	$2097152, (%r8,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%r11d, %ecx
	jge	.L8
	movslq	%ecx, %rcx
	addl	$2, %eax
	movl	$2097152, (%r8,%rcx,4)
	cmpl	%eax, %r11d
	jle	.L8
	cltq
	movl	$2097152, (%r8,%rax,4)
.L8:
	movslq	%edi, %rdi
	movl	$0, (%r8,%rdi,4)
	cmpl	%esi, %edx
	je	.L9
.L19:
	xorl	%edi, %edi
	movslq	%r11d, %r9
	leaq	G(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	%esi, %rax
	movslq	(%r10,%rax,4), %rbp
	leal	1(%rsi), %eax
	movslq	%eax, %rsi
	movl	%eax, %ecx
	imulq	$274877907, %rsi, %rsi
	sarl	$31, %ecx
	sarq	$38, %rsi
	subl	%ecx, %esi
	imull	$1000, %esi, %ecx
	subl	%ecx, %eax
	movl	%eax, %esi
	testl	%r11d, %r11d
	jle	.L10
	leaq	0(%rbp,%rbp,4), %rax
	leaq	(%rax,%rax,4), %rcx
	xorl	%eax, %eax
	salq	$4, %rcx
	addq	%rbx, %rcx
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rcx,%rax,4), %r12d
	testl	%r12d, %r12d
	je	.L11
	cmpl	$2097152, (%r8,%rax,4)
	jne	.L11
	movl	(%r8,%rbp,4), %edi
	addl	$1, %edi
	movl	%edi, (%r8,%rax,4)
	movslq	%edx, %rdi
	movl	%eax, (%r10,%rdi,4)
	leal	1(%rdx), %edi
	movslq	%edi, %rdx
	movl	%edi, %r12d
	imulq	$274877907, %rdx, %rdx
	sarl	$31, %r12d
	sarq	$38, %rdx
	subl	%r12d, %edx
	imull	$1000, %edx, %r12d
	subl	%r12d, %edi
	movl	%edi, %edx
	movl	$1, %edi
.L11:
	addq	$1, %rax
	cmpq	%r9, %rax
	jne	.L12
.L10:
	cmpl	%esi, %edx
	jne	.L13
	movl	%edx, head(%rip)
	testb	%dil, %dil
	je	.L14
	movl	%edx, tail(%rip)
.L14:
	testl	%r11d, %r11d
	jle	.L4
.L9:
	leaq	d(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L18:
	movl	0(%rbp), %ecx
	addl	$1, %ebx
	cmpl	$2097152, %ecx
	jne	.L28
	movl	$-1, %ecx
.L28:
	xorl	%eax, %eax
	movl	%ebx, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	addq	$4, %rbp
	cmpl	n(%rip), %ebx
	jl	.L18
.L4:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	leaq	d(%rip), %r8
	movslq	%edi, %rdi
	movl	$0, (%r8,%rdi,4)
	cmpl	%esi, %eax
	jne	.L19
	jmp	.L4
.L20:
	xorl	%eax, %eax
	leaq	d(%rip), %r8
	jmp	.L6
	.cfi_endproc
.LFE25:
	.size	bfs, .-bfs
	.section	.rodata.str1.1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC2(%rip), %rbx
	movq	%rbx, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L30
	leal	-1(%rax), %edx
	leaq	G(%rip), %rbp
	leaq	(%rdx,%rdx,4), %rdx
	movq	%rbp, %rcx
	leaq	0(,%rax,4), %r12
	leaq	(%rdx,%rdx,4), %r13
	leaq	400(%rbp), %rdx
	salq	$4, %r13
	addq	%rdx, %r13
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%rcx, %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$400, %rcx
	cmpq	%rcx, %r13
	jne	.L31
	leaq	28(%rsp), %rax
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L34:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	subl	$1, 28(%rsp)
	testl	%eax, %eax
	jle	.L32
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L33:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	movslq	28(%rsp), %rcx
	subl	$1, %eax
	leaq	(%rcx,%rcx,4), %rcx
	movl	%eax, 36(%rsp)
	leaq	(%rcx,%rcx,4), %rcx
	cltq
	leaq	(%rax,%rcx,4), %rax
	movl	$1, 0(%rbp,%rax,4)
	cmpl	%r14d, 32(%rsp)
	jg	.L33
.L32:
	addl	$1, %r13d
	cmpl	%r13d, n(%rip)
	jg	.L34
.L30:
	xorl	%edi, %edi
	call	bfs
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	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
.L40:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	G
	.align 32
	.type	G, @object
	.size	G, 40000
G:
	.zero	40000
	.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	Q
	.align 32
	.type	Q, @object
	.size	Q, 4000
Q:
	.zero	4000
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	2097152
	.long	2097152
	.long	2097152
	.long	2097152
	.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), %rax
	movq	%rcx, %rdx
	movl	%edi, (%rax,%rcx,4)
	addl	$1, %edx
	movslq	%edx, %rax
	movl	%edx, %ecx
	imulq	$274877907, %rax, %rax
	sarl	$31, %ecx
	sarq	$38, %rax
	subl	%ecx, %eax
	imull	$1000, %eax, %eax
	subl	%eax, %edx
	movl	%edx, tail(%rip)
	ret
	.cfi_endproc
.LFE23:
	.size	enqueue, .-enqueue
	.p2align 4
	.globl	dequeue
	.type	dequeue, @function
dequeue:
.LFB24:
	.cfi_startproc
	endbr64
	movl	head(%rip), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	movl	%edx, %ecx
	imulq	$274877907, %rax, %rax
	sarl	$31, %ecx
	sarq	$38, %rax
	subl	%ecx, %eax
	imull	$1000, %eax, %eax
	subl	%eax, %edx
	movl	%edx, head(%rip)
	ret
	.cfi_endproc
.LFE24:
	.size	dequeue, .-dequeue
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"%d %d\n"
	.text
	.p2align 4
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	tail(%rip), %rdx
	leaq	Q(%rip), %r10
	movl	head(%rip), %esi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	n(%rip), %r11d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%rdx, %rax
	movl	%edi, (%r10,%rdx,4)
	addl	$1, %eax
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movslq	%eax, %rdx
	movl	%eax, %ecx
	imulq	$274877907, %rdx, %rdx
	sarl	$31, %ecx
	sarq	$38, %rdx
	subl	%ecx, %edx
	imull	$1000, %edx, %ecx
	subl	%ecx, %eax
	movl	%eax, tail(%rip)
	movl	%eax, %edx
	testl	%r11d, %r11d
	jle	.L5
	leal	-1(%r11), %eax
	cmpl	$2, %eax
	jbe	.L20
	movl	%r11d, %ecx
	leaq	d(%rip), %r8
	movdqa	.LC0(%rip), %xmm0
	shrl	$2, %ecx
	leaq	16(%r8), %r9
	movq	%r8, %rax
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%r9, %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movaps	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rcx, %rax
	jne	.L7
	movl	%r11d, %eax
	andl	$-4, %eax
	testb	$3, %r11b
	je	.L8
.L6:
	movslq	%eax, %rcx
	movl	$2097152, (%r8,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%r11d, %ecx
	jge	.L8
	movslq	%ecx, %rcx
	addl	$2, %eax
	movl	$2097152, (%r8,%rcx,4)
	cmpl	%eax, %r11d
	jle	.L8
	cltq
	movl	$2097152, (%r8,%rax,4)
.L8:
	movslq	%edi, %rdi
	movl	$0, (%r8,%rdi,4)
	cmpl	%esi, %edx
	je	.L9
.L19:
	xorl	%edi, %edi
	movslq	%r11d, %r9
	leaq	G(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	%esi, %rax
	movslq	(%r10,%rax,4), %rbp
	leal	1(%rsi), %eax
	movslq	%eax, %rsi
	movl	%eax, %ecx
	imulq	$274877907, %rsi, %rsi
	sarl	$31, %ecx
	sarq	$38, %rsi
	subl	%ecx, %esi
	imull	$1000, %esi, %ecx
	subl	%ecx, %eax
	movl	%eax, %esi
	testl	%r11d, %r11d
	jle	.L10
	leaq	0(%rbp,%rbp,4), %rax
	leaq	(%rax,%rax,4), %rcx
	xorl	%eax, %eax
	salq	$4, %rcx
	addq	%rbx, %rcx
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rcx,%rax,4), %r12d
	testl	%r12d, %r12d
	je	.L11
	cmpl	$2097152, (%r8,%rax,4)
	jne	.L11
	movl	(%r8,%rbp,4), %edi
	addl	$1, %edi
	movl	%edi, (%r8,%rax,4)
	movslq	%edx, %rdi
	movl	%eax, (%r10,%rdi,4)
	leal	1(%rdx), %edi
	movslq	%edi, %rdx
	movl	%edi, %r12d
	imulq	$274877907, %rdx, %rdx
	sarl	$31, %r12d
	sarq	$38, %rdx
	subl	%r12d, %edx
	imull	$1000, %edx, %r12d
	subl	%r12d, %edi
	movl	%edi, %edx
	movl	$1, %edi
.L11:
	addq	$1, %rax
	cmpq	%r9, %rax
	jne	.L12
.L10:
	cmpl	%esi, %edx
	jne	.L13
	movl	%edx, head(%rip)
	testb	%dil, %dil
	je	.L14
	movl	%edx, tail(%rip)
.L14:
	testl	%r11d, %r11d
	jle	.L4
.L9:
	leaq	d(%rip), %rbp
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L18:
	movl	0(%rbp), %ecx
	addl	$1, %ebx
	cmpl	$2097152, %ecx
	jne	.L28
	movl	$-1, %ecx
.L28:
	xorl	%eax, %eax
	movl	%ebx, %edx
	movq	%r12, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	addq	$4, %rbp
	cmpl	n(%rip), %ebx
	jl	.L18
.L4:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L5:
	.cfi_restore_state
	leaq	d(%rip), %r8
	movslq	%edi, %rdi
	movl	$0, (%r8,%rdi,4)
	cmpl	%esi, %eax
	jne	.L19
	jmp	.L4
.L20:
	xorl	%eax, %eax
	leaq	d(%rip), %r8
	jmp	.L6
	.cfi_endproc
.LFE25:
	.size	bfs, .-bfs
	.section	.rodata.str1.1
.LC2:
	.string	"%d"
.LC3:
	.string	"%d%d"
	.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
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	.LC2(%rip), %rbx
	movq	%rbx, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L30
	leal	-1(%rax), %edx
	leaq	G(%rip), %rbp
	leaq	(%rdx,%rdx,4), %rdx
	movq	%rbp, %rcx
	leaq	0(,%rax,4), %r12
	leaq	(%rdx,%rdx,4), %r13
	leaq	400(%rbp), %rdx
	salq	$4, %r13
	addq	%rdx, %r13
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%rcx, %rdi
	movq	%r12, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	%rax, %rcx
	addq	$400, %rcx
	cmpq	%rcx, %r13
	jne	.L31
	leaq	28(%rsp), %rax
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	36(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L34:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	subl	$1, 28(%rsp)
	testl	%eax, %eax
	jle	.L32
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L33:
	movq	%r12, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	movslq	28(%rsp), %rcx
	subl	$1, %eax
	leaq	(%rcx,%rcx,4), %rcx
	movl	%eax, 36(%rsp)
	leaq	(%rcx,%rcx,4), %rcx
	cltq
	leaq	(%rax,%rcx,4), %rax
	movl	$1, 0(%rbp,%rax,4)
	cmpl	%r14d, 32(%rsp)
	jg	.L33
.L32:
	addl	$1, %r13d
	cmpl	%r13d, n(%rip)
	jg	.L34
.L30:
	xorl	%edi, %edi
	call	bfs
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L40
	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
.L40:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.globl	G
	.align 32
	.type	G, @object
	.size	G, 40000
G:
	.zero	40000
	.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	Q
	.align 32
	.type	Q, @object
	.size	Q, 4000
Q:
	.zero	4000
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	2097152
	.long	2097152
	.long	2097152
	.long	2097152
	.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 100
#define INFTY (1<<21)
#define LEN 1000


int Q[LEN];
int head, tail;
int n, G[N][N], d[N];

void enqueue(int x){
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;
}

void dequeue(){
  int x = Q[head];
  head = ( head + 1 ) % LEN;
}

void bfs(int s){
  int i, u, v;

  enqueue(s);

  for( i = 0 ; i < n ; i++ ) d[i] = INFTY;
  d[s] = 0;

  while( head != tail ){
    u = Q[head];
    dequeue();
    for( v = 0 ; v < n ; v++ ){
      if( G[u][v] == 0 ) continue;
      if( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }

  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n",i+1,((d[i]==INFTY) ? (-1) : d[i]));
  }
}

int main(){
  int i, j, u, k ,v;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      G[i][j] = 0;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    u--;
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }
  
  bfs(0);
  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 100
#define INFTY (1<<21)
#define LEN 1000


int Q[LEN];
int head, tail;
int n, G[N][N], d[N];

void enqueue(int x){
  Q[tail] = x;
  tail = ( tail + 1 ) % LEN;
}

void dequeue(){
  int x = Q[head];
  head = ( head + 1 ) % LEN;
}

void bfs(int s){
  int i, u, v;

  enqueue(s);

  for( i = 0 ; i < n ; i++ ) d[i] = INFTY;
  d[s] = 0;

  while( head != tail ){
    u = Q[head];
    dequeue();
    for( v = 0 ; v < n ; v++ ){
      if( G[u][v] == 0 ) continue;
      if( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }

  for( i = 0 ; i < n ; i++ ){
    printf("%d %d\n",i+1,((d[i]==INFTY) ? (-1) : d[i]));
  }
}

int main(){
  int i, j, u, k ,v;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      G[i][j] = 0;
    }
  }

  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    u--;
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }
  
  bfs(0);
  return 0;

}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	Q
	.bss
	.align 32
	.type	Q, @object
	.size	Q, 4000
Q:
	.zero	4000
	.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	G
	.align 32
	.type	G, @object
	.size	G, 40000
G:
	.zero	40000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.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), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	imulq	$274877907, %rax, %rax
	shrq	$32, %rax
	sarl	$6, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, tail(%rip)
	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), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	imulq	$274877907, %rax, %rax
	shrq	$32, %rax
	sarl	$6, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, head(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dequeue, .-dequeue
	.section	.rodata
.LC0:
	.string	"%d %d\n"
	.text
	.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	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	enqueue
	movl	$0, -12(%rbp)
	jmp	.L4
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$2097152, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L5
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	jmp	.L6
.L12:
	movl	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	$0, %eax
	call	dequeue
	movl	$0, -8(%rbp)
	jmp	.L7
.L11:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L17
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	jne	.L18
	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
	jmp	.L9
.L17:
	nop
	jmp	.L9
.L18:
	nop
.L9:
	addl	$1, -8(%rbp)
.L7:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
.L6:
	movl	head(%rip), %edx
	movl	tail(%rip), %eax
	cmpl	%eax, %edx
	jne	.L12
	movl	$0, -12(%rbp)
	jmp	.L13
.L16:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	je	.L14
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L15
.L14:
	movl	$-1, %eax
.L15:
	movl	-12(%rbp), %edx
	leal	1(%rdx), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -12(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	bfs, .-bfs
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
	.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
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L20
.L23:
	movl	$0, -12(%rbp)
	jmp	.L21
.L22:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L22
	addl	$1, -16(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L23
	movl	$0, -16(%rbp)
	jmp	.L24
.L27:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -28(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L25
.L26:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	-28(%rbp), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L25:
	movl	-24(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L26
	addl	$1, -16(%rbp)
.L24:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L27
	movl	$0, %edi
	call	bfs
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	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, 4000
Q:
	.zero	4000
	.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	G
	.align 32
	.type	G, @object
	.size	G, 40000
G:
	.zero	40000
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 400
d:
	.zero	400
	.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), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	imulq	$274877907, %rax, %rax
	shrq	$32, %rax
	sarl	$6, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, tail(%rip)
	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), %eax
	leal	1(%rax), %edx
	movslq	%edx, %rax
	imulq	$274877907, %rax, %rax
	shrq	$32, %rax
	sarl	$6, %eax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	imull	$1000, %eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, head(%rip)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	dequeue, .-dequeue
	.section	.rodata
.LC0:
	.string	"%d %d\n"
	.text
	.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	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	enqueue
	movl	$0, -12(%rbp)
	jmp	.L4
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$2097152, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L5
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	$0, (%rdx,%rax)
	jmp	.L6
.L12:
	movl	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	$0, %eax
	call	dequeue
	movl	$0, -8(%rbp)
	jmp	.L7
.L11:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L17
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	jne	.L18
	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
	jmp	.L9
.L17:
	nop
	jmp	.L9
.L18:
	nop
.L9:
	addl	$1, -8(%rbp)
.L7:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
.L6:
	movl	head(%rip), %edx
	movl	tail(%rip), %eax
	cmpl	%eax, %edx
	jne	.L12
	movl	$0, -12(%rbp)
	jmp	.L13
.L16:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$2097152, %eax
	je	.L14
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L15
.L14:
	movl	$-1, %eax
.L15:
	movl	-12(%rbp), %edx
	leal	1(%rdx), %ecx
	movl	%eax, %edx
	movl	%ecx, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -12(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	bfs, .-bfs
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
	.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
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L20
.L23:
	movl	$0, -12(%rbp)
	jmp	.L21
.L22:
	movl	-12(%rbp), %eax
	movslq	%eax, %rcx
	movl	-16(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L22
	addl	$1, -16(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L23
	movl	$0, -16(%rbp)
	jmp	.L24
.L27:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -28(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L25
.L26:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-20(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	-28(%rbp), %eax
	movl	-20(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	G(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L25:
	movl	-24(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L26
	addl	$1, -16(%rbp)
.L24:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L27
	movl	$0, %edi
	call	bfs
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L29
	call	__stack_chk_fail@PLT
.L29:
	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:
