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 n;
int ni[200],di[200];
int x[200]={0},y[200]={0};
int mx[4]={-1,0,1,0};
int my[4]={0,-1,0,1};
int max,mix,may,miy;

int main(void){
  int i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=1;i<n;i++)scanf("%d%d",&ni[i],&di[i]);
    max=0;
    mix=0;
    may=0;
    miy=0;
    for(i=1;i<n;i++){
      x[i]=x[ni[i]]+mx[di[i]];
      y[i]=y[ni[i]]+my[di[i]];
      if(x[i]>max)max=x[i];
      if(x[i]<mix)mix=x[i];
      if(y[i]>may)may=y[i];
      if(y[i]<miy)miy=y[i];
    }
    printf("%d %d\n",max-mix+1,may-miy+1);
  }
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	ni
	.align 32
	.type	ni, @object
	.size	ni, 800
ni:
	.zero	800
	.globl	di
	.align 32
	.type	di, @object
	.size	di, 800
di:
	.zero	800
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 800
x:
	.zero	800
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 800
y:
	.zero	800
	.globl	mx
	.data
	.align 16
	.type	mx, @object
	.size	mx, 16
mx:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	my
	.align 16
	.type	my, @object
	.size	my, 16
my:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	max
	.bss
	.align 4
	.type	max, @object
	.size	max, 4
max:
	.zero	4
	.globl	mix
	.align 4
	.type	mix, @object
	.size	mix, 4
mix:
	.zero	4
	.globl	may
	.align 4
	.type	may, @object
	.size	may, 4
may:
	.zero	4
	.globl	miy
	.align 4
	.type	miy, @object
	.size	miy, 4
