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

```asm
<floats_mat_to_quat>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  movss  (%rdi),%xmm2
  movss  0x14(%rdi),%xmm1
  movss  0x28(%rdi),%xmm3
  movsd  D12(%rip),%xmm6
  movaps %xmm2,%xmm0
  addss  %xmm1,%xmm0
  addss  %xmm3,%xmm0
  cvtss2sd %xmm0,%xmm0
  addsd  %xmm6,%xmm0
  comisd D31(%rip),%xmm0
  ja     L37
  comiss %xmm1,%xmm2
  pxor   %xmm4,%xmm4
  pxor   %xmm7,%xmm7
  pxor   %xmm5,%xmm5
  cvtss2sd %xmm3,%xmm4
  cvtss2sd %xmm2,%xmm7
  cvtss2sd %xmm1,%xmm5
  jbe    L26
  comiss %xmm3,%xmm2
  ja     L61
L26:
  comiss %xmm3,%xmm1
  ja     L21
  addsd  %xmm6,%xmm4
  movapd %xmm4,%xmm0
  subsd  %xmm7,%xmm0
  subsd  %xmm5,%xmm0
  call   <sqrt@plt>
  pxor   %xmm0,%xmm0
  movss  0x10(%rbx),%xmm1
  subss  0x4(%rbx),%xmm1
  cvtsi2sd %eax,%xmm0
  cvtss2sd %xmm1,%xmm1
  divsd  %xmm0,%xmm1
  cvtsd2ss %xmm1,%xmm1
  movss  %xmm1,0x0(%rbp)
  movss  0x8(%rbx),%xmm1
  addss  0x20(%rbx),%xmm1
  cvtss2sd %xmm1,%xmm1
  divsd  %xmm0,%xmm1
  cvtsd2ss %xmm1,%xmm1
  movss  %xmm1,0x4(%rbp)
  movss  0x24(%rbx),%xmm1
  addss  0x18(%rbx),%xmm1
  cvtss2sd %xmm1,%xmm1
  divsd  %xmm0,%xmm1
  mulsd  D38(%rip),%xmm0
  cvtsd2ss %xmm0,%xmm0
  cvtsd2ss %xmm1,%xmm1
  movss  %xmm1,0x8(%rbp)
L11:
  movss  %xmm0,0xc(%rbp)
  add    $0x8,%rsp
  mov    %rbp,%rdx
  mov    %rbp,%rdi
  pop    %rbx
  mov    $0x4,%esi
  pop    %rbp
  jmp    1070 <floats_normalize@plt>
  nopl   0x0(%rax,%rax,1)
L21:
  addsd  %xmm6,%xmm5
  movapd %xmm5,%xmm0
  subsd  %xmm7,%xmm0
  subsd  %xmm4,%xmm0
  call   <sqrt@plt>
  pxor   %xmm1,%xmm1
  movss  0x8(%rbx),%xmm0
  subss  0x20(%rbx),%xmm0
  add    %eax,%eax
  cvtsi2sd %eax,%xmm1
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x0(%rbp)
  movss  0x10(%rbx),%xmm0
  addss  0x4(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x4(%rbp)
  movsd  D38(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x8(%rbp)
  movss  0x24(%rbx),%xmm0
  addss  0x18(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  jmp    L11
  nopl   (%rax)
L37:
  call   <sqrt@plt>
  pxor   %xmm1,%xmm1
  movsd  D38(%rip),%xmm0
  add    %eax,%eax
  cvtsi2sd %eax,%xmm1
  mulsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x0(%rbp)
  movss  0x24(%rbx),%xmm0
  subss  0x18(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x4(%rbp)
  movss  0x8(%rbx),%xmm0
  subss  0x20(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x8(%rbp)
  movss  0x10(%rbx),%xmm0
  subss  0x4(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  jmp    L11
  nopl   (%rax)
L61:
  addsd  %xmm6,%xmm7
  movapd %xmm7,%xmm0
  subsd  %xmm5,%xmm0
  subsd  %xmm4,%xmm0
  call   <sqrt@plt>
  pxor   %xmm1,%xmm1
  movss  0x24(%rbx),%xmm0
  subss  0x18(%rbx),%xmm0
  add    %eax,%eax
  cvtsi2sd %eax,%xmm1
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x0(%rbp)
  movsd  D38(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x4(%rbp)
  movss  0x10(%rbx),%xmm0
  addss  0x4(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x8(%rbp)
  movss  0x8(%rbx),%xmm0
  addss  0x20(%rbx),%xmm0
  cvtss2sd %xmm0,%xmm0
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  jmp    L11
```

tool_calls: name: parse_data
arguments: label: D12
data_type: f64
name: parse_data
arguments: label: D31
data_type: f64[2]
name: parse_data
arguments: label: D38
data_type: f64

tool: D12: 1

tool: {"D31": [1e-7,0.25]}

tool: D38: 0.25

assistant: ```c
void floats_mat_to_quat(const float M[16], float q[4]) {
  double T = M[0] + M[5] + M[10] + 1.0;
  double S;
  if (T > 0.0000001) {
    S = sqrt(T) * 2;
    q[0] = 0.25 * S;
    q[1] = (M[9] - M[6]) / S;
    q[2] = (M[2] - M[8]) / S;
    q[3] = (M[4] - M[1]) / S;
  } else if (M[0] > M[5] && M[0] > M[10]) {
    S = sqrt(1.0 + M[0] - M[5] - M[10]) * 2;
    q[0] = (M[9] - M[6]) / S;
    q[1] = 0.25 * S;
    q[2] = (M[4] + M[1]) / S;
    q[3] = (M[2] + M[8]) / S;
  } else if (M[5] > M[10]) {
    S = sqrt(1.0 + M[5] - M[0] - M[10]) * 2;
    q[0] = (M[2] - M[8]) / S;
    q[1] = (M[4] + M[1]) / S;
    q[2] = 0.25 * S;
    q[3] = (M[9] + M[6]) / S;
  } else {
    S = sqrt(1.0 + M[10] - M[0] - M[5]);
    q[0] = (M[4] - M[1]) / S;
    q[1] = (M[2] + M[8]) / S;
    q[2] = (M[9] + M[6]) / S;
    q[3] = 0.25 * S;
  }
  floats_normalize(q, 4, q);
}
```