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

```asm
<coinChange>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %edx,-0x40(%rbp)
  mov    -0x40(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  movl   $0x0,(%rax)
  movl   $0x1,-0x24(%rbp)
  jmp    L59
L85:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x14(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x24(%rbp)
L59:
  mov    -0x24(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L85
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L24
L21:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x14(%rbp)
  jle    L110
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x1,(%rax)
L110:
  addl   $0x1,-0x20(%rbp)
L24:
  mov    -0x20(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L21
  movl   $0x1,-0x1c(%rbp)
  jmp    L75
L26:
  movl   $0x0,-0x18(%rbp)
  jmp    L37
L25:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x1c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jle    L30
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jl     L52
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  jmp    L126
L52:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    $0x1,%eax
L126:
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    %eax,(%rdx)
L30:
  addl   $0x1,-0x18(%rbp)
L37:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L25
  addl   $0x1,-0x1c(%rbp)
L75:
  mov    -0x1c(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jle    L26
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x14(%rbp)
  jne    L29
  mov    $0xffffffff,%eax
  jmp    L133
L29:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
L133:
  leave
  ret
```

assistant: ```c
int coinChange(int *coins, int coinsSize, int amount) {
  int max = amount + 1;
  int *cnts = (int *)malloc(max * sizeof(int));
  cnts[0] = 0;
  for (int i = 1; i < max; i++) {
    cnts[i] = max;
  }
  int n = coinsSize;
  for (int i = 0; i < n; i++) {
    if (coins[i] < max) {
      cnts[coins[i]] = 1;
    }
  }
  for (int i = 1; i <= amount; i++) {
    for (int j = 0; j < n; j++) {
      int prev = i - coins[j];
      if (prev >= 1) {
        cnts[i] = (cnts[i] < cnts[prev] + 1 ? cnts[i] : cnts[prev] + 1);
      }
    }
  }
  if (cnts[amount] == max)
    return -1;
  return cnts[amount];
}
```