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

```asm
<minCostBST>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,-0x50(%rbp)
  movslq %edx,%rsi
  mov    %edx,-0x78(%rbp)
  mov    %rsp,%rcx
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsi,%rax
  imul   %rsi,%rax
  lea    0xf(,%rax,4),%rdx
  mov    %rdx,%rax
  and    $0xfffffffffffff000,%rdx
  sub    %rdx,%rcx
  and    $0xfffffffffffffff0,%rax
  cmp    %rcx,%rsp
  je     L152
L159:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L159
L152:
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L12
L81:
  lea    0x0(,%rsi,4),%rax
  mov    -0x78(%rbp),%edx
  mov    -0x50(%rbp),%r8
  mov    %rsp,%r15
  shr    $0x2,%rax
  mov    %rax,%rdi
  mov    %rax,-0x58(%rbp)
  xor    %eax,%eax
  add    $0x1,%rdi
  test   %edx,%edx
  jle    L19
  nopw   0x0(%rax,%rax,1)
L136:
  movslq %eax,%rdx
  mov    (%r8,%rax,4),%ecx
  add    $0x1,%rax
  imul   %rdi,%rdx
  mov    %ecx,(%r15,%rdx,4)
  cmp    %rsi,%rax
  jne    L136
  cmpl   $0x1,-0x78(%rbp)
  jle    L19
  shl    $0x2,%rax
  movl   $0x2,-0x74(%rbp)
  mov    %rax,-0x80(%rbp)
  nopl   0x0(%rax)
L89:
  mov    -0x74(%rbp),%eax
  mov    %r15,-0x68(%rbp)
  xor    %edx,%edx
  lea    -0x1(%rax),%r12d
  mov    %r12d,%r14d
  nopl   0x0(%rax,%rax,1)
L61:
  mov    D5(%rip),%rsi
  movslq %edx,%rax
  movslq %r14d,%rdi
  mov    %edx,-0x44(%rbp)
  imul   -0x58(%rbp),%rax
  mov    %rdi,-0x60(%rbp)
  mov    (%rsi),%ecx
  mov    %edx,-0x48(%rbp)
  add    %rdi,%rax
  mov    %ecx,(%r15,%rax,4)
  lea    0x1(%rdx),%rax
  mov    %rax,-0x70(%rbp)
  cmp    %edx,%r14d
  jl     L147
  mov    %rax,%r13
  xor    %r12d,%r12d
  mov    %r15,%rax
  movslq -0x44(%rbp),%rbx
  mov    %r14d,%r15d
  imul   -0x58(%rbp),%rbx
  mov    %r12d,%r14d
  add    -0x60(%rbp),%rbx
  mov    %r13,%r12
  mov    %rax,%r13
  jmp    L27
  nopw   0x0(%rax,%rax,1)
L124:
  xor    %r14d,%r14d
  cmp    -0x48(%rbp),%r12d
  jle    L131
  mov    -0x68(%rbp),%rax
  mov    -0x4(%rax,%r12,4),%r14d
L131:
  add    $0x1,%r12
L27:
  lea    -0x1(%r12),%eax
  cmp    %eax,%r15d
  jle    L155
  movslq %r12d,%rax
  imul   -0x58(%rbp),%rax
  add    -0x60(%rbp),%rax
  add    0x0(%r13,%rax,4),%r14d
L155:
  mov    -0x44(%rbp),%esi
  mov    -0x50(%rbp),%rdi
  mov    %r15d,%edx
  call   <sum@plt>
  add    %r14d,%eax
  cmp    %eax,0x0(%r13,%rbx,4)
  jle    L157
  mov    %eax,0x0(%r13,%rbx,4)
L157:
  cmp    %r15d,%r12d
  jle    L124
  mov    %r15d,%r14d
  mov    %r13,%r15
L147:
  mov    -0x70(%rbp),%rdx
  mov    -0x78(%rbp),%eax
  add    $0x1,%r14d
  sub    -0x74(%rbp),%eax
  mov    -0x80(%rbp),%rsi
  lea    -0x1(%rdx),%ecx
  add    %rsi,-0x68(%rbp)
  cmp    %eax,%ecx
  jle    L61
  addl   $0x1,-0x74(%rbp)
  mov    -0x74(%rbp),%eax
  cmp    %eax,-0x78(%rbp)
  jge    L89
L19:
  mov    -0x78(%rbp),%eax
  sub    $0x1,%eax
  cltq
  mov    (%r15,%rax,4),%eax
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L112
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L12:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L81
L112:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int minCostBST(int keys[], int freq[], int size) {
  int cost[size][size];
  for (int i = 0; i < size; i++)
    cost[i][i] = freq[i];
  for (int leng = 2; leng <= size; leng++) {
    for (int i = 0; i <= size - leng + 1; i++) {
      int j = i + leng - 1;
      cost[i][j] = INT_MAX;
      for (int r = i; r <= j; r++) {
        int c = ((r > i) ? cost[i][r - 1] : 0) + ((r < j) ? cost[r + 1][j] : 0) + sum(freq, i, j);
        if (c < cost[i][j])
          cost[i][j] = c;
      }
    }
  }
  return cost[0][size - 1];
}
```