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

```c
#include <stdio.h>
int v;
int parent[100001];
int sibling[100001];
int degree[100001];
int Depth(int i);
int Height(int i);
int main(){
  int i,j;
  int id, l, r;
  scanf("%d", &v);
  for(i = 0; i < v; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }
  for(i = 0; i < v; ++i) {
    scanf("%d %d %d", &id, &l, &r);
    if(l != -1){
      parent[l] = id;
      sibling[l] = r;
      ++degree[id];
    }
    if(r != -1){
      parent[r] = id;
      sibling[r] = l;
      ++degree[id];
    } }
  for(i = 0; i < v; ++i) {
    int depth = Depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, parent[i], sibling[i], degree[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(degree[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    } }
  return 0; }
           
           
           
int Depth(int i){
  if(parent[i] == -1) return 0;
  return Depth(parent[i]) + 1;
}
int Height(int i){
  int j, h;
  h = 0;
  for(j = 0; j < v; ++j){
    if(parent[j] == i){
      int tmp = Height(j) + 1;
      if(tmp > h){
	h = tmp;
      } }
  }
    return h; }

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	v
	.bss
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	parent
	.align 32
	.type	parent, @object
	.size	parent, 400004
parent:
	.zero	400004
	.globl	sibling
	.align 32
	.type	sibling, @object
	.size	sibling, 400004
sibling:
	.zero	400004
	.globl	degree
	.align 32
	.type	degree, @object
	.size	degree, 400004
degree:
	.zero	400004
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
	.align 8
.LC2:
	.string	"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
.LC3:
	.string	"root"
.LC4:
	.string	"leaf"
.LC5:
	.string	"internal node"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	v(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sibling(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L2:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L3
	movl	$0, -16(%rbp)
	jmp	.L4
.L7:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cmpl	$-1, %eax
	je	.L5
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	parent(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sibling(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	degree(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L5:
	movl	-20(%rbp), %eax
	cmpl	$-1, %eax
	je	.L6
	movl	-20(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	parent(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sibling(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	degree(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L6:
	addl	$1, -16(%rbp)
.L4:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L7
	movl	$0, -16(%rbp)
	jmp	.L8
.L12:
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	Depth
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	Height
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	(%rdx,%rax), %edi
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sibling(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-12(%rbp), %r8d
	movl	-16(%rbp), %eax
	subq	$8, %rsp
	pushq	%rsi
	movl	%r8d, %r9d
	movl	%edi, %r8d
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addq	$16, %rsp
	cmpl	$0, -12(%rbp)
	jne	.L9
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L11
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L11:
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	addl	$1, -16(%rbp)
.L8:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L12
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	Depth
	.type	Depth, @function
Depth:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	jne	.L16
	movl	$0, %eax
	jmp	.L17
.L16:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	Depth
	addl	$1, %eax
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Depth, .-Depth
	.globl	Height
	.type	Height, @function
Height:
.LFB2:
	.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	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L19
.L21:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	Height
	addl	$1, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L20
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L20:
	addl	$1, -12(%rbp)
.L19:
	movl	v(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L21
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Height, .-Height
	.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	Depth
	.type	Depth, @function
Depth:
.LFB24:
	.cfi_startproc
	endbr64
	leaq	parent(%rip), %rcx
	movslq	%edi, %rdi
	movl	$1, %edx
	xorl	%r8d, %r8d
	movslq	(%rcx,%rdi,4), %rax
	cmpl	$-1, %eax
	je	.L1
	.p2align 4,,10
	.p2align 3
.L2:
	movslq	(%rcx,%rax,4), %rax
	movl	%edx, %r8d
	addl	$1, %edx
	cmpl	$-1, %eax
	jne	.L2
.L1:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	Depth, .-Depth
	.p2align 4
	.globl	Height
	.type	Height, @function
Height:
.LFB25:
	.cfi_startproc
	endbr64
	movl	v(%rip), %eax
	xorl	%r11d, %r11d
	testl	%eax, %eax
	jle	.L35
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%eax, %r9
	movl	%r11d, %eax
	movl	%edi, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r9, %r11
	leaq	parent(%rip), %r10
	movl	%eax, %r9d
	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
	xorl	%ebx, %ebx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
.L25:
	cmpl	%r8d, (%r10,%rbx,4)
	je	.L38
.L12:
	addq	$1, %rbx
	cmpq	%rbx, %r11
	jne	.L25
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r9d, %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
.L38:
	.cfi_restore_state
	movl	%r8d, 8(%rsp)
	xorl	%esi, %esi
	xorl	%ebp, %ebp
	movl	%r9d, 4(%rsp)
	movl	%esi, %r9d
.L24:
	cmpl	%ebx, (%r10,%rbp,4)
	je	.L39
.L13:
	addq	$1, %rbp
	cmpq	%rbp, %r11
	jne	.L24
	movl	%r9d, %esi
	movl	4(%rsp), %r9d
	movl	8(%rsp), %r8d
	leal	1(%rsi), %eax
	cmpl	%eax, %r9d
	cmovl	%eax, %r9d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L39:
	movl	%r9d, 12(%rsp)
	xorl	%r12d, %r12d
	xorl	%r8d, %r8d
.L23:
	cmpl	%ebp, (%r10,%r12,4)
	je	.L40
.L14:
	addq	$1, %r12
	cmpq	%r12, %r11
	jne	.L23
	movl	12(%rsp), %r9d
	leal	1(%r8), %eax
	cmpl	%eax, %r9d
	cmovl	%eax, %r9d
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%r8d, 24(%rsp)
	xorl	%r13d, %r13d
	xorl	%r9d, %r9d
.L22:
	cmpl	%r12d, (%r10,%r13,4)
	je	.L41
.L15:
	addq	$1, %r13
	cmpq	%r13, %r11
	jne	.L22
	movl	24(%rsp), %r8d
	leal	1(%r9), %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rbx, 16(%rsp)
	xorl	%r14d, %r14d
	xorl	%r8d, %r8d
	movq	%rbp, %rdx
	movq	%r12, %rcx
.L21:
	cmpl	%r13d, (%r10,%r14,4)
	je	.L42
.L16:
	addq	$1, %r14
	cmpq	%r14, %r11
	jne	.L21
	leal	1(%r8), %eax
	movq	16(%rsp), %rbx
	movq	%rdx, %rbp
	movq	%rcx, %r12
	cmpl	%eax, %r9d
	cmovl	%eax, %r9d
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	movl	%r11d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L42:
	.cfi_def_cfa_offset 128
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	movq	%r13, %rsi
.L20:
	cmpl	%r14d, (%r10,%r15,4)
	je	.L43
.L17:
	addq	$1, %r15
	cmpq	%r15, %r11
	jne	.L20
	leal	1(%r12), %eax
	movq	%rsi, %r13
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L43:
	xorl	%ebp, %ebp
	movl	%r12d, 28(%rsp)
	xorl	%ebx, %ebx
	movl	%r9d, %r13d
	movq	%r14, 32(%rsp)
	movl	%ebp, %r12d
	movl	%r8d, %r14d
	movq	%r11, %rbp
.L19:
	movl	%ebx, %edi
	cmpl	%r15d, (%r10,%rbx,4)
	je	.L44
.L18:
	addq	$1, %rbx
	cmpq	%rbx, %rbp
	jne	.L19
	movq	%rbp, %r11
	movl	%r12d, %ebp
	movl	28(%rsp), %r12d
	movl	%r14d, %r8d
	addl	$1, %ebp
	movq	32(%rsp), %r14
	movl	%r13d, %r9d
	cmpl	%ebp, %r12d
	cmovl	%ebp, %r12d
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L44:
	movq	%rsi, 56(%rsp)
	movq	%rcx, 48(%rsp)
	movq	%rdx, 40(%rsp)
	call	Height
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rcx
	leaq	parent(%rip), %r10
	addl	$1, %eax
	movq	40(%rsp), %rdx
	cmpl	%eax, %r12d
	cmovl	%eax, %r12d
	jmp	.L18
	.cfi_endproc
.LFE25:
	.size	Height, .-Height
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC2:
	.string	"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
	.section	.rodata.str1.1
.LC3:
	.string	"root"
.LC4:
	.string	"leaf"
.LC5:
	.string	"internal node"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	v(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	v(%rip), %rax
	testl	%eax, %eax
	jle	.L46
	leaq	0(,%rax,4), %r12
	movl	$255, %esi
	leaq	84(%rsp), %r13
	xorl	%r15d, %r15d
	leaq	parent(%rip), %r14
	movq	%r12, %rdx
	leaq	76(%rsp), %rbp
	movq	%r14, %rdi
	leaq	.LC1(%rip), %rbx
	call	memset@PLT
	movq	%r12, %rdx
	movl	$255, %esi
	leaq	sibling(%rip), %rdi
	call	memset@PLT
	movq	%r12, %rdx
	xorl	%esi, %esi
	leaq	degree(%rip), %rdi
	call	memset@PLT
	leaq	80(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L52:
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	80(%rsp), %ecx
	cmpl	$-1, %ecx
	je	.L83
	movslq	84(%rsp), %rax
	movslq	76(%rsp), %rdx
	movslq	%ecx, %rsi
	leaq	sibling(%rip), %rdi
	movl	%eax, (%rdi,%rsi,4)
	leaq	degree(%rip), %rdi
	addl	$1, (%rdi,%rdx,4)
	movl	%edx, (%r14,%rsi,4)
.L48:
	cmpl	$-1, %eax
	je	.L49
	movl	76(%rsp), %edx
	leaq	sibling(%rip), %rdi
	movl	v(%rip), %r9d
	addl	$1, %r15d
	movl	%ecx, (%rdi,%rax,4)
	leaq	degree(%rip), %rcx
	movl	%edx, (%r14,%rax,4)
	movslq	%edx, %rax
	addl	$1, (%rcx,%rax,4)
	cmpl	%r15d, %r9d
	jg	.L52
.L51:
	testl	%r9d, %r9d
	jle	.L46
	xorl	%r15d, %r15d
	movl	%r9d, %r12d
	.p2align 4,,10
	.p2align 3
.L53:
	movl	(%r14,%r15,4), %r11d
	movl	%r15d, 12(%rsp)
	cmpl	$-1, %r11d
	je	.L72
	movslq	%r11d, %rax
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L67:
	movslq	(%r14,%rax,4), %rax
	movl	%edx, %r13d
	addl	$1, %edx
	cmpl	$-1, %eax
	jne	.L67
.L66:
	movl	%r11d, 16(%rsp)
	xorl	%ebx, %ebx
	xorl	%r10d, %r10d
.L63:
	cmpl	%r15d, (%r14,%rbx,4)
	je	.L84
.L54:
	addq	$1, %rbx
	cmpl	%ebx, %r12d
	jg	.L63
	leaq	degree(%rip), %rax
	movl	16(%rsp), %r11d
	pushq	%r10
	.cfi_def_cfa_offset 168
	leaq	.LC2(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 176
	movl	(%rax,%r15,4), %r9d
	leaq	sibling(%rip), %rax
	movl	$1, %edi
	movl	28(%rsp), %edx
	movl	(%rax,%r15,4), %r8d
	movl	%r11d, %ecx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rdx
	.cfi_def_cfa_offset 168
	popq	%rcx
	.cfi_def_cfa_offset 160
	testl	%r13d, %r13d
	je	.L85
	leaq	degree(%rip), %rax
	movl	(%rax,%r15,4), %eax
	testl	%eax, %eax
	jne	.L69
	leaq	.LC4(%rip), %rdi
	call	puts@PLT
.L68:
	movl	v(%rip), %r12d
	addq	$1, %r15
	cmpl	%r15d, %r12d
	jg	.L53
.L46:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L86
	addq	$104, %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
.L84:
	.cfi_restore_state
	movl	%r10d, 20(%rsp)
	xorl	%ebp, %ebp
	xorl	%r11d, %r11d
.L62:
	cmpl	%ebx, (%r14,%rbp,4)
	je	.L87
.L55:
	addq	$1, %rbp
	cmpl	%ebp, %r12d
	jg	.L62
	movl	20(%rsp), %r10d
	leal	1(%r11), %eax
	cmpl	%eax, %r10d
	cmovl	%eax, %r10d
	jmp	.L54
	.p2align 4,,10
	.p2align 3
.L87:
	movq	%r15, %rcx
	xorl	%edx, %edx
	xorl	%r10d, %r10d
	movq	%rbx, %rsi
	movl	%r13d, %r8d
	movq	%rbp, %r15
.L61:
	cmpl	%r15d, (%r14,%rdx,4)
	je	.L88
.L56:
	addq	$1, %rdx
	cmpl	%edx, %r12d
	jg	.L61
	leal	1(%r10), %eax
	movq	%r15, %rbp
	movq	%rsi, %rbx
	movl	%r8d, %r13d
	cmpl	%eax, %r11d
	movq	%rcx, %r15
	cmovl	%eax, %r11d
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L88:
	xorl	%r13d, %r13d
	movq	%r15, %r9
	xorl	%ebx, %ebx
	movl	%r13d, %r15d
.L60:
	cmpl	%edx, (%r14,%rbx,4)
	je	.L89
.L57:
	addq	$1, %rbx
	cmpl	%ebx, %r12d
	jg	.L60
	movl	%r15d, %r13d
	movq	%r9, %r15
	leal	1(%r13), %eax
	cmpl	%eax, %r10d
	cmovl	%eax, %r10d
	jmp	.L56
	.p2align 4,,10
	.p2align 3
.L49:
	movl	v(%rip), %r9d
	addl	$1, %r15d
	cmpl	%r15d, %r9d
	jg	.L52
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L83:
	movslq	84(%rsp), %rax
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L69:
	leaq	.LC5(%rip), %rdi
	call	puts@PLT
	jmp	.L68
	.p2align 4,,10
	.p2align 3
.L85:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L68
	.p2align 4,,10
	.p2align 3
.L89:
	movl	%r15d, 32(%rsp)
	xorl	%ebp, %ebp
	xorl	%r13d, %r13d
	movq	%rcx, %r15
.L59:
	movl	%ebp, %edi
	cmpl	%ebx, (%r14,%rbp,4)
	je	.L90
.L58:
	addq	$1, %rbp
	cmpl	%ebp, %r12d
	jg	.L59
	movq	%r15, %rcx
	movl	32(%rsp), %r15d
	addl	$1, %r13d
	cmpl	%r13d, %r15d
	cmovl	%r13d, %r15d
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L90:
	movl	%r10d, 60(%rsp)
	movq	%rdx, 48(%rsp)
	movl	%r11d, 56(%rsp)
	movq	%r9, 40(%rsp)
	movl	%r8d, 36(%rsp)
	movq	%rsi, 24(%rsp)
	call	Height
	movl	60(%rsp), %r10d
	movq	48(%rsp), %rdx
	addl	$1, %eax
	movl	56(%rsp), %r11d
	movq	40(%rsp), %r9
	cmpl	%eax, %r13d
	movl	36(%rsp), %r8d
	movq	24(%rsp), %rsi
	cmovl	%eax, %r13d
	jmp	.L58
	.p2align 4,,10
	.p2align 3
.L72:
	xorl	%r13d, %r13d
	jmp	.L66
.L86:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	degree
	.bss
	.align 32
	.type	degree, @object
	.size	degree, 400004
degree:
	.zero	400004
	.globl	sibling
	.align 32
	.type	sibling, @object
	.size	sibling, 400004
sibling:
	.zero	400004
	.globl	parent
	.align 32
	.type	parent, @object
	.size	parent, 400004
parent:
	.zero	400004
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	Depth
	.type	Depth, @function
Depth:
.LFB24:
	.cfi_startproc
	endbr64
	leaq	parent(%rip), %rcx
	movslq	%edi, %rdi
	movl	$1, %edx
	xorl	%r8d, %r8d
	movslq	(%rcx,%rdi,4), %rax
	cmpl	$-1, %eax
	je	.L1
	.p2align 4,,10
	.p2align 3
.L2:
	movslq	(%rcx,%rax,4), %rax
	movl	%edx, %r8d
	addl	$1, %edx
	cmpl	$-1, %eax
	jne	.L2
.L1:
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	Depth, .-Depth
	.p2align 4
	.globl	Height
	.type	Height, @function
Height:
.LFB25:
	.cfi_startproc
	endbr64
	movl	v(%rip), %eax
	xorl	%r11d, %r11d
	testl	%eax, %eax
	jle	.L35
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movslq	%eax, %r9
	movl	%r11d, %eax
	movl	%edi, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%r9, %r11
	leaq	parent(%rip), %r10
	movl	%eax, %r9d
	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
	xorl	%ebx, %ebx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
.L25:
	cmpl	%r8d, (%r10,%rbx,4)
	je	.L38
.L12:
	addq	$1, %rbx
	cmpq	%rbx, %r11
	jne	.L25
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	%r9d, %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
.L38:
	.cfi_restore_state
	movl	%r8d, 8(%rsp)
	xorl	%esi, %esi
	xorl	%ebp, %ebp
	movl	%r9d, 4(%rsp)
	movl	%esi, %r9d
.L24:
	cmpl	%ebx, (%r10,%rbp,4)
	je	.L39
.L13:
	addq	$1, %rbp
	cmpq	%rbp, %r11
	jne	.L24
	movl	%r9d, %esi
	movl	4(%rsp), %r9d
	movl	8(%rsp), %r8d
	leal	1(%rsi), %eax
	cmpl	%eax, %r9d
	cmovl	%eax, %r9d
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L39:
	movl	%r9d, 12(%rsp)
	xorl	%r12d, %r12d
	xorl	%r8d, %r8d
.L23:
	cmpl	%ebp, (%r10,%r12,4)
	je	.L40
.L14:
	addq	$1, %r12
	cmpq	%r12, %r11
	jne	.L23
	movl	12(%rsp), %r9d
	leal	1(%r8), %eax
	cmpl	%eax, %r9d
	cmovl	%eax, %r9d
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L40:
	movl	%r8d, 24(%rsp)
	xorl	%r13d, %r13d
	xorl	%r9d, %r9d
.L22:
	cmpl	%r12d, (%r10,%r13,4)
	je	.L41
.L15:
	addq	$1, %r13
	cmpq	%r13, %r11
	jne	.L22
	movl	24(%rsp), %r8d
	leal	1(%r9), %eax
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rbx, 16(%rsp)
	xorl	%r14d, %r14d
	xorl	%r8d, %r8d
	movq	%rbp, %rdx
	movq	%r12, %rcx
.L21:
	cmpl	%r13d, (%r10,%r14,4)
	je	.L42
.L16:
	addq	$1, %r14
	cmpq	%r14, %r11
	jne	.L21
	leal	1(%r8), %eax
	movq	16(%rsp), %rbx
	movq	%rdx, %rbp
	movq	%rcx, %r12
	cmpl	%eax, %r9d
	cmovl	%eax, %r9d
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L35:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	movl	%r11d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L42:
	.cfi_def_cfa_offset 128
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	movq	%r13, %rsi
.L20:
	cmpl	%r14d, (%r10,%r15,4)
	je	.L43
.L17:
	addq	$1, %r15
	cmpq	%r15, %r11
	jne	.L20
	leal	1(%r12), %eax
	movq	%rsi, %r13
	cmpl	%eax, %r8d
	cmovl	%eax, %r8d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L43:
	xorl	%ebp, %ebp
	movl	%r12d, 28(%rsp)
	xorl	%ebx, %ebx
	movl	%r9d, %r13d
	movq	%r14, 32(%rsp)
	movl	%ebp, %r12d
	movl	%r8d, %r14d
	movq	%r11, %rbp
.L19:
	movl	%ebx, %edi
	cmpl	%r15d, (%r10,%rbx,4)
	je	.L44
.L18:
	addq	$1, %rbx
	cmpq	%rbx, %rbp
	jne	.L19
	movq	%rbp, %r11
	movl	%r12d, %ebp
	movl	28(%rsp), %r12d
	movl	%r14d, %r8d
	addl	$1, %ebp
	movq	32(%rsp), %r14
	movl	%r13d, %r9d
	cmpl	%ebp, %r12d
	cmovl	%ebp, %r12d
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L44:
	movq	%rsi, 56(%rsp)
	movq	%rcx, 48(%rsp)
	movq	%rdx, 40(%rsp)
	call	Height
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rcx
	leaq	parent(%rip), %r10
	addl	$1, %eax
	movq	40(%rsp), %rdx
	cmpl	%eax, %r12d
	cmovl	%eax, %r12d
	jmp	.L18
	.cfi_endproc
.LFE25:
	.size	Height, .-Height
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC2:
	.string	"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
	.section	.rodata.str1.1
.LC3:
	.string	"root"
.LC4:
	.string	"leaf"
.LC5:
	.string	"internal node"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	v(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	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	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	v(%rip), %rax
	testl	%eax, %eax
	jle	.L46
	leaq	0(,%rax,4), %r12
	movl	$255, %esi
	leaq	84(%rsp), %r13
	xorl	%r15d, %r15d
	leaq	parent(%rip), %r14
	movq	%r12, %rdx
	leaq	76(%rsp), %rbp
	movq	%r14, %rdi
	leaq	.LC1(%rip), %rbx
	call	memset@PLT
	movq	%r12, %rdx
	movl	$255, %esi
	leaq	sibling(%rip), %rdi
	call	memset@PLT
	movq	%r12, %rdx
	xorl	%esi, %esi
	leaq	degree(%rip), %rdi
	call	memset@PLT
	leaq	80(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L52:
	movq	%r13, %rcx
	movq	%r12, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	80(%rsp), %ecx
	cmpl	$-1, %ecx
	je	.L83
	movslq	84(%rsp), %rax
	movslq	76(%rsp), %rdx
	movslq	%ecx, %rsi
	leaq	sibling(%rip), %rdi
	movl	%eax, (%rdi,%rsi,4)
	leaq	degree(%rip), %rdi
	addl	$1, (%rdi,%rdx,4)
	movl	%edx, (%r14,%rsi,4)
.L48:
	cmpl	$-1, %eax
	je	.L49
	movl	76(%rsp), %edx
	leaq	sibling(%rip), %rdi
	movl	v(%rip), %r9d
	addl	$1, %r15d
	movl	%ecx, (%rdi,%rax,4)
	leaq	degree(%rip), %rcx
	movl	%edx, (%r14,%rax,4)
	movslq	%edx, %rax
	addl	$1, (%rcx,%rax,4)
	cmpl	%r15d, %r9d
	jg	.L52
.L51:
	testl	%r9d, %r9d
	jle	.L46
	xorl	%r15d, %r15d
	movl	%r9d, %r12d
	.p2align 4,,10
	.p2align 3
.L53:
	movl	(%r14,%r15,4), %r11d
	movl	%r15d, 12(%rsp)
	cmpl	$-1, %r11d
	je	.L72
	movslq	%r11d, %rax
	movl	$1, %edx
	.p2align 4,,10
	.p2align 3
.L67:
	movslq	(%r14,%rax,4), %rax
	movl	%edx, %r13d
	addl	$1, %edx
	cmpl	$-1, %eax
	jne	.L67
.L66:
	movl	%r11d, 16(%rsp)
	xorl	%ebx, %ebx
	xorl	%r10d, %r10d
.L63:
	cmpl	%r15d, (%r14,%rbx,4)
	je	.L84
.L54:
	addq	$1, %rbx
	cmpl	%ebx, %r12d
	jg	.L63
	leaq	degree(%rip), %rax
	movl	16(%rsp), %r11d
	pushq	%r10
	.cfi_def_cfa_offset 168
	leaq	.LC2(%rip), %rsi
	pushq	%r13
	.cfi_def_cfa_offset 176
	movl	(%rax,%r15,4), %r9d
	leaq	sibling(%rip), %rax
	movl	$1, %edi
	movl	28(%rsp), %edx
	movl	(%rax,%r15,4), %r8d
	movl	%r11d, %ecx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rdx
	.cfi_def_cfa_offset 168
	popq	%rcx
	.cfi_def_cfa_offset 160
	testl	%r13d, %r13d
	je	.L85
	leaq	degree(%rip), %rax
	movl	(%rax,%r15,4), %eax
	testl	%eax, %eax
	jne	.L69
	leaq	.LC4(%rip), %rdi
	call	puts@PLT
.L68:
	movl	v(%rip), %r12d
	addq	$1, %r15
	cmpl	%r15d, %r12d
	jg	.L53
.L46:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L86
	addq	$104, %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
.L84:
	.cfi_restore_state
	movl	%r10d, 20(%rsp)
	xorl	%ebp, %ebp
	xorl	%r11d, %r11d
.L62:
	cmpl	%ebx, (%r14,%rbp,4)
	je	.L87
.L55:
	addq	$1, %rbp
	cmpl	%ebp, %r12d
	jg	.L62
	movl	20(%rsp), %r10d
	leal	1(%r11), %eax
	cmpl	%eax, %r10d
	cmovl	%eax, %r10d
	jmp	.L54
	.p2align 4,,10
	.p2align 3
.L87:
	movq	%r15, %rcx
	xorl	%edx, %edx
	xorl	%r10d, %r10d
	movq	%rbx, %rsi
	movl	%r13d, %r8d
	movq	%rbp, %r15
.L61:
	cmpl	%r15d, (%r14,%rdx,4)
	je	.L88
.L56:
	addq	$1, %rdx
	cmpl	%edx, %r12d
	jg	.L61
	leal	1(%r10), %eax
	movq	%r15, %rbp
	movq	%rsi, %rbx
	movl	%r8d, %r13d
	cmpl	%eax, %r11d
	movq	%rcx, %r15
	cmovl	%eax, %r11d
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L88:
	xorl	%r13d, %r13d
	movq	%r15, %r9
	xorl	%ebx, %ebx
	movl	%r13d, %r15d
.L60:
	cmpl	%edx, (%r14,%rbx,4)
	je	.L89
.L57:
	addq	$1, %rbx
	cmpl	%ebx, %r12d
	jg	.L60
	movl	%r15d, %r13d
	movq	%r9, %r15
	leal	1(%r13), %eax
	cmpl	%eax, %r10d
	cmovl	%eax, %r10d
	jmp	.L56
	.p2align 4,,10
	.p2align 3
.L49:
	movl	v(%rip), %r9d
	addl	$1, %r15d
	cmpl	%r15d, %r9d
	jg	.L52
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L83:
	movslq	84(%rsp), %rax
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L69:
	leaq	.LC5(%rip), %rdi
	call	puts@PLT
	jmp	.L68
	.p2align 4,,10
	.p2align 3
.L85:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L68
	.p2align 4,,10
	.p2align 3
.L89:
	movl	%r15d, 32(%rsp)
	xorl	%ebp, %ebp
	xorl	%r13d, %r13d
	movq	%rcx, %r15
.L59:
	movl	%ebp, %edi
	cmpl	%ebx, (%r14,%rbp,4)
	je	.L90
.L58:
	addq	$1, %rbp
	cmpl	%ebp, %r12d
	jg	.L59
	movq	%r15, %rcx
	movl	32(%rsp), %r15d
	addl	$1, %r13d
	cmpl	%r13d, %r15d
	cmovl	%r13d, %r15d
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L90:
	movl	%r10d, 60(%rsp)
	movq	%rdx, 48(%rsp)
	movl	%r11d, 56(%rsp)
	movq	%r9, 40(%rsp)
	movl	%r8d, 36(%rsp)
	movq	%rsi, 24(%rsp)
	call	Height
	movl	60(%rsp), %r10d
	movq	48(%rsp), %rdx
	addl	$1, %eax
	movl	56(%rsp), %r11d
	movq	40(%rsp), %r9
	cmpl	%eax, %r13d
	movl	36(%rsp), %r8d
	movq	24(%rsp), %rsi
	cmovl	%eax, %r13d
	jmp	.L58
	.p2align 4,,10
	.p2align 3
.L72:
	xorl	%r13d, %r13d
	jmp	.L66
.L86:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	degree
	.bss
	.align 32
	.type	degree, @object
	.size	degree, 400004
degree:
	.zero	400004
	.globl	sibling
	.align 32
	.type	sibling, @object
	.size	sibling, 400004
sibling:
	.zero	400004
	.globl	parent
	.align 32
	.type	parent, @object
	.size	parent, 400004
parent:
	.zero	400004
	.globl	v
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
int v;
int parent[100001];
int sibling[100001];
int degree[100001];
int Depth(int i);
int Height(int i);
int main(){
  int i,j;
  int id, l, r;
  scanf("%d", &v);
  for(i = 0; i < v; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }
  for(i = 0; i < v; ++i) {
    scanf("%d %d %d", &id, &l, &r);
    if(l != -1){
      parent[l] = id;
      sibling[l] = r;
      ++degree[id];
    }
    if(r != -1){
      parent[r] = id;
      sibling[r] = l;
      ++degree[id];
    } }
  for(i = 0; i < v; ++i) {
    int depth = Depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, parent[i], sibling[i], degree[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(degree[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    } }
  return 0; }
           
           
           
int Depth(int i){
  if(parent[i] == -1) return 0;
  return Depth(parent[i]) + 1;
}
int Height(int i){
  int j, h;
  h = 0;
  for(j = 0; j < v; ++j){
    if(parent[j] == i){
      int tmp = Height(j) + 1;
      if(tmp > h){
	h = tmp;
      } }
  }
    return h; }


9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
 9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
node 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node
node 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf
node 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf
node 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node
node 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node
node 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf
node 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf
node 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf
 node 0: parent = -1, sibling = -1, degree = 2, depth = 0, height = 3, root
node 1: parent = 0, sibling = 4, degree = 2, depth = 1, height = 1, internal node
node 2: parent = 1, sibling = 3, degree = 0, depth = 2, height = 0, leaf
node 3: parent = 1, sibling = 2, degree = 0, depth = 2, height = 0, leaf
node 4: parent = 0, sibling = 1, degree = 2, depth = 1, height = 2, internal node
node 5: parent = 4, sibling = 8, degree = 2, depth = 2, height = 1, internal node
node 6: parent = 5, sibling = 7, degree = 0, depth = 3, height = 0, leaf
node 7: parent = 5, sibling = 6, degree = 0, depth = 3, height = 0, leaf
node 8: parent = 4, sibling = 5, degree = 0, depth = 2, height = 0, leaf

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

```c
#include <stdio.h>
int v;
int parent[100001];
int sibling[100001];
int degree[100001];
int Depth(int i);
int Height(int i);
int main(){
  int i,j;
  int id, l, r;
  scanf("%d", &v);
  for(i = 0; i < v; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }
  for(i = 0; i < v; ++i) {
    scanf("%d %d %d", &id, &l, &r);
    if(l != -1){
      parent[l] = id;
      sibling[l] = r;
      ++degree[id];
    }
    if(r != -1){
      parent[r] = id;
      sibling[r] = l;
      ++degree[id];
    } }
  for(i = 0; i < v; ++i) {
    int depth = Depth(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, parent[i], sibling[i], degree[i], depth, Height(i));
    if(depth == 0) {
      printf("root\n");
    } else if(degree[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    } }
  return 0; }
           
           
           
int Depth(int i){
  if(parent[i] == -1) return 0;
  return Depth(parent[i]) + 1;
}
int Height(int i){
  int j, h;
  h = 0;
  for(j = 0; j < v; ++j){
    if(parent[j] == i){
      int tmp = Height(j) + 1;
      if(tmp > h){
	h = tmp;
      } }
  }
    return h; }

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	v
	.bss
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	parent
	.align 32
	.type	parent, @object
	.size	parent, 400004
parent:
	.zero	400004
	.globl	sibling
	.align 32
	.type	sibling, @object
	.size	sibling, 400004
sibling:
	.zero	400004
	.globl	degree
	.align 32
	.type	degree, @object
	.size	degree, 400004
degree:
	.zero	400004
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
	.align 8
.LC2:
	.string	"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
.LC3:
	.string	"root"
.LC4:
	.string	"leaf"
.LC5:
	.string	"internal node"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	v(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sibling(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L2:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L3
	movl	$0, -16(%rbp)
	jmp	.L4
.L7:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cmpl	$-1, %eax
	je	.L5
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	parent(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sibling(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	degree(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L5:
	movl	-20(%rbp), %eax
	cmpl	$-1, %eax
	je	.L6
	movl	-20(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	parent(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sibling(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	degree(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L6:
	addl	$1, -16(%rbp)
.L4:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L7
	movl	$0, -16(%rbp)
	jmp	.L8
.L12:
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	Depth
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	Height
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	(%rdx,%rax), %edi
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sibling(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-12(%rbp), %r8d
	movl	-16(%rbp), %eax
	subq	$8, %rsp
	pushq	%rsi
	movl	%r8d, %r9d
	movl	%edi, %r8d
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addq	$16, %rsp
	cmpl	$0, -12(%rbp)
	jne	.L9
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L11
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L11:
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	addl	$1, -16(%rbp)
.L8:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L12
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	Depth
	.type	Depth, @function
Depth:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	jne	.L16
	movl	$0, %eax
	jmp	.L17
.L16:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	Depth
	addl	$1, %eax
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Depth, .-Depth
	.globl	Height
	.type	Height, @function
Height:
.LFB2:
	.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	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L19
.L21:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	Height
	addl	$1, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L20
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L20:
	addl	$1, -12(%rbp)
.L19:
	movl	v(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L21
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Height, .-Height
	.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	v
	.bss
	.align 4
	.type	v, @object
	.size	v, 4
v:
	.zero	4
	.globl	parent
	.align 32
	.type	parent, @object
	.size	parent, 400004
parent:
	.zero	400004
	.globl	sibling
	.align 32
	.type	sibling, @object
	.size	sibling, 400004
sibling:
	.zero	400004
	.globl	degree
	.align 32
	.type	degree, @object
	.size	degree, 400004
degree:
	.zero	400004
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d %d"
	.align 8
.LC2:
	.string	"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, "
.LC3:
	.string	"root"
.LC4:
	.string	"leaf"
.LC5:
	.string	"internal node"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	v(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L2
.L3:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sibling(%rip), %rax
	movl	$-1, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L2:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L3
	movl	$0, -16(%rbp)
	jmp	.L4
.L7:
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	cmpl	$-1, %eax
	je	.L5
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	parent(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %edx
	movl	-20(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sibling(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	degree(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L5:
	movl	-20(%rbp), %eax
	cmpl	$-1, %eax
	je	.L6
	movl	-20(%rbp), %edx
	movl	-28(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	parent(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	sibling(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	degree(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L6:
	addl	$1, -16(%rbp)
.L4:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L7
	movl	$0, -16(%rbp)
	jmp	.L8
.L12:
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	Depth
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, %edi
	call	Height
	movl	%eax, %esi
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	(%rdx,%rax), %edi
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	sibling(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-12(%rbp), %r8d
	movl	-16(%rbp), %eax
	subq	$8, %rsp
	pushq	%rsi
	movl	%r8d, %r9d
	movl	%edi, %r8d
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addq	$16, %rsp
	cmpl	$0, -12(%rbp)
	jne	.L9
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L9:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	degree(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L11
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L10
.L11:
	leaq	.LC5(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	addl	$1, -16(%rbp)
.L8:
	movl	v(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L12
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	Depth
	.type	Depth, @function
Depth:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$-1, %eax
	jne	.L16
	movl	$0, %eax
	jmp	.L17
.L16:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %edi
	call	Depth
	addl	$1, %eax
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	Depth, .-Depth
	.globl	Height
	.type	Height, @function
Height:
.LFB2:
	.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	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L19
.L21:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	parent(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L20
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	Height
	addl	$1, %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jle	.L20
	movl	-4(%rbp), %eax
	movl	%eax, -8(%rbp)
.L20:
	addl	$1, -12(%rbp)
.L19:
	movl	v(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L21
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	Height, .-Height
	.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:
