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>
#include <string.h>

/* constant */

#define MAX_N   (100)

/* global variables */

static int nbrs[MAX_N][MAX_N];
static int nnbr[MAX_N];

static char visited[MAX_N];

/* subroutines */

int max_chain(int r0) {
  int cl, i, max_cl, r1;

  max_cl = 1;

  for (i = 0; i < nnbr[r0]; i++) {
    r1 = nbrs[r0][i];

    if (! visited[r1]) {
      visited[r1] = 1;
      cl = 1 + max_chain(r1);
      visited[r1] = 0;

      if (max_cl < cl) max_cl = cl;
    }
  }

  return max_cl;
}

/* main */

int main(int argc, char **argv) {
  int a, b, cl, i, j, max_cl, n, st;

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    memset(nnbr, 0, sizeof(int) * MAX_N);

    for (i = 0; i < n; i++) {
      scanf("%d %d", &a, &b);
      a--;
      b--;

      nbrs[a][nnbr[a]++] = b;
      nbrs[b][nnbr[b]++] = a;
    }

    max_cl = 0;

    for (st = 0; st < MAX_N; st++) {
      if (nnbr[st] > 0) {
        memset(visited, 0, sizeof(char) * MAX_N);
        visited[st] = 1;
        cl = max_chain(st);
        if (max_cl < cl) max_cl = cl;
      }
    }

    printf("%d\n", max_cl);
  }

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	nbrs
	.comm	nbrs,40000,32
	.local	nnbr
	.comm	nnbr,400,32
	.local	visited
	.comm	visited,100,32
	.globl	max_chain
	.type	max_chain, @function
max_chain:
.LFB6:
	.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	$1, -12(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L2
.L4:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	nbrs(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	jne	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	max_chain
	addl	$1, %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-12(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jge	.L3
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
.L3:
	addl	$1, -16(%rbp)
.L2:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	nnbr(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L4
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	max_chain, .-max_chain
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%rsi, -64(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L14:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L18
	movl	$400, %edx
	movl	$0, %esi
	leaq	nnbr(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -24(%rbp)
	jmp	.L9
.L10:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-36(%rbp), %esi
	movl	-36(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nnbr(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rdi
	leaq	nnbr(%rip), %rdx
	movl	%ecx, (%rdi,%rdx)
	movl	-32(%rbp), %edx
	movslq	%eax, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nbrs(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	-32(%rbp), %esi
	movl	-32(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nnbr(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rdi
	leaq	nnbr(%rip), %rdx
	movl	%ecx, (%rdi,%rdx)
	movl	-36(%rbp), %edx
	movslq	%eax, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nbrs(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -24(%rbp)
.L9:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L10
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L11
.L13:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	nnbr(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jle	.L12
	movl	$100, %edx
	movl	$0, %esi
	leaq	visited(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-16(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	max_chain
	movl	%eax, -12(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jge	.L12
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L12:
	addl	$1, -16(%rbp)
.L11:
	cmpl	$99, -16(%rbp)
	jle	.L13
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max_chain
	.type	max_chain, @function
max_chain:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rsi
	leaq	nnbr(%rip), %r9
	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
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movl	(%r9,%rsi,4), %eax
	movq	%rsi, 176(%rsp)
	movl	$1, 184(%rsp)
	testl	%eax, %eax
	jle	.L1
	leaq	(%rsi,%rsi,4), %rdx
	leaq	nbrs(%rip), %rdi
	movq	$0, 32(%rsp)
	leaq	(%rdx,%rdx,4), %rdx
	leaq	visited(%rip), %r11
	salq	$4, %rdx
	leaq	(%rdi,%rdx), %rsi
	movq	%rsi, 152(%rsp)
.L30:
	movq	152(%rsp), %rcx
	movq	32(%rsp), %rbx
	movslq	(%rcx,%rbx,4), %rsi
	cmpb	$0, (%r11,%rsi)
	movq	%rsi, 88(%rsp)
	je	.L50
.L3:
	addq	$1, 32(%rsp)
	movq	32(%rsp), %rcx
	cmpl	%ecx, %eax
	jg	.L30
.L1:
	movl	184(%rsp), %eax
	addq	$232, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L50:
	.cfi_restore_state
	movl	(%r9,%rsi,4), %edx
	movb	$1, (%r11,%rsi)
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L4
	leaq	(%rsi,%rsi,4), %rax
	leaq	nbrs(%rip), %rcx
	movq	$0, 24(%rsp)
	movl	$1, 148(%rsp)
	leaq	(%rax,%rax,4), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, 136(%rsp)
.L29:
	movq	136(%rsp), %rax
	movq	24(%rsp), %rcx
	movslq	(%rax,%rcx,4), %rax
	cmpb	$0, (%r11,%rax)
	movq	%rax, 72(%rsp)
	je	.L51
.L5:
	addq	$1, 24(%rsp)
	movq	24(%rsp), %rax
	cmpl	%eax, %edx
	jg	.L29
	movl	148(%rsp), %eax
	addl	$1, %eax
.L4:
	movq	88(%rsp), %rdi
	movb	$0, (%r11,%rdi)
	movl	184(%rsp), %edi
	cmpl	%eax, %edi
	cmovge	%edi, %eax
	movl	%eax, 184(%rsp)
	movq	176(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L51:
	movl	(%r9,%rax,4), %edx
	movb	$1, (%r11,%rax)
	movq	%rax, %rsi
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L6
	leaq	(%rsi,%rsi,4), %rax
	leaq	nbrs(%rip), %rbx
	movq	$0, 16(%rsp)
	movl	$1, 144(%rsp)
	leaq	(%rax,%rax,4), %rax
	salq	$4, %rax
	addq	%rbx, %rax
	movq	%rax, 128(%rsp)
.L28:
	movq	128(%rsp), %rax
	movq	16(%rsp), %rbx
	movslq	(%rax,%rbx,4), %rax
	cmpb	$0, (%r11,%rax)
	movq	%rax, 48(%rsp)
	je	.L52
.L7:
	addq	$1, 16(%rsp)
	movq	16(%rsp), %rax
	cmpl	%eax, %edx
	jg	.L28
	movl	144(%rsp), %eax
	addl	$1, %eax
.L6:
	movl	148(%rsp), %edi
	movq	72(%rsp), %rbx
	cmpl	%eax, %edi
	movb	$0, (%r11,%rbx)
	cmovge	%edi, %eax
	movl	%eax, 148(%rsp)
	movq	88(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L52:
	movl	(%r9,%rax,4), %edx
	movb	$1, (%r11,%rax)
	movq	%rax, %rdi
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L8
	leaq	(%rdi,%rdi,4), %rax
	leaq	nbrs(%rip), %rcx
	movq	$0, 8(%rsp)
	leaq	(%rax,%rax,4), %rax
	movl	$1, 116(%rsp)
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, 104(%rsp)
.L27:
	movq	104(%rsp), %rax
	movq	8(%rsp), %rdi
	movslq	(%rax,%rdi,4), %rax
	cmpb	$0, (%r11,%rax)
	movq	%rax, 40(%rsp)
	je	.L53
.L9:
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rax
	cmpl	%eax, %edx
	jg	.L27
	movl	116(%rsp), %eax
	addl	$1, %eax
.L8:
	movl	144(%rsp), %ecx
	movq	48(%rsp), %rbx
	cmpl	%eax, %ecx
	movb	$0, (%r11,%rbx)
	cmovge	%ecx, %eax
	movl	%eax, 144(%rsp)
	movq	72(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L53:
	movl	(%r9,%rax,4), %edx
	movb	$1, (%r11,%rax)
	movq	%rax, %rcx
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L10
	leaq	(%rcx,%rcx,4), %rax
	leaq	nbrs(%rip), %rcx
	movl	$1, 112(%rsp)
	xorl	%esi, %esi
	leaq	(%rax,%rax,4), %rax
	movq	%rsi, %r8
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, 80(%rsp)
.L26:
	movq	80(%rsp), %rax
	movslq	(%rax,%r8,4), %r10
	cmpb	$0, (%r11,%r10)
	je	.L54
.L11:
	addq	$1, %r8
	cmpl	%r8d, %edx
	jg	.L26
	movl	112(%rsp), %eax
	addl	$1, %eax
.L10:
	movl	116(%rsp), %esi
	movq	40(%rsp), %rbx
	cmpl	%eax, %esi
	movb	$0, (%r11,%rbx)
	cmovge	%esi, %eax
	movl	%eax, 116(%rsp)
	movq	48(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L54:
	movl	(%r9,%r10,4), %edx
	movb	$1, (%r11,%r10)
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L12
	leaq	(%r10,%r10,4), %rax
	leaq	nbrs(%rip), %rcx
	movl	$1, 68(%rsp)
	leaq	(%rax,%rax,4), %rax
	movq	%r8, 168(%rsp)
	salq	$4, %rax
	movq	%r10, 120(%rsp)
	addq	%rcx, %rax
	xorl	%ecx, %ecx
	movq	%rax, 56(%rsp)
	movq	%rcx, %r10
.L25:
	movq	56(%rsp), %rax
	movslq	(%rax,%r10,4), %r15
	cmpb	$0, (%r11,%r15)
	je	.L55
.L13:
	addq	$1, %r10
	cmpl	%r10d, %edx
	jg	.L25
	movl	68(%rsp), %eax
	movq	168(%rsp), %r8
	movq	120(%rsp), %r10
	addl	$1, %eax
.L12:
	movl	112(%rsp), %ebx
	movb	$0, (%r11,%r10)
	cmpl	%eax, %ebx
	cmovge	%ebx, %eax
	movl	%eax, 112(%rsp)
	movq	40(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L55:
	movl	(%r9,%r15,4), %edx
	movb	$1, (%r11,%r15)
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L14
	leaq	(%r15,%r15,4), %rax
	leaq	nbrs(%rip), %rcx
	xorl	%r12d, %r12d
	movl	$1, 64(%rsp)
	leaq	(%rax,%rax,4), %rax
	movq	%r15, 96(%rsp)
	salq	$4, %rax
	movq	%r10, 160(%rsp)
	addq	%rcx, %rax
	movq	%rax, %r10
.L24:
	movslq	(%r10,%r12,4), %r14
	cmpb	$0, (%r11,%r14)
	je	.L56
.L15:
	addq	$1, %r12
	cmpl	%r12d, %edx
	jg	.L24
	movl	64(%rsp), %eax
	movq	160(%rsp), %r10
	movq	96(%rsp), %r15
	addl	$1, %eax
.L14:
	movl	68(%rsp), %edi
	movb	$0, (%r11,%r15)
	cmpl	%eax, %edi
	cmovge	%edi, %eax
	movl	%eax, 68(%rsp)
	movq	120(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L56:
	movl	(%r9,%r14,4), %eax
	movb	$1, (%r11,%r14)
	movl	$2, %edx
	testl	%eax, %eax
	jle	.L16
	leaq	(%r14,%r14,4), %rdx
	leaq	nbrs(%rip), %rdi
	xorl	%ebp, %ebp
	movq	%r12, %r8
	leaq	(%rdx,%rdx,4), %rsi
	movq	%r14, %rcx
	movl	$1, %edx
	salq	$4, %rsi
	addq	%rdi, %rsi
.L23:
	movslq	(%rsi,%rbp,4), %r13
	cmpb	$0, (%r11,%r13)
	je	.L57
.L17:
	addq	$1, %rbp
	cmpl	%ebp, %eax
	jg	.L23
	movq	%r8, %r12
	movq	%rcx, %r14
	addl	$1, %edx
.L16:
	movl	64(%rsp), %eax
	movb	$0, (%r11,%r14)
	cmpl	%edx, %eax
	cmovge	%eax, %edx
	movq	96(%rsp), %rax
	movl	%edx, 64(%rsp)
	movl	(%r9,%rax,4), %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L57:
	movl	(%r9,%r13,4), %eax
	movb	$1, (%r11,%r13)
	movl	$2, %r14d
	testl	%eax, %eax
	jle	.L18
	leaq	0(%r13,%r13,4), %rdi
	leaq	nbrs(%rip), %rbx
	movl	$1, %r14d
	leaq	(%rdi,%rdi,4), %r12
	salq	$4, %r12
	addq	%rbx, %r12
	xorl	%ebx, %ebx
.L22:
	movslq	(%r12,%rbx,4), %r15
	cmpb	$0, (%r11,%r15)
	movq	%r15, %rdi
	je	.L58
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jg	.L22
.L21:
	addl	$1, %r14d
.L18:
	cmpl	%r14d, %edx
	movb	$0, (%r11,%r13)
	movl	(%r9,%rcx,4), %eax
	cmovl	%r14d, %edx
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L58:
	movq	%rcx, 216(%rsp)
	movq	%rsi, 208(%rsp)
	movq	%r8, 200(%rsp)
	movq	%r10, 192(%rsp)
	movl	%edx, 188(%rsp)
	movb	$1, (%r11,%r15)
	call	max_chain
	leaq	nnbr(%rip), %r9
	leaq	visited(%rip), %r11
	movl	188(%rsp), %edx
	addl	$1, %eax
	movb	$0, (%r11,%r15)
	movq	192(%rsp), %r10
	cmpl	%eax, %r14d
	movq	200(%rsp), %r8
	movq	208(%rsp), %rsi
	cmovl	%eax, %r14d
	movl	(%r9,%r13,4), %eax
	addq	$1, %rbx
	movq	216(%rsp), %rcx
	cmpl	%ebx, %eax
	jg	.L22
	jmp	.L21
	.cfi_endproc
.LFE51:
	.size	max_chain, .-max_chain
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.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
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 8(%rsp)
.L70:
	movq	8(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	je	.L60
	movl	$50, %ecx
	leaq	nnbr(%rip), %rdi
	movl	$0, %eax
	rep stosq
	jle	.L72
	xorl	%r12d, %r12d
	leaq	32(%rsp), %rbp
	leaq	28(%rsp), %rbx
	leaq	nbrs(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L62:
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	leaq	nnbr(%rip), %r9
	addl	$1, %r12d
	leal	-1(%rax), %edx
	movl	32(%rsp), %eax
	movslq	%edx, %rsi
	movl	%edx, 28(%rsp)
	movslq	(%r9,%rsi,4), %rcx
	subl	$1, %eax
	movl	%eax, 32(%rsp)
	leal	1(%rcx), %edi
	movl	%edi, (%r9,%rsi,4)
	leaq	(%rsi,%rsi,4), %rsi
	leaq	(%rsi,%rsi,4), %rsi
	leaq	(%rcx,%rsi,4), %rcx
	movl	%eax, 0(%r13,%rcx,4)
	cltq
	movslq	(%r9,%rax,4), %rcx
	leal	1(%rcx), %esi
	movl	%esi, (%r9,%rax,4)
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rcx,%rax,4), %rax
	movl	%edx, 0(%r13,%rax,4)
	cmpl	%r12d, 36(%rsp)
	jg	.L62
	movl	(%r9), %edx
.L61:
	leaq	visited(%rip), %rsi
	leaq	nnbr(%rip), %rbp
	xorl	%r8d, %r8d
	leaq	nbrs(%rip), %r15
	movq	%rsi, %r14
	jmp	.L69
	.p2align 4,,10
	.p2align 3
.L63:
	addq	$4, %rbp
	leaq	400+nnbr(%rip), %rax
	addq	$400, %r15
	addq	$1, %r14
	cmpq	%rax, %rbp
	je	.L68
	movl	0(%rbp), %edx
.L69:
	testl	%edx, %edx
	jle	.L63
	movl	$12, %ecx
	movq	%rsi, %rdi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	rep stosq
	movl	$1, %r13d
	movl	$0, (%rdi)
	movb	$1, (%r14)
.L67:
	movslq	(%r15,%rbx,4), %r12
	cmpb	$0, (%rsi,%r12)
	movq	%r12, %rdi
	je	.L75
	addq	$1, %rbx
	cmpl	%ebx, %edx
	jg	.L67
	cmpl	%r13d, %r8d
	cmovl	%r13d, %r8d
	jmp	.L63
	.p2align 4,,10
	.p2align 3
.L75:
	movb	$1, (%rsi,%r12)
	movl	%r8d, 4(%rsp)
	call	max_chain
	movl	0(%rbp), %edx
	movl	4(%rsp), %r8d
	leaq	visited(%rip), %rsi
	addl	$1, %eax
	movb	$0, (%rsi,%r12)
	cmpl	%eax, %r13d
	cmovl	%eax, %r13d
	addq	$1, %rbx
	cmpl	%ebx, %edx
	jg	.L67
	cmpl	%r13d, %r8d
	cmovl	%r13d, %r8d
	jmp	.L63
.L68:
	movl	%r8d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L70
.L60:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L72:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L61
.L76:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.size	main, .-main
	.local	visited
	.comm	visited,100,32
	.local	nnbr
	.comm	nnbr,400,32
	.local	nbrs
	.comm	nbrs,40000,32
	.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	max_chain
	.type	max_chain, @function
max_chain:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%edi, %rsi
	leaq	nnbr(%rip), %r9
	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
	subq	$232, %rsp
	.cfi_def_cfa_offset 288
	movl	(%r9,%rsi,4), %eax
	movq	%rsi, 176(%rsp)
	movl	$1, 184(%rsp)
	testl	%eax, %eax
	jle	.L1
	leaq	(%rsi,%rsi,4), %rdx
	leaq	nbrs(%rip), %rdi
	movq	$0, 32(%rsp)
	leaq	(%rdx,%rdx,4), %rdx
	leaq	visited(%rip), %r11
	salq	$4, %rdx
	leaq	(%rdi,%rdx), %rsi
	movq	%rsi, 152(%rsp)
.L30:
	movq	152(%rsp), %rcx
	movq	32(%rsp), %rbx
	movslq	(%rcx,%rbx,4), %rsi
	cmpb	$0, (%r11,%rsi)
	movq	%rsi, 88(%rsp)
	je	.L50
.L3:
	addq	$1, 32(%rsp)
	movq	32(%rsp), %rcx
	cmpl	%ecx, %eax
	jg	.L30
.L1:
	movl	184(%rsp), %eax
	addq	$232, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L50:
	.cfi_restore_state
	movl	(%r9,%rsi,4), %edx
	movb	$1, (%r11,%rsi)
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L4
	leaq	(%rsi,%rsi,4), %rax
	leaq	nbrs(%rip), %rcx
	movq	$0, 24(%rsp)
	movl	$1, 148(%rsp)
	leaq	(%rax,%rax,4), %rax
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, 136(%rsp)
.L29:
	movq	136(%rsp), %rax
	movq	24(%rsp), %rcx
	movslq	(%rax,%rcx,4), %rax
	cmpb	$0, (%r11,%rax)
	movq	%rax, 72(%rsp)
	je	.L51
.L5:
	addq	$1, 24(%rsp)
	movq	24(%rsp), %rax
	cmpl	%eax, %edx
	jg	.L29
	movl	148(%rsp), %eax
	addl	$1, %eax
.L4:
	movq	88(%rsp), %rdi
	movb	$0, (%r11,%rdi)
	movl	184(%rsp), %edi
	cmpl	%eax, %edi
	cmovge	%edi, %eax
	movl	%eax, 184(%rsp)
	movq	176(%rsp), %rax
	movl	(%r9,%rax,4), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L51:
	movl	(%r9,%rax,4), %edx
	movb	$1, (%r11,%rax)
	movq	%rax, %rsi
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L6
	leaq	(%rsi,%rsi,4), %rax
	leaq	nbrs(%rip), %rbx
	movq	$0, 16(%rsp)
	movl	$1, 144(%rsp)
	leaq	(%rax,%rax,4), %rax
	salq	$4, %rax
	addq	%rbx, %rax
	movq	%rax, 128(%rsp)
.L28:
	movq	128(%rsp), %rax
	movq	16(%rsp), %rbx
	movslq	(%rax,%rbx,4), %rax
	cmpb	$0, (%r11,%rax)
	movq	%rax, 48(%rsp)
	je	.L52
.L7:
	addq	$1, 16(%rsp)
	movq	16(%rsp), %rax
	cmpl	%eax, %edx
	jg	.L28
	movl	144(%rsp), %eax
	addl	$1, %eax
.L6:
	movl	148(%rsp), %edi
	movq	72(%rsp), %rbx
	cmpl	%eax, %edi
	movb	$0, (%r11,%rbx)
	cmovge	%edi, %eax
	movl	%eax, 148(%rsp)
	movq	88(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L52:
	movl	(%r9,%rax,4), %edx
	movb	$1, (%r11,%rax)
	movq	%rax, %rdi
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L8
	leaq	(%rdi,%rdi,4), %rax
	leaq	nbrs(%rip), %rcx
	movq	$0, 8(%rsp)
	leaq	(%rax,%rax,4), %rax
	movl	$1, 116(%rsp)
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, 104(%rsp)
.L27:
	movq	104(%rsp), %rax
	movq	8(%rsp), %rdi
	movslq	(%rax,%rdi,4), %rax
	cmpb	$0, (%r11,%rax)
	movq	%rax, 40(%rsp)
	je	.L53
.L9:
	addq	$1, 8(%rsp)
	movq	8(%rsp), %rax
	cmpl	%eax, %edx
	jg	.L27
	movl	116(%rsp), %eax
	addl	$1, %eax
.L8:
	movl	144(%rsp), %ecx
	movq	48(%rsp), %rbx
	cmpl	%eax, %ecx
	movb	$0, (%r11,%rbx)
	cmovge	%ecx, %eax
	movl	%eax, 144(%rsp)
	movq	72(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L53:
	movl	(%r9,%rax,4), %edx
	movb	$1, (%r11,%rax)
	movq	%rax, %rcx
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L10
	leaq	(%rcx,%rcx,4), %rax
	leaq	nbrs(%rip), %rcx
	movl	$1, 112(%rsp)
	xorl	%esi, %esi
	leaq	(%rax,%rax,4), %rax
	movq	%rsi, %r8
	salq	$4, %rax
	addq	%rcx, %rax
	movq	%rax, 80(%rsp)
.L26:
	movq	80(%rsp), %rax
	movslq	(%rax,%r8,4), %r10
	cmpb	$0, (%r11,%r10)
	je	.L54
.L11:
	addq	$1, %r8
	cmpl	%r8d, %edx
	jg	.L26
	movl	112(%rsp), %eax
	addl	$1, %eax
.L10:
	movl	116(%rsp), %esi
	movq	40(%rsp), %rbx
	cmpl	%eax, %esi
	movb	$0, (%r11,%rbx)
	cmovge	%esi, %eax
	movl	%eax, 116(%rsp)
	movq	48(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L54:
	movl	(%r9,%r10,4), %edx
	movb	$1, (%r11,%r10)
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L12
	leaq	(%r10,%r10,4), %rax
	leaq	nbrs(%rip), %rcx
	movl	$1, 68(%rsp)
	leaq	(%rax,%rax,4), %rax
	movq	%r8, 168(%rsp)
	salq	$4, %rax
	movq	%r10, 120(%rsp)
	addq	%rcx, %rax
	xorl	%ecx, %ecx
	movq	%rax, 56(%rsp)
	movq	%rcx, %r10
.L25:
	movq	56(%rsp), %rax
	movslq	(%rax,%r10,4), %r15
	cmpb	$0, (%r11,%r15)
	je	.L55
.L13:
	addq	$1, %r10
	cmpl	%r10d, %edx
	jg	.L25
	movl	68(%rsp), %eax
	movq	168(%rsp), %r8
	movq	120(%rsp), %r10
	addl	$1, %eax
.L12:
	movl	112(%rsp), %ebx
	movb	$0, (%r11,%r10)
	cmpl	%eax, %ebx
	cmovge	%ebx, %eax
	movl	%eax, 112(%rsp)
	movq	40(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L55:
	movl	(%r9,%r15,4), %edx
	movb	$1, (%r11,%r15)
	movl	$2, %eax
	testl	%edx, %edx
	jle	.L14
	leaq	(%r15,%r15,4), %rax
	leaq	nbrs(%rip), %rcx
	xorl	%r12d, %r12d
	movl	$1, 64(%rsp)
	leaq	(%rax,%rax,4), %rax
	movq	%r15, 96(%rsp)
	salq	$4, %rax
	movq	%r10, 160(%rsp)
	addq	%rcx, %rax
	movq	%rax, %r10
.L24:
	movslq	(%r10,%r12,4), %r14
	cmpb	$0, (%r11,%r14)
	je	.L56
.L15:
	addq	$1, %r12
	cmpl	%r12d, %edx
	jg	.L24
	movl	64(%rsp), %eax
	movq	160(%rsp), %r10
	movq	96(%rsp), %r15
	addl	$1, %eax
.L14:
	movl	68(%rsp), %edi
	movb	$0, (%r11,%r15)
	cmpl	%eax, %edi
	cmovge	%edi, %eax
	movl	%eax, 68(%rsp)
	movq	120(%rsp), %rax
	movl	(%r9,%rax,4), %edx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L56:
	movl	(%r9,%r14,4), %eax
	movb	$1, (%r11,%r14)
	movl	$2, %edx
	testl	%eax, %eax
	jle	.L16
	leaq	(%r14,%r14,4), %rdx
	leaq	nbrs(%rip), %rdi
	xorl	%ebp, %ebp
	movq	%r12, %r8
	leaq	(%rdx,%rdx,4), %rsi
	movq	%r14, %rcx
	movl	$1, %edx
	salq	$4, %rsi
	addq	%rdi, %rsi
.L23:
	movslq	(%rsi,%rbp,4), %r13
	cmpb	$0, (%r11,%r13)
	je	.L57
.L17:
	addq	$1, %rbp
	cmpl	%ebp, %eax
	jg	.L23
	movq	%r8, %r12
	movq	%rcx, %r14
	addl	$1, %edx
.L16:
	movl	64(%rsp), %eax
	movb	$0, (%r11,%r14)
	cmpl	%edx, %eax
	cmovge	%eax, %edx
	movq	96(%rsp), %rax
	movl	%edx, 64(%rsp)
	movl	(%r9,%rax,4), %edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L57:
	movl	(%r9,%r13,4), %eax
	movb	$1, (%r11,%r13)
	movl	$2, %r14d
	testl	%eax, %eax
	jle	.L18
	leaq	0(%r13,%r13,4), %rdi
	leaq	nbrs(%rip), %rbx
	movl	$1, %r14d
	leaq	(%rdi,%rdi,4), %r12
	salq	$4, %r12
	addq	%rbx, %r12
	xorl	%ebx, %ebx
.L22:
	movslq	(%r12,%rbx,4), %r15
	cmpb	$0, (%r11,%r15)
	movq	%r15, %rdi
	je	.L58
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jg	.L22
.L21:
	addl	$1, %r14d
.L18:
	cmpl	%r14d, %edx
	movb	$0, (%r11,%r13)
	movl	(%r9,%rcx,4), %eax
	cmovl	%r14d, %edx
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L58:
	movq	%rcx, 216(%rsp)
	movq	%rsi, 208(%rsp)
	movq	%r8, 200(%rsp)
	movq	%r10, 192(%rsp)
	movl	%edx, 188(%rsp)
	movb	$1, (%r11,%r15)
	call	max_chain
	leaq	nnbr(%rip), %r9
	leaq	visited(%rip), %r11
	movl	188(%rsp), %edx
	addl	$1, %eax
	movb	$0, (%r11,%r15)
	movq	192(%rsp), %r10
	cmpl	%eax, %r14d
	movq	200(%rsp), %r8
	movq	208(%rsp), %rsi
	cmovl	%eax, %r14d
	movl	(%r9,%r13,4), %eax
	addq	$1, %rbx
	movq	216(%rsp), %rcx
	cmpl	%ebx, %eax
	jg	.L22
	jmp	.L21
	.cfi_endproc
.LFE51:
	.size	max_chain, .-max_chain
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.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
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 8(%rsp)
.L70:
	movq	8(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	je	.L60
	movl	$50, %ecx
	leaq	nnbr(%rip), %rdi
	movl	$0, %eax
	rep stosq
	jle	.L72
	xorl	%r12d, %r12d
	leaq	32(%rsp), %rbp
	leaq	28(%rsp), %rbx
	leaq	nbrs(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L62:
	movq	%rbp, %rdx
	movq	%rbx, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	leaq	nnbr(%rip), %r9
	addl	$1, %r12d
	leal	-1(%rax), %edx
	movl	32(%rsp), %eax
	movslq	%edx, %rsi
	movl	%edx, 28(%rsp)
	movslq	(%r9,%rsi,4), %rcx
	subl	$1, %eax
	movl	%eax, 32(%rsp)
	leal	1(%rcx), %edi
	movl	%edi, (%r9,%rsi,4)
	leaq	(%rsi,%rsi,4), %rsi
	leaq	(%rsi,%rsi,4), %rsi
	leaq	(%rcx,%rsi,4), %rcx
	movl	%eax, 0(%r13,%rcx,4)
	cltq
	movslq	(%r9,%rax,4), %rcx
	leal	1(%rcx), %esi
	movl	%esi, (%r9,%rax,4)
	leaq	(%rax,%rax,4), %rax
	leaq	(%rax,%rax,4), %rax
	leaq	(%rcx,%rax,4), %rax
	movl	%edx, 0(%r13,%rax,4)
	cmpl	%r12d, 36(%rsp)
	jg	.L62
	movl	(%r9), %edx
.L61:
	leaq	visited(%rip), %rsi
	leaq	nnbr(%rip), %rbp
	xorl	%r8d, %r8d
	leaq	nbrs(%rip), %r15
	movq	%rsi, %r14
	jmp	.L69
	.p2align 4,,10
	.p2align 3
.L63:
	addq	$4, %rbp
	leaq	400+nnbr(%rip), %rax
	addq	$400, %r15
	addq	$1, %r14
	cmpq	%rax, %rbp
	je	.L68
	movl	0(%rbp), %edx
.L69:
	testl	%edx, %edx
	jle	.L63
	movl	$12, %ecx
	movq	%rsi, %rdi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	rep stosq
	movl	$1, %r13d
	movl	$0, (%rdi)
	movb	$1, (%r14)
.L67:
	movslq	(%r15,%rbx,4), %r12
	cmpb	$0, (%rsi,%r12)
	movq	%r12, %rdi
	je	.L75
	addq	$1, %rbx
	cmpl	%ebx, %edx
	jg	.L67
	cmpl	%r13d, %r8d
	cmovl	%r13d, %r8d
	jmp	.L63
	.p2align 4,,10
	.p2align 3
.L75:
	movb	$1, (%rsi,%r12)
	movl	%r8d, 4(%rsp)
	call	max_chain
	movl	0(%rbp), %edx
	movl	4(%rsp), %r8d
	leaq	visited(%rip), %rsi
	addl	$1, %eax
	movb	$0, (%rsi,%r12)
	cmpl	%eax, %r13d
	cmovl	%eax, %r13d
	addq	$1, %rbx
	cmpl	%ebx, %edx
	jg	.L67
	cmpl	%r13d, %r8d
	cmovl	%r13d, %r8d
	jmp	.L63
.L68:
	movl	%r8d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L70
.L60:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L76
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L72:
	.cfi_restore_state
	xorl	%edx, %edx
	jmp	.L61
.L76:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.size	main, .-main
	.local	visited
	.comm	visited,100,32
	.local	nnbr
	.comm	nnbr,400,32
	.local	nbrs
	.comm	nbrs,40000,32
	.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>
#include <string.h>

/* constant */

#define MAX_N   (100)

/* global variables */

static int nbrs[MAX_N][MAX_N];
static int nnbr[MAX_N];

static char visited[MAX_N];

/* subroutines */

int max_chain(int r0) {
  int cl, i, max_cl, r1;

  max_cl = 1;

  for (i = 0; i < nnbr[r0]; i++) {
    r1 = nbrs[r0][i];

    if (! visited[r1]) {
      visited[r1] = 1;
      cl = 1 + max_chain(r1);
      visited[r1] = 0;

      if (max_cl < cl) max_cl = cl;
    }
  }

  return max_cl;
}

/* main */

int main(int argc, char **argv) {
  int a, b, cl, i, j, max_cl, n, st;

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    memset(nnbr, 0, sizeof(int) * MAX_N);

    for (i = 0; i < n; i++) {
      scanf("%d %d", &a, &b);
      a--;
      b--;

      nbrs[a][nnbr[a]++] = b;
      nbrs[b][nnbr[b]++] = a;
    }

    max_cl = 0;

    for (st = 0; st < MAX_N; st++) {
      if (nnbr[st] > 0) {
        memset(visited, 0, sizeof(char) * MAX_N);
        visited[st] = 1;
        cl = max_chain(st);
        if (max_cl < cl) max_cl = cl;
      }
    }

    printf("%d\n", max_cl);
  }

  return 0;
}
7
1 3
3 4
1 4
2 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 4
1 5
2 6
7
1 3
2 4
3 5
4 6
6 7
2 6
4 7
0
 7
1 3
3 4
1 4
2 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 6
1 5
2 6
7
1 3
2 4
3 5
4 6
6 7
2 6
4 7
0
 7
1 3
3 4
1 4
1 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 6
1 5
2 6
7
1 3
2 4
3 5
4 6
5 7
2 6
4 7
0
 7
2 3
3 4
1 4
2 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 4
1 5
2 6
7
1 3
2 4
3 5
4 6
6 7
2 6
4 7
0
 7
1 3
3 4
1 2
2 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 6
1 5
2 6
7
1 3
2 4
3 5
4 6
6 7
2 6
4 7
0
 7
1 3
3 4
1 4
1 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 6
1 5
2 6
7
1 3
2 4
3 3
4 6
5 7
2 6
4 7
0
 7
2 3
3 4
1 4
2 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 4
1 5
2 6
7
1 3
2 4
6 5
4 6
6 7
2 6
4 7
0
 7
1 3
3 4
1 4
2 7
5 7
6 7
1 7
6
1 2
2 2
3 4
4 5
1 10
2 6
7
1 3
2 4
5 5
4 6
6 7
2 6
4 7
0
 7
1 3
3 4
1 4
1 7
5 7
6 7
1 7
6
1 2
2 3
3 4
4 6
1 5
2 6
7
1 3
2 4
3 5
4 3
6 7
2 6
4 7
0
 7
1 3
3 4
1 4
2 7
5 7
6 7
2 7
6
1 2
2 2
3 4
4 5
1 5
2 6
7
1 3
2 4
3 5
4 6
6 7
2 6
4 7
0

5
5
4
 5
6
4
 5
6
7
 6
5
4
 6
6
4
 5
6
5
 6
5
5
 5
4
4
 5
6
6
 3
6
4

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>
#include <string.h>

/* constant */

#define MAX_N   (100)

/* global variables */

static int nbrs[MAX_N][MAX_N];
static int nnbr[MAX_N];

static char visited[MAX_N];

/* subroutines */

int max_chain(int r0) {
  int cl, i, max_cl, r1;

  max_cl = 1;

  for (i = 0; i < nnbr[r0]; i++) {
    r1 = nbrs[r0][i];

    if (! visited[r1]) {
      visited[r1] = 1;
      cl = 1 + max_chain(r1);
      visited[r1] = 0;

      if (max_cl < cl) max_cl = cl;
    }
  }

  return max_cl;
}

/* main */

int main(int argc, char **argv) {
  int a, b, cl, i, j, max_cl, n, st;

  for (;;) {
    scanf("%d", &n);
    if (n == 0) break;

    memset(nnbr, 0, sizeof(int) * MAX_N);

    for (i = 0; i < n; i++) {
      scanf("%d %d", &a, &b);
      a--;
      b--;

      nbrs[a][nnbr[a]++] = b;
      nbrs[b][nnbr[b]++] = a;
    }

    max_cl = 0;

    for (st = 0; st < MAX_N; st++) {
      if (nnbr[st] > 0) {
        memset(visited, 0, sizeof(char) * MAX_N);
        visited[st] = 1;
        cl = max_chain(st);
        if (max_cl < cl) max_cl = cl;
      }
    }

    printf("%d\n", max_cl);
  }

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	nbrs
	.comm	nbrs,40000,32
	.local	nnbr
	.comm	nnbr,400,32
	.local	visited
	.comm	visited,100,32
	.globl	max_chain
	.type	max_chain, @function
max_chain:
.LFB6:
	.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	$1, -12(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L2
.L4:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	nbrs(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	jne	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	max_chain
	addl	$1, %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-12(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jge	.L3
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
.L3:
	addl	$1, -16(%rbp)
.L2:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	nnbr(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L4
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	max_chain, .-max_chain
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%rsi, -64(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L14:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L18
	movl	$400, %edx
	movl	$0, %esi
	leaq	nnbr(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -24(%rbp)
	jmp	.L9
.L10:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-36(%rbp), %esi
	movl	-36(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nnbr(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rdi
	leaq	nnbr(%rip), %rdx
	movl	%ecx, (%rdi,%rdx)
	movl	-32(%rbp), %edx
	movslq	%eax, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nbrs(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	-32(%rbp), %esi
	movl	-32(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nnbr(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rdi
	leaq	nnbr(%rip), %rdx
	movl	%ecx, (%rdi,%rdx)
	movl	-36(%rbp), %edx
	movslq	%eax, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nbrs(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -24(%rbp)
.L9:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L10
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L11
.L13:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	nnbr(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jle	.L12
	movl	$100, %edx
	movl	$0, %esi
	leaq	visited(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-16(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	max_chain
	movl	%eax, -12(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jge	.L12
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L12:
	addl	$1, -16(%rbp)
.L11:
	cmpl	$99, -16(%rbp)
	jle	.L13
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	nbrs
	.comm	nbrs,40000,32
	.local	nnbr
	.comm	nnbr,400,32
	.local	visited
	.comm	visited,100,32
	.globl	max_chain
	.type	max_chain, @function
max_chain:
.LFB6:
	.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	$1, -12(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L2
.L4:
	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), %rdx
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	nbrs(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	jne	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-8(%rbp), %eax
	movl	%eax, %edi
	call	max_chain
	addl	$1, %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movl	-12(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jge	.L3
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
.L3:
	addl	$1, -16(%rbp)
.L2:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	nnbr(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L4
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	max_chain, .-max_chain
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%rsi, -64(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L14:
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	je	.L18
	movl	$400, %edx
	movl	$0, %esi
	leaq	nnbr(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -24(%rbp)
	jmp	.L9
.L10:
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -36(%rbp)
	movl	-32(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -32(%rbp)
	movl	-36(%rbp), %esi
	movl	-36(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nnbr(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rdi
	leaq	nnbr(%rip), %rdx
	movl	%ecx, (%rdi,%rdx)
	movl	-32(%rbp), %edx
	movslq	%eax, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nbrs(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	-32(%rbp), %esi
	movl	-32(%rbp), %edx
	movslq	%edx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nnbr(%rip), %rax
	movl	(%rcx,%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rdi
	leaq	nnbr(%rip), %rdx
	movl	%ecx, (%rdi,%rdx)
	movl	-36(%rbp), %edx
	movslq	%eax, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	addq	%rcx, %rax
	salq	$2, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	nbrs(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -24(%rbp)
.L9:
	movl	-28(%rbp), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L10
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L11
.L13:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	nnbr(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jle	.L12
	movl	$100, %edx
	movl	$0, %esi
	leaq	visited(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-16(%rbp), %eax
	cltq
	leaq	visited(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	max_chain
	movl	%eax, -12(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jge	.L12
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L12:
	addl	$1, -16(%rbp)
.L11:
	cmpl	$99, -16(%rbp)
	jle	.L13
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L14
.L18:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