miy:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.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	$16, %rsp
.L12:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L15
	movl	$1, -4(%rbp)
	jmp	.L4
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	ni(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
	movl	$0, max(%rip)
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	movl	$1, -4(%rbp)
	jmp	.L6
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ni(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ni(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	my(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	max(%rip), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, max(%rip)
.L7:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	mix(%rip), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, mix(%rip)
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	may(%rip), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, may(%rip)
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	miy(%rip), %eax
	cmpl	%eax, %edx
	jge	.L10
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, miy(%rip)
.L10:
	addl	$1, -4(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L11
	movl	may(%rip), %eax
	movl	miy(%rip), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	max(%rip), %eax
	movl	mix(%rip), %ecx
	subl	%ecx, %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L15:
	nop
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.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	ni(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	di(%rip), %r14
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L24
	cmpl	$1, %eax
	jle	.L3
	movl	$4, %ebx
	movl	$1, %ebp
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	(%r14,%rbx), %rdx
	leaq	(%r15,%rbx), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	n(%rip), %r8
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, %r8d
	jg	.L4
	movl	$0, max(%rip)
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	cmpl	$1, %r8d
	jle	.L16
	movb	$0, 12(%rsp)
	movl	$1, %eax
	xorl	%ebx, %ebx
	xorl	%ecx, %ecx
	movb	$0, 13(%rsp)
	xorl	%ebp, %ebp
	xorl	%edx, %edx
	leaq	mx(%rip), %r13
	movb	$0, 14(%rsp)
	leaq	x(%rip), %r11
	leaq	my(%rip), %r12
	movb	$0, 15(%rsp)
	leaq	y(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	(%r14,%rax,4), %r9
	movslq	(%r15,%rax,4), %rsi
	movl	(%r11,%rsi,4), %edi
	addl	0(%r13,%r9,4), %edi
	movl	(%r10,%rsi,4), %esi
	addl	(%r12,%r9,4), %esi
	movl	%edi, (%r11,%rax,4)
	cmpl	%edx, %edi
	jle	.L6
	movb	$1, 15(%rsp)
	movl	%edi, %edx
.L6:
	movl	%esi, (%r10,%rax,4)
	cmpl	%ebp, %edi
	jge	.L7
	movb	$1, 14(%rsp)
	movl	%edi, %ebp
.L7:
	cmpl	%ecx, %esi
	jle	.L8
	movb	$1, 13(%rsp)
	movl	%esi, %ecx
.L8:
	cmpl	%ebx, %esi
	jge	.L9
	movb	$1, 12(%rsp)
	movl	%esi, %ebx
.L9:
	addq	$1, %rax
	cmpq	%r8, %rax
	jne	.L10
	cmpb	$0, 12(%rsp)
	je	.L21
	cmpb	$0, 13(%rsp)
	movl	%ebx, miy(%rip)
	je	.L22
.L30:
	cmpb	$0, 14(%rsp)
	movl	%ecx, may(%rip)
	je	.L23
.L31:
	subl	%ebx, %ecx
	movl	%ebp, mix(%rip)
	addl	$1, %ecx
	cmpb	$0, 15(%rsp)
	je	.L29
.L14:
	movl	%edx, max(%rip)
	subl	%ebp, %edx
	addl	$1, %edx
.L5:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%ebx, %ebx
	cmpb	$0, 13(%rsp)
	jne	.L30
.L22:
	xorl	%ecx, %ecx
	cmpb	$0, 14(%rsp)
	jne	.L31
.L23:
	subl	%ebx, %ecx
	xorl	%ebp, %ebp
	addl	$1, %ecx
	cmpb	$0, 15(%rsp)
	jne	.L14
.L29:
	movl	$1, %edx
	subl	%ebp, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$24, %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
.L3:
	.cfi_restore_state
	movl	$0, max(%rip)
	movl	$1, %edx
	movl	$1, %ecx
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	jmp	.L5
.L16:
	movl	$1, %edx
	movl	$1, %ecx
	jmp	.L5
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	miy
	.bss
	.align 4
	.type	miy, @object
	.size	miy, 4
miy:
	.zero	4
	.globl	may
	.align 4
	.type	may, @object
	.size	may, 4
may:
	.zero	4
	.globl	mix
	.align 4
	.type	mix, @object
	.size	mix, 4
mix:
	.zero	4
	.globl	max
	.align 4
	.type	max, @object
	.size	max, 4
max:
	.zero	4
	.globl	my
	.data
	.align 16
	.type	my, @object
	.size	my, 16
my:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	mx
	.align 16
	.type	mx, @object
	.size	mx, 16
mx:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	y
	.bss
	.align 32
	.type	y, @object
	.size	y, 800
y:
	.zero	800
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 800
x:
	.zero	800
	.globl	di
	.align 32
	.type	di, @object
	.size	di, 800
di:
	.zero	800
	.globl	ni
	.align 32
	.type	ni, @object
	.size	ni, 800
ni:
	.zero	800
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.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	ni(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	di(%rip), %r14
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L24
	cmpl	$1, %eax
	jle	.L3
	movl	$4, %ebx
	movl	$1, %ebp
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	(%r14,%rbx), %rdx
	leaq	(%r15,%rbx), %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	n(%rip), %r8
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, %r8d
	jg	.L4
	movl	$0, max(%rip)
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	cmpl	$1, %r8d
	jle	.L16
	movb	$0, 12(%rsp)
	movl	$1, %eax
	xorl	%ebx, %ebx
	xorl	%ecx, %ecx
	movb	$0, 13(%rsp)
	xorl	%ebp, %ebp
	xorl	%edx, %edx
	leaq	mx(%rip), %r13
	movb	$0, 14(%rsp)
	leaq	x(%rip), %r11
	leaq	my(%rip), %r12
	movb	$0, 15(%rsp)
	leaq	y(%rip), %r10
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	(%r14,%rax,4), %r9
	movslq	(%r15,%rax,4), %rsi
	movl	(%r11,%rsi,4), %edi
	addl	0(%r13,%r9,4), %edi
	movl	(%r10,%rsi,4), %esi
	addl	(%r12,%r9,4), %esi
	movl	%edi, (%r11,%rax,4)
	cmpl	%edx, %edi
	jle	.L6
	movb	$1, 15(%rsp)
	movl	%edi, %edx
.L6:
	movl	%esi, (%r10,%rax,4)
	cmpl	%ebp, %edi
	jge	.L7
	movb	$1, 14(%rsp)
	movl	%edi, %ebp
.L7:
	cmpl	%ecx, %esi
	jle	.L8
	movb	$1, 13(%rsp)
	movl	%esi, %ecx
.L8:
	cmpl	%ebx, %esi
	jge	.L9
	movb	$1, 12(%rsp)
	movl	%esi, %ebx
.L9:
	addq	$1, %rax
	cmpq	%r8, %rax
	jne	.L10
	cmpb	$0, 12(%rsp)
	je	.L21
	cmpb	$0, 13(%rsp)
	movl	%ebx, miy(%rip)
	je	.L22
.L30:
	cmpb	$0, 14(%rsp)
	movl	%ecx, may(%rip)
	je	.L23
.L31:
	subl	%ebx, %ecx
	movl	%ebp, mix(%rip)
	addl	$1, %ecx
	cmpb	$0, 15(%rsp)
	je	.L29
.L14:
	movl	%edx, max(%rip)
	subl	%ebp, %edx
	addl	$1, %edx
.L5:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L21:
	xorl	%ebx, %ebx
	cmpb	$0, 13(%rsp)
	jne	.L30
.L22:
	xorl	%ecx, %ecx
	cmpb	$0, 14(%rsp)
	jne	.L31
.L23:
	subl	%ebx, %ecx
	xorl	%ebp, %ebp
	addl	$1, %ecx
	cmpb	$0, 15(%rsp)
	jne	.L14
.L29:
	movl	$1, %edx
	subl	%ebp, %edx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L24:
	addq	$24, %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
.L3:
	.cfi_restore_state
	movl	$0, max(%rip)
	movl	$1, %edx
	movl	$1, %ecx
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	jmp	.L5
.L16:
	movl	$1, %edx
	movl	$1, %ecx
	jmp	.L5
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	miy
	.bss
	.align 4
	.type	miy, @object
	.size	miy, 4
miy:
	.zero	4
	.globl	may
	.align 4
	.type	may, @object
	.size	may, 4
may:
	.zero	4
	.globl	mix
	.align 4
	.type	mix, @object
	.size	mix, 4
mix:
	.zero	4
	.globl	max
	.align 4
	.type	max, @object
	.size	max, 4
max:
	.zero	4
	.globl	my
	.data
	.align 16
	.type	my, @object
	.size	my, 16
my:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	mx
	.align 16
	.type	mx, @object
	.size	mx, 16
mx:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	y
	.bss
	.align 32
	.type	y, @object
	.size	y, 800
y:
	.zero	800
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 800
x:
	.zero	800
	.globl	di
	.align 32
	.type	di, @object
	.size	di, 800
di:
	.zero	800
	.globl	ni
	.align 32
	.type	ni, @object
	.size	ni, 800
ni:
	.zero	800
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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 n;
int ni[200],di[200];
int x[200]={0},y[200]={0};
int mx[4]={-1,0,1,0};
int my[4]={0,-1,0,1};
int max,mix,may,miy;

int main(void){
  int i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=1;i<n;i++)scanf("%d%d",&ni[i],&di[i]);
    max=0;
    mix=0;
    may=0;
    miy=0;
    for(i=1;i<n;i++){
      x[i]=x[ni[i]]+mx[di[i]];
      y[i]=y[ni[i]]+my[di[i]];
      if(x[i]>max)max=x[i];
      if(x[i]<mix)mix=x[i];
      if(y[i]>may)may=y[i];
      if(y[i]<miy)miy=y[i];
    }
    printf("%d %d\n",max-mix+1,may-miy+1);
  }
  return 0;
}

1
5
0 0
0 1
0 2
0 3
12
0 0
1 1
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 0
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 0
0 2
0 3
12
0 0
1 0
2 0
3 0
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 0
0 2
0 3
12
0 0
1 0
2 0
3 0
4 1
5 1
6 2
3 2
8 2
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 2
3 2
2 1
5 1
6 1
7 1
8 2
0
 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 2
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 1
5 1
6 2
7 2
8 2
9 3
10 3
10
0 2
1 2
2 1
3 2
2 1
5 1
6 1
7 1
8 2
0
 1
5
0 0
0 1
0 2
0 3
12
0 0
1 0
2 0
3 1
4 2
5 1
6 2
7 1
8 1
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0
 1
5
0 0
0 1
0 2
0 3
12
0 1
1 0
2 0
3 1
4 2
5 1
6 2
7 1
8 1
9 3
10 3
10
0 2
1 3
2 2
3 2
2 1
5 1
6 1
7 1
8 1
0

1 1
3 3
4 5
5 6
 1 1
3 3
4 4
4 6
 1 1
3 2
4 4
4 6
 1 1
3 2
5 3
4 6
 1 1
3 2
5 5
4 6
 1 1
3 3
4 4
5 5
 1 1
3 3
5 3
4 6
 1 1
3 3
4 4
4 5
 1 1
3 3
4 5
4 6
 1 1
3 3
3 6
4 6

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 n;
int ni[200],di[200];
int x[200]={0},y[200]={0};
int mx[4]={-1,0,1,0};
int my[4]={0,-1,0,1};
int max,mix,may,miy;

int main(void){
  int i,j;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=1;i<n;i++)scanf("%d%d",&ni[i],&di[i]);
    max=0;
    mix=0;
    may=0;
    miy=0;
    for(i=1;i<n;i++){
      x[i]=x[ni[i]]+mx[di[i]];
      y[i]=y[ni[i]]+my[di[i]];
      if(x[i]>max)max=x[i];
      if(x[i]<mix)mix=x[i];
      if(y[i]>may)may=y[i];
      if(y[i]<miy)miy=y[i];
    }
    printf("%d %d\n",max-mix+1,may-miy+1);
  }
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	ni
	.align 32
	.type	ni, @object
	.size	ni, 800
ni:
	.zero	800
	.globl	di
	.align 32
	.type	di, @object
	.size	di, 800
di:
	.zero	800
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 800
x:
	.zero	800
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 800
y:
	.zero	800
	.globl	mx
	.data
	.align 16
	.type	mx, @object
	.size	mx, 16
mx:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	my
	.align 16
	.type	my, @object
	.size	my, 16
my:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	max
	.bss
	.align 4
	.type	max, @object
	.size	max, 4
max:
	.zero	4
	.globl	mix
	.align 4
	.type	mix, @object
	.size	mix, 4
mix:
	.zero	4
	.globl	may
	.align 4
	.type	may, @object
	.size	may, 4
may:
	.zero	4
	.globl	miy
	.align 4
	.type	miy, @object
	.size	miy, 4
miy:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.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	$16, %rsp
.L12:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L15
	movl	$1, -4(%rbp)
	jmp	.L4
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	ni(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
	movl	$0, max(%rip)
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	movl	$1, -4(%rbp)
	jmp	.L6
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ni(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ni(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	my(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	max(%rip), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, max(%rip)
.L7:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	mix(%rip), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, mix(%rip)
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	may(%rip), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, may(%rip)
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	miy(%rip), %eax
	cmpl	%eax, %edx
	jge	.L10
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, miy(%rip)
.L10:
	addl	$1, -4(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L11
	movl	may(%rip), %eax
	movl	miy(%rip), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	max(%rip), %eax
	movl	mix(%rip), %ecx
	subl	%ecx, %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L15:
	nop
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	ni
	.align 32
	.type	ni, @object
	.size	ni, 800
ni:
	.zero	800
	.globl	di
	.align 32
	.type	di, @object
	.size	di, 800
di:
	.zero	800
	.globl	x
	.align 32
	.type	x, @object
	.size	x, 800
x:
	.zero	800
	.globl	y
	.align 32
	.type	y, @object
	.size	y, 800
y:
	.zero	800
	.globl	mx
	.data
	.align 16
	.type	mx, @object
	.size	mx, 16
mx:
	.long	-1
	.long	0
	.long	1
	.long	0
	.globl	my
	.align 16
	.type	my, @object
	.size	my, 16
my:
	.long	0
	.long	-1
	.long	0
	.long	1
	.globl	max
	.bss
	.align 4
	.type	max, @object
	.size	max, 4
max:
	.zero	4
	.globl	mix
	.align 4
	.type	mix, @object
	.size	mix, 4
mix:
	.zero	4
	.globl	may
	.align 4
	.type	may, @object
	.size	may, 4
may:
	.zero	4
	.globl	miy
	.align 4
	.type	miy, @object
	.size	miy, 4
miy:
	.zero	4
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d %d\n"
	.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	$16, %rsp
.L12:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L15
	movl	$1, -4(%rbp)
	jmp	.L4
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	ni(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L4:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
	movl	$0, max(%rip)
	movl	$0, mix(%rip)
	movl	$0, may(%rip)
	movl	$0, miy(%rip)
	movl	$1, -4(%rbp)
	jmp	.L6
.L11:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ni(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	mx(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ni(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	di(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	my(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	max(%rip), %eax
	cmpl	%eax, %edx
	jle	.L7
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, max(%rip)
.L7:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	mix(%rip), %eax
	cmpl	%eax, %edx
	jge	.L8
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	x(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, mix(%rip)
.L8:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	may(%rip), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, may(%rip)
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	miy(%rip), %eax
	cmpl	%eax, %edx
	jge	.L10
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, miy(%rip)
.L10:
	addl	$1, -4(%rbp)
.L6:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L11
	movl	may(%rip), %eax
	movl	miy(%rip), %edx
	subl	%edx, %eax
	leal	1(%rax), %edx
	movl	max(%rip), %eax
	movl	mix(%rip), %ecx
	subl	%ecx, %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L15:
	nop
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
