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>

long *tree[100010];

int main(void) {

  long n,m,a,b;
  scanf("%ld %ld", &n, &m);
  long tree_s[n+1];
  for (long i = 1; i <= n; i++) {
    tree_s[i] = 0;
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
    tree_s[a]++;
    tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
    tree_s[b]++;
  }
  long visited[n+1],que[n];
  visited[1] = 1;
  for (long i = 2; i <= n; i++) {
    visited[i] = 0;
  }
  que[0] = 1;
  long head = 1,cur,next,start = 0,end = 0,tail = 0,count = 0;
  int flag;
  while (1) {
    flag = 0;
    for (long i = start; i <= end; i++) {
      cur = que[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        visited[next] = 1;
        tail++;
        que[tail] = next;
        flag = 1;
      }
    }
    if (flag == 1) {
      start = end+1;
      end = tail;
    } else {
      if (tail == n-1) {
        break;
      }
      for (long i = head+1; i <= n; i++) {
        if (visited[i] == 0) {
          head = i;
          visited[i] = 1;
          tail++;
          que[tail] = i;
          start = tail;
          end = tail;
          count++;
          break;
        }
      }
    }
  }
  printf("%ld\n", count);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	tree
	.bss
	.align 32
	.type	tree, @object
	.size	tree, 800080
tree:
	.zero	800080
	.section	.rodata
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld\n"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	subq	$288, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 12, -40
	.cfi_offset 3, -48
	movq	%fs:40, %rax
	movq	%rax, -40(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %r12
	leaq	-216(%rbp), %rax
	leaq	-224(%rbp), %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-224(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -104(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -256(%rbp)
	movq	$0, -248(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -272(%rbp)
	movq	$0, -264(%rbp)
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -96(%rbp)
	movq	$1, -192(%rbp)
	jmp	.L5
.L6:
	movq	-96(%rbp), %rax
	movq	-192(%rbp), %rdx
	movq	$0, (%rax,%rdx,8)
	addq	$1, -192(%rbp)
.L5:
	movq	-224(%rbp), %rax
	cmpq	%rax, -192(%rbp)
	jle	.L6
	movq	$0, -184(%rbp)
	jmp	.L7
.L8:
	leaq	-200(%rbp), %rdx
	leaq	-208(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-208(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-208(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	tree(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	-208(%rbp), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	leaq	0(,%rbx,8), %rcx
	leaq	tree(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-208(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-208(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	salq	$3, %rax
	leaq	(%rcx,%rax), %rdx
	movq	-200(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-208(%rbp), %rax
	movq	-96(%rbp), %rdx
	movq	(%rdx,%rax,8), %rdx
	leaq	1(%rdx), %rcx
	movq	-96(%rbp), %rdx
	movq	%rcx, (%rdx,%rax,8)
	movq	-200(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-200(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	tree(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	-200(%rbp), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	leaq	0(,%rbx,8), %rcx
	leaq	tree(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-200(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-200(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	salq	$3, %rax
	leaq	(%rcx,%rax), %rdx
	movq	-208(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-200(%rbp), %rax
	movq	-96(%rbp), %rdx
	movq	(%rdx,%rax,8), %rdx
	leaq	1(%rdx), %rcx
	movq	-96(%rbp), %rdx
	movq	%rcx, (%rdx,%rax,8)
	addq	$1, -184(%rbp)
.L7:
	movq	-216(%rbp), %rax
	cmpq	%rax, -184(%rbp)
	jl	.L8
	movq	-224(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -88(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -288(%rbp)
	movq	$0, -280(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -304(%rbp)
	movq	$0, -296(%rbp)
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L9:
	cmpq	%rdx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L11
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L11:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -80(%rbp)
	movq	-224(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -320(%rbp)
	movq	$0, -312(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L12:
	cmpq	%rdx, %rsp
	je	.L13
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L12
.L13:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L14
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L14:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	-80(%rbp), %rax
	movq	$1, 8(%rax)
	movq	$2, -176(%rbp)
	jmp	.L15
.L16:
	movq	-80(%rbp), %rax
	movq	-176(%rbp), %rdx
	movq	$0, (%rax,%rdx,8)
	addq	$1, -176(%rbp)
.L15:
	movq	-224(%rbp), %rax
	cmpq	%rax, -176(%rbp)
	jle	.L16
	movq	-64(%rbp), %rax
	movq	$1, (%rax)
	movq	$1, -168(%rbp)
	movq	$0, -160(%rbp)
	movq	$0, -152(%rbp)
	movq	$0, -144(%rbp)
	movq	$0, -136(%rbp)
.L30:
	movl	$0, -228(%rbp)
	movq	-160(%rbp), %rax
	movq	%rax, -128(%rbp)
	jmp	.L17
.L22:
	movq	-64(%rbp), %rax
	movq	-128(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, -56(%rbp)
	movq	$0, -120(%rbp)
	jmp	.L18
.L21:
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-120(%rbp), %rax
	salq	$3, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	-80(%rbp), %rax
	movq	-48(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	$1, %rax
	je	.L34
	movq	-80(%rbp), %rax
	movq	-48(%rbp), %rdx
	movq	$1, (%rax,%rdx,8)
	addq	$1, -144(%rbp)
	movq	-64(%rbp), %rax
	movq	-144(%rbp), %rdx
	movq	-48(%rbp), %rcx
	movq	%rcx, (%rax,%rdx,8)
	movl	$1, -228(%rbp)
	jmp	.L20
.L34:
	nop
.L20:
	addq	$1, -120(%rbp)
.L18:
	movq	-96(%rbp), %rax
	movq	-56(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	%rax, -120(%rbp)
	jl	.L21
	addq	$1, -128(%rbp)
.L17:
	movq	-128(%rbp), %rax
	cmpq	-152(%rbp), %rax
	jle	.L22
	cmpl	$1, -228(%rbp)
	jne	.L23
	movq	-152(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -160(%rbp)
	movq	-144(%rbp), %rax
	movq	%rax, -152(%rbp)
	jmp	.L30
.L23:
	movq	-224(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -144(%rbp)
	je	.L35
	movq	-168(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -112(%rbp)
	jmp	.L27
.L29:
	movq	-80(%rbp), %rax
	movq	-112(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	testq	%rax, %rax
	jne	.L28
	movq	-112(%rbp), %rax
	movq	%rax, -168(%rbp)
	movq	-80(%rbp), %rax
	movq	-112(%rbp), %rdx
	movq	$1, (%rax,%rdx,8)
	addq	$1, -144(%rbp)
	movq	-64(%rbp), %rax
	movq	-144(%rbp), %rdx
	movq	-112(%rbp), %rcx
	movq	%rcx, (%rax,%rdx,8)
	movq	-144(%rbp), %rax
	movq	%rax, -160(%rbp)
	movq	-144(%rbp), %rax
	movq	%rax, -152(%rbp)
	addq	$1, -136(%rbp)
	jmp	.L24
.L28:
	addq	$1, -112(%rbp)
.L27:
	movq	-224(%rbp), %rax
	cmpq	%rax, -112(%rbp)
	jle	.L29
.L24:
	jmp	.L30
.L35:
	nop
	movq	-136(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%r12, %rsp
	movq	-40(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	leaq	-32(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	.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
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-80(%rbp), %rdx
	leaq	-88(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	.LC0(%rip), %r12
	pushq	%rbx
	movq	%r12, %rdi
	subq	$88, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rsi
	movq	%rsp, %rdi
	leaq	8(,%rsi,8), %rdx
	leaq	15(%rdx), %rcx
	movq	%rcx, %rax
	andq	$-4096, %rcx
	subq	%rcx, %rdi
	andq	$-16, %rax
	cmpq	%rdi, %rsp
	je	.L3
.L42:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L42
.L3:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L43
.L4:
	movq	%rsp, %r13
	testq	%rsi, %rsi
	jle	.L5
	subq	$8, %rdx
	leaq	8(%r13), %rdi
	xorl	%esi, %esi
	call	memset@PLT
.L5:
	cmpq	$0, -80(%rbp)
	jle	.L6
	leaq	-64(%rbp), %rax
	xorl	%r14d, %r14d
	leaq	tree(%rip), %rbx
	movq	%rax, -112(%rbp)
	leaq	-72(%rbp), %rax
	movq	%rax, -104(%rbp)
.L7:
	movq	-112(%rbp), %rdx
	movq	-104(%rbp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$1, %r14
	call	__isoc99_scanf@PLT
	movq	-72(%rbp), %r15
	movq	0(%r13,%r15,8), %rax
	movq	(%rbx,%r15,8), %rdi
	leaq	8(,%rax,8), %rsi
	call	realloc@PLT
	movq	-64(%rbp), %rsi
	movq	%rax, (%rbx,%r15,8)
	movq	-72(%rbp), %rax
	movq	0(%r13,%rax,8), %rdx
	movq	(%rbx,%rax,8), %rax
	movq	%rsi, (%rax,%rdx,8)
	movq	-64(%rbp), %r15
	movq	-72(%rbp), %rax
	movq	(%rbx,%r15,8), %rdi
	addq	$1, 0(%r13,%rax,8)
	movq	0(%r13,%r15,8), %rax
	leaq	8(,%rax,8), %rsi
	call	realloc@PLT
	movq	-72(%rbp), %rsi
	movq	%rax, (%rbx,%r15,8)
	movq	-64(%rbp), %rax
	movq	0(%r13,%rax,8), %rdx
	movq	(%rbx,%rax,8), %rax
	movq	%rsi, (%rax,%rdx,8)
	movq	-64(%rbp), %rax
	addq	$1, 0(%r13,%rax,8)
	cmpq	%r14, -80(%rbp)
	jg	.L7
.L6:
	movq	-88(%rbp), %r14
	movq	%rsp, %rsi
	leaq	8(,%r14,8), %rdx
	leaq	15(%rdx), %rcx
	movq	%rcx, %rax
	andq	$-4096, %rcx
	subq	%rcx, %rsi
	andq	$-16, %rax
	cmpq	%rsi, %rsp
	je	.L9
.L44:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L44
.L9:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L45
.L10:
	leaq	7(%rsp), %rbx
	leaq	-1(%r14), %rax
	movq	%rsp, %rsi
	movq	%rbx, %rcx
	movq	%rax, -112(%rbp)
	movq	%rdx, %rax
	andq	$-8, %rbx
	andq	$-4096, %rdx
	shrq	$3, %rcx
	andq	$-16, %rax
	subq	%rdx, %rsi
.L11:
	cmpq	%rsi, %rsp
	je	.L12
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L11
.L45:
	orq	$0, -8(%rsp,%rax)
	jmp	.L10
.L43:
	orq	$0, -8(%rsp,%rax)
	jmp	.L4
.L12:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L46
.L13:
	leaq	7(%rsp), %r12
	movq	$1, 8(,%rcx,8)
	movq	%r12, %r15
	andq	$-8, %r12
	shrq	$3, %r15
	cmpq	$1, %r14
	jle	.L14
	movq	-112(%rbp), %rax
	leaq	16(%rbx), %rdi
	xorl	%esi, %esi
	leaq	0(,%rax,8), %rdx
	call	memset@PLT
.L14:
	movq	$0, -120(%rbp)
	xorl	%ecx, %ecx
	xorl	%r11d, %r11d
	leaq	tree(%rip), %r10
	movq	$1, -104(%rbp)
	movq	$1, 0(,%r15,8)
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L15:
	cmpq	%r15, %r11
	jg	.L16
	leaq	1(%r15), %r9
	movq	%r11, %r8
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L20:
	movq	(%r12,%r8,8), %rax
	movq	0(%r13,%rax,8), %rdx
	testq	%rdx, %rdx
	jle	.L17
	movq	(%r10,%rax,8), %rax
	leaq	(%rax,%rdx,8), %rsi
	.p2align 4,,10
	.p2align 3
.L19:
	movq	(%rax), %rdx
	cmpq	$1, (%rbx,%rdx,8)
	je	.L18
	addq	$1, %rcx
	movq	$1, (%rbx,%rdx,8)
	movl	$1, %edi
	movq	%rdx, (%r12,%rcx,8)
.L18:
	addq	$8, %rax
	cmpq	%rax, %rsi
	jne	.L19
.L17:
	addq	$1, %r8
	cmpq	%r8, %r9
	jne	.L20
	cmpl	$1, %edi
	je	.L47
.L16:
	cmpq	-112(%rbp), %rcx
	je	.L22
	movq	-104(%rbp), %rax
	.p2align 4,,10
	.p2align 3
.L40:
	addq	$1, %rax
	cmpq	%rax, %r14
	jl	.L15
	cmpq	$0, (%rbx,%rax,8)
	jne	.L40
	leaq	1(%rcx), %r11
	addq	$1, -120(%rbp)
	movq	$1, (%rbx,%rax,8)
	movq	%r11, %rcx
	movq	%r11, %r15
	movq	%rax, (%r12,%r11,8)
	movq	%rax, -104(%rbp)
	jmp	.L15
.L47:
	movq	%r9, %r11
	movq	%rcx, %r15
	jmp	.L15
.L22:
	movq	-120(%rbp), %rdx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L48
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L46:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rax)
	jmp	.L13
.L48:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	tree
	.bss
	.align 32
	.type	tree, @object
	.size	tree, 800080
tree:
	.zero	800080
	.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	"%ld %ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-80(%rbp), %rdx
	leaq	-88(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	leaq	.LC0(%rip), %r12
	pushq	%rbx
	movq	%r12, %rdi
	subq	$88, %rsp
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	-88(%rbp), %rsi
	movq	%rsp, %rdi
	leaq	8(,%rsi,8), %rdx
	leaq	15(%rdx), %rcx
	movq	%rcx, %rax
	andq	$-4096, %rcx
	subq	%rcx, %rdi
	andq	$-16, %rax
	cmpq	%rdi, %rsp
	je	.L3
.L42:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L42
.L3:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L43
.L4:
	movq	%rsp, %r13
	testq	%rsi, %rsi
	jle	.L5
	subq	$8, %rdx
	leaq	8(%r13), %rdi
	xorl	%esi, %esi
	call	memset@PLT
.L5:
	cmpq	$0, -80(%rbp)
	jle	.L6
	leaq	-64(%rbp), %rax
	xorl	%r14d, %r14d
	leaq	tree(%rip), %rbx
	movq	%rax, -112(%rbp)
	leaq	-72(%rbp), %rax
	movq	%rax, -104(%rbp)
.L7:
	movq	-112(%rbp), %rdx
	movq	-104(%rbp), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	addq	$1, %r14
	call	__isoc99_scanf@PLT
	movq	-72(%rbp), %r15
	movq	0(%r13,%r15,8), %rax
	movq	(%rbx,%r15,8), %rdi
	leaq	8(,%rax,8), %rsi
	call	realloc@PLT
	movq	-64(%rbp), %rsi
	movq	%rax, (%rbx,%r15,8)
	movq	-72(%rbp), %rax
	movq	0(%r13,%rax,8), %rdx
	movq	(%rbx,%rax,8), %rax
	movq	%rsi, (%rax,%rdx,8)
	movq	-64(%rbp), %r15
	movq	-72(%rbp), %rax
	movq	(%rbx,%r15,8), %rdi
	addq	$1, 0(%r13,%rax,8)
	movq	0(%r13,%r15,8), %rax
	leaq	8(,%rax,8), %rsi
	call	realloc@PLT
	movq	-72(%rbp), %rsi
	movq	%rax, (%rbx,%r15,8)
	movq	-64(%rbp), %rax
	movq	0(%r13,%rax,8), %rdx
	movq	(%rbx,%rax,8), %rax
	movq	%rsi, (%rax,%rdx,8)
	movq	-64(%rbp), %rax
	addq	$1, 0(%r13,%rax,8)
	cmpq	%r14, -80(%rbp)
	jg	.L7
.L6:
	movq	-88(%rbp), %r14
	movq	%rsp, %rsi
	leaq	8(,%r14,8), %rdx
	leaq	15(%rdx), %rcx
	movq	%rcx, %rax
	andq	$-4096, %rcx
	subq	%rcx, %rsi
	andq	$-16, %rax
	cmpq	%rsi, %rsp
	je	.L9
.L44:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rsi, %rsp
	jne	.L44
.L9:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L45
.L10:
	leaq	7(%rsp), %rbx
	leaq	-1(%r14), %rax
	movq	%rsp, %rsi
	movq	%rbx, %rcx
	movq	%rax, -112(%rbp)
	movq	%rdx, %rax
	andq	$-8, %rbx
	andq	$-4096, %rdx
	shrq	$3, %rcx
	andq	$-16, %rax
	subq	%rdx, %rsi
.L11:
	cmpq	%rsi, %rsp
	je	.L12
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L11
.L45:
	orq	$0, -8(%rsp,%rax)
	jmp	.L10
.L43:
	orq	$0, -8(%rsp,%rax)
	jmp	.L4
.L12:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	jne	.L46
.L13:
	leaq	7(%rsp), %r12
	movq	$1, 8(,%rcx,8)
	movq	%r12, %r15
	andq	$-8, %r12
	shrq	$3, %r15
	cmpq	$1, %r14
	jle	.L14
	movq	-112(%rbp), %rax
	leaq	16(%rbx), %rdi
	xorl	%esi, %esi
	leaq	0(,%rax,8), %rdx
	call	memset@PLT
.L14:
	movq	$0, -120(%rbp)
	xorl	%ecx, %ecx
	xorl	%r11d, %r11d
	leaq	tree(%rip), %r10
	movq	$1, -104(%rbp)
	movq	$1, 0(,%r15,8)
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L15:
	cmpq	%r15, %r11
	jg	.L16
	leaq	1(%r15), %r9
	movq	%r11, %r8
	xorl	%edi, %edi
	.p2align 4,,10
	.p2align 3
.L20:
	movq	(%r12,%r8,8), %rax
	movq	0(%r13,%rax,8), %rdx
	testq	%rdx, %rdx
	jle	.L17
	movq	(%r10,%rax,8), %rax
	leaq	(%rax,%rdx,8), %rsi
	.p2align 4,,10
	.p2align 3
.L19:
	movq	(%rax), %rdx
	cmpq	$1, (%rbx,%rdx,8)
	je	.L18
	addq	$1, %rcx
	movq	$1, (%rbx,%rdx,8)
	movl	$1, %edi
	movq	%rdx, (%r12,%rcx,8)
.L18:
	addq	$8, %rax
	cmpq	%rax, %rsi
	jne	.L19
.L17:
	addq	$1, %r8
	cmpq	%r8, %r9
	jne	.L20
	cmpl	$1, %edi
	je	.L47
.L16:
	cmpq	-112(%rbp), %rcx
	je	.L22
	movq	-104(%rbp), %rax
	.p2align 4,,10
	.p2align 3
.L40:
	addq	$1, %rax
	cmpq	%rax, %r14
	jl	.L15
	cmpq	$0, (%rbx,%rax,8)
	jne	.L40
	leaq	1(%rcx), %r11
	addq	$1, -120(%rbp)
	movq	$1, (%rbx,%rax,8)
	movq	%r11, %rcx
	movq	%r11, %r15
	movq	%rax, (%r12,%r11,8)
	movq	%rax, -104(%rbp)
	jmp	.L15
.L47:
	movq	%r9, %r11
	movq	%rcx, %r15
	jmp	.L15
.L22:
	movq	-120(%rbp), %rdx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L48
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L46:
	.cfi_restore_state
	orq	$0, -8(%rsp,%rax)
	jmp	.L13
.L48:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	tree
	.bss
	.align 32
	.type	tree, @object
	.size	tree, 800080
tree:
	.zero	800080
	.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>

long *tree[100010];

int main(void) {

  long n,m,a,b;
  scanf("%ld %ld", &n, &m);
  long tree_s[n+1];
  for (long i = 1; i <= n; i++) {
    tree_s[i] = 0;
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
    tree_s[a]++;
    tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
    tree_s[b]++;
  }
  long visited[n+1],que[n];
  visited[1] = 1;
  for (long i = 2; i <= n; i++) {
    visited[i] = 0;
  }
  que[0] = 1;
  long head = 1,cur,next,start = 0,end = 0,tail = 0,count = 0;
  int flag;
  while (1) {
    flag = 0;
    for (long i = start; i <= end; i++) {
      cur = que[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        visited[next] = 1;
        tail++;
        que[tail] = next;
        flag = 1;
      }
    }
    if (flag == 1) {
      start = end+1;
      end = tail;
    } else {
      if (tail == n-1) {
        break;
      }
      for (long i = head+1; i <= n; i++) {
        if (visited[i] == 0) {
          head = i;
          visited[i] = 1;
          tail++;
          que[tail] = i;
          start = tail;
          end = tail;
          count++;
          break;
        }
      }
    }
  }
  printf("%ld\n", count);

  return 0;
}
3 1
1 1
 5 1
1 1
 6 1
1 1
 3 1
3 2
 5 1
3 2
 2 1
1 2
 9 1
1 2
 15 1
1 2
 10 1
1 2
 10 1
1 1

2
 4
 5
 1
 3
 0
 7
 13
 8
 9

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>

long *tree[100010];

int main(void) {

  long n,m,a,b;
  scanf("%ld %ld", &n, &m);
  long tree_s[n+1];
  for (long i = 1; i <= n; i++) {
    tree_s[i] = 0;
  }
  for (long i = 0; i < m; i++) {
    scanf("%ld %ld", &a, &b);
    tree[a] = realloc(tree[a], sizeof(long)*(tree_s[a]+1));
    tree[a][tree_s[a]] = b;
    tree_s[a]++;
    tree[b] = realloc(tree[b], sizeof(long)*(tree_s[b]+1));
    tree[b][tree_s[b]] = a;
    tree_s[b]++;
  }
  long visited[n+1],que[n];
  visited[1] = 1;
  for (long i = 2; i <= n; i++) {
    visited[i] = 0;
  }
  que[0] = 1;
  long head = 1,cur,next,start = 0,end = 0,tail = 0,count = 0;
  int flag;
  while (1) {
    flag = 0;
    for (long i = start; i <= end; i++) {
      cur = que[i];
      for (long j = 0; j < tree_s[cur]; j++) {
        next = tree[cur][j];
        if (visited[next] == 1) {
          continue;
        }
        visited[next] = 1;
        tail++;
        que[tail] = next;
        flag = 1;
      }
    }
    if (flag == 1) {
      start = end+1;
      end = tail;
    } else {
      if (tail == n-1) {
        break;
      }
      for (long i = head+1; i <= n; i++) {
        if (visited[i] == 0) {
          head = i;
          visited[i] = 1;
          tail++;
          que[tail] = i;
          start = tail;
          end = tail;
          count++;
          break;
        }
      }
    }
  }
  printf("%ld\n", count);

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	tree
	.bss
	.align 32
	.type	tree, @object
	.size	tree, 800080
tree:
	.zero	800080
	.section	.rodata
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld\n"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	subq	$288, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 12, -40
	.cfi_offset 3, -48
	movq	%fs:40, %rax
	movq	%rax, -40(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %r12
	leaq	-216(%rbp), %rax
	leaq	-224(%rbp), %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-224(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -104(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -256(%rbp)
	movq	$0, -248(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -272(%rbp)
	movq	$0, -264(%rbp)
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -96(%rbp)
	movq	$1, -192(%rbp)
	jmp	.L5
.L6:
	movq	-96(%rbp), %rax
	movq	-192(%rbp), %rdx
	movq	$0, (%rax,%rdx,8)
	addq	$1, -192(%rbp)
.L5:
	movq	-224(%rbp), %rax
	cmpq	%rax, -192(%rbp)
	jle	.L6
	movq	$0, -184(%rbp)
	jmp	.L7
.L8:
	leaq	-200(%rbp), %rdx
	leaq	-208(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-208(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-208(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	tree(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	-208(%rbp), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	leaq	0(,%rbx,8), %rcx
	leaq	tree(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-208(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-208(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	salq	$3, %rax
	leaq	(%rcx,%rax), %rdx
	movq	-200(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-208(%rbp), %rax
	movq	-96(%rbp), %rdx
	movq	(%rdx,%rax,8), %rdx
	leaq	1(%rdx), %rcx
	movq	-96(%rbp), %rdx
	movq	%rcx, (%rdx,%rax,8)
	movq	-200(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-200(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	tree(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	-200(%rbp), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	leaq	0(,%rbx,8), %rcx
	leaq	tree(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-200(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-200(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	salq	$3, %rax
	leaq	(%rcx,%rax), %rdx
	movq	-208(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-200(%rbp), %rax
	movq	-96(%rbp), %rdx
	movq	(%rdx,%rax,8), %rdx
	leaq	1(%rdx), %rcx
	movq	-96(%rbp), %rdx
	movq	%rcx, (%rdx,%rax,8)
	addq	$1, -184(%rbp)
.L7:
	movq	-216(%rbp), %rax
	cmpq	%rax, -184(%rbp)
	jl	.L8
	movq	-224(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -88(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -288(%rbp)
	movq	$0, -280(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -304(%rbp)
	movq	$0, -296(%rbp)
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L9:
	cmpq	%rdx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L11
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L11:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -80(%rbp)
	movq	-224(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -320(%rbp)
	movq	$0, -312(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L12:
	cmpq	%rdx, %rsp
	je	.L13
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L12
.L13:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L14
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L14:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	-80(%rbp), %rax
	movq	$1, 8(%rax)
	movq	$2, -176(%rbp)
	jmp	.L15
.L16:
	movq	-80(%rbp), %rax
	movq	-176(%rbp), %rdx
	movq	$0, (%rax,%rdx,8)
	addq	$1, -176(%rbp)
.L15:
	movq	-224(%rbp), %rax
	cmpq	%rax, -176(%rbp)
	jle	.L16
	movq	-64(%rbp), %rax
	movq	$1, (%rax)
	movq	$1, -168(%rbp)
	movq	$0, -160(%rbp)
	movq	$0, -152(%rbp)
	movq	$0, -144(%rbp)
	movq	$0, -136(%rbp)
.L30:
	movl	$0, -228(%rbp)
	movq	-160(%rbp), %rax
	movq	%rax, -128(%rbp)
	jmp	.L17
.L22:
	movq	-64(%rbp), %rax
	movq	-128(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, -56(%rbp)
	movq	$0, -120(%rbp)
	jmp	.L18
.L21:
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-120(%rbp), %rax
	salq	$3, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	-80(%rbp), %rax
	movq	-48(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	$1, %rax
	je	.L34
	movq	-80(%rbp), %rax
	movq	-48(%rbp), %rdx
	movq	$1, (%rax,%rdx,8)
	addq	$1, -144(%rbp)
	movq	-64(%rbp), %rax
	movq	-144(%rbp), %rdx
	movq	-48(%rbp), %rcx
	movq	%rcx, (%rax,%rdx,8)
	movl	$1, -228(%rbp)
	jmp	.L20
.L34:
	nop
.L20:
	addq	$1, -120(%rbp)
.L18:
	movq	-96(%rbp), %rax
	movq	-56(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	%rax, -120(%rbp)
	jl	.L21
	addq	$1, -128(%rbp)
.L17:
	movq	-128(%rbp), %rax
	cmpq	-152(%rbp), %rax
	jle	.L22
	cmpl	$1, -228(%rbp)
	jne	.L23
	movq	-152(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -160(%rbp)
	movq	-144(%rbp), %rax
	movq	%rax, -152(%rbp)
	jmp	.L30
.L23:
	movq	-224(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -144(%rbp)
	je	.L35
	movq	-168(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -112(%rbp)
	jmp	.L27
.L29:
	movq	-80(%rbp), %rax
	movq	-112(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	testq	%rax, %rax
	jne	.L28
	movq	-112(%rbp), %rax
	movq	%rax, -168(%rbp)
	movq	-80(%rbp), %rax
	movq	-112(%rbp), %rdx
	movq	$1, (%rax,%rdx,8)
	addq	$1, -144(%rbp)
	movq	-64(%rbp), %rax
	movq	-144(%rbp), %rdx
	movq	-112(%rbp), %rcx
	movq	%rcx, (%rax,%rdx,8)
	movq	-144(%rbp), %rax
	movq	%rax, -160(%rbp)
	movq	-144(%rbp), %rax
	movq	%rax, -152(%rbp)
	addq	$1, -136(%rbp)
	jmp	.L24
.L28:
	addq	$1, -112(%rbp)
.L27:
	movq	-224(%rbp), %rax
	cmpq	%rax, -112(%rbp)
	jle	.L29
.L24:
	jmp	.L30
.L35:
	nop
	movq	-136(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%r12, %rsp
	movq	-40(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	leaq	-32(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	.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
	.globl	tree
	.bss
	.align 32
	.type	tree, @object
	.size	tree, 800080
tree:
	.zero	800080
	.section	.rodata
.LC0:
	.string	"%ld %ld"
.LC1:
	.string	"%ld\n"
	.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
	pushq	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	subq	$288, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 12, -40
	.cfi_offset 3, -48
	movq	%fs:40, %rax
	movq	%rax, -40(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %r12
	leaq	-216(%rbp), %rax
	leaq	-224(%rbp), %rcx
	movq	%rax, %rdx
	movq	%rcx, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-224(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -104(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -256(%rbp)
	movq	$0, -248(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -272(%rbp)
	movq	$0, -264(%rbp)
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L2:
	cmpq	%rdx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L4
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -96(%rbp)
	movq	$1, -192(%rbp)
	jmp	.L5
.L6:
	movq	-96(%rbp), %rax
	movq	-192(%rbp), %rdx
	movq	$0, (%rax,%rdx,8)
	addq	$1, -192(%rbp)
.L5:
	movq	-224(%rbp), %rax
	cmpq	%rax, -192(%rbp)
	jle	.L6
	movq	$0, -184(%rbp)
	jmp	.L7
.L8:
	leaq	-200(%rbp), %rdx
	leaq	-208(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-208(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-208(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	tree(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	-208(%rbp), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	leaq	0(,%rbx,8), %rcx
	leaq	tree(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-208(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-208(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	salq	$3, %rax
	leaq	(%rcx,%rax), %rdx
	movq	-200(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-208(%rbp), %rax
	movq	-96(%rbp), %rdx
	movq	(%rdx,%rax,8), %rdx
	leaq	1(%rdx), %rcx
	movq	-96(%rbp), %rdx
	movq	%rcx, (%rdx,%rax,8)
	movq	-200(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	addq	$1, %rax
	leaq	0(,%rax,8), %rdx
	movq	-200(%rbp), %rax
	leaq	0(,%rax,8), %rcx
	leaq	tree(%rip), %rax
	movq	(%rcx,%rax), %rax
	movq	-200(%rbp), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	leaq	0(,%rbx,8), %rcx
	leaq	tree(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movq	-200(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rcx
	movq	-200(%rbp), %rdx
	movq	-96(%rbp), %rax
	movq	(%rax,%rdx,8), %rax
	salq	$3, %rax
	leaq	(%rcx,%rax), %rdx
	movq	-208(%rbp), %rax
	movq	%rax, (%rdx)
	movq	-200(%rbp), %rax
	movq	-96(%rbp), %rdx
	movq	(%rdx,%rax,8), %rdx
	leaq	1(%rdx), %rcx
	movq	-96(%rbp), %rdx
	movq	%rcx, (%rdx,%rax,8)
	addq	$1, -184(%rbp)
.L7:
	movq	-216(%rbp), %rax
	cmpq	%rax, -184(%rbp)
	jl	.L8
	movq	-224(%rbp), %rax
	addq	$1, %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -88(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -288(%rbp)
	movq	$0, -280(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -304(%rbp)
	movq	$0, -296(%rbp)
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L9:
	cmpq	%rdx, %rsp
	je	.L10
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L9
.L10:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L11
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L11:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -80(%rbp)
	movq	-224(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	%rdx, -72(%rbp)
	movq	%rax, %rdx
	movq	%rdx, -320(%rbp)
	movq	$0, -312(%rbp)
	movq	%rax, %rdx
	movq	%rdx, %r14
	movl	$0, %r15d
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L12:
	cmpq	%rdx, %rsp
	je	.L13
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L12
.L13:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L14
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L14:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movq	-80(%rbp), %rax
	movq	$1, 8(%rax)
	movq	$2, -176(%rbp)
	jmp	.L15
.L16:
	movq	-80(%rbp), %rax
	movq	-176(%rbp), %rdx
	movq	$0, (%rax,%rdx,8)
	addq	$1, -176(%rbp)
.L15:
	movq	-224(%rbp), %rax
	cmpq	%rax, -176(%rbp)
	jle	.L16
	movq	-64(%rbp), %rax
	movq	$1, (%rax)
	movq	$1, -168(%rbp)
	movq	$0, -160(%rbp)
	movq	$0, -152(%rbp)
	movq	$0, -144(%rbp)
	movq	$0, -136(%rbp)
.L30:
	movl	$0, -228(%rbp)
	movq	-160(%rbp), %rax
	movq	%rax, -128(%rbp)
	jmp	.L17
.L22:
	movq	-64(%rbp), %rax
	movq	-128(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, -56(%rbp)
	movq	$0, -120(%rbp)
	jmp	.L18
.L21:
	movq	-56(%rbp), %rax
	leaq	0(,%rax,8), %rdx
	leaq	tree(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movq	-120(%rbp), %rax
	salq	$3, %rax
	addq	%rdx, %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	-80(%rbp), %rax
	movq	-48(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	$1, %rax
	je	.L34
	movq	-80(%rbp), %rax
	movq	-48(%rbp), %rdx
	movq	$1, (%rax,%rdx,8)
	addq	$1, -144(%rbp)
	movq	-64(%rbp), %rax
	movq	-144(%rbp), %rdx
	movq	-48(%rbp), %rcx
	movq	%rcx, (%rax,%rdx,8)
	movl	$1, -228(%rbp)
	jmp	.L20
.L34:
	nop
.L20:
	addq	$1, -120(%rbp)
.L18:
	movq	-96(%rbp), %rax
	movq	-56(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	cmpq	%rax, -120(%rbp)
	jl	.L21
	addq	$1, -128(%rbp)
.L17:
	movq	-128(%rbp), %rax
	cmpq	-152(%rbp), %rax
	jle	.L22
	cmpl	$1, -228(%rbp)
	jne	.L23
	movq	-152(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -160(%rbp)
	movq	-144(%rbp), %rax
	movq	%rax, -152(%rbp)
	jmp	.L30
.L23:
	movq	-224(%rbp), %rax
	subq	$1, %rax
	cmpq	%rax, -144(%rbp)
	je	.L35
	movq	-168(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -112(%rbp)
	jmp	.L27
.L29:
	movq	-80(%rbp), %rax
	movq	-112(%rbp), %rdx
	movq	(%rax,%rdx,8), %rax
	testq	%rax, %rax
	jne	.L28
	movq	-112(%rbp), %rax
	movq	%rax, -168(%rbp)
	movq	-80(%rbp), %rax
	movq	-112(%rbp), %rdx
	movq	$1, (%rax,%rdx,8)
	addq	$1, -144(%rbp)
	movq	-64(%rbp), %rax
	movq	-144(%rbp), %rdx
	movq	-112(%rbp), %rcx
	movq	%rcx, (%rax,%rdx,8)
	movq	-144(%rbp), %rax
	movq	%rax, -160(%rbp)
	movq	-144(%rbp), %rax
	movq	%rax, -152(%rbp)
	addq	$1, -136(%rbp)
	jmp	.L24
.L28:
	addq	$1, -112(%rbp)
.L27:
	movq	-224(%rbp), %rax
	cmpq	%rax, -112(%rbp)
	jle	.L29
.L24:
	jmp	.L30
.L35:
	nop
	movq	-136(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	%r12, %rsp
	movq	-40(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L32
	call	__stack_chk_fail@PLT
.L32:
	leaq	-32(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	.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:
