user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<cubic_spline_sp>:
  endbr64
  push   %r15
  push   %r14
  mov    %rcx,%r14
  push   %r13
  push   %r12
  mov    %r8,%r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x58,%rsp
  mov    %edi,0x10(%rsp)
  mov    %esi,0x18(%rsp)
  mov    %r9,0x28(%rsp)
  cmp    $0x1,%edi
  jle    L399
  lea    -0x2(%rdi),%eax
  mov    %rdx,%r13
  lea    D61(%rip),%rbp
  lea    0x8(%rdx,%rax,8),%r15
  jmp    L21
  nopl   (%rax)
L45:
  add    $0x8,%r13
  cmp    %r15,%r13
  je     L122
L21:
  movsd  0x0(%r13),%xmm0
  comisd 0x8(%r13),%xmm0
  jb     L45
  mov    %rbp,%rdi
  add    $0x8,%r13
  call   <error_handler@plt>
  cmp    %r15,%r13
  jne    L21
L122:
  mov    0x18(%rsp),%eax
  test   %eax,%eax
  jle    L540
L239:
  movslq 0x10(%rsp),%rax
  mov    %r12,0x8(%rsp)
  mov    %rbx,%r12
  xor    %r15d,%r15d
  lea    D54(%rip),%r13
  lea    -0x8(%rbx,%rax,8),%rbp
  mov    %rbp,%rbx
  mov    0x18(%rsp),%ebp
  nop
L244:
  movsd  (%r14,%r15,8),%xmm0
  movsd  (%r12),%xmm1
  comisd %xmm0,%xmm1
  ja     L55
  comisd (%rbx),%xmm0
  jbe    L86
L55:
  mov    %r13,%rdi
  call   <error_handler@plt>
L86:
  add    $0x1,%r15
  cmp    %r15d,%ebp
  jg     L244
  cmpl   $0x1,0x10(%rsp)
  mov    %r12,%rbx
  mov    0x8(%rsp),%r12
  jle    L337
  cmpl   $0x2,0x10(%rsp)
  je     L568
L354:
  mov    0x10(%rsp),%eax
  sub    $0x1,%eax
  lea    0x0(,%rax,8),%ebp
  mov    %eax,0x20(%rsp)
  movslq %eax,%r13
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    %ebp,%edi
  mov    %rax,0x30(%rsp)
  call   <malloc@plt>
  lea    0x8(%rbp),%edi
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  mov    0x20(%rsp),%edi
  mov    0x8(%rsp),%r9
  mov    0x30(%rsp),%r8
  mov    %rax,%r15
  test   %edi,%edi
  jle    L105
  lea    0x8(%rbx),%rdx
  mov    %r8,%rax
  lea    0x8(%r9),%rcx
  sub    %rdx,%rax
  lea    0x8(%r12),%rsi
  cmp    $0x8,%rax
  seta   %al
  cmp    %rcx,%r8
  setne  %cl
  and    %ecx,%eax
  cmpl   $0x2,0x10(%rsp)
  setne  %cl
  and    %ecx,%eax
  mov    %r8,%rcx
  sub    %rsi,%rcx
  cmp    $0x8,%rcx
  seta   %cl
  and    %ecx,%eax
  mov    %r9,%rcx
  sub    %rdx,%rcx
  cmp    $0x8,%rcx
  seta   %dl
  test   %dl,%al
  je     L532
  lea    0x18(%r12),%rax
  lea    0x10(%r9),%rdx
  cmp    %rax,%r9
  setae  %al
  cmp    %rdx,%r12
  setae  %dl
  or     %dl,%al
  je     L532
  mov    0x20(%rsp),%esi
  mov    %rbx,%rcx
  mov    %r12,%rdx
  mov    %r8,%rdi
  mov    %r9,%rax
  sub    %r9,%rcx
  sub    %r9,%rdx
  sub    %r9,%rdi
  shr    %esi
  shl    $0x4,%rsi
  add    %r9,%rsi
  nopl   0x0(%rax)
