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

```asm
<knapSack>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    -0x40(%rbp),%rax
  add    $0x1,%rax
  shl    $0x3,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  movq   $0x0,-0x28(%rbp)
  jmp    L100
L43:
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  shl    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    -0x28(%rbp),%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    %rax,(%rdx)
  addq   $0x1,-0x28(%rbp)
L100:
  mov    -0x28(%rbp),%rax
  cmp    -0x40(%rbp),%rax
  jle    L43
  movq   $0x0,-0x28(%rbp)
  jmp    L75
L13:
  movq   $0x0,-0x20(%rbp)
  jmp    L12
L86:
  cmpq   $0x0,-0x28(%rbp)
  je     L17
  cmpq   $0x0,-0x20(%rbp)
  jne    L62
L17:
  mov    -0x28(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  jmp    L1
L62:
  mov    -0x28(%rbp),%rax
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  cmp    %rax,-0x20(%rbp)
  jl     L103
  mov    -0x28(%rbp),%rax
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x28(%rbp),%rdx
  shl    $0x2,%rdx
  lea    -0x4(%rdx),%rcx
  mov    -0x50(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%ecx
  mov    -0x28(%rbp),%rdx
  shl    $0x3,%rdx
  lea    -0x8(%rdx),%rsi
  mov    -0x18(%rbp),%rdx
  add    %rsi,%rdx
  mov    (%rdx),%rsi
  mov    -0x28(%rbp),%rdx
  shl    $0x2,%rdx
  lea    -0x4(%rdx),%rdi
  mov    -0x48(%rbp),%rdx
  add    %rdi,%rdx
  mov    (%rdx),%edx
  movslq %edx,%rdi
  mov    -0x20(%rbp),%rdx
  sub    %rdi,%rdx
  shl    $0x2,%rdx
  add    %rsi,%rdx
  mov    (%rdx),%edx
  add    %ecx,%edx
  mov    -0x28(%rbp),%rcx
  lea    0x0(,%rcx,8),%rsi
  mov    -0x18(%rbp),%rcx
  add    %rsi,%rcx
  mov    (%rcx),%rsi
  mov    -0x20(%rbp),%rcx
  shl    $0x2,%rcx
  lea    (%rsi,%rcx,1),%rbx
  mov    %eax,%esi
  mov    %edx,%edi
  call   <max@plt>
  mov    %eax,(%rbx)
  jmp    L1
L103:
  mov    -0x28(%rbp),%rax
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    -0x28(%rbp),%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  mov    -0x20(%rbp),%rdx
  shl    $0x2,%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
L1:
  addq   $0x1,-0x20(%rbp)
L12:
  mov    -0x20(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jle    L86
  addq   $0x1,-0x28(%rbp)
L75:
  mov    -0x28(%rbp),%rax
  cmp    -0x40(%rbp),%rax
  jle    L13
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int knapSack(long int W, long int N, int wt[], int val[]) {
  int **K;
  long int i, w;
  K = (int **)malloc((N + 1) * sizeof(int *));
  for (i = 0; i <= N; i++)
    K[i] = (int *)malloc((W + 1) * sizeof(int));
  for (i = 0; i <= N; i++) {
    for (w = 0; w <= W; w++) {
      if (i == 0 || w == 0)
        K[i][w] = 0;
      else if (wt[i - 1] <= w)
        K[i][w] = max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
      else
        K[i][w] = K[i - 1][w];
    }
  }
  return K[N][W];
}
```