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 100000

int main(void)
{
  int n,p,r,k,t,a,count[101];
  int queue[1000000],head=0,tail=0;
  int router[101][101],visited[101],i,j,b;
  
  struct mail{
    int s;
    int d;
    int v;
  }packet[N];
  
  for(i=0;i<101;i++)
    {
      for(j=0;j<101;j++)
	{
	  router[i][j]=0;
	}
    }
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&r,&k);
      
      for(j=1;j<=k;j++)
	{
	  scanf("%d",&t);
	  router[r][t]=1;
	}
    }
  
  for(i=1;i<=n;i++)
    {
      router[i][i]=0;
    }
  
  /*
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  printf("%d",router[i][j]);
	}
      printf("\n");
    }
  */
  scanf("%d",&p);
  
  for(i=1;i<=p;i++)
    {
      scanf("%d%d%d",&packet[i].s,&packet[i].d,&packet[i].v);
    }
  
  for(i=1;i<=p;i++)
    {
      for(b=0;b<101;b++)
	count[b]=0;

      count[packet[i].s]=1;
      queue[tail++]=packet[i].s;
      
      for(b=0;b<=n;b++)
	visited[b]=0;
	    

      visited[packet[i].s]=1;

      while(head!=tail)
	{
	  
	  a=queue[head++];

	  for(j=1;j<=n;j++)
	    {
	      if(router[a][j]==1 && visited[j]==0)
		{
		  queue[tail++]=j;
		  visited[j]=1;
		  count[j]=count[a]+1;	
		} 
	      
	    }

	}
        if(count[packet[i].d]<=packet[i].v && count[packet[i].d]!=0)printf("%d\n",count[packet[i].d]);
	else printf("NA\n");
		  
    }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.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
	leaq	-5238784(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2928, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -5241688(%rbp)
	movl	$0, -5241684(%rbp)
	movl	$0, -5241680(%rbp)
	jmp	.L2
.L5:
	movl	$0, -5241676(%rbp)
	jmp	.L3
.L4:
	movl	-5241676(%rbp), %eax
	movslq	%eax, %rcx
	movl	-5241680(%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
	movl	$0, -5240832(%rbp,%rax,4)
	addl	$1, -5241676(%rbp)
.L3:
	cmpl	$100, -5241676(%rbp)
	jle	.L4
	addl	$1, -5241680(%rbp)
.L2:
	cmpl	$100, -5241680(%rbp)
	jle	.L5
	leaq	-5241708(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241680(%rbp)
	jmp	.L6
.L9:
	leaq	-5241696(%rbp), %rdx
	leaq	-5241700(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241676(%rbp)
	jmp	.L7
.L8:
	leaq	-5241692(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-5241700(%rbp), %eax
	movl	-5241692(%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
	movl	$1, -5240832(%rbp,%rax,4)
	addl	$1, -5241676(%rbp)
.L7:
	movl	-5241696(%rbp), %eax
	cmpl	%eax, -5241676(%rbp)
	jle	.L8
	addl	$1, -5241680(%rbp)
.L6:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L9
	movl	$1, -5241680(%rbp)
	jmp	.L10
.L11:
	movl	-5241680(%rbp), %eax
	cltq
	imulq	$408, %rax, %rax
	addq	%rbp, %rax
	subq	$5240832, %rax
	movl	$0, (%rax)
	addl	$1, -5241680(%rbp)
.L10:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L11
	leaq	-5241704(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241680(%rbp)
	jmp	.L12
.L13:
	leaq	-5200016(%rbp), %rcx
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	8(%rax), %rcx
	leaq	-5200016(%rbp), %rsi
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	4(%rax), %rdx
	leaq	-5200016(%rbp), %rdi
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -5241680(%rbp)
.L12:
	movl	-5241704(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L13
	movl	$1, -5241680(%rbp)
	jmp	.L14
.L26:
	movl	$0, -5241672(%rbp)
	jmp	.L15
.L16:
	movl	-5241672(%rbp), %eax
	cltq
	movl	$0, -5241664(%rbp,%rax,4)
	addl	$1, -5241672(%rbp)
.L15:
	cmpl	$100, -5241672(%rbp)
	jle	.L16
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %eax
	cltq
	movl	$1, -5241664(%rbp,%rax,4)
	movl	-5241684(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -5241684(%rbp)
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %ecx
	movslq	%edx, %rax
	movl	%ecx, -4000016(%rbp,%rax,4)
	movl	$0, -5241672(%rbp)
	jmp	.L17
.L18:
	movl	-5241672(%rbp), %eax
	cltq
	movl	$0, -5241248(%rbp,%rax,4)
	addl	$1, -5241672(%rbp)
.L17:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241672(%rbp)
	jle	.L18
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %eax
	cltq
	movl	$1, -5241248(%rbp,%rax,4)
	jmp	.L19
.L23:
	movl	-5241688(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -5241688(%rbp)
	cltq
	movl	-4000016(%rbp,%rax,4), %eax
	movl	%eax, -5241668(%rbp)
	movl	$1, -5241676(%rbp)
	jmp	.L20
.L22:
	movl	-5241676(%rbp), %eax
	movslq	%eax, %rcx
	movl	-5241668(%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
	movl	-5240832(%rbp,%rax,4), %eax
	cmpl	$1, %eax
	jne	.L21
	movl	-5241676(%rbp), %eax
	cltq
	movl	-5241248(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L21
	movl	-5241684(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -5241684(%rbp)
	cltq
	movl	-5241676(%rbp), %edx
	movl	%edx, -4000016(%rbp,%rax,4)
	movl	-5241676(%rbp), %eax
	cltq
	movl	$1, -5241248(%rbp,%rax,4)
	movl	-5241668(%rbp), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-5241676(%rbp), %eax
	cltq
	movl	%edx, -5241664(%rbp,%rax,4)
.L21:
	addl	$1, -5241676(%rbp)
.L20:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241676(%rbp)
	jle	.L22
.L19:
	movl	-5241688(%rbp), %eax
	cmpl	-5241684(%rbp), %eax
	jne	.L23
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %ecx
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200008, %rax
	movl	(%rax), %eax
	cmpl	%eax, %ecx
	jg	.L24
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L24
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L25
.L24:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L25:
	addl	$1, -5241680(%rbp)
.L14:
	movl	-5241704(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L26
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.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
	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	-5238784(%rsp), %r11
	.cfi_def_cfa 11, 5238840
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2952, %rsp
	.cfi_def_cfa_offset 5241792
	movl	$40804, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %r13
	movq	%fs:40, %rax
	movq	%rax, 5241720(%rsp)
	xorl	%eax, %eax
	leaq	896(%rsp), %r12
	movq	%r12, %rdi
	call	memset@PLT
	leaq	44(%rsp), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L8
	leaq	52(%rsp), %rax
	movl	$1, %ebp
	leaq	56(%rsp), %r15
	movq	%rax, (%rsp)
	leaq	60(%rsp), %rbx
.L2:
	movq	(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	56(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L7
.L5:
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	52(%rsp), %rax
	movslq	60(%rsp), %rcx
	leaq	(%rax,%rax,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rax,%rdx,4), %rax
	addq	%rcx, %rax
	movl	$1, 896(%rsp,%rax,4)
	cmpl	%r14d, 56(%rsp)
	jge	.L5
.L7:
	movl	44(%rsp), %edx
	addl	$1, %ebp
	cmpl	%ebp, %edx
	jge	.L2
	testl	%edx, %edx
	jle	.L8
	subl	$1, %edx
	leaq	1304(%rsp), %rax
	imulq	$408, %rdx, %rdx
	leaq	1712(%rsp,%rdx), %rdx
.L9:
	movl	$0, (%rax)
	addq	$408, %rax
	cmpq	%rax, %rdx
	jne	.L9
.L8:
	leaq	48(%rsp), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L4
	leaq	41724(%rsp), %r15
	movl	$1, %ebp
	leaq	.LC2(%rip), %r13
	movq	%r15, %rbx
.L10:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	addq	$12, %rbx
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %eax
	cmpl	%ebp, %eax
	jge	.L10
	testl	%eax, %eax
	jle	.L4
	movl	$1, %r9d
	xorl	%r10d, %r10d
	movq	%r12, (%rsp)
	leaq	64(%rsp), %r14
	movl	%r9d, %r12d
	leaq	1241712(%rsp), %r13
	movslq	%r10d, %r9
	leaq	480(%rsp), %rbp
.L19:
	movl	$50, %ecx
	movq	%r14, %rdi
	xorl	%eax, %eax
	movslq	(%r15), %r10
	rep stosq
	movl	44(%rsp), %ecx
	leal	1(%r9), %ebx
	movl	%r10d, 1241712(%rsp,%r9,4)
	movl	$0, (%rdi)
	movl	$1, 64(%rsp,%r10,4)
	testl	%ecx, %ecx
	js	.L13
	movslq	%ecx, %rax
	xorl	%esi, %esi
	movq	%rbp, %rdi
	movq	%r10, 24(%rsp)
	leaq	4(,%rax,4), %rdx
	movq	%r9, 16(%rsp)
	movl	%ecx, 12(%rsp)
	call	memset@PLT
	movl	12(%rsp), %ecx
	movq	16(%rsp), %r9
	movq	24(%rsp), %r10
.L13:
	movl	$1, 480(%rsp,%r10,4)
	movq	(%rsp), %r8
	leal	1(%rcx), %esi
.L12:
	movslq	0(%r13,%r9,4), %r10
	testl	%ecx, %ecx
	jle	.L14
	imulq	$404, %r10, %rdx
	movl	$1, %eax
	addq	%r8, %rdx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L14
.L16:
	cmpl	$1, (%rdx,%rax,4)
	jne	.L15
	movl	0(%rbp,%rax,4), %edi
	testl	%edi, %edi
	jne	.L15
	movslq	%ebx, %rdi
	movl	$1, 0(%rbp,%rax,4)
	addl	$1, %ebx
	movl	%eax, 1241712(%rsp,%rdi,4)
	movl	64(%rsp,%r10,4), %edi
	addl	$1, %edi
	movl	%edi, (%r14,%rax,4)
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L16
.L14:
	addq	$1, %r9
	cmpl	%r9d, %ebx
	jne	.L12
	movslq	4(%r15), %rax
	movl	64(%rsp,%rax,4), %edx
	cmpl	8(%r15), %edx
	jg	.L17
	testl	%edx, %edx
	jne	.L40
.L17:
	leaq	.LC4(%rip), %rdi
	addl	$1, %r12d
	addq	$12, %r15
	call	puts@PLT
	cmpl	%r12d, 48(%rsp)
	jl	.L4
.L18:
	movslq	%ebx, %r9
	jmp	.L19
.L40:
	movl	$1, %edi
	xorl	%eax, %eax
	addl	$1, %r12d
	addq	$12, %r15
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	cmpl	48(%rsp), %r12d
	jle	.L18
.L4:
	movq	5241720(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$5241736, %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
.L41:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

rule
	.file	"temp.c"
	.text
	.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
	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	-5238784(%rsp), %r11
	.cfi_def_cfa 11, 5238840
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2952, %rsp
	.cfi_def_cfa_offset 5241792
	movl	$40804, %edx
	xorl	%esi, %esi
	leaq	.LC0(%rip), %r13
	movq	%fs:40, %rax
	movq	%rax, 5241720(%rsp)
	xorl	%eax, %eax
	leaq	896(%rsp), %r12
	movq	%r12, %rdi
	call	memset@PLT
	leaq	44(%rsp), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	44(%rsp), %r10d
	testl	%r10d, %r10d
	jle	.L8
	leaq	52(%rsp), %rax
	movl	$1, %ebp
	leaq	56(%rsp), %r15
	movq	%rax, (%rsp)
	leaq	60(%rsp), %rbx
.L2:
	movq	(%rsp), %rsi
	movq	%r15, %rdx
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	movl	$1, %r14d
	call	__isoc99_scanf@PLT
	movl	56(%rsp), %r8d
	testl	%r8d, %r8d
	jle	.L7
.L5:
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r14d
	call	__isoc99_scanf@PLT
	movslq	52(%rsp), %rax
	movslq	60(%rsp), %rcx
	leaq	(%rax,%rax,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rax,%rdx,4), %rax
	addq	%rcx, %rax
	movl	$1, 896(%rsp,%rax,4)
	cmpl	%r14d, 56(%rsp)
	jge	.L5
.L7:
	movl	44(%rsp), %edx
	addl	$1, %ebp
	cmpl	%ebp, %edx
	jge	.L2
	testl	%edx, %edx
	jle	.L8
	subl	$1, %edx
	leaq	1304(%rsp), %rax
	imulq	$408, %rdx, %rdx
	leaq	1712(%rsp,%rdx), %rdx
.L9:
	movl	$0, (%rax)
	addq	$408, %rax
	cmpq	%rax, %rdx
	jne	.L9
.L8:
	leaq	48(%rsp), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %r9d
	testl	%r9d, %r9d
	jle	.L4
	leaq	41724(%rsp), %r15
	movl	$1, %ebp
	leaq	.LC2(%rip), %r13
	movq	%r15, %rbx
.L10:
	leaq	8(%rbx), %rcx
	leaq	4(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	addq	$12, %rbx
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %eax
	cmpl	%ebp, %eax
	jge	.L10
	testl	%eax, %eax
	jle	.L4
	movl	$1, %r9d
	xorl	%r10d, %r10d
	movq	%r12, (%rsp)
	leaq	64(%rsp), %r14
	movl	%r9d, %r12d
	leaq	1241712(%rsp), %r13
	movslq	%r10d, %r9
	leaq	480(%rsp), %rbp
.L19:
	movl	$50, %ecx
	movq	%r14, %rdi
	xorl	%eax, %eax
	movslq	(%r15), %r10
	rep stosq
	movl	44(%rsp), %ecx
	leal	1(%r9), %ebx
	movl	%r10d, 1241712(%rsp,%r9,4)
	movl	$0, (%rdi)
	movl	$1, 64(%rsp,%r10,4)
	testl	%ecx, %ecx
	js	.L13
	movslq	%ecx, %rax
	xorl	%esi, %esi
	movq	%rbp, %rdi
	movq	%r10, 24(%rsp)
	leaq	4(,%rax,4), %rdx
	movq	%r9, 16(%rsp)
	movl	%ecx, 12(%rsp)
	call	memset@PLT
	movl	12(%rsp), %ecx
	movq	16(%rsp), %r9
	movq	24(%rsp), %r10
.L13:
	movl	$1, 480(%rsp,%r10,4)
	movq	(%rsp), %r8
	leal	1(%rcx), %esi
.L12:
	movslq	0(%r13,%r9,4), %r10
	testl	%ecx, %ecx
	jle	.L14
	imulq	$404, %r10, %rdx
	movl	$1, %eax
	addq	%r8, %rdx
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L15:
	addq	$1, %rax
	cmpq	%rax, %rsi
	je	.L14
.L16:
	cmpl	$1, (%rdx,%rax,4)
	jne	.L15
	movl	0(%rbp,%rax,4), %edi
	testl	%edi, %edi
	jne	.L15
	movslq	%ebx, %rdi
	movl	$1, 0(%rbp,%rax,4)
	addl	$1, %ebx
	movl	%eax, 1241712(%rsp,%rdi,4)
	movl	64(%rsp,%r10,4), %edi
	addl	$1, %edi
	movl	%edi, (%r14,%rax,4)
	addq	$1, %rax
	cmpq	%rax, %rsi
	jne	.L16
.L14:
	addq	$1, %r9
	cmpl	%r9d, %ebx
	jne	.L12
	movslq	4(%r15), %rax
	movl	64(%rsp,%rax,4), %edx
	cmpl	8(%r15), %edx
	jg	.L17
	testl	%edx, %edx
	jne	.L40
.L17:
	leaq	.LC4(%rip), %rdi
	addl	$1, %r12d
	addq	$12, %r15
	call	puts@PLT
	cmpl	%r12d, 48(%rsp)
	jl	.L4
.L18:
	movslq	%ebx, %r9
	jmp	.L19
.L40:
	movl	$1, %edi
	xorl	%eax, %eax
	addl	$1, %r12d
	addq	$12, %r15
	leaq	.LC3(%rip), %rsi
	call	__printf_chk@PLT
	cmpl	48(%rsp), %r12d
	jle	.L18
.L4:
	movq	5241720(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$5241736, %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
.L41:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

#include<stdio.h>
#define N 100000

int main(void)
{
  int n,p,r,k,t,a,count[101];
  int queue[1000000],head=0,tail=0;
  int router[101][101],visited[101],i,j,b;
  
  struct mail{
    int s;
    int d;
    int v;
  }packet[N];
  
  for(i=0;i<101;i++)
    {
      for(j=0;j<101;j++)
	{
	  router[i][j]=0;
	}
    }
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&r,&k);
      
      for(j=1;j<=k;j++)
	{
	  scanf("%d",&t);
	  router[r][t]=1;
	}
    }
  
  for(i=1;i<=n;i++)
    {
      router[i][i]=0;
    }
  
  /*
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  printf("%d",router[i][j]);
	}
      printf("\n");
    }
  */
  scanf("%d",&p);
  
  for(i=1;i<=p;i++)
    {
      scanf("%d%d%d",&packet[i].s,&packet[i].d,&packet[i].v);
    }
  
  for(i=1;i<=p;i++)
    {
      for(b=0;b<101;b++)
	count[b]=0;

      count[packet[i].s]=1;
      queue[tail++]=packet[i].s;
      
      for(b=0;b<=n;b++)
	visited[b]=0;
	    

      visited[packet[i].s]=1;

      while(head!=tail)
	{
	  
	  a=queue[head++];

	  for(j=1;j<=n;j++)
	    {
	      if(router[a][j]==1 && visited[j]==0)
		{
		  queue[tail++]=j;
		  visited[j]=1;
		  count[j]=count[a]+1;	
		} 
	      
	    }

	}
        if(count[packet[i].d]<=packet[i].v && count[packet[i].d]!=0)printf("%d\n",count[packet[i].d]);
	else printf("NA\n");
		  
    }
  return 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>
#define N 100000

int main(void)
{
  int n,p,r,k,t,a,count[101];
  int queue[1000000],head=0,tail=0;
  int router[101][101],visited[101],i,j,b;
  
  struct mail{
    int s;
    int d;
    int v;
  }packet[N];
  
  for(i=0;i<101;i++)
    {
      for(j=0;j<101;j++)
	{
	  router[i][j]=0;
	}
    }
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&r,&k);
      
      for(j=1;j<=k;j++)
	{
	  scanf("%d",&t);
	  router[r][t]=1;
	}
    }
  
  for(i=1;i<=n;i++)
    {
      router[i][i]=0;
    }
  
  /*
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  printf("%d",router[i][j]);
	}
      printf("\n");
    }
  */
  scanf("%d",&p);
  
  for(i=1;i<=p;i++)
    {
      scanf("%d%d%d",&packet[i].s,&packet[i].d,&packet[i].v);
    }
  
  for(i=1;i<=p;i++)
    {
      for(b=0;b<101;b++)
	count[b]=0;

      count[packet[i].s]=1;
      queue[tail++]=packet[i].s;
      
      for(b=0;b<=n;b++)
	visited[b]=0;
	    

      visited[packet[i].s]=1;

      while(head!=tail)
	{
	  
	  a=queue[head++];

	  for(j=1;j<=n;j++)
	    {
	      if(router[a][j]==1 && visited[j]==0)
		{
		  queue[tail++]=j;
		  visited[j]=1;
		  count[j]=count[a]+1;	
		} 
	      
	    }

	}
        if(count[packet[i].d]<=packet[i].v && count[packet[i].d]!=0)printf("%d\n",count[packet[i].d]);
	else printf("NA\n");
		  
    }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.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
	leaq	-5238784(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2928, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -5241688(%rbp)
	movl	$0, -5241684(%rbp)
	movl	$0, -5241680(%rbp)
	jmp	.L2
.L5:
	movl	$0, -5241676(%rbp)
	jmp	.L3
.L4:
	movl	-5241676(%rbp), %eax
	movslq	%eax, %rcx
	movl	-5241680(%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
	movl	$0, -5240832(%rbp,%rax,4)
	addl	$1, -5241676(%rbp)
.L3:
	cmpl	$100, -5241676(%rbp)
	jle	.L4
	addl	$1, -5241680(%rbp)
.L2:
	cmpl	$100, -5241680(%rbp)
	jle	.L5
	leaq	-5241708(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241680(%rbp)
	jmp	.L6
.L9:
	leaq	-5241696(%rbp), %rdx
	leaq	-5241700(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241676(%rbp)
	jmp	.L7
.L8:
	leaq	-5241692(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-5241700(%rbp), %eax
	movl	-5241692(%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
	movl	$1, -5240832(%rbp,%rax,4)
	addl	$1, -5241676(%rbp)
.L7:
	movl	-5241696(%rbp), %eax
	cmpl	%eax, -5241676(%rbp)
	jle	.L8
	addl	$1, -5241680(%rbp)
.L6:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L9
	movl	$1, -5241680(%rbp)
	jmp	.L10
.L11:
	movl	-5241680(%rbp), %eax
	cltq
	imulq	$408, %rax, %rax
	addq	%rbp, %rax
	subq	$5240832, %rax
	movl	$0, (%rax)
	addl	$1, -5241680(%rbp)
.L10:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L11
	leaq	-5241704(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241680(%rbp)
	jmp	.L12
.L13:
	leaq	-5200016(%rbp), %rcx
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	8(%rax), %rcx
	leaq	-5200016(%rbp), %rsi
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	4(%rax), %rdx
	leaq	-5200016(%rbp), %rdi
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -5241680(%rbp)
.L12:
	movl	-5241704(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L13
	movl	$1, -5241680(%rbp)
	jmp	.L14
.L26:
	movl	$0, -5241672(%rbp)
	jmp	.L15
.L16:
	movl	-5241672(%rbp), %eax
	cltq
	movl	$0, -5241664(%rbp,%rax,4)
	addl	$1, -5241672(%rbp)
.L15:
	cmpl	$100, -5241672(%rbp)
	jle	.L16
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %eax
	cltq
	movl	$1, -5241664(%rbp,%rax,4)
	movl	-5241684(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -5241684(%rbp)
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %ecx
	movslq	%edx, %rax
	movl	%ecx, -4000016(%rbp,%rax,4)
	movl	$0, -5241672(%rbp)
	jmp	.L17
.L18:
	movl	-5241672(%rbp), %eax
	cltq
	movl	$0, -5241248(%rbp,%rax,4)
	addl	$1, -5241672(%rbp)
.L17:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241672(%rbp)
	jle	.L18
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %eax
	cltq
	movl	$1, -5241248(%rbp,%rax,4)
	jmp	.L19
.L23:
	movl	-5241688(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -5241688(%rbp)
	cltq
	movl	-4000016(%rbp,%rax,4), %eax
	movl	%eax, -5241668(%rbp)
	movl	$1, -5241676(%rbp)
	jmp	.L20
.L22:
	movl	-5241676(%rbp), %eax
	movslq	%eax, %rcx
	movl	-5241668(%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
	movl	-5240832(%rbp,%rax,4), %eax
	cmpl	$1, %eax
	jne	.L21
	movl	-5241676(%rbp), %eax
	cltq
	movl	-5241248(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L21
	movl	-5241684(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -5241684(%rbp)
	cltq
	movl	-5241676(%rbp), %edx
	movl	%edx, -4000016(%rbp,%rax,4)
	movl	-5241676(%rbp), %eax
	cltq
	movl	$1, -5241248(%rbp,%rax,4)
	movl	-5241668(%rbp), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-5241676(%rbp), %eax
	cltq
	movl	%edx, -5241664(%rbp,%rax,4)
.L21:
	addl	$1, -5241676(%rbp)
.L20:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241676(%rbp)
	jle	.L22
.L19:
	movl	-5241688(%rbp), %eax
	cmpl	-5241684(%rbp), %eax
	jne	.L23
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %ecx
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200008, %rax
	movl	(%rax), %eax
	cmpl	%eax, %ecx
	jg	.L24
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L24
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L25
.L24:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L25:
	addl	$1, -5241680(%rbp)
.L14:
	movl	-5241704(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L26
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.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
	leaq	-5238784(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$2928, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -5241688(%rbp)
	movl	$0, -5241684(%rbp)
	movl	$0, -5241680(%rbp)
	jmp	.L2
.L5:
	movl	$0, -5241676(%rbp)
	jmp	.L3
.L4:
	movl	-5241676(%rbp), %eax
	movslq	%eax, %rcx
	movl	-5241680(%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
	movl	$0, -5240832(%rbp,%rax,4)
	addl	$1, -5241676(%rbp)
.L3:
	cmpl	$100, -5241676(%rbp)
	jle	.L4
	addl	$1, -5241680(%rbp)
.L2:
	cmpl	$100, -5241680(%rbp)
	jle	.L5
	leaq	-5241708(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241680(%rbp)
	jmp	.L6
.L9:
	leaq	-5241696(%rbp), %rdx
	leaq	-5241700(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241676(%rbp)
	jmp	.L7
.L8:
	leaq	-5241692(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-5241700(%rbp), %eax
	movl	-5241692(%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
	movl	$1, -5240832(%rbp,%rax,4)
	addl	$1, -5241676(%rbp)
.L7:
	movl	-5241696(%rbp), %eax
	cmpl	%eax, -5241676(%rbp)
	jle	.L8
	addl	$1, -5241680(%rbp)
.L6:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L9
	movl	$1, -5241680(%rbp)
	jmp	.L10
.L11:
	movl	-5241680(%rbp), %eax
	cltq
	imulq	$408, %rax, %rax
	addq	%rbp, %rax
	subq	$5240832, %rax
	movl	$0, (%rax)
	addl	$1, -5241680(%rbp)
.L10:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L11
	leaq	-5241704(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -5241680(%rbp)
	jmp	.L12
.L13:
	leaq	-5200016(%rbp), %rcx
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	8(%rax), %rcx
	leaq	-5200016(%rbp), %rsi
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	leaq	4(%rax), %rdx
	leaq	-5200016(%rbp), %rdi
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rsi
	movq	%rsi, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -5241680(%rbp)
.L12:
	movl	-5241704(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L13
	movl	$1, -5241680(%rbp)
	jmp	.L14
.L26:
	movl	$0, -5241672(%rbp)
	jmp	.L15
.L16:
	movl	-5241672(%rbp), %eax
	cltq
	movl	$0, -5241664(%rbp,%rax,4)
	addl	$1, -5241672(%rbp)
.L15:
	cmpl	$100, -5241672(%rbp)
	jle	.L16
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %eax
	cltq
	movl	$1, -5241664(%rbp,%rax,4)
	movl	-5241684(%rbp), %edx
	leal	1(%rdx), %eax
	movl	%eax, -5241684(%rbp)
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %ecx
	movslq	%edx, %rax
	movl	%ecx, -4000016(%rbp,%rax,4)
	movl	$0, -5241672(%rbp)
	jmp	.L17
.L18:
	movl	-5241672(%rbp), %eax
	cltq
	movl	$0, -5241248(%rbp,%rax,4)
	addl	$1, -5241672(%rbp)
.L17:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241672(%rbp)
	jle	.L18
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200016, %rax
	movl	(%rax), %eax
	cltq
	movl	$1, -5241248(%rbp,%rax,4)
	jmp	.L19
.L23:
	movl	-5241688(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -5241688(%rbp)
	cltq
	movl	-4000016(%rbp,%rax,4), %eax
	movl	%eax, -5241668(%rbp)
	movl	$1, -5241676(%rbp)
	jmp	.L20
.L22:
	movl	-5241676(%rbp), %eax
	movslq	%eax, %rcx
	movl	-5241668(%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
	movl	-5240832(%rbp,%rax,4), %eax
	cmpl	$1, %eax
	jne	.L21
	movl	-5241676(%rbp), %eax
	cltq
	movl	-5241248(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L21
	movl	-5241684(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -5241684(%rbp)
	cltq
	movl	-5241676(%rbp), %edx
	movl	%edx, -4000016(%rbp,%rax,4)
	movl	-5241676(%rbp), %eax
	cltq
	movl	$1, -5241248(%rbp,%rax,4)
	movl	-5241668(%rbp), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-5241676(%rbp), %eax
	cltq
	movl	%edx, -5241664(%rbp,%rax,4)
.L21:
	addl	$1, -5241676(%rbp)
.L20:
	movl	-5241708(%rbp), %eax
	cmpl	%eax, -5241676(%rbp)
	jle	.L22
.L19:
	movl	-5241688(%rbp), %eax
	cmpl	-5241684(%rbp), %eax
	jne	.L23
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %ecx
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200008, %rax
	movl	(%rax), %eax
	cmpl	%eax, %ecx
	jg	.L24
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L24
	movl	-5241680(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rbp, %rax
	subq	$5200012, %rax
	movl	(%rax), %eax
	cltq
	movl	-5241664(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L25
.L24:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L25:
	addl	$1, -5241680(%rbp)
.L14:
	movl	-5241704(%rbp), %eax
	cmpl	%eax, -5241680(%rbp)
	jle	.L26
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