L347:
  movupd 0x8(%rcx,%rax,1),%xmm1
  movupd (%rcx,%rax,1),%xmm6
  subpd  %xmm6,%xmm1
  movups %xmm1,(%rax)
  movupd 0x8(%rdx,%rax,1),%xmm0
  movupd (%rdx,%rax,1),%xmm7
  subpd  %xmm7,%xmm0
  divpd  %xmm1,%xmm0
  movups %xmm0,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %rsi,%rax
  jne    L347
  mov    0x20(%rsp),%ecx
  mov    %ecx,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%ecx
  je     L206
  cltq
  add    $0x1,%rax
  movsd  (%rbx,%rax,8),%xmm1
  subsd  -0x8(%rbx,%rax,8),%xmm1
  lea    0x0(,%rax,8),%rdx
  movsd  %xmm1,-0x8(%r9,%rdx,1)
  movsd  (%r12,%rax,8),%xmm0
  subsd  -0x8(%r12,%rdx,1),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%r8,%rdx,1)
L206:
  mov    0x10(%rsp),%ecx
  mov    %r9,%r11
  lea    -0x8(%r9),%rdi
  lea    0x8(%r8),%rax
  pxor   %xmm5,%xmm5
  sub    %r8,%r11
  sub    %r8,%rdi
  lea    -0x3(%rcx),%edx
  mov    %r15,%rcx
  lea    0x10(%r8,%rdx,8),%rsi
  sub    %r8,%rcx
  nopw   0x0(%rax,%rax,1)
L477:
  movsd  (%rax),%xmm2
  movsd  -0x8(%rax),%xmm3
  lea    (%rcx,%rax,1),%rdx
  movapd %xmm2,%xmm0
  mulsd  %xmm3,%xmm0
  comisd %xmm5,%xmm0
  jbe    L465
  movsd  (%r11,%rax,1),%xmm4
  movsd  (%rdi,%rax,1),%xmm0
  add    $0x8,%rax
  movapd %xmm4,%xmm1
  addsd  %xmm4,%xmm1
  addsd  %xmm0,%xmm1
  addsd  %xmm0,%xmm0
  addsd  %xmm4,%xmm0
  movapd %xmm1,%xmm4
  divsd  %xmm3,%xmm1
  addsd  %xmm0,%xmm4
  divsd  %xmm2,%xmm0
  addsd  %xmm0,%xmm1
  divsd  %xmm1,%xmm4
  movsd  %xmm4,(%rdx)
  cmp    %rax,%rsi
  jne    L477
L486:
  movsd  (%r9),%xmm1
  movsd  0x8(%r9),%xmm2
  movsd  0x8(%r8),%xmm3
  movapd %xmm1,%xmm0
  addsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm3
  addsd  %xmm2,%xmm1
  addsd  %xmm2,%xmm0
  mulsd  (%r8),%xmm0
  subsd  %xmm3,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%r15)
  movsd  (%r8),%xmm1
  movapd %xmm0,%xmm2
  mulsd  %xmm1,%xmm2
  comisd %xmm2,%xmm5
  ja     L280
  mulsd  0x8(%r8),%xmm1
  comisd %xmm1,%xmm5
  ja     L207
L566:
  shl    $0x3,%r13
  movsd  -0x8(%r9,%r13,1),%xmm1
  lea    -0x10(%r8,%r13,1),%rax
  lea    -0x8(%r8,%r13,1),%rdx
  movsd  -0x10(%r9,%r13,1),%xmm2
  movsd  (%rax),%xmm3
  add    %r15,%r13
  movapd %xmm1,%xmm0
  addsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm3
  addsd  %xmm2,%xmm1
  addsd  %xmm2,%xmm0
  mulsd  (%rdx),%xmm0
  subsd  %xmm3,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x0(%r13)
  movsd  (%rdx),%xmm1
  movapd %xmm0,%xmm2
  mulsd  %xmm1,%xmm2
  comisd %xmm2,%xmm5
  ja     L367
  mulsd  (%rax),%xmm1
  comisd %xmm1,%xmm5
  ja     L82
L473:
  mov    %ebp,%edi
  mov    %r9,0x38(%rsp)
  mov    %r8,0x30(%rsp)
  call   <malloc@plt>
  mov    %ebp,%edi
  mov    %rax,%r13
  call   <malloc@plt>
  mov    0x20(%rsp),%esi
  mov    0x30(%rsp),%r8
  mov    %rax,0x8(%rsp)
  mov    0x38(%rsp),%r9
  test   %esi,%esi
  jle    L506
  mov    %rax,%rbp
  lea    0x10(%rax),%r10
  lea    0x8(%r9),%rax
  mov    %r8,%rcx
  cmp    %rax,%r13
  lea    0x8(%r8),%rax
  lea    0x8(%r15),%rdx
  mov    %r9,%rsi
  setne  %dil
  cmp    %rax,%r13
  setne  %al
  and    %edi,%eax
  cmpl   $0x2,0x10(%rsp)
  setne  %dil
  and    %edi,%eax
  mov    %r13,%rdi
  sub    %rdx,%rdi
  cmp    $0x8,%rdi
  seta   %dil
  and    %edi,%eax
  lea    0x8(%rbp),%rdi
  cmp    %rdi,%r13
  setne  %dil
  and    %edi,%eax
  lea    0x10(%r8),%rdi
  cmp    %rdi,%rbp
  setae  %dil
  cmp    %r10,%r8
  setae  %r11b
  or     %r11d,%edi
  and    %edi,%eax
  lea    0x10(%r9),%rdi
  cmp    %rdi,%rbp
  setae  %dil
  cmp    %r10,%r9
  setae  %r11b
  or     %r11d,%edi
  test   %dil,%al
  je     L578
  lea    0x18(%r15),%rax
  mov    %rbp,%r11
  cmp    %rax,%rbp
  setae  %al
  cmp    %r10,%r15
  setae  %dil
  or     %al,%dil
  je     L578
  mov    0x20(%rsp),%eax
  mov    %r13,%rdi
  movapd D62(%rip),%xmm2
  sub    %r15,%r11
  sub    %r15,%rdi
  shr    %eax
  shl    $0x4,%rax
  lea    (%rax,%r15,1),%r10
  mov    %r15,%rax
  nopl   0x0(%rax,%rax,1)
L553:
  movupd (%rcx),%xmm0
  movupd (%rax),%xmm1
  add    $0x10,%rsi
  add    $0x10,%rdx
  movupd -0x10(%rdx),%xmm7
  movupd -0x10(%rsi),%xmm5
  add    $0x10,%rcx
  mulpd  %xmm2,%xmm0
  addpd  %xmm1,%xmm1
  subpd  %xmm1,%xmm0
  subpd  %xmm7,%xmm0
  divpd  %xmm5,%xmm0
  movups %xmm0,(%r11,%rax,1)
  movupd -0x10(%rcx),%xmm1
  movupd (%rax),%xmm0
  movupd -0x10(%rdx),%xmm7
  addpd  %xmm1,%xmm1
  subpd  %xmm1,%xmm0
  movupd -0x10(%rsi),%xmm1
  mulpd  %xmm1,%xmm1
  addpd  %xmm7,%xmm0
  divpd  %xmm1,%xmm0
  movups %xmm0,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%r10
  jne    L553
  mov    0x20(%rsp),%eax
  mov    %eax,%edx
  and    $0xfffffffe,%edx
  test   $0x1,%al
  je     L506
  movslq %edx,%rdx
  movsd  D62(%rip),%xmm0
  mov    0x8(%rsp),%r11
  lea    0x0(,%rdx,8),%rax
  lea    (%r8,%rax,1),%rdi
  lea    (%r15,%rax,1),%rsi
  mulsd  (%rdi),%xmm0
  movsd  (%rsi),%xmm1
  lea    0x8(%r15,%rax,1),%rcx
  add    %r9,%rax
  addsd  %xmm1,%xmm1
  subsd  %xmm1,%xmm0
  subsd  (%rcx),%xmm0
  divsd  (%rax),%xmm0
  movsd  %xmm0,(%r11,%rdx,8)
  movsd  (%rdi),%xmm0
  movsd  (%rax),%xmm1
  mulsd  %xmm1,%xmm1
  movapd %xmm0,%xmm2
  addsd  %xmm0,%xmm2
  movsd  (%rsi),%xmm0
  subsd  %xmm2,%xmm0
  addsd  (%rcx),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x0(%r13,%rdx,8)
L506:
  mov    0x18(%rsp),%ecx
  test   %ecx,%ecx
  jle    L325
  mov    0x18(%rsp),%eax
  mov    %r14,%rbp
  mov    0x28(%rsp),%r14
  mov    %r12,0x20(%rsp)
  mov    %r8,0x28(%rsp)
  sub    $0x1,%eax
  mov    %r14,%r12
  mov    %r9,0x30(%rsp)
  mov    %rbx,%r14
  lea    0x8(%rbp,%rax,8),%rax
  mov    %rbp,%rbx
  mov    0x10(%rsp),%ebp
  mov    %rax,0x18(%rsp)
  jmp    L353
  nopl   0x0(%rax)
L296:
  mov    0x20(%rsp),%rax
  mov    0x8(%rsp),%rcx
  lea    (%r15,%rsi,1),%r8
  add    %rsi,%rax
  lea    (%rcx,%rsi,1),%r9
  add    %r13,%rsi
L147:
  subsd  %xmm0,%xmm1
  movsd  (%rsi),%xmm0
  add    $0x8,%rbx
  add    $0x8,%r12
  mulsd  %xmm1,%xmm0
  addsd  (%r9),%xmm0
  mulsd  %xmm1,%xmm0
  addsd  (%r8),%xmm0
  mulsd  %xmm1,%xmm0
  addsd  (%rax),%xmm0
  movsd  %xmm0,-0x8(%r12)
  cmp    0x18(%rsp),%rbx
  je     L274
L353:
  movsd  (%rbx),%xmm0
  mov    %ebp,%esi
  mov    %r14,%rdi
  call   <nearest_index@plt>
  movsd  (%rbx),%xmm1
  movslq %eax,%r8
  movsd  (%r14,%r8,8),%xmm0
  lea    0x0(,%r8,8),%rsi
  comisd %xmm0,%xmm1
  ja     L296
  test   %eax,%eax
  jne    L230
  movsd  (%r14),%xmm0
  mov    0x8(%rsp),%r9
  mov    %r13,%rsi
  mov    %r15,%r8
  mov    0x20(%rsp),%rax
  jmp    L147
  nop
L568:
  movsd  (%r12),%xmm2
  movsd  (%rbx),%xmm3
  movsd  0x8(%r12),%xmm1
  movsd  0x8(%rbx),%xmm0
  mov    0x28(%rsp),%rdi
  mov    0x18(%rsp),%r10d
  subsd  %xmm3,%xmm0
  subsd  %xmm2,%xmm1
  divsd  %xmm0,%xmm1
  movsd  (%r14),%xmm0
  subsd  %xmm3,%xmm0
  mulsd  %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  movsd  %xmm0,(%rdi)
  cmp    $0x1,%r10d
  je     L152
  mov    %r10d,%eax
  lea    0x8(%rdi),%rdx
  lea    -0x1(%r10),%ecx
  lea    (%rdi,%rax,8),%rsi
  lea    0x10(%r14),%rax
  cmp    %rax,%rdx
  setne  %dl
  cmp    $0x2,%r10d
  mov    %rdi,%r10
  setne  %al
  and    %eax,%edx
  cmp    %rdi,%rbx
  setbe  %al
  cmp    %rsi,%rbx
  setae  %dil
  or     %edi,%eax
  test   %al,%dl
  je     L535
  cmp    %r10,%r12
  setbe  %al
  cmp    %rsi,%r12
  setae  %dl
  or     %dl,%al
  je     L535
  mov    %ecx,%eax
  movsd  (%rbx),%xmm4
  movsd  (%r12),%xmm3
  movapd %xmm1,%xmm2
  shr    %eax
  mov    0x28(%rsp),%rsi
  unpcklpd %xmm2,%xmm2
  lea    -0x1(%rax),%edx
  unpcklpd %xmm4,%xmm4
  unpcklpd %xmm3,%xmm3
  mov    $0x8,%eax
  shl    $0x4,%rdx
  add    $0x18,%rdx
  xchg   %ax,%ax
