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

```c
#include <stdio.h>
#include <stdlib.h>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define INFTY 19980725
#define N 100

/** ルータの総数 */
static int n;
/** ネットワークの隣接行列 */
static int g[ N + 1 ][ N + 1 ] = { { 0 } };
/** パケットの個数 */
static int p;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j, k;

  /* ルータの個数の読み込みと隣接行列の初期化 */
  scanf ( "%d", &n );
  for ( i = 1; i <= n; ++i )
  for ( j = 1; j <= n; ++j )
  {
    g[ i ][ j ] = ( i == j ? 0 : INFTY );
  }

  /* ネットワーク状態の読み込み */
  for ( i = 0; i < n; ++i )
  {
    int r, k;

    scanf ( "%d%d", &r, &k );
    for ( j = 0; j < k; ++j )
    {
      int t;

      scanf ( "%d", &t );
      g[ r ][ t ] = 1;
    }
  }

  /* ワーシャルフロイド法による最短経路の算出 */
  for ( k = 1; k <= n; ++k )
  for ( i = 1; i <= n; ++i )
  for ( j = 1; j <= n; ++j )
  {
    g[ i ][ j ] = MIN( g[ i ][ j ], g[ i ][ k ] + g[ k ][ j ] );
  }

  /* パケット情報の読み込みと処理 */
  scanf ( "%d", &p );
  for ( i = 0; i < p; ++i )
  {
    int s, d, v;

    scanf ( "%d%d%d", &s, &d, &v );
    if ( g[ s ][ d ] + 1 <= v )
    {
      printf ( "%d\n", g[ s ][ d ] + 1 );
    }
    else
    {
      puts ( "NA" );
    }
  }

  return ( EXIT_SUCCESS );
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	n
	.comm	n,4,4
	.local	g
	.comm	g,40804,32
	.local	p
	.comm	p,4,4
	.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:
.LFB6:
	.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
	movl	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	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	$1, -20(%rbp)
	jmp	.L2
.L7:
	movl	$1, -16(%rbp)
	jmp	.L3
.L6:
	movl	-20(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jne	.L4
	movl	$0, %ecx
	jmp	.L5
.L4:
	movl	$19980725, %ecx
.L5:
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L6
	addl	$1, -20(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L7
	movl	$0, -20(%rbp)
	jmp	.L8
.L11:
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L9
.L10:
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movl	-24(%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	g(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L9:
	movl	-28(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	addl	$1, -20(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	movl	$1, -12(%rbp)
	jmp	.L12
.L17:
	movl	$1, -20(%rbp)
	jmp	.L13
.L16:
	movl	$1, -16(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %r8
	addq	%r8, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L14:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L15
	addl	$1, -20(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L16
	addl	$1, -12(%rbp)
.L12:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L17
	leaq	p(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L21:
	leaq	-24(%rbp), %rcx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L19
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L19:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L20:
	addl	$1, -20(%rbp)
.L18:
	movl	p(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
.LC1:
	.string	"%d"
.LC4:
	.string	"%d%d"
.LC5:
	.string	"%d%d%d"
.LC6:
	.string	"%d\n"
.LC7:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	leaq	n(%rip), %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r15, %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leal	-1(%r8), %eax
	movl	%r8d, %r14d
	leaq	408+g(%rip), %rsi
	xorl	%ebx, %ebx
	movl	%eax, (%rsp)
	movl	%r8d, %eax
	andl	$-4, %r14d
	leal	1(%r8), %r13d
	shrl	$2, %eax
	movl	$1, %edx
	movdqa	.LC2(%rip), %xmm4
	movdqa	.LC3(%rip), %xmm3
	leal	-1(%rax), %r12d
	leal	1(%r14), %eax
	movl	$19980725, %r11d
	movl	%eax, 8(%rsp)
	addq	$1, %r12
	leaq	-408(%rsi), %r10
	salq	$4, %r12
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	$2, (%rsp)
	jbe	.L29
	movd	%edx, %xmm7
	movdqa	.LC0(%rip), %xmm1
	leaq	(%r12,%rsi), %rcx
	movq	%rsi, %rax
	pshufd	$0, %xmm7, %xmm2
	.p2align 4,,10
	.p2align 3
.L4:
	movdqa	%xmm1, %xmm0
	addq	$16, %rax
	paddd	%xmm4, %xmm1
	pcmpeqd	%xmm2, %xmm0
	pandn	%xmm3, %xmm0
	movups	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L4
	cmpl	%r8d, %r14d
	je	.L5
	movl	8(%rsp), %eax
.L3:
	movslq	%edx, %rdi
	cmpl	%eax, %edx
	movl	%r11d, %ebp
	movslq	%eax, %rcx
	leaq	(%rdi,%rdi,4), %r9
	cmove	%ebx, %ebp
	leaq	(%r9,%r9,4), %r9
	leaq	(%rdi,%r9,4), %rdi
	addq	%rdi, %rcx
	movl	%ebp, (%r10,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %r8d
	jl	.L5
	cmpl	%ecx, %edx
	movl	%r11d, %r9d
	movslq	%ecx, %rcx
	cmove	%ebx, %r9d
	addq	%rdi, %rcx
	addl	$2, %eax
	movl	%r9d, (%r10,%rcx,4)
	cmpl	%r8d, %eax
	jg	.L5
	cmpl	%edx, %eax
	movl	%r11d, %ecx
	cltq
	cmove	%ebx, %ecx
	addq	%rax, %rdi
	movl	%ecx, (%r10,%rdi,4)
.L5:
	addl	$1, %edx
	addq	$404, %rsi
	cmpl	%r13d, %edx
	jne	.L9
	leaq	140(%rsp), %rbp
	xorl	%eax, %eax
	leaq	144(%rsp), %r12
	movq	%rbp, (%rsp)
	leaq	g(%rip), %r13
	movl	%eax, %ebp
	movq	%r12, %r14
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%rsp), %rsi
	movq	%r14, %rdx
	leaq	.LC4(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	144(%rsp), %edx
	testl	%edx, %edx
	jle	.L10
	xorl	%r12d, %r12d
	leaq	148(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rbx, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movslq	140(%rsp), %rax
	movslq	148(%rsp), %rsi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rax
	addq	%rsi, %rax
	movl	$1, 0(%r13,%rax,4)
	cmpl	%r12d, 144(%rsp)
	jg	.L11
.L10:
	movl	n(%rip), %eax
	addl	$1, %ebp
	cmpl	%ebp, %eax
	jg	.L12
	movl	%eax, %r14d
	testl	%eax, %eax
	jle	.L2
	leal	-1(%rax), %edx
	movl	%r14d, %edi
	leal	1(%r14), %ebx
	movl	$404, %r13d
	leaq	2(%rdx), %rax
	andl	$-4, %edi
	movl	%edx, 40(%rsp)
	leaq	408+g(%rip), %r9
	movq	%rax, 120(%rsp)
	movslq	%r14d, %rax
	leal	2(%rdi), %esi
	leaq	-408(%r9), %r8
	salq	$2, %rax
	movl	%edi, 44(%rsp)
	movq	%rax, 24(%rsp)
	movl	%r14d, %eax
	shrl	$2, %eax
	movl	%esi, 72(%rsp)
	subl	$1, %eax
	movl	%ebx, 36(%rsp)
	addq	$1, %rax
	movq	$-404, 104(%rsp)
	salq	$4, %rax
	movq	$4, (%rsp)
	movq	$1, 88(%rsp)
	movq	%rax, %r12
	leal	1(%rdi), %eax
	addl	$3, %edi
	cltq
	movl	%edi, 76(%rsp)
	movq	%rax, 48(%rsp)
	movslq	%esi, %rax
	movq	%rax, 80(%rsp)
	movslq	%edi, %rax
	movq	%rax, 96(%rsp)
	leaq	4(%r8), %rax
	leaq	(%rax,%rdx,4), %rax
	movq	%rax, 112(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	movq	(%rsp), %rcx
	movslq	88(%rsp), %rdx
	movl	$408, %esi
	leaq	408+g(%rip), %rax
	movl	$1, %r11d
	leaq	-4(%rcx), %rbx
	leaq	(%r8,%rcx), %rdi
	movq	%rbx, 8(%rsp)
	movq	104(%rsp), %rbx
	leaq	-8(%rbx), %rcx
	movq	%rcx, 16(%rsp)
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rcx
	movq	%rcx, 64(%rsp)
	addq	48(%rsp), %rcx
	movq	%rcx, 56(%rsp)
	.p2align 4,,10
	.p2align 3
.L23:
	movq	24(%rsp), %rbx
	leaq	(%rsi,%rbx), %rcx
	movq	8(%rsp), %rbx
	leaq	(%rbx,%rsi), %rdx
	movq	(%rsp), %rbx
	cmpq	%rdx, %rcx
	leaq	(%rsi,%rbx), %rdx
	setle	%cl
	cmpq	%rsi, %rdx
	setle	%dl
	orb	%cl, %dl
	je	.L22
	movq	16(%rsp), %rbx
	leaq	(%rbx,%rsi), %rdx
	cmpq	$8, %rdx
	seta	%cl
	cmpl	$2, 40(%rsp)
	seta	%dl
	testb	%dl, %cl
	je	.L22
	movd	404(%rdi), %xmm6
	xorl	%edx, %edx
	pshufd	$0, %xmm6, %xmm3
	.p2align 4,,10
	.p2align 3
.L17:
	movdqu	(%r9,%rdx), %xmm2
	movdqu	(%rax,%rdx), %xmm5
	paddd	%xmm3, %xmm2
	movdqa	%xmm5, %xmm1
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm5, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movups	%xmm0, (%rax,%rdx)
	addq	$16, %rdx
	cmpq	%rdx, %r12
	jne	.L17
	cmpl	%r14d, 44(%rsp)
	je	.L16
	movslq	%r11d, %rdx
	movq	48(%rsp), %rbx
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rcx
	movl	404(%rdi), %edx
	leaq	(%rcx,%rbx), %r10
	movq	56(%rsp), %rbx
	addl	(%r8,%rbx,4), %edx
	movl	(%r8,%r10,4), %ebx
	cmpl	%ebx, %edx
	cmovg	%ebx, %edx
	movl	%edx, (%r8,%r10,4)
	cmpl	72(%rsp), %r14d
	jl	.L16
	movq	80(%rsp), %rbx
	movq	64(%rsp), %rbp
	leaq	(%rcx,%rbx), %r10
	movq	%rbp, %rdx
	addq	%rbx, %rdx
	movl	(%r8,%r10,4), %ebx
	movl	(%r8,%rdx,4), %edx
	addl	404(%rdi), %edx
	cmpl	%ebx, %edx
	cmovg	%ebx, %edx
	movl	%edx, (%r8,%r10,4)
	cmpl	76(%rsp), %r14d
	jl	.L16
	movq	96(%rsp), %rbx
	movq	%rbp, %rdx
	addq	%rbx, %rcx
	addq	%rbx, %rdx
	movl	(%r8,%rcx,4), %r10d
	movl	(%r8,%rdx,4), %edx
	addl	404(%rdi), %edx
	cmpl	%r10d, %edx
	cmovg	%r10d, %edx
	movl	%edx, (%r8,%rcx,4)
.L16:
	addl	$1, %r11d
	addq	$404, %rsi
	addq	$404, %rax
	addq	$404, %rdi
	cmpl	36(%rsp), %r11d
	jne	.L23
	addq	$1, 88(%rsp)
	addq	$404, %r13
	movq	88(%rsp), %rax
	addq	$404, %r9
	addq	$4, (%rsp)
	subq	$404, 104(%rsp)
	cmpq	120(%rsp), %rax
	jne	.L13
.L2:
	leaq	p(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	p(%rip), %eax
	testl	%eax, %eax
	jle	.L24
	leaq	g(%rip), %r8
	xorl	%ebx, %ebx
	leaq	144(%rsp), %r12
	movq	%r8, (%rsp)
	leaq	140(%rsp), %rbp
	leaq	148(%rsp), %r14
	leaq	.LC5(%rip), %r13
	leaq	.LC7(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%r14, %rcx
	movq	%r12, %rdx
	movq	%r13, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	140(%rsp), %rax
	movq	(%rsp), %rdi
	movslq	144(%rsp), %rcx
	leaq	(%rax,%rax,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rax,%rdx,4), %rax
	addq	%rcx, %rax
	movl	(%rdi,%rax,4), %eax
	cmpl	148(%rsp), %eax
	jge	.L25
	leal	1(%rax), %edx
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	addl	$1, %ebx
	movl	$1, %edi
	call	__printf_chk@PLT
	cmpl	%ebx, p(%rip)
	jg	.L27
.L24:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$168, %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
	.p2align 4,,10
	.p2align 3
.L22:
	.cfi_restore_state
	movq	112(%rsp), %rcx
	movl	$4, %ebx
	subq	%rsi, %rbx
	leaq	(%rcx,%rsi), %rbp
	movq	%rax, %rcx
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	(%rbx,%rcx), %r10
	movl	404(%rdi), %edx
	addl	(%r10,%r13), %edx
	movl	(%rcx), %r10d
	cmpl	%r10d, %edx
	cmovg	%r10d, %edx
	addq	$4, %rcx
	movl	%edx, -4(%rcx)
	cmpq	%rbp, %rcx
	jne	.L15
	jmp	.L16
.L25:
	movq	%r15, %rdi
	addl	$1, %ebx
	call	puts@PLT
	cmpl	%ebx, p(%rip)
	jg	.L27
	jmp	.L24
.L29:
	movl	$1, %eax
	jmp	.L3
.L45:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.local	p
	.comm	p,4,4
	.local	g
	.comm	g,40804,32
	.local	n
	.comm	n,4,4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC3:
	.long	19980725
	.long	19980725
	.long	19980725
	.long	19980725
	.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
.LC1:
	.string	"%d"
.LC4:
	.string	"%d%d"
.LC5:
	.string	"%d%d%d"
.LC6:
	.string	"%d\n"
.LC7:
	.string	"NA"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	leaq	n(%rip), %rsi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r15, %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	movq	%fs:40, %rax
	movq	%rax, 152(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r8d
	testl	%r8d, %r8d
	jle	.L2
	leal	-1(%r8), %eax
	movl	%r8d, %r14d
	leaq	408+g(%rip), %rsi
	xorl	%ebx, %ebx
	movl	%eax, (%rsp)
	movl	%r8d, %eax
	andl	$-4, %r14d
	leal	1(%r8), %r13d
	shrl	$2, %eax
	movl	$1, %edx
	movdqa	.LC2(%rip), %xmm4
	movdqa	.LC3(%rip), %xmm3
	leal	-1(%rax), %r12d
	leal	1(%r14), %eax
	movl	$19980725, %r11d
	movl	%eax, 8(%rsp)
	addq	$1, %r12
	leaq	-408(%rsi), %r10
	salq	$4, %r12
	.p2align 4,,10
	.p2align 3
.L9:
	cmpl	$2, (%rsp)
	jbe	.L29
	movd	%edx, %xmm7
	movdqa	.LC0(%rip), %xmm1
	leaq	(%r12,%rsi), %rcx
	movq	%rsi, %rax
	pshufd	$0, %xmm7, %xmm2
	.p2align 4,,10
	.p2align 3
.L4:
	movdqa	%xmm1, %xmm0
	addq	$16, %rax
	paddd	%xmm4, %xmm1
	pcmpeqd	%xmm2, %xmm0
	pandn	%xmm3, %xmm0
	movups	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L4
	cmpl	%r8d, %r14d
	je	.L5
	movl	8(%rsp), %eax
.L3:
	movslq	%edx, %rdi
	cmpl	%eax, %edx
	movl	%r11d, %ebp
	movslq	%eax, %rcx
	leaq	(%rdi,%rdi,4), %r9
	cmove	%ebx, %ebp
	leaq	(%r9,%r9,4), %r9
	leaq	(%rdi,%r9,4), %rdi
	addq	%rdi, %rcx
	movl	%ebp, (%r10,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %r8d
	jl	.L5
	cmpl	%ecx, %edx
	movl	%r11d, %r9d
	movslq	%ecx, %rcx
	cmove	%ebx, %r9d
	addq	%rdi, %rcx
	addl	$2, %eax
	movl	%r9d, (%r10,%rcx,4)
	cmpl	%r8d, %eax
	jg	.L5
	cmpl	%edx, %eax
	movl	%r11d, %ecx
	cltq
	cmove	%ebx, %ecx
	addq	%rax, %rdi
	movl	%ecx, (%r10,%rdi,4)
.L5:
	addl	$1, %edx
	addq	$404, %rsi
	cmpl	%r13d, %edx
	jne	.L9
	leaq	140(%rsp), %rbp
	xorl	%eax, %eax
	leaq	144(%rsp), %r12
	movq	%rbp, (%rsp)
	leaq	g(%rip), %r13
	movl	%eax, %ebp
	movq	%r12, %r14
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%rsp), %rsi
	movq	%r14, %rdx
	leaq	.LC4(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	144(%rsp), %edx
	testl	%edx, %edx
	jle	.L10
	xorl	%r12d, %r12d
	leaq	148(%rsp), %rbx
	.p2align 4,,10
	.p2align 3
.L11:
	movq	%rbx, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %r12d
	call	__isoc99_scanf@PLT
	movslq	140(%rsp), %rax
	movslq	148(%rsp), %rsi
	leaq	(%rax,%rax,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rax,%rcx,4), %rax
	addq	%rsi, %rax
	movl	$1, 0(%r13,%rax,4)
	cmpl	%r12d, 144(%rsp)
	jg	.L11
.L10:
	movl	n(%rip), %eax
	addl	$1, %ebp
	cmpl	%ebp, %eax
	jg	.L12
	movl	%eax, %r14d
	testl	%eax, %eax
	jle	.L2
	leal	-1(%rax), %edx
	movl	%r14d, %edi
	leal	1(%r14), %ebx
	movl	$404, %r13d
	leaq	2(%rdx), %rax
	andl	$-4, %edi
	movl	%edx, 40(%rsp)
	leaq	408+g(%rip), %r9
	movq	%rax, 120(%rsp)
	movslq	%r14d, %rax
	leal	2(%rdi), %esi
	leaq	-408(%r9), %r8
	salq	$2, %rax
	movl	%edi, 44(%rsp)
	movq	%rax, 24(%rsp)
	movl	%r14d, %eax
	shrl	$2, %eax
	movl	%esi, 72(%rsp)
	subl	$1, %eax
	movl	%ebx, 36(%rsp)
	addq	$1, %rax
	movq	$-404, 104(%rsp)
	salq	$4, %rax
	movq	$4, (%rsp)
	movq	$1, 88(%rsp)
	movq	%rax, %r12
	leal	1(%rdi), %eax
	addl	$3, %edi
	cltq
	movl	%edi, 76(%rsp)
	movq	%rax, 48(%rsp)
	movslq	%esi, %rax
	movq	%rax, 80(%rsp)
	movslq	%edi, %rax
	movq	%rax, 96(%rsp)
	leaq	4(%r8), %rax
	leaq	(%rax,%rdx,4), %rax
	movq	%rax, 112(%rsp)
	.p2align 4,,10
	.p2align 3
.L13:
	movq	(%rsp), %rcx
	movslq	88(%rsp), %rdx
	movl	$408, %esi
	leaq	408+g(%rip), %rax
	movl	$1, %r11d
	leaq	-4(%rcx), %rbx
	leaq	(%r8,%rcx), %rdi
	movq	%rbx, 8(%rsp)
	movq	104(%rsp), %rbx
	leaq	-8(%rbx), %rcx
	movq	%rcx, 16(%rsp)
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rcx
	movq	%rcx, 64(%rsp)
	addq	48(%rsp), %rcx
	movq	%rcx, 56(%rsp)
	.p2align 4,,10
	.p2align 3
.L23:
	movq	24(%rsp), %rbx
	leaq	(%rsi,%rbx), %rcx
	movq	8(%rsp), %rbx
	leaq	(%rbx,%rsi), %rdx
	movq	(%rsp), %rbx
	cmpq	%rdx, %rcx
	leaq	(%rsi,%rbx), %rdx
	setle	%cl
	cmpq	%rsi, %rdx
	setle	%dl
	orb	%cl, %dl
	je	.L22
	movq	16(%rsp), %rbx
	leaq	(%rbx,%rsi), %rdx
	cmpq	$8, %rdx
	seta	%cl
	cmpl	$2, 40(%rsp)
	seta	%dl
	testb	%dl, %cl
	je	.L22
	movd	404(%rdi), %xmm6
	xorl	%edx, %edx
	pshufd	$0, %xmm6, %xmm3
	.p2align 4,,10
	.p2align 3
.L17:
	movdqu	(%r9,%rdx), %xmm2
	movdqu	(%rax,%rdx), %xmm5
	paddd	%xmm3, %xmm2
	movdqa	%xmm5, %xmm1
	movdqa	%xmm2, %xmm0
	pcmpgtd	%xmm5, %xmm0
	pand	%xmm0, %xmm1
	pandn	%xmm2, %xmm0
	por	%xmm1, %xmm0
	movups	%xmm0, (%rax,%rdx)
	addq	$16, %rdx
	cmpq	%rdx, %r12
	jne	.L17
	cmpl	%r14d, 44(%rsp)
	je	.L16
	movslq	%r11d, %rdx
	movq	48(%rsp), %rbx
	leaq	(%rdx,%rdx,4), %rcx
	leaq	(%rcx,%rcx,4), %rcx
	leaq	(%rdx,%rcx,4), %rcx
	movl	404(%rdi), %edx
	leaq	(%rcx,%rbx), %r10
	movq	56(%rsp), %rbx
	addl	(%r8,%rbx,4), %edx
	movl	(%r8,%r10,4), %ebx
	cmpl	%ebx, %edx
	cmovg	%ebx, %edx
	movl	%edx, (%r8,%r10,4)
	cmpl	72(%rsp), %r14d
	jl	.L16
	movq	80(%rsp), %rbx
	movq	64(%rsp), %rbp
	leaq	(%rcx,%rbx), %r10
	movq	%rbp, %rdx
	addq	%rbx, %rdx
	movl	(%r8,%r10,4), %ebx
	movl	(%r8,%rdx,4), %edx
	addl	404(%rdi), %edx
	cmpl	%ebx, %edx
	cmovg	%ebx, %edx
	movl	%edx, (%r8,%r10,4)
	cmpl	76(%rsp), %r14d
	jl	.L16
	movq	96(%rsp), %rbx
	movq	%rbp, %rdx
	addq	%rbx, %rcx
	addq	%rbx, %rdx
	movl	(%r8,%rcx,4), %r10d
	movl	(%r8,%rdx,4), %edx
	addl	404(%rdi), %edx
	cmpl	%r10d, %edx
	cmovg	%r10d, %edx
	movl	%edx, (%r8,%rcx,4)
.L16:
	addl	$1, %r11d
	addq	$404, %rsi
	addq	$404, %rax
	addq	$404, %rdi
	cmpl	36(%rsp), %r11d
	jne	.L23
	addq	$1, 88(%rsp)
	addq	$404, %r13
	movq	88(%rsp), %rax
	addq	$404, %r9
	addq	$4, (%rsp)
	subq	$404, 104(%rsp)
	cmpq	120(%rsp), %rax
	jne	.L13
.L2:
	leaq	p(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	p(%rip), %eax
	testl	%eax, %eax
	jle	.L24
	leaq	g(%rip), %r8
	xorl	%ebx, %ebx
	leaq	144(%rsp), %r12
	movq	%r8, (%rsp)
	leaq	140(%rsp), %rbp
	leaq	148(%rsp), %r14
	leaq	.LC5(%rip), %r13
	leaq	.LC7(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L27:
	movq	%r14, %rcx
	movq	%r12, %rdx
	movq	%r13, %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	140(%rsp), %rax
	movq	(%rsp), %rdi
	movslq	144(%rsp), %rcx
	leaq	(%rax,%rax,4), %rdx
	leaq	(%rdx,%rdx,4), %rdx
	leaq	(%rax,%rdx,4), %rax
	addq	%rcx, %rax
	movl	(%rdi,%rax,4), %eax
	cmpl	148(%rsp), %eax
	jge	.L25
	leal	1(%rax), %edx
	leaq	.LC6(%rip), %rsi
	xorl	%eax, %eax
	addl	$1, %ebx
	movl	$1, %edi
	call	__printf_chk@PLT
	cmpl	%ebx, p(%rip)
	jg	.L27
.L24:
	movq	152(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$168, %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
	.p2align 4,,10
	.p2align 3
.L22:
	.cfi_restore_state
	movq	112(%rsp), %rcx
	movl	$4, %ebx
	subq	%rsi, %rbx
	leaq	(%rcx,%rsi), %rbp
	movq	%rax, %rcx
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	(%rbx,%rcx), %r10
	movl	404(%rdi), %edx
	addl	(%r10,%r13), %edx
	movl	(%rcx), %r10d
	cmpl	%r10d, %edx
	cmovg	%r10d, %edx
	addq	$4, %rcx
	movl	%edx, -4(%rcx)
	cmpq	%rbp, %rcx
	jne	.L15
	jmp	.L16
.L25:
	movq	%r15, %rdi
	addl	$1, %ebx
	call	puts@PLT
	cmpl	%ebx, p(%rip)
	jg	.L27
	jmp	.L24
.L29:
	movl	$1, %eax
	jmp	.L3
.L45:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.local	p
	.comm	p,4,4
	.local	g
	.comm	g,40804,32
	.local	n
	.comm	n,4,4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC2:
	.long	4
	.long	4
	.long	4
	.long	4
	.align 16
.LC3:
	.long	19980725
	.long	19980725
	.long	19980725
	.long	19980725
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define INFTY 19980725
#define N 100

/** ルータの総数 */
static int n;
/** ネットワークの隣接行列 */
static int g[ N + 1 ][ N + 1 ] = { { 0 } };
/** パケットの個数 */
static int p;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j, k;

  /* ルータの個数の読み込みと隣接行列の初期化 */
  scanf ( "%d", &n );
  for ( i = 1; i <= n; ++i )
  for ( j = 1; j <= n; ++j )
  {
    g[ i ][ j ] = ( i == j ? 0 : INFTY );
  }

  /* ネットワーク状態の読み込み */
  for ( i = 0; i < n; ++i )
  {
    int r, k;

    scanf ( "%d%d", &r, &k );
    for ( j = 0; j < k; ++j )
    {
      int t;

      scanf ( "%d", &t );
      g[ r ][ t ] = 1;
    }
  }

  /* ワーシャルフロイド法による最短経路の算出 */
  for ( k = 1; k <= n; ++k )
  for ( i = 1; i <= n; ++i )
  for ( j = 1; j <= n; ++j )
  {
    g[ i ][ j ] = MIN( g[ i ][ j ], g[ i ][ k ] + g[ k ][ j ] );
  }

  /* パケット情報の読み込みと処理 */
  scanf ( "%d", &p );
  for ( i = 0; i < p; ++i )
  {
    int s, d, v;

    scanf ( "%d%d%d", &s, &d, &v );
    if ( g[ s ][ d ] + 1 <= v )
    {
      printf ( "%d\n", g[ s ][ d ] + 1 );
    }
    else
    {
      puts ( "NA" );
    }
  }

  return ( EXIT_SUCCESS );
}
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>
#include <stdlib.h>

#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )
#define INFTY 19980725
#define N 100

/** ルータの総数 */
static int n;
/** ネットワークの隣接行列 */
static int g[ N + 1 ][ N + 1 ] = { { 0 } };
/** パケットの個数 */
static int p;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i, j, k;

  /* ルータの個数の読み込みと隣接行列の初期化 */
  scanf ( "%d", &n );
  for ( i = 1; i <= n; ++i )
  for ( j = 1; j <= n; ++j )
  {
    g[ i ][ j ] = ( i == j ? 0 : INFTY );
  }

  /* ネットワーク状態の読み込み */
  for ( i = 0; i < n; ++i )
  {
    int r, k;

    scanf ( "%d%d", &r, &k );
    for ( j = 0; j < k; ++j )
    {
      int t;

      scanf ( "%d", &t );
      g[ r ][ t ] = 1;
    }
  }

  /* ワーシャルフロイド法による最短経路の算出 */
  for ( k = 1; k <= n; ++k )
  for ( i = 1; i <= n; ++i )
  for ( j = 1; j <= n; ++j )
  {
    g[ i ][ j ] = MIN( g[ i ][ j ], g[ i ][ k ] + g[ k ][ j ] );
  }

  /* パケット情報の読み込みと処理 */
  scanf ( "%d", &p );
  for ( i = 0; i < p; ++i )
  {
    int s, d, v;

    scanf ( "%d%d%d", &s, &d, &v );
    if ( g[ s ][ d ] + 1 <= v )
    {
      printf ( "%d\n", g[ s ][ d ] + 1 );
    }
    else
    {
      puts ( "NA" );
    }
  }

  return ( EXIT_SUCCESS );
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	n
	.comm	n,4,4
	.local	g
	.comm	g,40804,32
	.local	p
	.comm	p,4,4
	.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:
.LFB6:
	.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
	movl	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	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	$1, -20(%rbp)
	jmp	.L2
.L7:
	movl	$1, -16(%rbp)
	jmp	.L3
.L6:
	movl	-20(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jne	.L4
	movl	$0, %ecx
	jmp	.L5
.L4:
	movl	$19980725, %ecx
.L5:
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L6
	addl	$1, -20(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L7
	movl	$0, -20(%rbp)
	jmp	.L8
.L11:
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L9
.L10:
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movl	-24(%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	g(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L9:
	movl	-28(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	addl	$1, -20(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	movl	$1, -12(%rbp)
	jmp	.L12
.L17:
	movl	$1, -20(%rbp)
	jmp	.L13
.L16:
	movl	$1, -16(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %r8
	addq	%r8, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L14:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L15
	addl	$1, -20(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L16
	addl	$1, -12(%rbp)
.L12:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L17
	leaq	p(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L21:
	leaq	-24(%rbp), %rcx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L19
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L19:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L20:
	addl	$1, -20(%rbp)
.L18:
	movl	p(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.local	n
	.comm	n,4,4
	.local	g
	.comm	g,40804,32
	.local	p
	.comm	p,4,4
	.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:
.LFB6:
	.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
	movl	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	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	$1, -20(%rbp)
	jmp	.L2
.L7:
	movl	$1, -16(%rbp)
	jmp	.L3
.L6:
	movl	-20(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jne	.L4
	movl	$0, %ecx
	jmp	.L5
.L4:
	movl	$19980725, %ecx
.L5:
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L3:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L6
	addl	$1, -20(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L7
	movl	$0, -20(%rbp)
	jmp	.L8
.L11:
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L9
.L10:
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movl	-24(%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	g(%rip), %rax
	movl	$1, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L9:
	movl	-28(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L10
	addl	$1, -20(%rbp)
.L8:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L11
	movl	$1, -12(%rbp)
	jmp	.L12
.L17:
	movl	$1, -20(%rbp)
	jmp	.L13
.L16:
	movl	$1, -16(%rbp)
	jmp	.L14
.L15:
	movl	-16(%rbp), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-12(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-16(%rbp), %eax
	movslq	%eax, %rdi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %r8
	addq	%r8, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%esi, %eax
	cmpl	%eax, %ecx
	cmovg	%eax, %ecx
	movl	-16(%rbp), %eax
	movslq	%eax, %rsi
	movl	-20(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdi
	addq	%rdi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L14:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L15
	addl	$1, -20(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L16
	addl	$1, -12(%rbp)
.L12:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jle	.L17
	leaq	p(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L21:
	leaq	-24(%rbp), %rcx
	leaq	-28(%rbp), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jge	.L19
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rsi
	addq	%rsi, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	g(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L19:
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L20:
	addl	$1, -20(%rbp)
.L18:
	movl	p(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
