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>

#define N_MAX 200

/* 正方形の位置を記録する構造体 */
typedef struct {
  int x;
  int y;
} Square;

int main(void) {
  int N;
  
 
  
  while(scanf("%d", &N) != EOF) { // 作品の制作手数を読み込む
    /* x,y座標で最大と最小を記録しておく */
    int max_x = 0;
    int min_x = 0;
    int max_y = 0;
    int min_y = 0;
    
    int i;

    /* 一番最初の正方形を(0,0)として，付け足してゆく正方形の座標を測る */
    Square sqrs[N_MAX];
    sqrs[0].x = 0;
    sqrs[0].y = 0;
    
    if (N == 0)
      break; // Nが0だったら終了

    for (i=1; i<N; i++) { // 制作手順を一行ずつ読んで，正方形を付け足してゆく
      int x, y; // 新しく付け足す正方形の座標
      int n, d; // 新しい正方形を付け足すすでにある正方形の番号と，正方形付け足す向き
      scanf("%d %d", &n, &d); // 手順を読み込む

      x = sqrs[n].x; // 付け足す元の正方形の座標を読み込んでおく
      y = sqrs[n].y;
      /* 指定された向きより付けたす正方形の座標を決める */
      switch(d) {
      case 0: // 左側
	x--;
	break;
      case 1: // 下側
	y--;
	break;
      case 2: // 右側
	x++;
	break;
      case 3: // 上川
	y++;
	break;
      }

      /* 新しく付け足す正方形の座標を代入*/
      sqrs[i].x = x;
      sqrs[i].y = y;

      /* 新しく付け足す正方形の座標が最大，最小であれば，更新 */
      if (x > max_x) {
	max_x = x;
      } else if (x < min_x) {
	min_x = x;
      }
      if (y > max_y) {
	max_y = y;
      } else if (y < min_y) {
	min_y = y;
      }

    }

    /* 作品の幅と高さは，x,y座標それぞれぞれの最大と最小の差+1（正方形の中心を座標としてとっているため） */
    printf("%d %d\n", max_x-min_x+1, max_y-min_y+1);
  }
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d"
	.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	$1664, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L16:
	movl	$0, -1644(%rbp)
	movl	$0, -1640(%rbp)
	movl	$0, -1636(%rbp)
	movl	$0, -1632(%rbp)
	movl	$0, -1616(%rbp)
	movl	$0, -1612(%rbp)
	movl	-1656(%rbp), %eax
	testl	%eax, %eax
	je	.L19
	movl	$1, -1628(%rbp)
	jmp	.L5
.L15:
	leaq	-1648(%rbp), %rdx
	leaq	-1652(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1652(%rbp), %eax
	cltq
	movl	-1616(%rbp,%rax,8), %eax
	movl	%eax, -1624(%rbp)
	movl	-1652(%rbp), %eax
	cltq
	movl	-1612(%rbp,%rax,8), %eax
	movl	%eax, -1620(%rbp)
	movl	-1648(%rbp), %eax
	cmpl	$3, %eax
	je	.L6
	cmpl	$3, %eax
	jg	.L7
	cmpl	$2, %eax
	je	.L8
	cmpl	$2, %eax
	jg	.L7
	testl	%eax, %eax
	je	.L9
	cmpl	$1, %eax
	je	.L10
	jmp	.L7
.L9:
	subl	$1, -1624(%rbp)
	jmp	.L7
.L10:
	subl	$1, -1620(%rbp)
	jmp	.L7
.L8:
	addl	$1, -1624(%rbp)
	jmp	.L7
.L6:
	addl	$1, -1620(%rbp)
	nop
.L7:
	movl	-1628(%rbp), %eax
	cltq
	movl	-1624(%rbp), %edx
	movl	%edx, -1616(%rbp,%rax,8)
	movl	-1628(%rbp), %eax
	cltq
	movl	-1620(%rbp), %edx
	movl	%edx, -1612(%rbp,%rax,8)
	movl	-1624(%rbp), %eax
	cmpl	-1644(%rbp), %eax
	jle	.L11
	movl	-1624(%rbp), %eax
	movl	%eax, -1644(%rbp)
	jmp	.L12
.L11:
	movl	-1624(%rbp), %eax
	cmpl	-1640(%rbp), %eax
	jge	.L12
	movl	-1624(%rbp), %eax
	movl	%eax, -1640(%rbp)
.L12:
	movl	-1620(%rbp), %eax
	cmpl	-1636(%rbp), %eax
	jle	.L13
	movl	-1620(%rbp), %eax
	movl	%eax, -1636(%rbp)
	jmp	.L14
.L13:
	movl	-1620(%rbp), %eax
	cmpl	-1632(%rbp), %eax
	jge	.L14
	movl	-1620(%rbp), %eax
	movl	%eax, -1632(%rbp)
.L14:
	addl	$1, -1628(%rbp)
.L5:
	movl	-1656(%rbp), %eax
	cmpl	%eax, -1628(%rbp)
	jl	.L15
	movl	-1636(%rbp), %eax
	subl	-1632(%rbp), %eax
	leal	1(%rax), %edx
	movl	-1644(%rbp), %eax
	subl	-1640(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-1656(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L16
	jmp	.L4
.L19:
	nop
.L4:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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 %d"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d"
	.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
	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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1672, %rsp
	.cfi_def_cfa_offset 1728
	movq	%fs:40, %rax
	movq	%rax, 1656(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	24(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movq	$0, 48(%rsp)
	movl	36(%rsp), %eax
	testl	%eax, %eax
	je	.L14
	cmpl	$1, %eax
	jle	.L17
	leaq	48(%rsp), %rax
	movl	$1, %ebp
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	movq	%rax, 16(%rsp)
	leaq	44(%rsp), %r15
	leaq	40(%rsp), %r14
	movl	$0, 12(%rsp)
	movl	$0, 8(%rsp)
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L27:
	movl	12(%rsp), %esi
	cmpl	%edx, %esi
	cmovle	%esi, %edx
	movl	%edx, 12(%rsp)
	cmpl	%ebx, %eax
	jg	.L19
.L28:
	cmpl	%eax, %r13d
	cmovg	%eax, %r13d
	addq	$1, %rbp
	cmpl	%ebp, 36(%rsp)
	jle	.L26
.L13:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	40(%rsp), %rax
	movl	44(%rsp), %ecx
	movl	48(%rsp,%rax,8), %edx
	movl	52(%rsp,%rax,8), %eax
	cmpl	$2, %ecx
	je	.L5
	jg	.L6
	testl	%ecx, %ecx
	je	.L7
	cmpl	$1, %ecx
	jne	.L9
	subl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movq	16(%rsp), %rsi
	movd	%edx, %xmm0
	movd	%eax, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rsi,%rbp,8)
	cmpl	8(%rsp), %edx
	jle	.L27
	movl	%edx, 8(%rsp)
	cmpl	%ebx, %eax
	jle	.L28
.L19:
	movl	%eax, %ebx
	addq	$1, %rbp
	cmpl	%ebp, 36(%rsp)
	jg	.L13
.L26:
	movl	8(%rsp), %edx
	subl	%r13d, %ebx
	subl	12(%rsp), %edx
	leal	1(%rbx), %ecx
	addl	$1, %edx
.L4:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$3, %ecx
	sete	%cl
	movzbl	%cl, %ecx
	addl	%ecx, %eax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	subl	$1, %edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movq	1656(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$1672, %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
.L17:
	.cfi_restore_state
	movl	$1, %edx
	movl	$1, %ecx
	jmp	.L4
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d"
	.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
	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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$1672, %rsp
	.cfi_def_cfa_offset 1728
	movq	%fs:40, %rax
	movq	%rax, 1656(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	24(%rsp), %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L14
	movq	$0, 48(%rsp)
	movl	36(%rsp), %eax
	testl	%eax, %eax
	je	.L14
	cmpl	$1, %eax
	jle	.L17
	leaq	48(%rsp), %rax
	movl	$1, %ebp
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	movq	%rax, 16(%rsp)
	leaq	44(%rsp), %r15
	leaq	40(%rsp), %r14
	movl	$0, 12(%rsp)
	movl	$0, 8(%rsp)
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L27:
	movl	12(%rsp), %esi
	cmpl	%edx, %esi
	cmovle	%esi, %edx
	movl	%edx, 12(%rsp)
	cmpl	%ebx, %eax
	jg	.L19
.L28:
	cmpl	%eax, %r13d
	cmovg	%eax, %r13d
	addq	$1, %rbp
	cmpl	%ebp, 36(%rsp)
	jle	.L26
.L13:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	40(%rsp), %rax
	movl	44(%rsp), %ecx
	movl	48(%rsp,%rax,8), %edx
	movl	52(%rsp,%rax,8), %eax
	cmpl	$2, %ecx
	je	.L5
	jg	.L6
	testl	%ecx, %ecx
	je	.L7
	cmpl	$1, %ecx
	jne	.L9
	subl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movq	16(%rsp), %rsi
	movd	%edx, %xmm0
	movd	%eax, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rsi,%rbp,8)
	cmpl	8(%rsp), %edx
	jle	.L27
	movl	%edx, 8(%rsp)
	cmpl	%ebx, %eax
	jle	.L28
.L19:
	movl	%eax, %ebx
	addq	$1, %rbp
	cmpl	%ebp, 36(%rsp)
	jg	.L13
.L26:
	movl	8(%rsp), %edx
	subl	%r13d, %ebx
	subl	12(%rsp), %edx
	leal	1(%rbx), %ecx
	addl	$1, %edx
.L4:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$3, %ecx
	sete	%cl
	movzbl	%cl, %ecx
	addl	%ecx, %eax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L7:
	subl	$1, %edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L5:
	addl	$1, %edx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	movq	1656(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L29
	addq	$1672, %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
.L17:
	.cfi_restore_state
	movl	$1, %edx
	movl	$1, %ecx
	jmp	.L4
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

#include <stdio.h>

#define N_MAX 200

/* 正方形の位置を記録する構造体 */
typedef struct {
  int x;
  int y;
} Square;

int main(void) {
  int N;
  
 
  
  while(scanf("%d", &N) != EOF) { // 作品の制作手数を読み込む
    /* x,y座標で最大と最小を記録しておく */
    int max_x = 0;
    int min_x = 0;
    int max_y = 0;
    int min_y = 0;
    
    int i;

    /* 一番最初の正方形を(0,0)として，付け足してゆく正方形の座標を測る */
    Square sqrs[N_MAX];
    sqrs[0].x = 0;
    sqrs[0].y = 0;
    
    if (N == 0)
      break; // Nが0だったら終了

    for (i=1; i<N; i++) { // 制作手順を一行ずつ読んで，正方形を付け足してゆく
      int x, y; // 新しく付け足す正方形の座標
      int n, d; // 新しい正方形を付け足すすでにある正方形の番号と，正方形付け足す向き
      scanf("%d %d", &n, &d); // 手順を読み込む

      x = sqrs[n].x; // 付け足す元の正方形の座標を読み込んでおく
      y = sqrs[n].y;
      /* 指定された向きより付けたす正方形の座標を決める */
      switch(d) {
      case 0: // 左側
	x--;
	break;
      case 1: // 下側
	y--;
	break;
      case 2: // 右側
	x++;
	break;
      case 3: // 上川
	y++;
	break;
      }

      /* 新しく付け足す正方形の座標を代入*/
      sqrs[i].x = x;
      sqrs[i].y = y;

      /* 新しく付け足す正方形の座標が最大，最小であれば，更新 */
      if (x > max_x) {
	max_x = x;
      } else if (x < min_x) {
	min_x = x;
      }
      if (y > max_y) {
	max_y = y;
      } else if (y < min_y) {
	min_y = y;
      }

    }

    /* 作品の幅と高さは，x,y座標それぞれぞれの最大と最小の差+1（正方形の中心を座標としてとっているため） */
    printf("%d %d\n", max_x-min_x+1, max_y-min_y+1);
  }
}
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>

#define N_MAX 200

/* 正方形の位置を記録する構造体 */
typedef struct {
  int x;
  int y;
} Square;

int main(void) {
  int N;
  
 
  
  while(scanf("%d", &N) != EOF) { // 作品の制作手数を読み込む
    /* x,y座標で最大と最小を記録しておく */
    int max_x = 0;
    int min_x = 0;
    int max_y = 0;
    int min_y = 0;
    
    int i;

    /* 一番最初の正方形を(0,0)として，付け足してゆく正方形の座標を測る */
    Square sqrs[N_MAX];
    sqrs[0].x = 0;
    sqrs[0].y = 0;
    
    if (N == 0)
      break; // Nが0だったら終了

    for (i=1; i<N; i++) { // 制作手順を一行ずつ読んで，正方形を付け足してゆく
      int x, y; // 新しく付け足す正方形の座標
      int n, d; // 新しい正方形を付け足すすでにある正方形の番号と，正方形付け足す向き
      scanf("%d %d", &n, &d); // 手順を読み込む

      x = sqrs[n].x; // 付け足す元の正方形の座標を読み込んでおく
      y = sqrs[n].y;
      /* 指定された向きより付けたす正方形の座標を決める */
      switch(d) {
      case 0: // 左側
	x--;
	break;
      case 1: // 下側
	y--;
	break;
      case 2: // 右側
	x++;
	break;
      case 3: // 上川
	y++;
	break;
      }

      /* 新しく付け足す正方形の座標を代入*/
      sqrs[i].x = x;
      sqrs[i].y = y;

      /* 新しく付け足す正方形の座標が最大，最小であれば，更新 */
      if (x > max_x) {
	max_x = x;
      } else if (x < min_x) {
	min_x = x;
      }
      if (y > max_y) {
	max_y = y;
      } else if (y < min_y) {
	min_y = y;
      }

    }

    /* 作品の幅と高さは，x,y座標それぞれぞれの最大と最小の差+1（正方形の中心を座標としてとっているため） */
    printf("%d %d\n", max_x-min_x+1, max_y-min_y+1);
  }
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d"
	.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	$1664, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L16:
	movl	$0, -1644(%rbp)
	movl	$0, -1640(%rbp)
	movl	$0, -1636(%rbp)
	movl	$0, -1632(%rbp)
	movl	$0, -1616(%rbp)
	movl	$0, -1612(%rbp)
	movl	-1656(%rbp), %eax
	testl	%eax, %eax
	je	.L19
	movl	$1, -1628(%rbp)
	jmp	.L5
.L15:
	leaq	-1648(%rbp), %rdx
	leaq	-1652(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1652(%rbp), %eax
	cltq
	movl	-1616(%rbp,%rax,8), %eax
	movl	%eax, -1624(%rbp)
	movl	-1652(%rbp), %eax
	cltq
	movl	-1612(%rbp,%rax,8), %eax
	movl	%eax, -1620(%rbp)
	movl	-1648(%rbp), %eax
	cmpl	$3, %eax
	je	.L6
	cmpl	$3, %eax
	jg	.L7
	cmpl	$2, %eax
	je	.L8
	cmpl	$2, %eax
	jg	.L7
	testl	%eax, %eax
	je	.L9
	cmpl	$1, %eax
	je	.L10
	jmp	.L7
.L9:
	subl	$1, -1624(%rbp)
	jmp	.L7
.L10:
	subl	$1, -1620(%rbp)
	jmp	.L7
.L8:
	addl	$1, -1624(%rbp)
	jmp	.L7
.L6:
	addl	$1, -1620(%rbp)
	nop
.L7:
	movl	-1628(%rbp), %eax
	cltq
	movl	-1624(%rbp), %edx
	movl	%edx, -1616(%rbp,%rax,8)
	movl	-1628(%rbp), %eax
	cltq
	movl	-1620(%rbp), %edx
	movl	%edx, -1612(%rbp,%rax,8)
	movl	-1624(%rbp), %eax
	cmpl	-1644(%rbp), %eax
	jle	.L11
	movl	-1624(%rbp), %eax
	movl	%eax, -1644(%rbp)
	jmp	.L12
.L11:
	movl	-1624(%rbp), %eax
	cmpl	-1640(%rbp), %eax
	jge	.L12
	movl	-1624(%rbp), %eax
	movl	%eax, -1640(%rbp)
.L12:
	movl	-1620(%rbp), %eax
	cmpl	-1636(%rbp), %eax
	jle	.L13
	movl	-1620(%rbp), %eax
	movl	%eax, -1636(%rbp)
	jmp	.L14
.L13:
	movl	-1620(%rbp), %eax
	cmpl	-1632(%rbp), %eax
	jge	.L14
	movl	-1620(%rbp), %eax
	movl	%eax, -1632(%rbp)
.L14:
	addl	$1, -1628(%rbp)
.L5:
	movl	-1656(%rbp), %eax
	cmpl	%eax, -1628(%rbp)
	jl	.L15
	movl	-1636(%rbp), %eax
	subl	-1632(%rbp), %eax
	leal	1(%rax), %edx
	movl	-1644(%rbp), %eax
	subl	-1640(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-1656(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L16
	jmp	.L4
.L19:
	nop
.L4:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d"
	.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	$1664, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L2
.L16:
	movl	$0, -1644(%rbp)
	movl	$0, -1640(%rbp)
	movl	$0, -1636(%rbp)
	movl	$0, -1632(%rbp)
	movl	$0, -1616(%rbp)
	movl	$0, -1612(%rbp)
	movl	-1656(%rbp), %eax
	testl	%eax, %eax
	je	.L19
	movl	$1, -1628(%rbp)
	jmp	.L5
.L15:
	leaq	-1648(%rbp), %rdx
	leaq	-1652(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-1652(%rbp), %eax
	cltq
	movl	-1616(%rbp,%rax,8), %eax
	movl	%eax, -1624(%rbp)
	movl	-1652(%rbp), %eax
	cltq
	movl	-1612(%rbp,%rax,8), %eax
	movl	%eax, -1620(%rbp)
	movl	-1648(%rbp), %eax
	cmpl	$3, %eax
	je	.L6
	cmpl	$3, %eax
	jg	.L7
	cmpl	$2, %eax
	je	.L8
	cmpl	$2, %eax
	jg	.L7
	testl	%eax, %eax
	je	.L9
	cmpl	$1, %eax
	je	.L10
	jmp	.L7
.L9:
	subl	$1, -1624(%rbp)
	jmp	.L7
.L10:
	subl	$1, -1620(%rbp)
	jmp	.L7
.L8:
	addl	$1, -1624(%rbp)
	jmp	.L7
.L6:
	addl	$1, -1620(%rbp)
	nop
.L7:
	movl	-1628(%rbp), %eax
	cltq
	movl	-1624(%rbp), %edx
	movl	%edx, -1616(%rbp,%rax,8)
	movl	-1628(%rbp), %eax
	cltq
	movl	-1620(%rbp), %edx
	movl	%edx, -1612(%rbp,%rax,8)
	movl	-1624(%rbp), %eax
	cmpl	-1644(%rbp), %eax
	jle	.L11
	movl	-1624(%rbp), %eax
	movl	%eax, -1644(%rbp)
	jmp	.L12
.L11:
	movl	-1624(%rbp), %eax
	cmpl	-1640(%rbp), %eax
	jge	.L12
	movl	-1624(%rbp), %eax
	movl	%eax, -1640(%rbp)
.L12:
	movl	-1620(%rbp), %eax
	cmpl	-1636(%rbp), %eax
	jle	.L13
	movl	-1620(%rbp), %eax
	movl	%eax, -1636(%rbp)
	jmp	.L14
.L13:
	movl	-1620(%rbp), %eax
	cmpl	-1632(%rbp), %eax
	jge	.L14
	movl	-1620(%rbp), %eax
	movl	%eax, -1632(%rbp)
.L14:
	addl	$1, -1628(%rbp)
.L5:
	movl	-1656(%rbp), %eax
	cmpl	%eax, -1628(%rbp)
	jl	.L15
	movl	-1636(%rbp), %eax
	subl	-1632(%rbp), %eax
	leal	1(%rax), %edx
	movl	-1644(%rbp), %eax
	subl	-1640(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L2:
	leaq	-1656(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L16
	jmp	.L4
.L19:
	nop
.L4:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