L327:
  movupd (%r14,%rax,1),%xmm0
  subpd  %xmm4,%xmm0
  mulpd  %xmm2,%xmm0
  addpd  %xmm3,%xmm0
  movups %xmm0,(%rsi,%rax,1)
  add    $0x10,%rax
  cmp    %rdx,%rax
  jne    L327
  mov    %ecx,%eax
  or     $0x1,%eax
  and    $0x1,%ecx
  je     L152
  cltq
  movsd  (%r14,%rax,8),%xmm0
  subsd  (%rbx),%xmm0
  mov    0x28(%rsp),%rbx
  mulsd  %xmm1,%xmm0
  addsd  (%r12),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
L152:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L465:
  add    $0x8,%rax
  movq   $0x0,(%rdx)
  cmp    %rax,%rsi
  jne    L477
  jmp    L486
  nopl   0x0(%rax)
L230:
  mov    0x20(%rsp),%rax
  mov    0x8(%rsp),%rcx
  lea    -0x8(%rsi),%r10
  movsd  -0x8(%r14,%rsi,1),%xmm0
  lea    (%r15,%r10,1),%r8
  lea    0x0(%r13,%r10,1),%rsi
  add    %r10,%rax
  lea    (%rcx,%r10,1),%r9
  jmp    L147
  nopw   0x0(%rax,%rax,1)
L274:
  mov    0x28(%rsp),%r8
  mov    0x30(%rsp),%r9
L325:
  mov    0x8(%rsp),%rdi
  mov    %r9,0x18(%rsp)
  mov    %r8,0x10(%rsp)
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    %r15,%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1090 <free@plt>
L367:
  movq   $0x0,0x0(%r13)
  jmp    L473
  nopl   (%rax)
L280:
  movq   $0x0,(%r15)
  jmp    L566
  nopl   0x0(%rax)
L399:
  mov    0x18(%rsp),%edx
  test   %edx,%edx
  jg     L239
  nopl   0x0(%rax)
L337:
  lea    D57(%rip),%rdi
  call   <error_handler@plt>
  jmp    L354
  nopl   0x0(%rax)
L532:
  mov    0x10(%rsp),%eax
  mov    %rbx,%rcx
  mov    %r12,%rdx
  mov    %r8,%rsi
  sub    %r9,%rcx
  sub    %r9,%rdx
  sub    %r9,%rsi
  sub    $0x2,%eax
  lea    0x8(%r9,%rax,8),%rdi
  mov    %r9,%rax
  nopl   0x0(%rax)
L81:
  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    L81
  cmpl   $0x1,0x20(%rsp)
  jg     L206
L105:
  pxor   %xmm5,%xmm5
  jmp    L486
L578:
  mov    0x10(%rsp),%eax
  mov    0x8(%rsp),%r10
  mov    %r8,%r11
  mov    %r9,%rbp
  mov    %r13,%rdi
  mov    %r8,0x20(%rsp)
  sub    %r15,%r11
  sub    %r15,%rbp
  sub    $0x2,%eax
  movsd  D62(%rip),%xmm3
  sub    %r15,%r10
  sub    %r15,%rdi
  lea    0x8(%r15,%rax,8),%rcx
  mov    %r15,%rax
  mov    %rcx,%r8
  nopl   0x0(%rax)
