user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<refine_psd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x118,%rsp
  mov    %edi,-0x94(%rbp)
  mov    %esi,-0x98(%rbp)
  mov    %edx,-0x9c(%rbp)
  mov    %rcx,-0xa8(%rbp)
  mov    %r8,-0xb0(%rbp)
  mov    %r9,-0xb8(%rbp)
  movsd  %xmm0,-0xf8(%rbp)
  movsd  %xmm1,-0x100(%rbp)
  mov    0x10(%rbp),%rax
  mov    %rax,-0xc0(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rax,-0xc8(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rax,-0xd0(%rbp)
  mov    0x28(%rbp),%rax
  mov    %rax,-0xd8(%rbp)
  mov    0x30(%rbp),%rax
  mov    %rax,-0xe0(%rbp)
  mov    0x38(%rbp),%rax
  mov    %rax,-0xe8(%rbp)
  mov    0x40(%rbp),%rax
  mov    %rax,-0xf0(%rbp)
  mov    0x48(%rbp),%rax
  mov    %rax,-0x108(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    -0x98(%rbp),%eax
  add    %eax,%eax
  mov    %eax,-0x84(%rbp)
  mov    -0x84(%rbp),%edx
  movslq %edx,%rax
  sub    $0x1,%rax
  mov    %rax,-0x78(%rbp)
  movslq %edx,%rax
  mov    %rax,-0x120(%rbp)
  movq   $0x0,-0x118(%rbp)
  movslq %edx,%rax
  mov    %rax,-0x130(%rbp)
  movq   $0x0,-0x128(%rbp)
  movslq %edx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L81:
  cmp    %rdx,%rsp
  je     L61
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L81
L61:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L86
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L86:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x70(%rbp)
  mov    -0x84(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x68(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0x140(%rbp)
  movq   $0x0,-0x138(%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,%edi
  mov    $0x0,%edx
  div    %rdi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L141:
  cmp    %rdx,%rsp
  je     L78
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L141
L78:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L30
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L30:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x60(%rbp)
  mov    -0x84(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x58(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L146:
  cmp    %rdx,%rsp
  je     L38
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L146
L38:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L103
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L103:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x50(%rbp)
  mov    -0xe8(%rbp),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x48(%rbp)
  mov    -0xe8(%rbp),%rax
  mov    (%rax),%rdi
  mov    -0xc0(%rbp),%r9
  mov    -0xb0(%rbp),%r8
  mov    -0xa8(%rbp),%rcx
  mov    -0x9c(%rbp),%edx
  mov    -0x98(%rbp),%esi
  mov    -0x94(%rbp),%eax
  sub    $0x8,%rsp
  push   -0x60(%rbp)
  push   -0xb8(%rbp)
  push   -0xd8(%rbp)
  push   -0xd0(%rbp)
  push   -0xc8(%rbp)
  movq   %rdi,%xmm0
  mov    %eax,%edi
  call   <def_hat@plt>
  add    $0x30,%rsp
  mov    -0x50(%rbp),%rdx
  mov    -0xb8(%rbp),%rcx
  mov    -0x84(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <get_eigs@plt>
  movl   $0x0,-0x8c(%rbp)
  jmp    L22
L2:
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x80(%rbp)
  movl   $0x0,-0x88(%rbp)
  jmp    L73
L75:
  mov    -0x88(%rbp),%eax
  imul   -0x84(%rbp),%eax
  mov    %eax,%edx
  mov    -0x8c(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0xb8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x60(%rbp),%rax
  mov    -0x88(%rbp),%edx
  movslq %edx,%rdx
  movsd  (%rax,%rdx,8),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  -0x80(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x80(%rbp)
  addl   $0x1,-0x88(%rbp)
L73:
  mov    -0x88(%rbp),%eax
  cmp    -0x84(%rbp),%eax
  jl     L75
  mov    -0x70(%rbp),%rax
  mov    -0x8c(%rbp),%edx
  movslq %edx,%rdx
  movsd  -0x80(%rbp),%xmm0
  movsd  %xmm0,(%rax,%rdx,8)
  addl   $0x1,-0x8c(%rbp)
L22:
  mov    -0x8c(%rbp),%eax
  cmp    -0x84(%rbp),%eax
  jl     L2
  movsd  -0x100(%rbp),%xmm0
  mov    -0xf8(%rbp),%rdi
  mov    -0xe8(%rbp),%r9
  mov    -0x50(%rbp),%r8
  mov    -0xb8(%rbp),%rcx
  mov    -0x70(%rbp),%rdx
  mov    -0x94(%rbp),%esi
  mov    -0x84(%rbp),%eax
  push   -0x108(%rbp)
  push   -0xf0(%rbp)
  movapd %xmm0,%xmm1
  movq   %rdi,%xmm0
  mov    %eax,%edi
  call   <optimize_px@plt>
  add    $0x10,%rsp
  movq   %xmm0,%rax
  mov    %rax,-0x40(%rbp)
  cmpl   $0x1,0x50(%rbp)
  jne    L85
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x94(%rbp),%xmm1
  mov    -0xe8(%rbp),%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%edi
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x94(%rbp),%xmm0
  mulsd  -0x48(%rbp),%xmm0
  cvttsd2si %xmm0,%r9d
  mov    -0x50(%rbp),%r8
  mov    -0xe0(%rbp),%rcx
  mov    -0x60(%rbp),%rdx
  mov    -0xb8(%rbp),%rsi
  mov    -0x84(%rbp),%eax
  sub    $0x8,%rsp
  push   %rdi
  mov    %eax,%edi
  call   <inv_hat@plt>
  add    $0x10,%rsp
L85:
  movsd  -0x40(%rbp),%xmm0
  mov    %rbx,%rsp
  movq   %xmm0,%rax
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L52
  call   <__stack_chk_fail@plt>
L52:
  movq   %rax,%xmm0
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
double refine_psd(int numt, int nharm, int detrend_order, double hat_matr[], double hat0[], double hat_hat[], double sinx[], double cosx[], double wt[], double cn[], double vec1[], double *lambda0, double *lambda0_range, double chi0, double tc, double *Tr, int inv) {
  int i, j, k, npar = 2 * nharm;
  double p[npar], vec[npar], eigs[npar], sum, px, lambda00 = *lambda0;
  def_hat(numt, nharm, detrend_order, hat_matr, hat0, sinx, cosx, wt, cn, hat_hat, vec, *lambda0);
  get_eigs(npar, hat_hat, eigs);
  for (i = 0; i < npar; i++) {
    for (sum = 0, j = 0; j < npar; j++)
      sum += hat_hat[i + j * npar] * vec[j];
    p[i] = sum;
  }
  px = optimize_px(npar, numt, p, hat_hat, eigs, lambda0, lambda0_range, chi0, tc, Tr);
  if (inv == 1)
    inv_hat(npar, hat_hat, vec, vec1, eigs, numt * lambda00, numt * (*lambda0));
  return px;
}
```