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

```c
#include<stdio.h>

int bfs(int,int,int);
void push(int);
int pop(void);
int empty(void);

int n,que[1000000],graph[101][101],head=0,tail=0,vst[101],count[101];

int main(void){
  int r,k,t,p,s,d,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&r,&k);

    for(j=0;j<k;j++){
      scanf("%d",&t);
      graph[r][t]=1;
    }
  }
  
  scanf("%d",&p);

  for(i=0;i<p;i++){
    scanf("%d %d %d",&s,&d,&v);

    if(bfs(s,d,v)<=v && bfs(s,d,v)>0) printf("%d\n",bfs(s,d,v));
    else printf("NA\n");
  }

  return 0;
}

int bfs(int s,int d,int v){
  int u,i,j;

  for(i=0;i<=n;i++)vst[i]=count[i]=0;
  
  count[s]=1;
  push(s);
  vst[s]=1;

  while(!empty()){
    u=pop();

    for(i=1;i<=n;i++){
      if(!vst[i] && graph[u][i]){
	push(i);
	vst[i]=1;
	count[i]=count[u]+1;
      }
    }
  }

  return count[d];
}

void push(int a){
  que[tail++]=a;
}

int pop(void){
  int res=que[head++];
  return res;
}

int empty(void){
  return tail==head?1:0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 4000000
que:
	.zero	4000000
	.globl	graph
	.align 32
	.type	graph, @object
	.size	graph, 40804
graph:
	.zero	40804
	.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	vst
	.align 32
	.type	vst, @object
	.size	vst, 404
vst:
	.zero	404
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 404
count:
	.zero	404
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"NA"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L5:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L3
.L4:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	movl	-36(%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	graph(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L3:
	movl	-40(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	addl	$1, -16(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L5
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L6
.L9:
	leaq	-20(%rbp), %rcx
	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	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	movl	-20(%rbp), %edx
	cmpl	%edx, %eax
	jg	.L7
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	testl	%eax, %eax
	jle	.L7
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L7:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L8:
	addl	$1, -16(%rbp)
.L6:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	vst(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L14
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	push
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	$1, (%rdx,%rax)
	jmp	.L15
.L19:
	call	pop
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L16
.L18:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L17
	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	graph(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L17
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	push
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L17:
	addl	$1, -8(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L18
.L15:
	call	empty
	testl	%eax, %eax
	je	.L19
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	bfs, .-bfs
	.globl	push
	.type	push, @function
push:
.LFB2:
	.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
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	que(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB3:
	.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
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	que(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	pop, .-pop
	.globl	empty
	.type	empty, @function
empty:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	tail(%rip), %edx
	movl	head(%rip), %eax
	cmpl	%eax, %edx
	sete	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	empty, .-empty
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	n(%rip), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%esi, %rbx
	testl	%r12d, %r12d
	js	.L18
	movslq	%r12d, %rax
	leaq	count(%rip), %rbp
	xorl	%esi, %esi
	leaq	4(,%rax,4), %r13
	movq	%rbp, %rdi
	movq	%r13, %rdx
	call	memset@PLT
	leaq	vst(%rip), %rcx
	movq	%r13, %rdx
	xorl	%esi, %esi
	movq	%rcx, %rdi
	call	memset@PLT
	movq	%rax, %rcx
.L5:
	movslq	tail(%rip), %rax
	movl	head(%rip), %r10d
	movslq	%r14d, %rdx
	leaq	que(%rip), %r13
	movl	$1, 0(%rbp,%rdx,4)
	leal	1(%rax), %edi
	movl	%r14d, 0(%r13,%rax,4)
	movl	%edi, tail(%rip)
	movl	$1, (%rcx,%rdx,4)
	cmpl	%r10d, %edi
	je	.L6
	movslq	%r10d, %rax
	xorl	%esi, %esi
	leal	1(%r12), %edx
	leaq	0(%r13,%rax,4), %r11
	leaq	graph(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	(%r11), %r9
	addl	$1, %r10d
	testl	%r12d, %r12d
	jle	.L7
	imulq	$404, %r9, %r8
	movl	$1, %eax
	addq	%r14, %r8
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	$0, (%rcx,%rax,4)
	jne	.L8
	cmpl	$0, (%r8,%rax,4)
	je	.L8
	movslq	%edi, %rsi
	movl	$1, (%rcx,%rax,4)
	addl	$1, %edi
	movl	%eax, 0(%r13,%rsi,4)
	movl	0(%rbp,%r9,4), %esi
	addl	$1, %esi
	movl	%esi, 0(%rbp,%rax,4)
	movl	$1, %esi
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdx
	jne	.L9
.L7:
	addq	$4, %r11
	cmpl	%edi, %r10d
	jne	.L10
	movl	%r10d, head(%rip)
	testb	%sil, %sil
	je	.L6
	movl	%r10d, tail(%rip)
.L6:
	movl	0(%rbp,%rbx,4), %eax
	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
.L18:
	.cfi_restore_state
	leaq	count(%rip), %rbp
	leaq	vst(%rip), %rcx
	jmp	.L5
	.cfi_endproc
.LFE24:
	.size	bfs, .-bfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L20
	leaq	28(%rsp), %rax
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	graph(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L23:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %edx
	testl	%edx, %edx
	jle	.L21
	xorl	%r14d, %r14d
	leaq	36(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rax
	movslq	36(%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, 32(%rsp)
	jg	.L22
.L21:
	addl	$1, %r13d
	cmpl	%r13d, n(%rip)
	jg	.L23
.L20:
	leaq	40(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L24
	xorl	%ebx, %ebx
	leaq	52(%rsp), %r14
	leaq	48(%rsp), %r13
	leaq	44(%rsp), %r12
	leaq	.LC2(%rip), %rbp
	leaq	.LC4(%rip), %r15
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%r15, %rdi
	addl	$1, %ebx
	call	puts@PLT
	cmpl	%ebx, 40(%rsp)
	jle	.L24
.L27:
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %edx
	movl	48(%rsp), %esi
	movl	44(%rsp), %edi
	call	bfs
	movl	52(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L25
	movl	48(%rsp), %esi
	movl	44(%rsp), %edi
	call	bfs
	testl	%eax, %eax
	jle	.L25
	movl	52(%rsp), %edx
	movl	48(%rsp), %esi
	addl	$1, %ebx
	movl	44(%rsp), %edi
	call	bfs
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebx, 40(%rsp)
	jg	.L27
	.p2align 4,,10
	.p2align 3
.L24:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	addq	$72, %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
.L33:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	tail(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	leaq	que(%rip), %rdx
	movl	%edi, (%rdx,%rax,4)
	ret
	.cfi_endproc
.LFE25:
	.size	push, .-push
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB26:
	.cfi_startproc
	endbr64
	movslq	head(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	leaq	que(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.cfi_endproc
.LFE26:
	.size	pop, .-pop
	.p2align 4
	.globl	empty
	.type	empty, @function
empty:
.LFB27:
	.cfi_startproc
	endbr64
	movl	head(%rip), %eax
	cmpl	%eax, tail(%rip)
	sete	%al
	movzbl	%al, %eax
	ret
	.cfi_endproc
.LFE27:
	.size	empty, .-empty
	.globl	count
	.bss
	.align 32
	.type	count, @object
	.size	count, 404
count:
	.zero	404
	.globl	vst
	.align 32
	.type	vst, @object
	.size	vst, 404
vst:
	.zero	404
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	graph
	.align 32
	.type	graph, @object
	.size	graph, 40804
graph:
	.zero	40804
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 4000000
que:
	.zero	4000000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	%edi, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	n(%rip), %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movslq	%esi, %rbx
	testl	%r12d, %r12d
	js	.L18
	movslq	%r12d, %rax
	leaq	count(%rip), %rbp
	xorl	%esi, %esi
	leaq	4(,%rax,4), %r13
	movq	%rbp, %rdi
	movq	%r13, %rdx
	call	memset@PLT
	leaq	vst(%rip), %rcx
	movq	%r13, %rdx
	xorl	%esi, %esi
	movq	%rcx, %rdi
	call	memset@PLT
	movq	%rax, %rcx
.L5:
	movslq	tail(%rip), %rax
	movl	head(%rip), %r10d
	movslq	%r14d, %rdx
	leaq	que(%rip), %r13
	movl	$1, 0(%rbp,%rdx,4)
	leal	1(%rax), %edi
	movl	%r14d, 0(%r13,%rax,4)
	movl	%edi, tail(%rip)
	movl	$1, (%rcx,%rdx,4)
	cmpl	%r10d, %edi
	je	.L6
	movslq	%r10d, %rax
	xorl	%esi, %esi
	leal	1(%r12), %edx
	leaq	0(%r13,%rax,4), %r11
	leaq	graph(%rip), %r14
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	(%r11), %r9
	addl	$1, %r10d
	testl	%r12d, %r12d
	jle	.L7
	imulq	$404, %r9, %r8
	movl	$1, %eax
	addq	%r14, %r8
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	$0, (%rcx,%rax,4)
	jne	.L8
	cmpl	$0, (%r8,%rax,4)
	je	.L8
	movslq	%edi, %rsi
	movl	$1, (%rcx,%rax,4)
	addl	$1, %edi
	movl	%eax, 0(%r13,%rsi,4)
	movl	0(%rbp,%r9,4), %esi
	addl	$1, %esi
	movl	%esi, 0(%rbp,%rax,4)
	movl	$1, %esi
.L8:
	addq	$1, %rax
	cmpq	%rax, %rdx
	jne	.L9
.L7:
	addq	$4, %r11
	cmpl	%edi, %r10d
	jne	.L10
	movl	%r10d, head(%rip)
	testb	%sil, %sil
	je	.L6
	movl	%r10d, tail(%rip)
.L6:
	movl	0(%rbp,%rbx,4), %eax
	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
.L18:
	.cfi_restore_state
	leaq	count(%rip), %rbp
	leaq	vst(%rip), %rcx
	jmp	.L5
	.cfi_endproc
.LFE24:
	.size	bfs, .-bfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L20
	leaq	28(%rsp), %rax
	xorl	%r13d, %r13d
	leaq	32(%rsp), %r15
	movq	%rax, 8(%rsp)
	leaq	graph(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L23:
	movq	8(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %edx
	testl	%edx, %edx
	jle	.L21
	xorl	%r14d, %r14d
	leaq	36(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L22:
	movq	%rbx, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rax
	movslq	36(%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, 32(%rsp)
	jg	.L22
.L21:
	addl	$1, %r13d
	cmpl	%r13d, n(%rip)
	jg	.L23
.L20:
	leaq	40(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	jle	.L24
	xorl	%ebx, %ebx
	leaq	52(%rsp), %r14
	leaq	48(%rsp), %r13
	leaq	44(%rsp), %r12
	leaq	.LC2(%rip), %rbp
	leaq	.LC4(%rip), %r15
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L25:
	movq	%r15, %rdi
	addl	$1, %ebx
	call	puts@PLT
	cmpl	%ebx, 40(%rsp)
	jle	.L24
.L27:
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %edx
	movl	48(%rsp), %esi
	movl	44(%rsp), %edi
	call	bfs
	movl	52(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L25
	movl	48(%rsp), %esi
	movl	44(%rsp), %edi
	call	bfs
	testl	%eax, %eax
	jle	.L25
	movl	52(%rsp), %edx
	movl	48(%rsp), %esi
	addl	$1, %ebx
	movl	44(%rsp), %edi
	call	bfs
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%ebx, 40(%rsp)
	jg	.L27
	.p2align 4,,10
	.p2align 3
.L24:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L33
	addq	$72, %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
.L33:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.text
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB25:
	.cfi_startproc
	endbr64
	movslq	tail(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	leaq	que(%rip), %rdx
	movl	%edi, (%rdx,%rax,4)
	ret
	.cfi_endproc
.LFE25:
	.size	push, .-push
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB26:
	.cfi_startproc
	endbr64
	movslq	head(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	leaq	que(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.cfi_endproc
.LFE26:
	.size	pop, .-pop
	.p2align 4
	.globl	empty
	.type	empty, @function
empty:
.LFB27:
	.cfi_startproc
	endbr64
	movl	head(%rip), %eax
	cmpl	%eax, tail(%rip)
	sete	%al
	movzbl	%al, %eax
	ret
	.cfi_endproc
.LFE27:
	.size	empty, .-empty
	.globl	count
	.bss
	.align 32
	.type	count, @object
	.size	count, 404
count:
	.zero	404
	.globl	vst
	.align 32
	.type	vst, @object
	.size	vst, 404
vst:
	.zero	404
	.globl	tail
	.align 4
	.type	tail, @object
	.size	tail, 4
tail:
	.zero	4
	.globl	head
	.align 4
	.type	head, @object
	.size	head, 4
head:
	.zero	4
	.globl	graph
	.align 32
	.type	graph, @object
	.size	graph, 40804
graph:
	.zero	40804
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 4000000
que:
	.zero	4000000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>

int bfs(int,int,int);
void push(int);
int pop(void);
int empty(void);

int n,que[1000000],graph[101][101],head=0,tail=0,vst[101],count[101];

int main(void){
  int r,k,t,p,s,d,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&r,&k);

    for(j=0;j<k;j++){
      scanf("%d",&t);
      graph[r][t]=1;
    }
  }
  
  scanf("%d",&p);

  for(i=0;i<p;i++){
    scanf("%d %d %d",&s,&d,&v);

    if(bfs(s,d,v)<=v && bfs(s,d,v)>0) printf("%d\n",bfs(s,d,v));
    else printf("NA\n");
  }

  return 0;
}

int bfs(int s,int d,int v){
  int u,i,j;

  for(i=0;i<=n;i++)vst[i]=count[i]=0;
  
  count[s]=1;
  push(s);
  vst[s]=1;

  while(!empty()){
    u=pop();

    for(i=1;i<=n;i++){
      if(!vst[i] && graph[u][i]){
	push(i);
	vst[i]=1;
	count[i]=count[u]+1;
      }
    }
  }

  return count[d];
}

void push(int a){
  que[tail++]=a;
}

int pop(void){
  int res=que[head++];
  return res;
}

int empty(void){
  return tail==head?1:0;
}
7
1 4 2 5 4 3
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 5 3
1 2 0
5 1 3
6 3 3
1 7 4
 7
1 4 2 5 4 6
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 3 3
1 2 0
5 1 3
6 3 3
1 7 4
 7
1 4 2 5 4 3
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 3 6
1 2 0
5 1 3
6 3 1
1 7 4
 7
1 4 2 7 4 6
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 3 3
1 2 0
5 1 3
6 3 3
1 7 4
 7
1 4 2 7 3 6
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 3 3
1 2 0
5 1 3
6 3 3
1 7 4
 7
1 4 3 5 4 3
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 5 3
1 2 1
5 1 3
6 3 3
1 7 4
 7
1 4 2 5 4 3
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
2 3 3
1 2 0
5 1 3
6 3 3
1 7 4
 7
1 4 2 5 4 6
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 2
7 0
6
1 2 2
1 3 3
1 2 0
5 1 3
6 3 3
1 7 4
 7
1 4 2 7 3 6
2 1 7
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 3 3
1 2 0
5 1 3
6 3 3
1 5 4
 7
1 4 4 5 4 6
2 1 5
3 1 6
4 1 7
5 2 7 6
6 1 1
7 0
6
1 2 2
1 3 2
1 2 0
5 1 3
6 3 3
1 7 4

2
2
NA
3
3
3
 2
NA
NA
3
NA
3
 2
2
NA
3
NA
3
 2
NA
NA
3
NA
2
 2
2
NA
3
3
2
 NA
2
NA
3
3
3
 2
NA
NA
3
3
3
 2
NA
NA
NA
NA
3
 2
2
NA
3
3
NA
 NA
NA
NA
3
NA
3

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

```c
#include<stdio.h>

