user: Translate the below assembly code into C programming language:

```asm
<polyfit>:
  endbr64
  push   %r15
  mov    %rsi,%r11
  mov    %rdi,%r15
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %r8d,%r13d
  push   %r12
  lea    (%r9,%r9,1),%r12d
  push   %rbp
  lea    -0x1(%r12),%r8d
  mov    %r9d,%ebp
  push   %rbx
  sub    $0x48,%rsp
  mov    0x88(%rsp),%rax
  mov    %rdx,0x18(%rsp)
  mov    0x80(%rsp),%rcx
  mov    0x90(%rsp),%rbx
  movsd  %xmm1,0x8(%rsp)
  mov    %rax,0x10(%rsp)
  test   %r8d,%r8d
  jle    L123
  lea    -0x2(%r12),%eax
  mov    %rsi,0x28(%rsp)
  mov    %rbx,%rdi
  xor    %esi,%esi
  lea    0x8(,%rax,8),%rdx
  mov    %rcx,0x38(%rsp)
  mov    %r8d,0x20(%rsp)
  movsd  %xmm0,0x30(%rsp)
  call   <memset@plt>
  mov    0x38(%rsp),%rcx
  movsd  0x30(%rsp),%xmm0
  mov    0x28(%rsp),%r11
  mov    0x20(%rsp),%r8d
L123:
  test   %ebp,%ebp
  jle    L41
  movslq %ebp,%r9
  xor    %esi,%esi
  mov    %rcx,%rdi
  mov    %r11,0x30(%rsp)
  lea    0x0(,%r9,8),%rdx
  mov    %r8d,0x28(%rsp)
  mov    %r9,0x20(%rsp)
  movsd  %xmm0,0x38(%rsp)
  call   <memset@plt>
  test   %r13d,%r13d
  mov    0x20(%rsp),%r9
  mov    0x28(%rsp),%r8d
  mov    0x30(%rsp),%r11
  movsd  0x38(%rsp),%xmm0
  mov    %rax,%rcx
  jle    L40
L42:
  lea    -0x2(%rbp),%eax
  mov    0x18(%rsp),%r9
  xor    %edx,%edx
  lea    0x10(%rcx,%rax,8),%rsi
  lea    -0x3(%r12),%eax
  lea    0x10(%rbx,%rax,8),%rdi
  jmp    L134
  cs nopw 0x0(%rax,%rax,1)
L68:
  add    $0x1,%rdx
  cmp    %edx,%r13d
  jle    L163
L134:
  movsd  (%r14,%rdx,8),%xmm4
  comisd %xmm0,%xmm4
  jbe    L68
  movsd  (%r11,%rdx,8),%xmm2
  movapd %xmm4,%xmm1
  divsd  (%r9,%rdx,8),%xmm1
  movsd  (%r15,%rdx,8),%xmm3
  mulsd  %xmm1,%xmm1
  subsd  0x8(%rsp),%xmm3
  divsd  %xmm4,%xmm2
  movsd  (%rcx),%xmm4
  mulsd  %xmm1,%xmm2
  addsd  %xmm2,%xmm4
  movsd  %xmm4,(%rcx)
  cmp    $0x1,%ebp
  jle    L120
  lea    0x8(%rcx),%rax
  cs nopw 0x0(%rax,%rax,1)
L130:
  mulsd  %xmm3,%xmm2
  movsd  (%rax),%xmm4
  add    $0x8,%rax
  addsd  %xmm2,%xmm4
  movsd  %xmm4,-0x8(%rax)
  cmp    %rax,%rsi
  jne    L130
L120:
  movsd  (%rbx),%xmm2
  addsd  %xmm1,%xmm2
  movsd  %xmm2,(%rbx)
  cmp    $0x1,%r8d
  jle    L68
  lea    0x8(%rbx),%rax
  nopl   0x0(%rax)
L93:
  mulsd  %xmm3,%xmm1
  movsd  (%rax),%xmm2
  add    $0x8,%rax
  addsd  %xmm1,%xmm2
  movsd  %xmm2,-0x8(%rax)
  cmp    %rax,%rdi
  jne    L93
  add    $0x1,%rdx
  cmp    %edx,%r13d
  jg     L134
L163:
  movslq %ebp,%r9
  test   %ebp,%ebp
  jle    L104
L40:
  mov    0x10(%rsp),%rsi
  lea    0x0(,%r9,8),%r12
  xor    %edi,%edi
  nopl   (%rax)
L155:
  mov    %rsi,%rdx
  xor    %eax,%eax
  nopl   (%rax)
L152:
  movsd  (%rbx,%rax,8),%xmm1
  add    $0x1,%rax
  movsd  %xmm1,(%rdx)
  add    %r12,%rdx
  cmp    %eax,%ebp
  jg     L152
  add    $0x1,%edi
  add    $0x8,%rsi
  add    $0x8,%rbx
  cmp    %edi,%ebp
  jg     L155
L104:
  mov    0x10(%rsp),%rdi
  mov    %ebp,%edx
  mov    %rcx,%rsi
  mov    %r11,0x28(%rsp)
  mov    %rcx,0x20(%rsp)
  movsd  %xmm0,0x30(%rsp)
  call   <cholsol@plt>
  test   %eax,%eax
  je     L35
  movsd  D8(%rip),%xmm0
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L35:
  mov    0x20(%rsp),%rcx
  mov    0x18(%rsp),%rdx
  mov    %ebp,%r9d
  mov    %r13d,%r8d
  movsd  0x8(%rsp),%xmm1
  movsd  0x30(%rsp),%xmm0
  mov    %r15,%rdi
  mov    %rcx,0x80(%rsp)
  mov    0x28(%rsp),%rsi
  mov    %r14,%rcx
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <chisq@plt>
L41:
  test   %r13d,%r13d
  jg     L42
  jmp    L104
```

tool_calls: name: unpack_data
arguments: label: D8
type_guessed: f32[2]

tool: {"D8": [0.0,-1.875]}

assistant: ```c
double polyfit(double *wave, double *flux, double *ferr, double *fmod, double ind, int n, double wcen, int deg, double *p, double *lhs, double *covar) {
  int i, k;
  double xi, yi, wi, *b = p, *A = covar, mom;
  for (k = 0; k < 2 * deg - 1; ++k)
    A[k] = 0.;
  for (k = 0; k < deg; ++k)
    b[k] = 0.;
  for (i = 0; i < n; ++i) {
    if (fmod[i] > ind) {
      xi = wave[i] - wcen;
      yi = flux[i] / fmod[i];
      wi = fmod[i] / ferr[i];
      wi *= wi;
      mom = wi * yi;
      b[0] += mom;
      for (k = 1; k < deg; ++k)
        b[k] += (mom *= xi);
      mom = wi;
      A[0] += mom;
      for (k = 1; k < 2 * deg - 1; ++k)
        A[k] += (mom *= xi);
    }
  }
  for (k = 0; k < deg; ++k)
    for (i = 0; i < deg; ++i)
      lhs[k + deg * i] = A[k + i];
  i = cholsol(lhs, b, deg);
  if (i)
    return -1.0;
  return chisq(wave, flux, ferr, fmod, ind, n, wcen, deg, p);
}
```