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

```asm
<glbChiSpectrumCalib>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r12
  push   %rbx
  sub    $0xf0,%rsp
  mov    %edi,-0xb4(%rbp)
  mov    %esi,-0xb8(%rbp)
  mov    %edx,-0xbc(%rbp)
  mov    %rcx,-0xc8(%rbp)
  mov    %r8,-0xd0(%rbp)
  mov    %r9,-0xd8(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%r12
  mov    -0xb4(%rbp),%eax
  mov    %eax,%edi
  call   <glbGetNumberOfBins@plt>
  mov    %eax,-0x9c(%rbp)
  mov    -0xb8(%rbp),%edx
  mov    -0xb4(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <glbGetRuleRatePtr@plt>
  mov    %rax,-0x70(%rbp)
  mov    -0x9c(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x68(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0xf0(%rbp)
  movq   $0x0,-0xe8(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0x100(%rbp)
  movq   $0x0,-0xf8(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%ebx
  mov    $0x0,%edx
  div    %rbx
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L1:
  cmp    %rdx,%rsp
  je     L44
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L1
L44:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L56
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L56:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x60(%rbp)
  mov    -0x9c(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x58(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0x110(%rbp)
  movq   $0x0,-0x108(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%ebx
  mov    $0x0,%edx
  div    %rbx
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L10:
  cmp    %rdx,%rsp
  je     L19
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L10
L19:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L55
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L55:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x50(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x78(%rbp)
  lea    -0x80(%rbp),%rdx
  lea    -0x88(%rbp),%rcx
  mov    -0xb4(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <glbGetEminEmax@plt>
  lea    -0xa4(%rbp),%rcx
  lea    -0xa8(%rbp),%rdx
  mov    -0xb8(%rbp),%esi
  mov    -0xb4(%rbp),%eax
  mov    %eax,%edi
  call   <glbGetEnergyWindowBins@plt>
  lea    -0x90(%rbp),%rcx
  lea    -0x98(%rbp),%rdx
  mov    -0xb8(%rbp),%esi
  mov    -0xb4(%rbp),%eax
  mov    %eax,%edi
  call   <glbGetBGCenters@plt>
  mov    -0xc8(%rbp),%rax
  movsd  (%rax),%xmm1
  movsd  D1(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x48(%rbp)
  mov    -0xc8(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm1
  movsd  D1(%rip),%xmm0
  addsd  %xmm0,%xmm1
  movsd  -0x98(%rbp),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x40(%rbp)
  mov    -0xc8(%rbp),%rax
  add    $0x18,%rax
  movsd  (%rax),%xmm1
  movsd  -0x90(%rbp),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x38(%rbp)
  movsd  -0x80(%rbp),%xmm3
  movsd  %xmm3,-0xf0(%rbp)
  movsd  -0x88(%rbp),%xmm4
  movsd  %xmm4,-0x100(%rbp)
  mov    -0xb8(%rbp),%edx
  mov    -0xb4(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <glbGetSignalFitRatePtr@plt>
  mov    %eax,%edi
  mov    -0xc8(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  mov    -0x9c(%rbp),%edx
  mov    -0x60(%rbp),%rcx
  movsd  -0xf0(%rbp),%xmm2
  movsd  -0x100(%rbp),%xmm1
  mov    %rcx,%rsi
  movq   %rax,%xmm0
  call   <glbShiftEnergyScale@plt>
  movsd  -0x80(%rbp),%xmm5
  movsd  %xmm5,-0xf0(%rbp)
  movsd  -0x88(%rbp),%xmm6
  movsd  %xmm6,-0x100(%rbp)
  mov    -0xb8(%rbp),%edx
  mov    -0xb4(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <glbGetBGFitRatePtr@plt>
  mov    %eax,%edi
  mov    -0x9c(%rbp),%edx
  mov    -0x50(%rbp),%rcx
  mov    -0x38(%rbp),%rax
  movsd  -0xf0(%rbp),%xmm2
  movsd  -0x100(%rbp),%xmm1
  mov    %rcx,%rsi
  movq   %rax,%xmm0
  call   <glbShiftEnergyScale@plt>
  mov    -0xa8(%rbp),%eax
  mov    %eax,-0xa0(%rbp)
  jmp    L31
L49:
  mov    -0x60(%rbp),%rax
  mov    -0xa0(%rbp),%edx
  movslq %edx,%rdx
  movsd  (%rax,%rdx,8),%xmm0
  movapd %xmm0,%xmm1
  mulsd  -0x48(%rbp),%xmm1
  mov    -0x50(%rbp),%rax
  mov    -0xa0(%rbp),%edx
  movslq %edx,%rdx
  movsd  (%rax,%rdx,8),%xmm0
  mulsd  -0x40(%rbp),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x30(%rbp)
  mov    -0xa0(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x70(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  -0x30(%rbp),%xmm0
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <glb_likelihood@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  movsd  -0x78(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x78(%rbp)
  addl   $0x1,-0xa0(%rbp)
L31:
  mov    -0xa4(%rbp),%eax
  cmp    %eax,-0xa0(%rbp)
  jle    L49
  mov    -0xd0(%rbp),%rax
  movsd  (%rax),%xmm0
  mov    -0xc8(%rbp),%rax
  mov    (%rax),%rax
  movapd %xmm0,%xmm2
  pxor   %xmm1,%xmm1
  movq   %rax,%xmm0
  call   <glb_prior@plt>
  mov    %rax,%rbx
  mov    -0xd0(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm0
  mov    -0xc8(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%rax
  movapd %xmm0,%xmm2
  pxor   %xmm1,%xmm1
  movq   %rax,%xmm0
  call   <glb_prior@plt>
  add    %rax,%rbx
  mov    -0xd0(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm1
  movsd  -0x98(%rbp),%xmm0
  mov    -0x40(%rbp),%rax
  movapd %xmm1,%xmm2
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <glb_prior@plt>
  add    %rax,%rbx
  mov    -0xd0(%rbp),%rax
  add    $0x18,%rax
  movsd  (%rax),%xmm1
  movsd  -0x90(%rbp),%xmm0
  mov    -0x38(%rbp),%rax
  movapd %xmm1,%xmm2
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <glb_prior@plt>
  add    %rbx,%rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  movsd  -0x78(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x78(%rbp)
  movsd  -0x78(%rbp),%xmm0
  mov    %r12,%rsp
  movq   %xmm0,%rax
  mov    -0x28(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L6
  call   <__stack_chk_fail@plt>
L6:
  movq   %rax,%xmm0
  lea    -0x20(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

tool_calls: name: read_data
arguments: label: D1
type_guessed: f64

tool: D1: 1

assistant: ```c
double glbChiSpectrumCalib(int exp, int rule, int n_params, double *x, double *errors, void *user_data) {
  int n_bins = glbGetNumberOfBins(exp);
  double *true_rates = glbGetRuleRatePtr(exp, rule);
  double signal_fit_rates[n_bins];
  double bg_fit_rates[n_bins];
  double signal_norm;
  double bg_norm_center, bg_tilt_center;
  double bg_norm, bg_tilt;
  int ew_low, ew_high;
  double emin, emax;
  double fit_rate, true_rate;
  double chi2 = 0.0;
  int i;
  glbGetEminEmax(exp, &emin, &emax);
  glbGetEnergyWindowBins(exp, rule, &ew_low, &ew_high);
  glbGetBGCenters(exp, rule, &bg_norm_center, &bg_tilt_center);
  signal_norm = 1.0 + x[0];
  bg_norm = bg_norm_center * (1.0 + x[2]);
  bg_tilt = bg_tilt_center + x[3];
  glbShiftEnergyScale(x[1], glbGetSignalFitRatePtr(exp, rule), signal_fit_rates, n_bins, emin, emax);
  glbShiftEnergyScale(bg_tilt, glbGetBGFitRatePtr(exp, rule), bg_fit_rates, n_bins, emin, emax);
  for (i = ew_low; i <= ew_high; i++) {
    fit_rate = signal_norm * signal_fit_rates[i] + bg_norm * bg_fit_rates[i];
    chi2 += glb_likelihood(true_rates[i], fit_rate);
  }
  chi2 += glb_prior(x[0], 0.0, errors[0]) + glb_prior(x[1], 0.0, errors[1]) + glb_prior(bg_norm, bg_norm_center, errors[2]) + glb_prior(bg_tilt, bg_tilt_center, errors[3]);
  return chi2;
}
```