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

```asm
<cquat_from_matrix>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  add    $0x20,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x30(%rbp),%rax
  add    $0x40,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  movsd  -0x20(%rbp),%xmm1
  movsd  D24(%rip),%xmm0
  addsd  %xmm1,%xmm0
  addsd  -0x18(%rbp),%xmm0
  movsd  -0x10(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  comisd D37(%rip),%xmm0
  jbe    L21
  mov    -0x8(%rbp),%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  addsd  %xmm0,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x18,%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  D87(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x38,%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  add    $0x28,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  divsd  -0x8(%rbp),%xmm0
  mov    -0x28(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  add    $0x30,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x18,%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L120
L21:
  movsd  -0x20(%rbp),%xmm0
  comisd -0x18(%rbp),%xmm0
  jbe    L30
  movsd  -0x20(%rbp),%xmm0
  comisd -0x10(%rbp),%xmm0
  jbe    L30
  movsd  -0x20(%rbp),%xmm1
  movsd  D24(%rip),%xmm0
  addsd  %xmm1,%xmm0
  subsd  -0x18(%rbp),%xmm0
  subsd  -0x10(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  addsd  %xmm0,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movsd  D87(%rip),%xmm1
  divsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x18,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x30,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x38,%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  add    $0x28,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x18,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L120
L30:
  movsd  -0x18(%rbp),%xmm0
  comisd -0x20(%rbp),%xmm0
  jbe    L86
  movsd  -0x18(%rbp),%xmm0
  comisd -0x10(%rbp),%xmm0
  jbe    L86
  movsd  D24(%rip),%xmm0
  subsd  -0x20(%rbp),%xmm0
  addsd  -0x18(%rbp),%xmm0
  subsd  -0x10(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  addsd  %xmm0,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  D87(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x18,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  divsd  -0x8(%rbp),%xmm0
  mov    -0x28(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x28,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x38,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  add    $0x30,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x18,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L120
L86:
  movsd  -0x10(%rbp),%xmm0
  comisd -0x20(%rbp),%xmm0
  ja     L5
  jmp    L120
L5:
  movsd  -0x10(%rbp),%xmm0
  comisd -0x18(%rbp),%xmm0
  ja     L36
  jmp    L120
L36:
  movsd  D24(%rip),%xmm0
  subsd  -0x20(%rbp),%xmm0
  subsd  -0x18(%rbp),%xmm0
  addsd  -0x10(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  call   <sqrt@plt>
  addsd  %xmm0,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  add    $0x10,%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  D87(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x10,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x30,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x18,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x28,%rax
  movsd  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x38,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  divsd  -0x8(%rbp),%xmm0
  mov    -0x28(%rbp),%rax
  movsd  %xmm0,(%rax)
  mov    -0x30(%rbp),%rax
  add    $0x18,%rax
  movsd  (%rax),%xmm0
  mov    -0x30(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  divsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L120
L120:
  nop
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D24
datatype: f64
name: extract_symbolic_data
arguments: tag: D37
datatype: f64[2]
name: extract_symbolic_data
arguments: tag: D87
datatype: f64

tool: D24: 1

tool: {"D37": [0.1,4.0]}

tool: D87: 4

assistant: ```c
void cquat_from_matrix(double *q, const double *m) {
  double m11 = m[((1) - 1) * (3) + ((1) - 1)];
  double m22 = m[((2) - 1) * (3) + ((2) - 1)];
  double m33 = m[((3) - 1) * (3) + ((3) - 1)];
  double s;
  s = 1.0 + m11 + m22 + m33;
  if (s > 0.1) {
    s = 2.0 * sqrt(s);
    q[3] = s / 4.0;
    q[0] = (m[((3) - 1) * (3) + ((2) - 1)] - m[((2) - 1) * (3) + ((3) - 1)]) / s;
    q[1] = (m[((1) - 1) * (3) + ((3) - 1)] - m[((3) - 1) * (3) + ((1) - 1)]) / s;
    q[2] = (m[((2) - 1) * (3) + ((1) - 1)] - m[((1) - 1) * (3) + ((2) - 1)]) / s;
  } else if ((m11 > m22) && (m11 > m33)) {
    s = 2.0 * sqrt(1.0 + m11 - m22 - m33);
    q[0] = s / 4.0;
    q[1] = (m[((1) - 1) * (3) + ((2) - 1)] + m[((2) - 1) * (3) + ((1) - 1)]) / s;
    q[2] = (m[((1) - 1) * (3) + ((3) - 1)] + m[((3) - 1) * (3) + ((1) - 1)]) / s;
    q[3] = (m[((3) - 1) * (3) + ((2) - 1)] - m[((2) - 1) * (3) + ((3) - 1)]) / s;
  } else if ((m22 > m11) && (m22 > m33)) {
    s = 2.0 * sqrt(1.0 - m11 + m22 - m33);
    q[1] = s / 4.0;
    q[0] = (m[((1) - 1) * (3) + ((2) - 1)] + m[((2) - 1) * (3) + ((1) - 1)]) / s;
    q[2] = (m[((2) - 1) * (3) + ((3) - 1)] + m[((3) - 1) * (3) + ((2) - 1)]) / s;
    q[3] = (m[((1) - 1) * (3) + ((3) - 1)] - m[((3) - 1) * (3) + ((1) - 1)]) / s;
  } else if ((m33 > m11) && (m33 > m22)) {
    s = 2.0 * sqrt(1.0 - m11 - m22 + m33);
    q[2] = s / 4.0;
    q[3] = (m[((1) - 1) * (3) + ((3) - 1)] + m[((3) - 1) * (3) + ((1) - 1)]) / s;
    q[0] = (m[((2) - 1) * (3) + ((3) - 1)] + m[((3) - 1) * (3) + ((2) - 1)]) / s;
    q[1] = (m[((2) - 1) * (3) + ((1) - 1)] - m[((1) - 1) * (3) + ((2) - 1)]) / s;
  }
}
```