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

```asm
<cubic_spline_sp>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %edi,%r15d
  mov    %esi,0x14(%rsp)
  mov    %rdx,%rbx
  mov    %rcx,%r13
  mov    %r8,0x28(%rsp)
  mov    %r9,0x30(%rsp)
  cmp    $0x1,%edi
  jle    L219
  mov    %rdx,%rbp
  lea    -0x2(%rdi),%eax
  lea    0x8(%rdx,%rax,8),%r12
  lea    D20(%rip),%r14
  jmp    L438
L63:
  add    $0x8,%rbp
  cmp    %r12,%rbp
  je     L364
L438:
  movsd  0x0(%rbp),%xmm0
  comisd 0x8(%rbp),%xmm0
  jb     L63
  mov    %r14,%rdi
  call   <error_handler@plt>
  jmp    L63
L294:
  mov    %r14,%rdi
  call   <error_handler@plt>
L390:
  add    $0x1,%rbp
  cmp    %ebp,%r15d
  jle    L205
L64:
  movsd  0x0(%r13,%rbp,8),%xmm0
  movsd  (%rbx),%xmm1
  comisd %xmm0,%xmm1
  ja     L294
  comisd (%r12),%xmm0
  jbe    L390
  jmp    L294
L205:
  mov    (%rsp),%r15d
  cmp    $0x1,%r15d
  jle    L15
  cmp    $0x2,%r15d
  je     L160
L231:
  lea    -0x1(%r15),%r12d
  movslq %r12d,%rbp
  lea    0x0(,%r12,8),%r14d
  mov    %r14d,0x8(%rsp)
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  lea    0x0(,%r15,8),%edi
  call   <malloc@plt>
  mov    %rax,%r14
  test   %r12d,%r12d
  jle    L377
  lea    -0x2(%r15),%eax
  mov    0x20(%rsp),%r9
  lea    0x8(%r9,%rax,8),%rdi
  mov    %r9,%rax
  mov    %rbx,%rcx
  sub    %r9,%rcx
  mov    0x28(%rsp),%rdx
  sub    %r9,%rdx
  mov    0x18(%rsp),%rsi
  sub    %r9,%rsi
L86:
  movsd  0x8(%rcx,%rax,1),%xmm1
  subsd  (%rcx,%rax,1),%xmm1
  movsd  %xmm1,(%rax)
  movsd  0x8(%rdx,%rax,1),%xmm0
  subsd  (%rdx,%rax,1),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rsi,%rax,1)
  add    $0x8,%rax
  cmp    %rdi,%rax
  jne    L86
L377:
  cmp    $0x1,%r12d
  jle    L182
  lea    0x8(%r14),%rax
  lea    -0x3(%r15),%edx
  lea    0x10(%r14,%rdx,8),%rsi
  mov    0x18(%rsp),%rdi
  mov    %rdi,%rcx
  sub    %r14,%rcx
  lea    -0x8(%rdi),%rdx
  sub    %r14,%rdx
  pxor   %xmm5,%xmm5
  mov    0x20(%rsp),%rdi
  mov    %rdi,%r8
  sub    %r14,%r8
  sub    $0x8,%rdi
  sub    %r14,%rdi
  jmp    L171
L160:
  mov    0x28(%rsp),%rcx
  movsd  0x8(%rcx),%xmm1
  subsd  (%rcx),%xmm1
  movsd  0x8(%rbx),%xmm0
  subsd  (%rbx),%xmm0
  divsd  %xmm0,%xmm1
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L413
  mov    %eax,%edx
  mov    $0x0,%eax
  mov    0x30(%rsp),%rsi
L363:
  movsd  0x0(%r13,%rax,8),%xmm0
  subsd  (%rbx),%xmm0
  mulsd  %xmm1,%xmm0
  addsd  (%rcx),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L363
  jmp    L413
L38:
  movq   $0x0,(%rax)
L28:
  add    $0x8,%rax
  cmp    %rsi,%rax
  je     L182
L171:
  movsd  (%rcx,%rax,1),%xmm2
  movsd  (%rdx,%rax,1),%xmm3
  movapd %xmm2,%xmm0
  mulsd  %xmm3,%xmm0
  comisd %xmm5,%xmm0
  jbe    L38
  movsd  (%r8,%rax,1),%xmm4
  movsd  (%rdi,%rax,1),%xmm0
  movapd %xmm4,%xmm1
  addsd  %xmm4,%xmm1
  addsd  %xmm0,%xmm1
  addsd  %xmm0,%xmm0
  addsd  %xmm4,%xmm0
  movapd %xmm1,%xmm4
  addsd  %xmm0,%xmm4
  divsd  %xmm3,%xmm1
  divsd  %xmm2,%xmm0
  addsd  %xmm0,%xmm1
  divsd  %xmm1,%xmm4
  movsd  %xmm4,(%rax)
  jmp    L28
L182:
  mov    0x20(%rsp),%rax
  movsd  (%rax),%xmm1
  movsd  0x8(%rax),%xmm2
  movapd %xmm1,%xmm0
  addsd  %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  mov    0x18(%rsp),%rax
  mulsd  (%rax),%xmm0
  movapd %xmm1,%xmm3
  mulsd  0x8(%rax),%xmm3
  subsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%r14)
  movsd  (%rax),%xmm1
  movapd %xmm0,%xmm2
  mulsd  %xmm1,%xmm2
  pxor   %xmm3,%xmm3
  comisd %xmm2,%xmm3
  ja     L104
  mov    0x18(%rsp),%rax
  mulsd  0x8(%rax),%xmm1
  pxor   %xmm2,%xmm2
  comisd %xmm1,%xmm2
  ja     L289
L352:
  shl    $0x3,%rbp
  mov    0x20(%rsp),%rax
  movsd  -0x8(%rax,%rbp,1),%xmm1
  movsd  -0x10(%rax,%rbp,1),%xmm2
  mov    0x18(%rsp),%rax
  lea    -0x8(%rax,%rbp,1),%rcx
  mov    %rcx,(%rsp)
  lea    -0x10(%rax,%rbp,1),%rax
  add    %r14,%rbp
  movapd %xmm1,%xmm0
  addsd  %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  mulsd  (%rcx),%xmm0
  movapd %xmm1,%xmm3
  mulsd  (%rax),%xmm3
  subsd  %xmm3,%xmm0
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x0(%rbp)
  movsd  (%rcx),%xmm1
  movapd %xmm0,%xmm2
  mulsd  %xmm1,%xmm2
  pxor   %xmm3,%xmm3
  comisd %xmm2,%xmm3
  ja     L9
  mulsd  (%rax),%xmm1
  pxor   %xmm2,%xmm2
  comisd %xmm1,%xmm2
  ja     L57
L283:
  mov    0x8(%rsp),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %rax,(%rsp)
  mov    0x8(%rsp),%edi
  call   <malloc@plt>
  mov    %rax,%rsi
  mov    %rax,0x8(%rsp)
  test   %r12d,%r12d
  jle    L100
  lea    -0x2(%r15),%eax
  lea    0x8(%r14,%rax,8),%r9
  mov    %r14,%rax
  mov    0x18(%rsp),%r8
  sub    %r14,%r8
  mov    0x20(%rsp),%rdi
  sub    %r14,%rdi
  sub    %r14,%rsi
  movsd  D33(%rip),%xmm3
  mov    %rbp,%rcx
  sub    %r14,%rcx
L385:
  lea    (%r8,%rax,1),%r10
  mov    %rax,%rdx
  add    $0x8,%rax
  lea    (%rdi,%rdx,1),%r11
  movapd %xmm3,%xmm0
  mulsd  (%r10),%xmm0
  movsd  (%rdx),%xmm1
  addsd  %xmm1,%xmm1
  subsd  %xmm1,%xmm0
  subsd  (%rax),%xmm0
  divsd  (%r11),%xmm0
  movsd  %xmm0,(%rsi,%rdx,1)
  movsd  (%r11),%xmm1
  movsd  (%r10),%xmm2
  addsd  %xmm2,%xmm2
  movsd  (%rdx),%xmm0
  subsd  %xmm2,%xmm0
  addsd  (%rax),%xmm0
  mulsd  %xmm1,%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rcx,%rdx,1)
  cmp    %r9,%rax
  jne    L385
L100:
  mov    0x14(%rsp),%eax
  test   %eax,%eax
  jle    L335
  mov    %r13,%rbp
  mov    0x30(%rsp),%r12
  lea    -0x1(%rax),%eax
  lea    0x8(%r13,%rax,8),%r13
  mov    %r15d,0x14(%rsp)
  mov    0x28(%rsp),%r15
  jmp    L208
L104:
  movq   $0x0,(%r14)
  jmp    L352
L289:
  call   <fabs@plt>
  mov    %rax,(%rsp)
  movsd  D33(%rip),%xmm0
  mov    0x18(%rsp),%rsi
  mulsd  (%rsi),%xmm0
  call   <fabs@plt>
  cmp    %rax,(%rsp)
  jle    L352
  movsd  D33(%rip),%xmm0
  mov    0x18(%rsp),%rsi
  mulsd  (%rsi),%xmm0
  movsd  %xmm0,(%r14)
  jmp    L352
L9:
  movq   $0x0,0x0(%rbp)
  jmp    L283
L57:
  call   <fabs@plt>
  mov    %rax,0x38(%rsp)
  movsd  D33(%rip),%xmm0
  mov    (%rsp),%rsi
  mulsd  (%rsi),%xmm0
  call   <fabs@plt>
  cmp    %rax,0x38(%rsp)
  jle    L283
  movsd  D33(%rip),%xmm0
  mov    (%rsp),%rsi
  mulsd  (%rsi),%xmm0
  movsd  %xmm0,0x0(%rbp)
  jmp    L283
L102:
  cltq
  subsd  (%rbx,%rax,8),%xmm1
  mov    (%rsp),%rcx
  movapd %xmm1,%xmm0
  mulsd  (%rcx,%rax,8),%xmm0
  mov    0x8(%rsp),%rsi
  addsd  (%rsi,%rax,8),%xmm0
  mulsd  %xmm1,%xmm0
  addsd  (%r14,%rax,8),%xmm0
  mulsd  %xmm1,%xmm0
  addsd  (%r15,%rax,8),%xmm0
  movsd  %xmm0,(%r12)
  add    $0x8,%rbp
  add    $0x8,%r12
  cmp    %rbp,%r13
  je     L335
L208:
  mov    0x14(%rsp),%esi
  mov    %rbx,%rdi
  movsd  0x0(%rbp),%xmm0
  call   <nearest_index@plt>
  movsd  0x0(%rbp),%xmm1
  movslq %eax,%rdx
  comisd (%rbx,%rdx,8),%xmm1
  ja     L102
  cmp    $0x1,%eax
  adc    $0xffffffff,%eax
  jmp    L102
L335:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    (%rsp),%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rdi
  call   <free@plt>
L413:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L219:
  cmpl   $0x0,0x14(%rsp)
  jg     L175
L15:
  lea    D19(%rip),%rdi
  call   <error_handler@plt>
  jmp    L231
L364:
  cmpl   $0x0,0x14(%rsp)
  jle    L91
L175:
  movslq %r15d,%rax
  lea    -0x8(%rbx,%rax,8),%r12
  mov    $0x0,%ebp
  lea    D74(%rip),%r14
  mov    %r15d,(%rsp)
  mov    0x14(%rsp),%r15d
  jmp    L64
L91:
  cmp    $0x2,%r15d
  jne    L231
  jmp    L413
```