L501:
  lea    (%r11,%rax,1),%rcx
  mov    %rax,%rdx
  add    $0x8,%rax
  movsd  (%rcx),%xmm0
  movsd  (%rdx),%xmm1
  lea    0x0(%rbp,%rdx,1),%rsi
  mulsd  %xmm3,%xmm0
  addsd  %xmm1,%xmm1
  subsd  %xmm1,%xmm0
  subsd  (%rax),%xmm0
  divsd  (%rsi),%xmm0
  movsd  %xmm0,(%r10,%rdx,1)
  movsd  (%rcx),%xmm0
  movsd  (%rsi),%xmm1
  mulsd  %xmm1,%xmm1
  movapd %xmm0,%xmm2
  addsd  %xmm0,%xmm2
  movsd  (%rdx),%xmm0
  subsd  %xmm2,%xmm0
  addsd  (%rax),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdi,%rdx,1)
  cmp    %r8,%rax
  jne    L501
  mov    0x20(%rsp),%r8
  jmp    L506
  nopw   0x0(%rax,%rax,1)
L540:
  cmpl   $0x2,0x10(%rsp)
  jne    L354
  jmp    L152
L82:
  mov    %r9,0x38(%rsp)
  mov    %r8,0x30(%rsp)
  mov    %rdx,0x40(%rsp)
  call   <fabs@plt>
  movsd  D62(%rip),%xmm3
  mov    0x40(%rsp),%rdx
  mov    %rax,0x8(%rsp)
  movapd %xmm3,%xmm0
  movsd  %xmm3,0x48(%rsp)
  mulsd  (%rdx),%xmm0
  call   <fabs@plt>
  cmp    %rax,0x8(%rsp)
  mov    0x30(%rsp),%r8
  mov    0x38(%rsp),%r9
  jle    L473
  mov    0x40(%rsp),%rdx
  movsd  0x48(%rsp),%xmm3
  mulsd  (%rdx),%xmm3
  movsd  %xmm3,0x0(%r13)
  jmp    L473
  nopl   0x0(%rax,%rax,1)
L207:
  mov    %r9,0x38(%rsp)
  movsd  %xmm5,0x40(%rsp)
  mov    %r8,0x30(%rsp)
  call   <fabs@plt>
  movsd  D62(%rip),%xmm3
  mov    0x30(%rsp),%r8
  mov    %rax,0x8(%rsp)
  movapd %xmm3,%xmm0
  movsd  %xmm3,0x48(%rsp)
  mulsd  (%r8),%xmm0
  call   <fabs@plt>
  cmp    %rax,0x8(%rsp)
  mov    0x30(%rsp),%r8
  mov    0x38(%rsp),%r9
  movsd  0x40(%rsp),%xmm5
  jle    L566
  movsd  0x48(%rsp),%xmm3
  mulsd  (%r8),%xmm3
  movsd  %xmm3,(%r15)
  jmp    L566
L535:
  movslq 0x18(%rsp),%rdx
  mov    0x28(%rsp),%rcx
  mov    $0x1,%eax
  nopw   0x0(%rax,%rax,1)
L309:
  movsd  (%r14,%rax,8),%xmm0
  subsd  (%rbx),%xmm0
  mulsd  %xmm1,%xmm0
  addsd  (%r12),%xmm0
  movsd  %xmm0,(%rcx,%rax,8)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L309
  jmp    L152
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D61
datatype: string
name: extract_symbolic_data
arguments: data_tag: D54
datatype: string
name: extract_symbolic_data
arguments: data_tag: D62
datatype: f64[2]
name: extract_symbolic_data
arguments: data_tag: D57
datatype: string

tool: D61: cubic_spline_sp: grid1 is not monotonic increasing

tool: D54: cubic_spline_sp: grid2 lies outside grid1

tool: {"D62": [3.0,3.0]}

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

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);
}
```