user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x688,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x678(%rsp)
  xor    %eax,%eax
  lea    0x24(%rsp),%rax
  mov    %rax,0x18(%rsp)
  lea    0x2c(%rsp),%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L51:
  mov    0x18(%rsp),%rsi
  lea    D8(%rip),%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x24(%rsp),%eax
  test   %eax,%eax
  je     L44
  movq   $0x0,0x30(%rsp)
  cmp    $0x1,%eax
  jle    L59
  lea    0x28(%rsp),%rax
  lea    0x38(%rsp),%rbx
  xor    %r12d,%r12d
  xor    %r15d,%r15d
  mov    %rax,0x8(%rsp)
  xor    %r13d,%r13d
  xor    %r14d,%r14d
  mov    $0x1,%ebp
  jmp    L131
  nopl   0x0(%rax,%rax,1)
L27:
  cmp    $0x1,%eax
  jne    L100
  movslq 0x28(%rsp),%rdx
  mov    0x34(%rsp,%rdx,8),%eax
  movd   0x30(%rsp,%rdx,8),%xmm0
  sub    $0x1,%eax
  movd   %eax,%xmm2
  punpckldq %xmm2,%xmm0
  movq   %xmm0,(%rbx)
L86:
  mov    (%rbx),%edx
  cmp    %edx,%r12d
  cmovl  %edx,%r12d
  cmp    %eax,%r15d
  cmovl  %eax,%r15d
  cmp    %edx,%r14d
  cmovg  %edx,%r14d
  cmp    %eax,%r13d
  cmovg  %eax,%r13d
  add    $0x1,%ebp
  add    $0x8,%rbx
  cmp    %ebp,0x24(%rsp)
  jle    L111
L131:
  mov    0x10(%rsp),%rdx
  mov    0x8(%rsp),%rsi
  lea    D25(%rip),%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x2c(%rsp),%eax
  cmp    $0x2,%eax
  je     L22
  jg     L2
  test   %eax,%eax
  jne    L27
  movslq 0x28(%rsp),%rdx
  mov    0x34(%rsp,%rdx,8),%eax
  mov    0x30(%rsp,%rdx,8),%edx
  lea    -0x1(%rdx),%ecx
  movd   %eax,%xmm1
  movd   %ecx,%xmm0
  punpckldq %xmm1,%xmm0
  movq   %xmm0,(%rbx)
  jmp    L86
  nopw   0x0(%rax,%rax,1)
L2:
  cmp    $0x3,%eax
  jne    L100
  movslq 0x28(%rsp),%rdx
  mov    0x34(%rsp,%rdx,8),%eax
  movd   0x30(%rsp,%rdx,8),%xmm0
  add    $0x1,%eax
  movd   %eax,%xmm4
  punpckldq %xmm4,%xmm0
  movq   %xmm0,(%rbx)
  jmp    L86
  nopl   0x0(%rax,%rax,1)
L22:
  movslq 0x28(%rsp),%rdx
  mov    0x34(%rsp,%rdx,8),%eax
  mov    0x30(%rsp,%rdx,8),%edx
  lea    0x1(%rdx),%ecx
  movd   %eax,%xmm3
  movd   %ecx,%xmm0
  punpckldq %xmm3,%xmm0
  movq   %xmm0,(%rbx)
  jmp    L86
  nopl   (%rax)
L100:
  mov    0x4(%rbx),%eax
  jmp    L86
L111:
  mov    %r12d,%eax
  mov    %r13d,%r12d
  mov    %r14d,%r13d
  mov    %eax,%r14d
  sub    %r12d,%r15d
  sub    %r13d,%r14d
  lea    0x1(%r15),%edx
  lea    0x1(%r14),%esi
L41:
  lea    D29(%rip),%rdi
  call   <printf@plt>
  jmp    L51
  nopl   0x0(%rax,%rax,1)
L44:
  mov    0x678(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L146
  add    $0x688,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L59:
  mov    $0x1,%esi
  mov    $0x1,%edx
  jmp    L41
L146:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D8
data_type: string
name: disassemble_data
arguments: data_label: D25
data_type: string
name: disassemble_data
arguments: data_label: D29
data_type: string

tool: D8: %d

tool: D25: %d %d

tool: D29: %d %d


assistant: ```c
int main(void) {
  int num, product[200][2], i, n, d, X, x, Y, y;
  while (1) {
    scanf("%d", &num);
    if (num == 0)
      break;
    product[0][0] = 0, product[0][1] = 0, X = 0, x = 0, Y = 0, y = 0;
    for (i = 1; i <= num - 1; i++) {
      scanf("%d %d", &n, &d);
      switch (d) {
      case 0:
        product[i][0] = product[n][0] - 1;
        product[i][1] = product[n][1];
        break;
      case 1:
        product[i][0] = product[n][0];
        product[i][1] = product[n][1] - 1;
        break;
      case 2:
        product[i][0] = product[n][0] + 1;
        product[i][1] = product[n][1];
        break;
      case 3:
        product[i][0] = product[n][0];
        product[i][1] = product[n][1] + 1;
        break;
      }
      if (product[i][0] > X)
        X = product[i][0];
      if (product[i][1] > Y)
        Y = product[i][1];
      if (product[i][0] < x)
        x = product[i][0];
      if (product[i][1] < y)
        y = product[i][1];
    }
    printf("%d %d\n", X - x + 1, Y - y + 1);
  }
  return 0;
}
```