tool_calls: name: parse_data
arguments: data_tag: D20
type_guessed: string
name: parse_data
arguments: data_tag: D33
type_guessed: f64
name: parse_data
arguments: data_tag: D19
type_guessed: string
name: parse_data
arguments: data_tag: D74
type_guessed: string

tool: D20: cubic_spline_sp: grid1 is not monotonic increasing

tool: D33: 3

tool: D19: cubic_spline_sp: the size of input grid should be at least 2

tool: D74: cubic_spline_sp: grid2 lies outside grid1

assistant: ```c
void cubic_spline_sp(int size1, int size2, const double *grid1, const double *grid2, const double *data1, double *data2) {
  double *delta = NULL, *d = NULL, *dh = NULL, *b = NULL, *c = NULL;
  double s, w1, w2, p;
  int i, k, n, klo, khi, kmax;
  for (i = 1; i < size1; i++) {
    if (grid1[i] <= grid1[i - 1])
      error_handler("cubic_spline_sp: grid1 is not monotonic increasing");
  }
  for (i = 0; i < size2; i++) {
    if (grid2[i] < grid1[0] || grid2[i] > grid1[size1 - 1])
      error_handler("cubic_spline_sp: grid2 lies outside grid1");
  }
  if (size1 < 2)
    error_handler("cubic_spline_sp: the size of input grid should be at least 2");
  if (size1 == 2) {
    p = (data1[1] - data1[0]) / (grid1[1] - grid1[0]);
    for (i = 0; i < size2; i++)
      data2[i] = p * (grid2[i] - grid1[0]) + data1[0];
    return;
  }
  delta = (double *)malloc((size1 - 1) * sizeof(double));
  dh = (double *)malloc((size1 - 1) * sizeof(double));
  d = (double *)malloc(size1 * sizeof(double));
  for (k = 0; k < size1 - 1; k++) {
    dh[k] = grid1[k + 1] - grid1[k];
    delta[k] = (data1[k + 1] - data1[k]) / (dh[k]);
  }
  for (k = 1; k < size1 - 1; k++) {
    if (delta[k] * delta[k - 1] > 0.0) {
      w1 = 2.0 * dh[k] + dh[k - 1];
      w2 = dh[k] + 2.0 * dh[k - 1];
      d[k] = (w1 + w2) / (w1 / delta[k - 1] + w2 / delta[k]);
    } else {
      d[k] = 0.0;
    }
  }
  kmax = size1 - 1;
  d[0] = ((2.0 * dh[0] + dh[1]) * delta[0] - dh[0] * delta[1]) / (dh[0] + dh[1]);
  if (d[0] * delta[0] < 0.0) {
    d[0] = 0.0;
  } else {
    if (delta[0] * delta[1] < 0.0 && fabs(d[0]) > fabs(3.0 * delta[0])) {
      d[0] = 3.0 * delta[0];
    }
  }
  d[kmax] = ((2.0 * dh[kmax - 1] + dh[kmax - 2]) * delta[kmax - 1] - dh[kmax - 1] * delta[kmax - 2]) / (dh[kmax - 1] + dh[kmax - 2]);
  if (d[kmax] * delta[kmax - 1] < 0.0) {
    d[kmax] = 0.0;
  } else {
    if (delta[kmax - 1] * delta[kmax - 2] < 0.0 && fabs(d[kmax]) > fabs(3.0 * delta[kmax - 1])) {
      d[kmax] = 3.0 * delta[kmax - 1];
    }
  }
  b = (double *)malloc((size1 - 1) * sizeof(double));
  c = (double *)malloc((size1 - 1) * sizeof(double));
  for (k = 0; k < size1 - 1; k++) {
    c[k] = (3.0 * delta[k] - 2.0 * d[k] - d[k + 1]) / dh[k];
    b[k] = (d[k] - 2.0 * delta[k] + d[k + 1]) / (dh[k] * dh[k]);
  }
  for (k = 0; k < size2; k++) {
    n = nearest_index(grid2[k], grid1, size1);
    if (grid1[n] < grid2[k]) {
      klo = n;
    } else {
      if (n == 0) {
        klo = n;
      } else {
        klo = n - 1;
      }
    }
    khi = klo + 1;
    s = grid2[k] - grid1[klo];
    data2[k] = data1[klo] + s * (d[klo] + s * (c[klo] + s * b[klo]));
  }
  free(c);
  free(b);
  free(d);
  free(dh);
  free(delta);
}
```