user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0xfa8,%rsp
  lea    D6(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x1f98(%rsp)
  xor    %eax,%eax
  lea    0x14(%rsp),%rsi
  call   <scanf@plt>
  mov    0x14(%rsp),%ebx
  movl   $0x1,0x24(%rsp)
  test   %ebx,%ebx
  js     L151
  movslq %ebx,%rax
  xor    %esi,%esi
  lea    0xfe0(%rsp),%rdi
  lea    0x4(,%rax,4),%rdx
  call   <memset@plt>
  test   %ebx,%ebx
  jle    L151
  mov    $0x1,%ebx
  xor    %r14d,%r14d
  lea    0x1c(%rsp),%r13
  lea    0x18(%rsp),%r12
  lea    D37(%rip),%rbp
  lea    0x20(%rsp),%r15
  jmp    L32
  nopl   0x0(%rax,%rax,1)
L172:
  movslq %eax,%rsi
  cmp    %eax,%r14d
  mov    0xfe0(%rsp,%rsi,4),%edx
  cmovl  %eax,%r14d
  lea    0x2(%rdx),%eax
  add    $0x1,%edx
  test   %ecx,%ecx
  cmovne %eax,%edx
  mov    %edx,0xfe0(%rsp,%rsi,4)
L49:
  mov    0x14(%rsp),%edx
  add    $0x1,%rbx
  cmp    %ebx,%edx
  jl     L67
L32:
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    (%r15,%rbx,4),%eax
  movslq 0x1c(%rsp),%rdx
  movslq 0x18(%rsp),%rsi
  add    $0x1,%eax
  mov    %rdx,%rcx
  mov    %eax,0x20(%rsp,%rdx,4)
  mov    %eax,0x20(%rsp,%rsi,4)
  test   %esi,%esi
  jne    L172
  test   %ecx,%ecx
  je     L49
  movslq %eax,%rdx
  addl   $0x1,0xfe0(%rsp,%rdx,4)
  cmp    %eax,%r14d
  mov    0x14(%rsp),%edx
  cmovl  %eax,%r14d
  add    $0x1,%rbx
  cmp    %ebx,%edx
  jge    L32
L67:
  test   %r14d,%r14d
  je     L76
  lea    -0x1(%r14),%eax
  cmp    $0x2,%eax
  jbe    L31
  mov    %r14d,%ecx
  lea    0xfe4(%rsp),%rax
  pxor   %xmm2,%xmm2
  shr    $0x2,%ecx
  sub    $0x1,%ecx
  shl    $0x4,%rcx
  lea    0xff4(%rsp,%rcx,1),%rcx
  nopl   0x0(%rax,%rax,1)
L143:
  movdqu (%rax),%xmm0
  add    $0x10,%rax
  movdqa %xmm0,%xmm1
  pcmpgtd %xmm2,%xmm1
  pand   %xmm1,%xmm0
  pandn  %xmm2,%xmm1
  movdqa %xmm1,%xmm2
  por    %xmm0,%xmm2
  cmp    %rcx,%rax
  jne    L143
  movdqa %xmm2,%xmm1
  mov    %r14d,%ecx
  psrldq $0x8,%xmm1
  and    $0xfffffffc,%ecx
  movdqa %xmm1,%xmm0
  lea    0x1(%rcx),%eax
  pcmpgtd %xmm2,%xmm0
  pand   %xmm0,%xmm1
  pandn  %xmm2,%xmm0
  por    %xmm1,%xmm0
  movdqa %xmm0,%xmm2
  psrldq $0x4,%xmm2
  movdqa %xmm2,%xmm1
  pcmpgtd %xmm0,%xmm1
  pand   %xmm1,%xmm2
  pandn  %xmm0,%xmm1
  por    %xmm2,%xmm1
  movd   %xmm1,%esi
  cmp    %r14d,%ecx
  je     L64
L85:
  movslq %eax,%rcx
  mov    0xfe0(%rsp,%rcx,4),%ecx
  cmp    %ecx,%esi
  cmovl  %ecx,%esi
  lea    0x1(%rax),%ecx
  cmp    %ecx,%r14d
  jl     L64
  movslq %ecx,%rcx
  mov    0xfe0(%rsp,%rcx,4),%ecx
  cmp    %ecx,%esi
  cmovl  %ecx,%esi
  add    $0x2,%eax
  cmp    %eax,%r14d
  jl     L64
  cltq
  mov    0xfe0(%rsp,%rax,4),%eax
  cmp    %eax,%esi
  cmovl  %eax,%esi
L64:
  cmp    $0x1,%edx
  je     L124
L149:
  mov    %r14d,%edx
  lea    D16(%rip),%rdi
  call   <printf@plt>
  mov    0x1f98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L146
  add    $0x1fa8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L124:
  lea    D28(%rip),%rdi
  mov    %esi,0xc(%rsp)
  call   <puts@plt>
  xor    %edi,%edi
  call   <exit@plt>
  mov    0xc(%rsp),%esi
  jmp    L149
L151:
  xor    %esi,%esi
  xor    %r14d,%r14d
  jmp    L149
L31:
  xor    %esi,%esi
  mov    $0x1,%eax
  jmp    L85
L76:
  xor    %esi,%esi
  jmp    L64
L146:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D6
data_type: string
name: unpack_data
arguments: data_label: D37
data_type: string
name: unpack_data
arguments: data_label: D16
data_type: string
name: unpack_data
arguments: data_label: D28
data_type: string

tool: D6: %d

tool: D37: %d %d

tool: D16: %d %d


tool: D28: 1 1

assistant: ```c
int main(int argc, const char *argv[]) {
  int lev[1005], wids[1005];
  int n, i, u, v, dep = 0, wid = 0;
  scanf("%d", &n);
  lev[1] = 1;
  for (i = 0; i <= n; i++)
    wids[i] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &u, &v);
    lev[u] = lev[v] = lev[i] + 1;
    u != 0 && (wids[lev[u]]++, lev[u] > dep && (dep = lev[u]));
    v != 0 && (wids[lev[v]]++, lev[v] > dep && (dep = lev[v]));
  }
  for (i = 1; i <= dep; i++)
    wids[i] > wid && (wid = wids[i]);
  n == 1 && (puts("1 1"), exit(0), 1);
  printf("%d %d\n", wid, dep);
  return 0;
}
```