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

```asm
<polyfit>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r15
  mov    %rdx,0x18(%rsp)
  mov    %rcx,%r12
  movsd  %xmm0,0x8(%rsp)
  mov    %r8d,%ebp
  movsd  %xmm1,0x10(%rsp)
  mov    %r9d,%ebx
  mov    0x60(%rsp),%r13
  mov    0x68(%rsp),%rdi
  mov    0x70(%rsp),%rcx
  lea    (%r9,%r9,1),%r10d
  lea    -0x1(%r10),%r9d
  test   %r9d,%r9d
  jle    L163
  mov    %rcx,%rax
  lea    -0x2(%r10),%edx
  mov    %edx,%edx
  lea    0x8(%rcx,%rdx,8),%rdx
L195:
  movq   $0x0,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L195
L163:
  test   %ebx,%ebx
  jle    L131
  mov    %r13,%rax
  lea    -0x1(%rbx),%edx
  lea    0x0(%r13,%rdx,8),%rsi
L106:
  movq   $0x0,(%rax)
  mov    %rax,%rdx
  add    $0x8,%rax
  cmp    %rsi,%rdx
  jne    L106
  test   %ebp,%ebp
  jle    L125
L23:
  lea    -0x2(%rbx),%eax
  lea    0x10(%r13,%rax,8),%r8
  lea    -0x3(%r10),%eax
  lea    0x10(%rcx,%rax,8),%rsi
  mov    $0x0,%edx
  mov    0x18(%rsp),%r10
  jmp    L42
L46:
  mulsd  %xmm2,%xmm0
  movapd %xmm0,%xmm1
  addsd  (%rax),%xmm1
  movsd  %xmm1,(%rax)
  add    $0x8,%rax
  cmp    %rax,%rsi
  jne    L46
L193:
  add    $0x1,%rdx
  cmp    %edx,%ebp
  jle    L108
L42:
  movsd  (%r12,%rdx,8),%xmm3
  comisd 0x8(%rsp),%xmm3
  jbe    L193
  movsd  (%r14,%rdx,8),%xmm2
  subsd  0x10(%rsp),%xmm2
  movapd %xmm3,%xmm0
  divsd  (%r10,%rdx,8),%xmm0
  mulsd  %xmm0,%xmm0
  movsd  (%r15,%rdx,8),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm0,%xmm1
  movapd %xmm1,%xmm3
  addsd  0x0(%r13),%xmm3
  movsd  %xmm3,0x0(%r13)
  cmp    $0x1,%ebx
  jle    L150
  lea    0x8(%r13),%rax
L41:
  mulsd  %xmm2,%xmm1
  movapd %xmm1,%xmm3
  addsd  (%rax),%xmm3
  movsd  %xmm3,(%rax)
  add    $0x8,%rax
  cmp    %r8,%rax
  jne    L41
L150:
  movapd %xmm0,%xmm1
  addsd  (%rcx),%xmm1
  movsd  %xmm1,(%rcx)
  cmp    $0x1,%r9d
  jle    L193
  lea    0x8(%rcx),%rax
  jmp    L46
L108:
  test   %ebx,%ebx
  jle    L70
L125:
  mov    %rdi,%r9
  movslq %ebx,%rsi
  shl    $0x3,%rsi
  mov    $0x0,%r8d
L96:
  mov    %r9,%rdx
  mov    $0x0,%eax
L51:
  movsd  (%rcx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx)
  add    $0x1,%rax
  add    %rsi,%rdx
  cmp    %eax,%ebx
  jg     L51
  add    $0x1,%r8d
  add    $0x8,%r9
  add    $0x8,%rcx
  cmp    %r8d,%ebx
  jg     L96
L70:
  mov    %ebx,%edx
  mov    %r13,%rsi
  call   <cholsol@plt>
  movsd  D3(%rip),%xmm0
  test   %eax,%eax
  je     L37
L101:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L37:
  sub    $0x8,%rsp
  push   %r13
  mov    %ebx,%r9d
  movsd  0x20(%rsp),%xmm1
  mov    %ebp,%r8d
  movsd  0x18(%rsp),%xmm0
  mov    %r12,%rcx
  mov    0x28(%rsp),%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <chisq@plt>
  add    $0x10,%rsp
  jmp    L101
L131:
  test   %ebp,%ebp
  jg     L23
  jmp    L70
```

tool_calls: name: disassemble_data
arguments: label: D3
type: f32[2]

tool: {"D3": [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);
}
```