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

```asm
<def_hat>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edi,%r12d
  push   %rbx
  mov    %edx,%ebx
  sub    $0xb8,%rsp
  mov    0x20(%rbp),%rax
  mov    %edx,-0x48(%rbp)
  mov    %r9,%rdx
  mov    %esi,-0xc4(%rbp)
  mov    %rsp,%r9
  mov    0x10(%rbp),%rdi
  mov    %rax,-0xd0(%rbp)
  mov    0x28(%rbp),%rax
  mov    %rcx,-0x70(%rbp)
  movslq %r12d,%rcx
  mov    0x18(%rbp),%r15
  mov    %rax,-0xa0(%rbp)
  mov    0x30(%rbp),%rax
  mov    %r8,-0x78(%rbp)
  mov    %rax,-0xb0(%rbp)
  movsd  %xmm0,-0xd8(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    %esi,%eax
  mov    %eax,%esi
  add    %eax,%eax
  mov    %eax,-0x50(%rbp)
  imul   %r12d,%esi
  lea    0x1(%rbx),%eax
  mov    %eax,-0x80(%rbp)
  lea    0x0(,%rcx,8),%rax
  mov    %rax,-0x98(%rbp)
  add    $0xf,%rax
  mov    %rax,%r10
  movslq %esi,%r8
  mov    %rax,%rsi
  and    $0xfffffffffffff000,%r10
  and    $0xfffffffffffffff0,%rsi
  sub    %r10,%r9
  cmp    %r9,%rsp
  je     L92
L172:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %r9,%rsp
  jne    L172
L92:
  and    $0xfff,%esi
  sub    %rsi,%rsp
  test   %rsi,%rsi
  jne    L24
L25:
  mov    %rax,%rsi
  mov    %rsp,%r9
  and    $0xfffffffffffff000,%rax
  mov    %rsp,-0x88(%rbp)
  sub    %rax,%r9
  and    $0xfffffffffffffff0,%rsi
  cmp    %r9,%rsp
  je     L133
L256:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %r9,%rsp
  jne    L256
L133:
  mov    %rsi,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L221
L292:
  mov    %rsp,-0x90(%rbp)
  test   %r12d,%r12d
  jle    L109
  mov    -0x70(%rbp),%r9
  movslq %r8d,%rax
  mov    -0x88(%rbp),%r10
  mov    -0x90(%rbp),%r11
  lea    (%r9,%rax,8),%rsi
  xor    %eax,%eax
  nopl   (%rax)
L89:
  movsd  (%rdx,%rax,8),%xmm0
  movsd  %xmm0,(%r9,%rax,8)
  divsd  (%r15,%rax,8),%xmm0
  movsd  %xmm0,(%r10,%rax,8)
  movsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  divsd  (%r15,%rax,8),%xmm0
  movsd  %xmm0,(%r11,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L89
L109:
  mov    -0xc4(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x7c(%rbp)
  test   %eax,%eax
  jle    L265
  lea    0x0(,%r8,8),%rax
  movl   $0x0,-0x68(%rbp)
  mov    -0x70(%rbp),%r14
  mov    %rax,-0xa8(%rbp)
  mov    -0xc4(%rbp),%eax
  imul   -0x80(%rbp),%eax
  movl   $0x0,-0x64(%rbp)
  mov    %r15,-0x60(%rbp)
  mov    %eax,-0xb8(%rbp)
  nop
L154:
  mov    -0xa8(%rbp),%rax
  mov    %r12d,%r9d
  mov    %r14,%rcx
  mov    %r12d,%edi
  mov    -0x90(%rbp),%rdx
  mov    -0x88(%rbp),%rsi
  lea    (%r14,%rax,1),%r15
  mov    %r15,%r8
  call   <update_sincos@plt>
  mov    -0x48(%rbp),%r10d
  test   %r10d,%r10d
  js     L246
  movslq -0x68(%rbp),%rax
  mov    -0x78(%rbp),%rsi
  mov    %rax,%rbx
  add    -0xb8(%rbp),%ebx
  lea    (%rsi,%rax,8),%r9
  movslq %ebx,%r13
  xor    %ebx,%ebx
  sub    %rax,%r13
  shl    $0x3,%r13
  mov    %r13,-0x58(%rbp)
  mov    %ebx,%r13d
  mov    %r9,%rbx
  xchg   %ax,%ax
L16:
  mov    -0x58(%rbp),%rax
  sub    $0x8,%rsp
  mov    -0x60(%rbp),%rcx
  mov    %rbx,%r9
  mov    %r13d,%r8d
  mov    %r15,%rdx
  mov    %r14,%rsi
  mov    %r12d,%edi
  add    %rbx,%rax
  add    $0x1,%r13d
  add    $0x8,%rbx
  push   %rax
  call   <calc_dotprod@plt>
  pop    %r8
  pop    %r9
  cmp    %r13d,-0x48(%rbp)
  jge    L16
L246:
  addl   $0x1,-0x64(%rbp)
  mov    -0x80(%rbp),%esi
  mov    -0x64(%rbp),%eax
  add    %esi,-0x68(%rbp)
  add    -0x98(%rbp),%r14
  cmp    -0x7c(%rbp),%eax
  jne    L154
  mov    -0x60(%rbp),%r15
L33:
  mov    -0x48(%rbp),%edi
  test   %edi,%edi
  js     L163
  mov    -0x7c(%rbp),%ebx
  mov    -0xc4(%rbp),%edx
  xor    %r8d,%r8d
  mov    -0x70(%rbp),%rdi
  add    %ebx,%edx
  mov    %edx,%eax
  imul   %r12d,%eax
  cltq
  lea    (%rdi,%rax,8),%r14
  mov    %ebx,%eax
  imul   %r12d,%eax
  cltq
  lea    (%rdi,%rax,8),%r13
  mov    %ebx,%eax
  mov    -0x80(%rbp),%ebx
  mov    -0x78(%rbp),%rdi
  imul   %ebx,%eax
  imul   %ebx,%edx
  cltq
  movslq %edx,%rdx
  lea    (%rdi,%rax,8),%r9
  sub    %rax,%rdx
  mov    %r9,%rbx
  lea    0x0(,%rdx,8),%rax
  mov    %rax,-0x60(%rbp)
  cs nopw 0x0(%rax,%rax,1)
L2:
  mov    -0x60(%rbp),%rax
  sub    $0x8,%rsp
  mov    %rbx,%r9
  mov    %r15,%rcx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12d,%edi
  mov    %r8d,-0x58(%rbp)
  add    %rbx,%rax
  add    $0x8,%rbx
  push   %rax
  call   <calc_dotprod@plt>
  mov    -0x58(%rbp),%r8d
  pop    %rdx
  pop    %rcx
  add    $0x1,%r8d
  cmp    %r8d,-0x48(%rbp)
  jge    L2
L163:
  mov    -0x50(%rbp),%esi
  test   %esi,%esi
  jle    L176
  movslq -0x50(%rbp),%rax
  movl   $0x0,-0x64(%rbp)
  pxor   %xmm2,%xmm2
  movl   $0x0,-0x68(%rbp)
  mov    -0x80(%rbp),%r10d
  mov    %rax,-0x60(%rbp)
  mov    -0x70(%rbp),%rax
  movl   $0x0,-0x7c(%rbp)
  add    $0x8,%rax
  movq   $0x0,-0x58(%rbp)
  mov    %rax,-0xb8(%rbp)
  mov    -0x48(%rbp),%eax
  movl   $0x0,-0x88(%rbp)
  mov    %rax,-0xa8(%rbp)
  mov    %rax,%r14
  mov    -0x78(%rbp),%rax
  movl   $0x0,-0x90(%rbp)
  add    $0x8,%rax
  mov    %rax,-0xc0(%rbp)
  lea    -0x1(%r12),%eax
  mov    %rax,-0x98(%rbp)
  nopl   0x0(%rax,%rax,1)
L9:
  movslq -0x68(%rbp),%r9
  mov    -0x70(%rbp),%rax
  mov    -0xb8(%rbp),%rbx
  movslq -0x64(%rbp),%r11
  lea    (%rax,%r9,8),%r13
  mov    -0x98(%rbp),%rax
  mov    -0xc0(%rbp),%rsi
  mov    -0xa0(%rbp),%rdi
  mov    -0x7c(%rbp),%r8d
  add    %r9,%rax
  lea    (%rbx,%rax,8),%rcx
  mov    -0x78(%rbp),%rax
  lea    (%rax,%r11,8),%rax
  mov    %rax,-0x48(%rbp)
  mov    -0xa8(%rbp),%rax
  add    %r11,%rax
  lea    (%rsi,%rax,8),%rdx
  movslq -0x90(%rbp),%rax
  mov    -0x58(%rbp),%rsi
  lea    (%rdi,%rax,8),%rbx
  mov    -0x88(%rbp),%edi
  cs nopw 0x0(%rax,%rax,1)
L205:
  movslq %edi,%r15
  mov    %r13,%rax
  movapd %xmm2,%xmm0
  sub    %r9,%r15
  test   %r12d,%r12d
  jle    L215
  nopw   0x0(%rax,%rax,1)
L195:
  movsd  (%rax,%r15,8),%xmm1
  mulsd  (%rax),%xmm1
  add    $0x8,%rax
  addsd  %xmm1,%xmm0
  cmp    %rax,%rcx
  jne    L195
L215:
  test   %r14d,%r14d
  js     L150
  movslq %r8d,%r15
  mov    -0x48(%rbp),%rax
  sub    %r11,%r15
  xchg   %ax,%ax
L168:
  movsd  (%rax,%r15,8),%xmm1
  mulsd  (%rax),%xmm1
  add    $0x8,%rax
  subsd  %xmm1,%xmm0
  cmp    %rax,%rdx
  jne    L168
L150:
  movsd  %xmm0,(%rbx,%rsi,8)
  add    %r12d,%edi
  add    $0x1,%rsi
  add    %r10d,%r8d
  cmp    %esi,-0x50(%rbp)
  jg     L205
  addq   $0x1,-0x58(%rbp)
  mov    -0x50(%rbp),%esi
  add    %r12d,-0x88(%rbp)
  mov    -0x58(%rbp),%rax
  add    %esi,-0x90(%rbp)
  add    %r10d,-0x7c(%rbp)
  add    %r12d,-0x68(%rbp)
  add    %r10d,-0x64(%rbp)
  cmp    -0x60(%rbp),%rax
  jne    L9
  mov    -0x50(%rbp),%esi
  pxor   %xmm5,%xmm5
  mov    -0xa0(%rbp),%r10
  xor    %ebx,%ebx
  cvtsi2sd %r12d,%xmm5
  mov    %r12d,-0x48(%rbp)
  mulsd  -0xd8(%rbp),%xmm5
  xor    %r9d,%r9d
  lea    0x1(%rsi),%eax
  mov    -0xc4(%rbp),%r12d
  mov    %r10,%rdi
  mov    %r10,%r11
  cltq
  movsd  D8(%rip),%xmm4
  mov    -0xd0(%rbp),%r15
  lea    0x0(,%rax,8),%r14
  mov    -0x60(%rbp),%rax
  mov    %r14,-0x58(%rbp)
  mov    -0x98(%rbp),%r14
  lea    0x8(,%rax,8),%r13
  lea    0x0(,%rax,8),%r8
  mov    %r13,-0x50(%rbp)
  mov    %esi,%r13d
  nopl   (%rax)
L117:
  mov    %r9d,%eax
  pxor   %xmm3,%xmm3
  cltd
  idiv   %r12d
  mov    -0x48(%rbp),%eax
  cvtsi2sd %edx,%xmm3
  addsd  %xmm4,%xmm3
  mulsd  %xmm3,%xmm3
  test   %eax,%eax
  jle    L175
  mov    -0x70(%rbp),%rsi
  movslq %ebx,%rax
  movapd %xmm2,%xmm1
  lea    (%rsi,%rax,8),%rcx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L264:
  movsd  (%rcx,%rax,8),%xmm0
  mulsd  (%r15,%rax,8),%xmm0
  mov    %rax,%rdx
  add    $0x1,%rax
  addsd  %xmm0,%xmm1
  cmp    %rdx,%r14
  jne    L264
L96:
  divsd  %xmm3,%xmm1
  mov    -0xb0(%rbp),%rax
  mov    %r11,%rsi
  mov    %r9,%rcx
  movsd  %xmm1,(%rax,%r9,8)
  nopw   0x0(%rax,%rax,1)
L83:
  mov    %ecx,%eax
  pxor   %xmm0,%xmm0
  movsd  (%rdi,%rcx,8),%xmm1
  cltd
  idiv   %r12d
  cvtsi2sd %edx,%xmm0
  addsd  %xmm4,%xmm0
  mulsd  %xmm0,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm1
  movsd  %xmm1,(%rdi,%rcx,8)
  add    $0x1,%rcx
  movsd  %xmm1,(%rsi)
  add    %r8,%rsi
  cmp    %ecx,%r13d
  jg     L83
  movsd  (%r10),%xmm0
  add    $0x1,%r9
  add    -0x50(%rbp),%r11
  add    %r8,%rdi
  add    -0x48(%rbp),%ebx
  addsd  %xmm5,%xmm0
  movsd  %xmm0,(%r10)
  add    -0x58(%rbp),%r10
  cmp    %r9,-0x60(%rbp)
  jne    L117
L176:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L99
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L24:
  orq    $0x0,-0x8(%rsp,%rsi,1)
  jmp    L25
L175:
  movapd %xmm2,%xmm1
  jmp    L96
L265:
  movl   $0x0,-0x7c(%rbp)
  jmp    L33
L221:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L292
L99:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D8
type_infered: f64

tool: D8: 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;
  }
}
```