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

```asm
<refine_psd>:
  endbr64
  push   %rbp
  movapd %xmm0,%xmm5
  mov    %rsp,%rbp
  push   %r15
  lea    (%rsi,%rsi,1),%r15d
  push   %r14
  mov    %r9,%r14
  push   %r13
  push   %r12
  push   %rbx
  movslq %r15d,%rbx
  shl    $0x3,%rbx
  sub    $0x88,%rsp
  mov    0x18(%rbp),%rax
  mov    %edi,-0x44(%rbp)
  mov    0x10(%rbp),%r9
  mov    0x40(%rbp),%r10
  mov    %edx,-0x68(%rbp)
  mov    %rbx,%rdx
  mov    %rax,-0x78(%rbp)
  mov    0x20(%rbp),%rax
  mov    %rcx,-0x70(%rbp)
  mov    %rsp,%rcx
  mov    0x48(%rbp),%r11
  mov    %rax,-0x80(%rbp)
  mov    0x28(%rbp),%rax
  mov    %rax,-0x88(%rbp)
  mov    0x30(%rbp),%rax
  mov    %rax,-0x60(%rbp)
  mov    0x38(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    0xf(%rbx),%rax
  mov    %rax,%rdi
  and    $0xfffffffffffff000,%rdi
  sub    %rdi,%rcx
  cmp    %rcx,%rsp
  je     L78
L113:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L113
L78:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L11
L69:
  mov    %rax,%rdi
  mov    %rsp,%rcx
  mov    %rax,%rdx
  mov    %rsp,%r12
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rcx
  cmp    %rcx,%rsp
  je     L15
L149:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L149
L15:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L74
L33:
  mov    %rax,%rcx
  mov    %rsp,%rdx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%r13
  sub    %rax,%rdx
  and    $0xfffffffffffffff0,%rcx
  cmp    %rdx,%rsp
  je     L116
L88:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdx,%rsp
  jne    L88
L116:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L125
  orq    $0x0,-0x8(%rsp,%rax,1)
L125:
  mov    -0x50(%rbp),%rax
  mov    -0x70(%rbp),%rcx
  mov    %rsp,-0x58(%rbp)
  sub    $0x8,%rsp
  mov    -0x68(%rbp),%edx
  mov    -0x44(%rbp),%edi
  mov    %r11,-0xb0(%rbp)
  movsd  (%rax),%xmm6
  push   %r13
  push   %r14
  push   -0x88(%rbp)
  movapd %xmm6,%xmm0
  push   -0x80(%rbp)
  push   -0x78(%rbp)
  mov    %r10,-0x98(%rbp)
  movsd  %xmm1,-0xa8(%rbp)
  movsd  %xmm5,-0xa0(%rbp)
  movsd  %xmm6,-0x90(%rbp)
  call   <def_hat@plt>
  mov    -0x58(%rbp),%rdx
  add    $0x30,%rsp
  mov    %r14,%rsi
  mov    %r15d,%edi
  call   <get_eigs@plt>
  test   %r15d,%r15d
  mov    -0x98(%rbp),%r10
  movsd  -0xa0(%rbp),%xmm5
  movsd  -0xa8(%rbp),%xmm1
  mov    -0xb0(%rbp),%r11
  jle    L121
  mov    %r15d,%r8d
  mov    %r14,%rdi
  pxor   %xmm4,%xmm4
  xor    %esi,%esi
  lea    0x0(%r13,%r8,8),%rcx
  nopl   0x0(%rax)
L47:
  mov    %r13,%rax
  mov    %rdi,%rdx
  movapd %xmm4,%xmm3
  nopw   0x0(%rax,%rax,1)
L34:
  movsd  (%rdx),%xmm2
  mulsd  (%rax),%xmm2
  add    $0x8,%rax
  add    %rbx,%rdx
  addsd  %xmm2,%xmm3
  cmp    %rax,%rcx
  jne    L34
  movsd  %xmm3,(%r12,%rsi,8)
  add    $0x1,%rsi
  add    $0x8,%rdi
  cmp    %rsi,%r8
  jne    L47
L121:
  push   %r11
  mov    -0x44(%rbp),%esi
  mov    %r14,%rcx
  movapd %xmm5,%xmm0
  push   %r10
  mov    -0x50(%rbp),%r9
  mov    %r12,%rdx
  mov    %r15d,%edi
  mov    -0x58(%rbp),%r8
  call   <optimize_px@plt>
  cmpl   $0x1,0x50(%rbp)
  pop    %rcx
  pop    %rsi
  je     L53
L46:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L157
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L11:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L69
L74:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L33
L53:
  pxor   %xmm1,%xmm1
  mov    -0x50(%rbp),%rax
  sub    $0x8,%rsp
  mov    -0x58(%rbp),%r8
  cvtsi2sdl -0x44(%rbp),%xmm1
  mov    -0x60(%rbp),%rcx
  mov    %r13,%rdx
  mov    %r14,%rsi
  movsd  -0x90(%rbp),%xmm2
  mov    %r15d,%edi
  movsd  %xmm0,-0x68(%rbp)
  mulsd  %xmm1,%xmm2
  mulsd  (%rax),%xmm1
  cvttsd2si %xmm2,%r9d
  cvttsd2si %xmm1,%eax
  push   %rax
  call   <inv_hat@plt>
  pop    %rax
  movsd  -0x68(%rbp),%xmm0
  pop    %rdx
  jmp    L46
L157:
  call   <__stack_chk_fail@plt>
```

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;
}
```