int bfs(int,int,int);
void push(int);
int pop(void);
int empty(void);

int n,que[1000000],graph[101][101],head=0,tail=0,vst[101],count[101];

int main(void){
  int r,k,t,p,s,d,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&r,&k);

    for(j=0;j<k;j++){
      scanf("%d",&t);
      graph[r][t]=1;
    }
  }
  
  scanf("%d",&p);

  for(i=0;i<p;i++){
    scanf("%d %d %d",&s,&d,&v);

    if(bfs(s,d,v)<=v && bfs(s,d,v)>0) printf("%d\n",bfs(s,d,v));
    else printf("NA\n");
  }

  return 0;
}

int bfs(int s,int d,int v){
  int u,i,j;

  for(i=0;i<=n;i++)vst[i]=count[i]=0;
  
  count[s]=1;
  push(s);
  vst[s]=1;

  while(!empty()){
    u=pop();

    for(i=1;i<=n;i++){
      if(!vst[i] && graph[u][i]){
	push(i);
	vst[i]=1;
	count[i]=count[u]+1;
      }
    }
  }

  return count[d];
}

void push(int a){
  que[tail++]=a;
}

int pop(void){
  int res=que[head++];
  return res;
}

int empty(void){
  return tail==head?1:0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 4000000
que:
	.zero	4000000
	.globl	graph
	.align 32
	.type	graph, @object
	.size	graph, 40804
graph:
	.zero	40804
	.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	vst
	.align 32
	.type	vst, @object
	.size	vst, 404
vst:
	.zero	404
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 404
count:
	.zero	404
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"NA"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L5:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L3
.L4:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	movl	-36(%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	graph(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L3:
	movl	-40(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	addl	$1, -16(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L5
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L6
.L9:
	leaq	-20(%rbp), %rcx
	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	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	movl	-20(%rbp), %edx
	cmpl	%edx, %eax
	jg	.L7
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	testl	%eax, %eax
	jle	.L7
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L7:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L8:
	addl	$1, -16(%rbp)
.L6:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	vst(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L14
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	push
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	$1, (%rdx,%rax)
	jmp	.L15
.L19:
	call	pop
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L16
.L18:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L17
	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	graph(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L17
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	push
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L17:
	addl	$1, -8(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L18
.L15:
	call	empty
	testl	%eax, %eax
	je	.L19
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	bfs, .-bfs
	.globl	push
	.type	push, @function
push:
.LFB2:
	.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
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	que(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB3:
	.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
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	que(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	pop, .-pop
	.globl	empty
	.type	empty, @function
empty:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	tail(%rip), %edx
	movl	head(%rip), %eax
	cmpl	%eax, %edx
	sete	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	empty, .-empty
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 4000000
que:
	.zero	4000000
	.globl	graph
	.align 32
	.type	graph, @object
	.size	graph, 40804
graph:
	.zero	40804
	.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	vst
	.align 32
	.type	vst, @object
	.size	vst, 404
vst:
	.zero	404
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 404
count:
	.zero	404
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d %d %d"
.LC3:
	.string	"%d\n"
.LC4:
	.string	"NA"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L5:
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L3
.L4:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	movl	-36(%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	graph(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -12(%rbp)
.L3:
	movl	-40(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	addl	$1, -16(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L5
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L6
.L9:
	leaq	-20(%rbp), %rcx
	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	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	movl	-20(%rbp), %edx
	cmpl	%edx, %eax
	jg	.L7
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	testl	%eax, %eax
	jle	.L7
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %ecx
	movl	-28(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	bfs
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L7:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L8:
	addl	$1, -16(%rbp)
.L6:
	movl	-32(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L9
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	bfs
	.type	bfs, @function
bfs:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-8(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	vst(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L14
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	push
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	$1, (%rdx,%rax)
	jmp	.L15
.L19:
	call	pop
	movl	%eax, -4(%rbp)
	movl	$1, -8(%rbp)
	jmp	.L16
.L18:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L17
	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	graph(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L17
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	push
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	vst(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L17:
	addl	$1, -8(%rbp)
.L16:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jle	.L18
.L15:
	call	empty
	testl	%eax, %eax
	je	.L19
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	bfs, .-bfs
	.globl	push
	.type	push, @function
push:
.LFB2:
	.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
	leal	1(%rax), %edx
	movl	%edx, tail(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	que(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB3:
	.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
	leal	1(%rax), %edx
	movl	%edx, head(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	que(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	pop, .-pop
	.globl	empty
	.type	empty, @function
empty:
.LFB4:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	tail(%rip), %edx
	movl	head(%rip), %eax
	cmpl	%eax, %edx
	sete	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	empty, .-empty
	.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:
