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    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%rsi
  lea    D7(%rip),%rdi
  call   <scanf@plt>
  mov    0x30(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %rax,0x20(%rsp)
  mov    0x30(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x10(%rsp)
  cmpl   $0x0,0x30(%rsp)
  jle    L46
  mov    $0x0,%ebx
  lea    D7(%rip),%r12
L72:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  add    $0x1,%ebx
  mov    0x30(%rsp),%eax
  add    $0x4,%rbp
  cmp    %ebx,%eax
  jg     L72
  test   %eax,%eax
  jle    L46
  mov    0x10(%rsp),%rbp
  mov    $0x0,%ebx
  lea    D7(%rip),%r12
L153:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  add    $0x1,%ebx
  add    $0x4,%rbp
  cmp    %ebx,0x30(%rsp)
  jg     L153
L46:
  lea    0x34(%rsp),%rsi
  lea    D7(%rip),%rdi
  call   <scanf@plt>
  mov    0x34(%rsp),%eax
  lea    0x1(%rax),%edi
  mov    0x30(%rsp),%esi
  call   <build_matrix@plt>
  mov    %rax,0x28(%rsp)
  mov    0x34(%rsp),%eax
  lea    0x1(%rax),%edi
  mov    0x30(%rsp),%esi
  call   <build_matrix@plt>
  mov    %rax,0x18(%rsp)
  cmpl   $0x0,0x30(%rsp)
  jle    L26
  mov    $0x0,%eax
L150:
  mov    0x18(%rsp),%rcx
  mov    (%rcx),%rdx
  movl   $0x0,(%rdx,%rax,4)
  add    $0x1,%rax
  cmp    %eax,0x30(%rsp)
  jg     L150
L26:
  mov    0x34(%rsp),%eax
  test   %eax,%eax
  jle    L100
  mov    0x28(%rsp),%rax
  add    $0x8,%rax
  mov    %rax,0x8(%rsp)
  mov    0x18(%rsp),%rax
  lea    0x8(%rax),%r13
  mov    $0x1,%r12d
  mov    $0x0,%r14d
  jmp    L65
L89:
  mov    %r13,(%rsp)
  mov    %rbx,%r15
  add    0x0(%r13),%r15
  mov    0x8(%rsp),%rax
  mov    %rbx,%rdx
  add    (%rax),%rdx
  call   <max@plt>
  mov    %eax,(%r15)
  add    $0x1,%ebp
  cmp    %ebp,0x30(%rsp)
  jle    L37
  mov    %r14d,%edi
  test   %ebp,%ebp
  jle    L134
  mov    (%rsp),%rax
  mov    (%rax),%rax
  mov    (%rax,%rbx,1),%edi
L134:
  add    $0x4,%rbx
L145:
  mov    %r14d,%esi
  mov    0x10(%rsp),%rcx
  mov    %r12d,%eax
  sub    (%rcx,%rbx,1),%eax
  js     L89
  cltq
  mov    0x18(%rsp),%rcx
  mov    (%rcx,%rax,8),%rax
  mov    0x20(%rsp),%rcx
  mov    (%rcx,%rbx,1),%esi
  add    -0x4(%rax,%rbx,1),%esi
  jmp    L89
L37:
  add    $0x1,%r12d
  mov    0x34(%rsp),%eax
  addq   $0x8,0x8(%rsp)
  add    $0x8,%r13
  cmp    %r12d,%eax
  jl     L100
L65:
  mov    $0x0,%ebx
  mov    $0x0,%ebp
  mov    %r14d,%edi
  cmpl   $0x0,0x30(%rsp)
  jg     L145
  jmp    L37
L100:
  lea    0x1(%rax),%edi
  mov    0x18(%rsp),%r15
  mov    %r15,%rdx
  mov    0x30(%rsp),%esi
  call   <print_matrix@plt>
  lea    D13(%rip),%rbx
  mov    %rbx,%rdi
  call   <puts@plt>
  mov    0x34(%rsp),%eax
  lea    0x1(%rax),%edi
  mov    0x28(%rsp),%r14
  mov    %r14,%rdx
  mov    0x30(%rsp),%esi
  call   <print_matrix@plt>
  lea    D49(%rip),%rdi
  call   <printf@plt>
  mov    %r14,%r8
  mov    %r15,%rcx
  mov    0x10(%rsp),%rdx
  mov    0x34(%rsp),%esi
  mov    0x30(%rsp),%edi
  call   <print_picked@plt>
  mov    %rbx,%rdi
  call   <puts@plt>
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L31
  mov    $0x0,%eax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L31:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D7
type_guessed: string
name: disassemble_data
arguments: data_tag: D13
type_guessed: string
name: disassemble_data
arguments: data_tag: D49
type_guessed: string

tool: D7: %d

tool: 

tool: D49: 
Picked: 

assistant: ```c
int main() {
  int i, j, x, y;
  int n, b;
  int *vs;
  int *ws;
  int **ps;
  int **zs;
  scanf("%d", &n);
  vs = (int *)malloc(sizeof(int) * n);
  ws = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++)
    scanf("%d", &vs[i]);
  for (i = 0; i < n; i++)
    scanf("%d", &ws[i]);
  scanf("%d", &b);
  ps = build_matrix(b + 1, n);
  zs = build_matrix(b + 1, n);
  for (i = 0; i < n; i++)
    zs[0][i] = 0;
  for (i = 1; i <= b; i++)
    for (j = 0; j < n; j++) {
      x = (j - 1 < 0) ? 0 : zs[i][j - 1];
      y = (i - ws[j] < 0) ? 0 : vs[j] + zs[i - ws[j]][j - 1];
      zs[i][j] = max(x, y, &ps[i][j]);
    }
  print_matrix(b + 1, n, zs);
  puts("");
  print_matrix(b + 1, n, ps);
  printf("\nPicked: ");
  print_picked(n, b, ws, zs, ps);
  puts("");
}
```