user: Demonstrate the C code that generates the assembly output below:

```asm
<def_hat>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0xb8,%rsp
  mov    %edi,%r15d
  mov    %esi,-0xd0(%rbp)
  mov    %edx,%r14d
  mov    %rcx,-0x78(%rbp)
  mov    %r8,-0x88(%rbp)
  mov    %r9,%rdx
  mov    0x10(%rbp),%rdi
  mov    0x18(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rax,-0xd8(%rbp)
  mov    0x28(%rbp),%rax
  mov    %rax,-0x90(%rbp)
  mov    0x30(%rbp),%rax
  mov    %rax,-0xb8(%rbp)
  movsd  %xmm0,-0xc0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %esi,%eax
  imul   %r15d,%esi
  mov    %esi,%r8d
  add    %eax,%eax
  mov    %eax,-0x6c(%rbp)
  lea    0x1(%r14),%eax
  mov    %eax,-0x48(%rbp)
  movslq %r15d,%rax
  shl    $0x3,%rax
  mov    %rax,-0x98(%rbp)
  lea    0xf(%rax),%rcx
  mov    %rcx,%rax
  and    $0xfffffffffffffff0,%rax
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rsi
  sub    %rcx,%rsi
L110:
  cmp    %rsi,%rsp
  je     L232
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L110
L232:
  mov    %rax,%rcx
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L41
  orq    $0x0,-0x8(%rsp,%rcx,1)
L41:
  mov    %rsp,-0xa0(%rbp)
  mov    -0x98(%rbp),%rax
  lea    0xf(%rax),%rcx
  mov    %rcx,%rax
  and    $0xfffffffffffffff0,%rax
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rsi
  sub    %rcx,%rsi
L86:
  cmp    %rsi,%rsp
  je     L189
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L86
L189:
  mov    %rax,%rcx
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L227
  orq    $0x0,-0x8(%rsp,%rcx,1)
L227:
  mov    %rsp,%rbx
  mov    %rbx,-0xc8(%rbp)
  test   %r15d,%r15d
  jle    L207
  mov    %r15d,%esi
  movslq %r8d,%rax
  mov    -0x78(%rbp),%r10
  lea    (%r10,%rax,8),%rcx
  mov    $0x0,%eax
  mov    -0x50(%rbp),%r9
  mov    -0xa0(%rbp),%r11
L93:
  movsd  (%rdx,%rax,8),%xmm0
  movsd  %xmm0,(%r10,%rax,8)
  divsd  (%r9,%rax,8),%xmm0
  movsd  %xmm0,(%r11,%rax,8)
  movsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%rcx,%rax,8)
  divsd  (%r9,%rax,8),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rsi,%rax
  jne    L93
L207:
  mov    -0xd0(%rbp),%eax
  cmp    $0x1,%eax
  jle    L279
  mov    -0x78(%rbp),%rdi
  mov    %rdi,-0x80(%rbp)
  lea    -0x1(%rax),%esi
  mov    %esi,-0xb0(%rbp)
  movslq %r8d,%r8
  lea    0x0(,%r8,8),%rdi
  mov    %rdi,-0xa8(%rbp)
  mov    -0x48(%rbp),%esi
  imul   %eax,%esi
  mov    %esi,-0xcc(%rbp)
  movl   $0x0,-0x70(%rbp)
  movl   $0x0,-0x68(%rbp)
  mov    %r14d,-0x58(%rbp)
L211:
  mov    -0x80(%rbp),%rcx
  mov    %rcx,%r14
  add    -0xa8(%rbp),%r14
  mov    %rcx,-0x60(%rbp)
  mov    %r15d,%r9d
  mov    %r14,%r8
  mov    -0xc8(%rbp),%rdx
  mov    -0xa0(%rbp),%rsi
  mov    %r15d,%edi
  call   <update_sincos@plt>
  cmpl   $0x0,-0x58(%rbp)
  js     L166
  mov    -0x70(%rbp),%edi
  movslq %edi,%rax
  mov    -0x88(%rbp),%rbx
  lea    (%rbx,%rax,8),%r12
  add    -0xcc(%rbp),%edi
  movslq %edi,%r13
  sub    %rax,%r13
  shl    $0x3,%r13
  mov    $0x0,%ebx
L171:
  sub    $0x8,%rsp
  lea    (%r12,%r13,1),%rax
  push   %rax
  mov    %r12,%r9
  mov    %ebx,%r8d
  mov    -0x50(%rbp),%rcx
  mov    %r14,%rdx
  mov    -0x60(%rbp),%rsi
  mov    %r15d,%edi
  call   <calc_dotprod@plt>
  add    $0x1,%ebx
  add    $0x8,%r12
  add    $0x10,%rsp
  cmp    %ebx,-0x58(%rbp)
  jge    L171
L166:
  addl   $0x1,-0x68(%rbp)
  mov    -0x68(%rbp),%eax
  mov    -0x98(%rbp),%rsi
  add    %rsi,-0x80(%rbp)
  mov    -0x48(%rbp),%ebx
  add    %ebx,-0x70(%rbp)
  cmp    -0xb0(%rbp),%eax
  jne    L211
  mov    -0x58(%rbp),%r14d
L29:
  test   %r14d,%r14d
  js     L281
  mov    -0xd0(%rbp),%edx
  mov    -0x68(%rbp),%edi
  add    %edi,%edx
  mov    %edx,%eax
  imul   %r15d,%eax
  cltq
  mov    -0x78(%rbp),%rsi
  lea    (%rsi,%rax,8),%r13
  mov    %edi,%eax
  imul   %r15d,%eax
  cltq
  lea    (%rsi,%rax,8),%rax
  mov    %rax,-0x58(%rbp)
  mov    %edi,%eax
  mov    -0x48(%rbp),%edi
  imul   %edi,%eax
  cltq
  mov    -0x88(%rbp),%rsi
  lea    (%rsi,%rax,8),%r12
  imul   %edi,%edx
  movslq %edx,%rdx
  sub    %rax,%rdx
  lea    0x0(,%rdx,8),%rax
  mov    %rax,-0x60(%rbp)
  mov    $0x0,%ebx
L256:
  sub    $0x8,%rsp
  mov    -0x60(%rbp),%rax
  add    %r12,%rax
  push   %rax
  mov    %r12,%r9
  mov    %ebx,%r8d
  mov    -0x50(%rbp),%rcx
  mov    %r13,%rdx
  mov    -0x58(%rbp),%rsi
  mov    %r15d,%edi
  call   <calc_dotprod@plt>
  add    $0x1,%ebx
  add    $0x8,%r12
  add    $0x10,%rsp
  cmp    %ebx,%r14d
  jge    L256
L281:
  mov    -0x6c(%rbp),%eax
  test   %eax,%eax
  jle    L294
  lea    -0x1(%rax),%edi
  mov    %edi,-0x70(%rbp)
  mov    %eax,%eax
  mov    %rax,-0x58(%rbp)
  movl   $0x0,-0x80(%rbp)
  movl   $0x0,-0x68(%rbp)
  movl   $0x0,-0x60(%rbp)
  mov    $0x0,%r9d
  mov    -0x90(%rbp),%rax
  add    $0x8,%rax
  mov    %rax,-0x98(%rbp)
  lea    -0x1(%r15),%eax
  mov    %rax,-0xa0(%rbp)
  mov    -0x78(%rbp),%rax
  add    $0x8,%rax
  mov    %rax,-0xa8(%rbp)
  mov    %r14d,%eax
  mov    %rax,-0xb0(%rbp)
  mov    -0x88(%rbp),%rax
  add    $0x8,%rax
  mov    %rax,-0xc8(%rbp)
  jmp    L25
L279:
  movl   $0x0,-0x68(%rbp)
  jmp    L29
L21:
  mov    %r12,%rax
  pxor   %xmm0,%xmm0
  movslq %edi,%r13
  sub    -0x50(%rbp),%r13
L304:
  movsd  (%rax,%r13,8),%xmm1
  mulsd  (%rax),%xmm1
  addsd  %xmm1,%xmm0
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L304
L224:
  test   %r14d,%r14d
  js     L328
  mov    %rbx,%rax
  movslq %r8d,%r13
  sub    %r10,%r13
L82:
  movsd  (%rax,%r13,8),%xmm1
  mulsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L82
L328:
  movsd  %xmm0,(%rsi)
  add    $0x8,%rsi
  add    %r15d,%edi
  add    -0x48(%rbp),%r8d
  cmp    %r11,%rsi
  je     L300
L205:
  pxor   %xmm0,%xmm0
  test   %r15d,%r15d
  jg     L21
  jmp    L224
L300:
  add    $0x1,%r9
  mov    -0x6c(%rbp),%ebx
  add    %ebx,-0x60(%rbp)
  add    %r15d,-0x68(%rbp)
  mov    -0x48(%rbp),%esi
  add    %esi,-0x80(%rbp)
  cmp    -0x58(%rbp),%r9
  je     L51
L25:
  cmp    %r9d,-0x6c(%rbp)
  jle    L300
  movslq -0x60(%rbp),%rax
  add    %r9,%rax
  mov    -0x90(%rbp),%rdi
  lea    (%rdi,%rax,8),%rsi
  mov    -0x70(%rbp),%edx
  sub    %r9d,%edx
  add    %rdx,%rax
  mov    -0x98(%rbp),%rbx
  lea    (%rbx,%rax,8),%r11
  mov    -0x68(%rbp),%edi
  movslq %edi,%rbx
  mov    %rbx,-0x50(%rbp)
  mov    -0x78(%rbp),%rax
  lea    (%rax,%rbx,8),%r12
  mov    -0xa0(%rbp),%rax
  add    %rbx,%rax
  mov    -0xa8(%rbp),%rbx
  lea    (%rbx,%rax,8),%rcx
  mov    -0x80(%rbp),%r8d
  movslq %r8d,%r10
  mov    -0x88(%rbp),%rax
  lea    (%rax,%r10,8),%rbx
  mov    -0xb0(%rbp),%rax
  add    %r10,%rax
  mov    -0xc8(%rbp),%rdx
  lea    (%rdx,%rax,8),%rdx
  jmp    L205
L51:
  mov    -0x6c(%rbp),%edi
  movslq %edi,%rax
  lea    0x8(,%rax,8),%r14
  mov    -0x90(%rbp),%r10
  lea    0x1(%rdi),%esi
  mov    %esi,-0x60(%rbp)
  lea    0x0(,%rax,8),%r13
  mov    $0x0,%ebx
  mov    $0x0,%r11d
  mov    $0x0,%r12d
  mov    $0x0,%r9d
  movsd  D0(%rip),%xmm4
  mov    %r15d,%r8d
  movapd %xmm4,%xmm3
  mov    %r13,-0x48(%rbp)
  mov    %r14,-0x68(%rbp)
  mov    %edi,%r14d
  mov    %r15d,-0x50(%rbp)
  mov    -0xd0(%rbp),%edi
  mov    -0xd8(%rbp),%r15
L17:
  mov    %r9d,%eax
  cltd
  idiv   %edi
  pxor   %xmm2,%xmm2
  cvtsi2sd %edx,%xmm2
  addsd  %xmm4,%xmm2
  mulsd  %xmm2,%xmm2
  cmpl   $0x0,-0x50(%rbp)
  jle    L162
  movslq %r11d,%rax
  mov    -0x78(%rbp),%rsi
  lea    (%rsi,%rax,8),%rdx
  mov    $0x0,%eax
  pxor   %xmm1,%xmm1
L66:
  movsd  (%rdx,%rax,8),%xmm0
  mulsd  (%r15,%rax,8),%xmm0
  addsd  %xmm0,%xmm1
  add    $0x1,%rax
  cmp    %rax,%r8
  jne    L66
L107:
  divsd  %xmm2,%xmm1
  mov    -0xb8(%rbp),%rax
  movsd  %xmm1,(%rax,%r9,8)
  cmp    %r9d,%r14d
  jle    L68
  movslq %ebx,%rax
  mov    -0x90(%rbp),%rdx
  lea    (%rdx,%rax,8),%rsi
  movslq %r12d,%rax
  lea    (%rdx,%rax,8),%r13
  mov    %r9,%rcx
L47:
  mov    %ecx,%eax
  cltd
  idiv   %edi
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  addsd  %xmm3,%xmm0
  mulsd  %xmm0,%xmm0
  mulsd  %xmm2,%xmm0
  movsd  0x0(%r13,%rcx,8),%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm1,0x0(%r13,%rcx,8)
  movsd  %xmm1,(%rsi)
  add    $0x1,%rcx
  add    -0x48(%rbp),%rsi
  cmp    %ecx,%r14d
  jg     L47
L68:
  mov    -0x50(%rbp),%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  -0xc0(%rbp),%xmm0
  addsd  (%r10),%xmm0
  movsd  %xmm0,(%r10)
  add    $0x1,%r9
  add    -0x68(%rbp),%r10
  add    %r14d,%r12d
  add    %eax,%r11d
  add    -0x60(%rbp),%ebx
  cmp    -0x58(%rbp),%r9
  jne    L17
L294:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L193
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L162:
  pxor   %xmm1,%xmm1
  jmp    L107
L193:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D0
type_infered: f64

tool: D0: 1

assistant: ```c
void def_hat(int numt, int nharm, int detrend_order, double hat_matr[], double hat0[], double sinx[], double cosx[], double wt[], double cn[], double hat_hat[], double vec[], double lambda0) {
  int i, j = numt * nharm, k, j1, npar = 2 * nharm, dord1 = detrend_order + 1;
  double sx0[numt], cx0[numt], ct, st, sum;
  for (i = 0; i < numt; i++) {
    sx0[i] = (hat_matr[i] = sinx[i]) / wt[i];
    cx0[i] = (hat_matr[i + j] = cosx[i]) / wt[i];
  }
  for (j = 0; j < nharm - 1; j++) {
    update_sincos(numt, sx0, cx0, hat_matr + j * numt, hat_matr + (j + nharm) * numt, numt);
    for (i = 0; i <= detrend_order; i++)
      calc_dotprod(numt, hat_matr + j * numt, hat_matr + (j + nharm) * numt, wt, i, &hat0[i + j * dord1], &hat0[i + (j + nharm) * dord1]);
  }
  for (i = 0; i <= detrend_order; i++)
    calc_dotprod(numt, hat_matr + j * numt, hat_matr + (j + nharm) * numt, wt, i, &hat0[i + j * dord1], &hat0[i + (j + nharm) * dord1]);
  for (j = 0; j < npar; j++) {
    for (k = j; k < npar; k++) {
      for (sum = 0, i = 0; i < numt; i++)
        sum += hat_matr[i + j * numt] * hat_matr[i + k * numt];
      for (i = 0; i <= detrend_order; i++)
        sum -= hat0[i + j * dord1] * hat0[i + k * dord1];
      hat_hat[k + j * npar] = sum;
    }
  }
  for (j = 0; j < npar; j++) {
    ct = (1. + (j % nharm));
    ct *= ct;
    for (sum = 0, i = 0; i < numt; i++)
      sum += hat_matr[i + j * numt] * cn[i];
    vec[j] = sum / ct;
    for (k = j; k < npar; k++) {
      st = (1. + (k % nharm));
      st *= st;
      hat_hat[k + j * npar] /= (ct * st);
      hat_hat[j + k * npar] = hat_hat[k + j * npar];
    }
    hat_hat[j + j * npar] += numt * lambda0;
  }
}
```