user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<solve2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r12
  push   %rbx
  sub    $0x50,%rsp
  mov    %edi,-0x54(%rbp)
  mov    %esi,-0x58(%rbp)
  mov    %rdx,-0x60(%rbp)
  mov    %rcx,-0x68(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%r12
  mov    -0x58(%rbp),%eax
  lea    0x1(%rax),%ecx
  movslq %ecx,%rax
  sub    $0x1,%rax
  mov    %rax,-0x38(%rbp)
  movslq %ecx,%rax
  mov    %rax,%r14
  mov    $0x0,%r15d
  movslq %ecx,%rax
  lea    0x0(,%rax,4),%rbx
  movslq %ecx,%rax
  mov    %rax,%r10
  mov    $0x0,%r11d
  movslq %ecx,%rax
  mov    %rax,%r8
  mov    $0x0,%r9d
  movslq %ecx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%edi
  mov    $0x0,%edx
  div    %rdi
  imul   $0x10,%rax,%rax
  mov    %rax,%rsi
  and    $0xfffffffffffff000,%rsi
  mov    %rsp,%rdx
  sub    %rsi,%rdx
L114:
  cmp    %rdx,%rsp
  je     L109
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L114
L109:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L0
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L0:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x30(%rbp)
  movl   $0x0,-0x3c(%rbp)
  movslq %ecx,%rax
  shl    $0x3,%eax
  mov    %eax,%edx
  mov    -0x30(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0x40(%rbp)
  jmp    L144
L127:
  mov    -0x60(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x40(%rbp)
  jge    L33
  mov    %rbx,%rcx
  shr    $0x2,%rcx
  mov    -0x30(%rbp),%rax
  mov    -0x40(%rbp),%edx
  movslq %edx,%rsi
  mov    -0x3c(%rbp),%edx
  movslq %edx,%rdx
  imul   %rcx,%rdx
  add    %rsi,%rdx
  movl   $0x0,(%rax,%rdx,4)
  jmp    L46
L33:
  mov    %rbx,%rsi
  shr    $0x2,%rsi
  mov    -0x68(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x30(%rbp),%rax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rdi
  mov    -0x3c(%rbp),%ecx
  movslq %ecx,%rcx
  imul   %rsi,%rcx
  add    %rdi,%rcx
  mov    %edx,(%rax,%rcx,4)
L46:
  addl   $0x1,-0x40(%rbp)
L144:
  mov    -0x40(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jle    L127
  mov    -0x58(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %rbx,%rcx
  shr    $0x2,%rcx
  mov    -0x3c(%rbp),%eax
  cltq
  imul   %rcx,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <pvector@plt>
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0x3c(%rbp)
  movl   $0x1,-0x44(%rbp)
  jmp    L95
L137:
  movl   $0x0,-0x40(%rbp)
  jmp    L134
L101:
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x40(%rbp)
  jl     L57
  mov    %rbx,%rsi
  shr    $0x2,%rsi
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%edx
  mov    -0x30(%rbp),%rax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rcx
  movslq %edx,%rdx
  imul   %rsi,%rdx
  add    %rcx,%rdx
  mov    (%rax,%rdx,4),%edx
  mov    %rbx,%rsi
  shr    $0x2,%rsi
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%ecx
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdi
  mov    -0x60(%rbp),%rax
  add    %rdi,%rax
  mov    (%rax),%r8d
  mov    -0x40(%rbp),%eax
  sub    %r8d,%eax
  mov    %eax,%edi
  mov    -0x30(%rbp),%rax
  movslq %edi,%rdi
  movslq %ecx,%rcx
  imul   %rsi,%rcx
  add    %rdi,%rcx
  mov    (%rax,%rcx,4),%ecx
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rsi
  mov    -0x68(%rbp),%rax
  add    %rsi,%rax
  mov    (%rax),%eax
  add    %ecx,%eax
  cmp    %eax,%edx
  jl     L61
L57:
  mov    %rbx,%rdi
  shr    $0x2,%rdi
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%edx
  mov    %rbx,%rsi
  shr    $0x2,%rsi
  mov    -0x30(%rbp),%rax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rcx
  movslq %edx,%rdx
  imul   %rdi,%rdx
  add    %rcx,%rdx
  mov    (%rax,%rdx,4),%edx
  mov    -0x30(%rbp),%rax
  mov    -0x40(%rbp),%ecx
  movslq %ecx,%rdi
  mov    -0x3c(%rbp),%ecx
  movslq %ecx,%rcx
  imul   %rsi,%rcx
  add    %rdi,%rcx
  mov    %edx,(%rax,%rcx,4)
  jmp    L94
L61:
  mov    %rbx,%rcx
  shr    $0x2,%rcx
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%edx
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rsi
  mov    -0x60(%rbp),%rax
  add    %rsi,%rax
  mov    (%rax),%edi
  mov    -0x40(%rbp),%eax
  sub    %edi,%eax
  mov    %eax,%esi
  mov    -0x30(%rbp),%rax
  movslq %esi,%rsi
  movslq %edx,%rdx
  imul   %rcx,%rdx
  add    %rsi,%rdx
  mov    (%rax,%rdx,4),%edx
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x68(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  mov    %rbx,%rsi
  shr    $0x2,%rsi
  lea    (%rdx,%rax,1),%ecx
  mov    -0x30(%rbp),%rax
  mov    -0x40(%rbp),%edx
  movslq %edx,%rdi
  mov    -0x3c(%rbp),%edx
  movslq %edx,%rdx
  imul   %rsi,%rdx
  add    %rdi,%rdx
  mov    %ecx,(%rax,%rdx,4)
L94:
  addl   $0x1,-0x40(%rbp)
L134:
  mov    -0x40(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jle    L101
  mov    -0x58(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %rbx,%rcx
  shr    $0x2,%rcx
  mov    -0x3c(%rbp),%eax
  cltq
  imul   %rcx,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <pvector@plt>
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0x3c(%rbp)
  addl   $0x1,-0x44(%rbp)
L95:
  mov    -0x44(%rbp),%eax
  cmp    -0x54(%rbp),%eax
  jl     L137
  shr    $0x2,%rbx
  mov    %rbx,%rsi
  cmpl   $0x0,-0x3c(%rbp)
  sete   %al
  movzbl %al,%edx
  mov    -0x30(%rbp),%rax
  mov    -0x58(%rbp),%ecx
  movslq %ecx,%rcx
  movslq %edx,%rdx
  imul   %rsi,%rdx
  add    %rcx,%rdx
  mov    (%rax,%rdx,4),%eax
  mov    %r12,%rsp
  mov    -0x28(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L39
  call   <__stack_chk_fail@plt>
L39:
  lea    -0x20(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
int solve2(int n, int c, int weight[n], int profit[n]) {
  int i, j;
  int total[2][c + 1];
  int curr = 0;
  memset(total, 0, sizeof total);
  for (j = 0; j <= c; j++) {
    if (weight[0] > j) {
      total[curr][j] = 0;
    } else {
      total[curr][j] = profit[0];
    }
  }
  pvector(total[curr], c + 1);
  curr = !curr;
  for (i = 1; i < n; i++) {
    for (j = 0; j <= c; j++) {
      if ((j < weight[i]) || (total[!curr][j] >= total[!curr][j - weight[i]] + profit[i])) {
        total[curr][j] = total[!curr][j];
      } else {
        total[curr][j] = total[!curr][j - weight[i]] + profit[i];
      }
    }
    pvector(total[curr], c + 1);
    curr = !curr;
  }
  return total[!curr][c];
}
```