user: Please show me the C implementation that matches the assembly code listed below:

```asm
<_calc_dihedral_angle>:
  endbr64
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x40,%rsp
  movsd  0x10(%rsi),%xmm4
  movsd  0x8(%rsi),%xmm7
  movsd  (%rsi),%xmm2
  movsd  0x8(%rdi),%xmm3
  movsd  0x10(%rdi),%xmm6
  movsd  (%rdi),%xmm1
  movapd %xmm4,%xmm10
  movapd %xmm4,%xmm11
  movapd %xmm3,%xmm0
  movsd  0x10(%rdx),%xmm8
  mulsd  %xmm1,%xmm10
  movapd %xmm6,%xmm5
  mulsd  %xmm7,%xmm1
  mulsd  %xmm2,%xmm3
  mulsd  %xmm4,%xmm0
  mulsd  %xmm7,%xmm5
  mulsd  %xmm2,%xmm6
  subsd  %xmm1,%xmm3
  movsd  0x8(%rdx),%xmm1
  subsd  %xmm0,%xmm5
  mulsd  %xmm1,%xmm11
  movapd %xmm7,%xmm0
  mulsd  %xmm8,%xmm0
  subsd  %xmm6,%xmm10
  movsd  (%rdx),%xmm6
  mulsd  %xmm2,%xmm8
  mulsd  %xmm2,%xmm1
  movapd %xmm10,%xmm9
  subsd  %xmm0,%xmm11
  movapd %xmm4,%xmm0
  mulsd  %xmm6,%xmm0
  mulsd  %xmm7,%xmm6
  subsd  %xmm0,%xmm8
  movapd %xmm6,%xmm0
  movapd %xmm10,%xmm6
  subsd  %xmm1,%xmm0
  movapd %xmm5,%xmm1
  mulsd  %xmm8,%xmm6
  mulsd  %xmm11,%xmm1
  mulsd  %xmm0,%xmm9
  addsd  %xmm6,%xmm1
  movapd %xmm3,%xmm6
  mulsd  %xmm0,%xmm6
  mulsd  %xmm5,%xmm0
  mulsd  %xmm8,%xmm5
  addsd  %xmm6,%xmm1
  movapd %xmm3,%xmm6
  mulsd  %xmm11,%xmm3
  mulsd  %xmm8,%xmm6
  pxor   %xmm8,%xmm8
  subsd  %xmm0,%xmm3
  movapd %xmm10,%xmm0
  mulsd  %xmm11,%xmm0
  subsd  %xmm6,%xmm9
  movapd %xmm7,%xmm6
  mulsd  %xmm7,%xmm6
  subsd  %xmm0,%xmm5
  movapd %xmm2,%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm6,%xmm0
  movapd %xmm4,%xmm6
  mulsd  %xmm4,%xmm6
  addsd  %xmm0,%xmm6
  ucomisd %xmm6,%xmm8
  ja     L29
  sqrtsd %xmm6,%xmm6
L9:
  mulsd  %xmm9,%xmm2
  ucomisd %xmm8,%xmm1
  mov    $0x0,%edx
  mulsd  %xmm7,%xmm3
  mulsd  %xmm5,%xmm4
  setnp  %al
  cmovne %edx,%eax
  addsd  %xmm3,%xmm2
  addsd  %xmm4,%xmm2
  movapd %xmm2,%xmm0
  divsd  %xmm6,%xmm0
  test   %al,%al
  je     L17
  ucomisd %xmm8,%xmm0
  setnp  %al
  cmovne %edx,%eax
  test   %al,%al
  je     L17
  mov    D6(%rip),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%rbx)
  add    $0x40,%rsp
  pop    %rbx
  ret
  nopl   0x0(%rax)
L17:
  call   <atan2@plt>
  movsd  %xmm0,(%rbx)
  add    $0x40,%rsp
  pop    %rbx
  ret
L29:
  movapd %xmm6,%xmm0
  movsd  %xmm1,0x38(%rsp)
  movsd  %xmm5,0x30(%rsp)
  movsd  %xmm3,0x28(%rsp)
  movsd  %xmm9,0x20(%rsp)
  movsd  %xmm2,0x18(%rsp)
  movsd  %xmm7,0x10(%rsp)
  movsd  %xmm4,0x8(%rsp)
  call   <sqrt@plt>
  movsd  0x38(%rsp),%xmm1
  movsd  0x30(%rsp),%xmm5
  pxor   %xmm8,%xmm8
  movsd  0x28(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm2
  movapd %xmm0,%xmm6
  movsd  0x20(%rsp),%xmm9
  movsd  0x10(%rsp),%xmm7
  movsd  0x8(%rsp),%xmm4
  jmp    L9
```

assistant: ```c
void _calc_dihedral_angle(double *va, double *vb, double *vc, double *result) {
  double n1[3], n2[3];
  double xp[3], vb_norm;
  double x, y;
  n1[0] = -va[1] * vb[2] + va[2] * vb[1];
  n1[1] = va[0] * vb[2] - va[2] * vb[0];
  n1[2] = -va[0] * vb[1] + va[1] * vb[0];
  n2[0] = -vb[1] * vc[2] + vb[2] * vc[1];
  n2[1] = vb[0] * vc[2] - vb[2] * vc[0];
  n2[2] = -vb[0] * vc[1] + vb[1] * vc[0];
  x = (n1[0] * n2[0] + n1[1] * n2[1] + n1[2] * n2[2]);
  xp[0] = n1[1] * n2[2] - n1[2] * n2[1];
  xp[1] = -n1[0] * n2[2] + n1[2] * n2[0];
  xp[2] = n1[0] * n2[1] - n1[1] * n2[0];
  vb_norm = sqrt(vb[0] * vb[0] + vb[1] * vb[1] + vb[2] * vb[2]);
  y = (xp[0] * vb[0] + xp[1] * vb[1] + xp[2] * vb[2]) / vb_norm;
  if ((fabs(x) == 0.0) && (fabs(y) == 0.0)) {
    *result = NAN;
    return;
  }
  *result = atan2(y, x);
}
```