user: What would the C source look like for the assembly code provided here?

```asm
<quatd_from_mat3d>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movsd  (%rsi),%xmm0
  addsd  0x20(%rsi),%xmm0
  addsd  0x40(%rsi),%xmm0
  comisd D34(%rip),%xmm0
  jbe    L67
  addsd  D44(%rip),%xmm0
  cvtsd2ss %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  ucomiss %xmm0,%xmm1
  ja     L37
  sqrtss %xmm0,%xmm0
L52:
  cvtss2sd %xmm0,%xmm0
  movsd  D31(%rip),%xmm1
  movapd %xmm0,%xmm2
  mulsd  %xmm1,%xmm2
  movsd  %xmm2,0x18(%rbp)
  divsd  %xmm0,%xmm1
  movsd  %xmm1,0x8(%rsp)
  mov    $0x1,%esi
  mov    $0x2,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r12
  mov    $0x2,%esi
  mov    $0x1,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movq   %r12,%xmm0
  subsd  (%rbx,%rax,8),%xmm0
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x0(%rbp)
  mov    $0x2,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r12
  mov    $0x0,%esi
  mov    $0x2,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movq   %r12,%xmm0
  subsd  (%rbx,%rax,8),%xmm0
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x8(%rbp)
  mov    $0x2,%esi
  mov    $0x1,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r12
  mov    $0x1,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movq   %r12,%xmm0
  subsd  (%rbx,%rax,8),%xmm0
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x10(%rbp)
L69:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L37:
  call   <sqrtf@plt>
  jmp    L52
L67:
  movl   $0x1,0x1c(%rsp)
  movl   $0x2,0x20(%rsp)
  movl   $0x0,0x24(%rsp)
  mov    $0x1,%esi
  mov    $0x1,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r12
  mov    $0x0,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movq   %r12,%xmm6
  comisd (%rbx,%rax,8),%xmm6
  seta   %r12b
  movzbl %r12b,%r12d
  mov    $0x2,%esi
  mov    $0x2,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r13
  mov    %r12d,%esi
  mov    %r12d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movq   %r13,%xmm7
  ucomisd (%rbx,%rax,8),%xmm7
  mov    $0x2,%eax
  cmova  %eax,%r12d
  movslq %r12d,%rax
  mov    0x1c(%rsp,%rax,4),%r13d
  movslq %r13d,%rax
  mov    0x1c(%rsp,%rax,4),%r14d
  mov    %r12d,%esi
  mov    %r12d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movsd  (%rbx,%rax,8),%xmm4
  movsd  %xmm4,0x8(%rsp)
  mov    %r13d,%esi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r15
  mov    %r14d,%esi
  mov    %r14d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  movq   %r15,%xmm1
  addsd  (%rbx,%rax,8),%xmm1
  movsd  0x8(%rsp),%xmm0
  subsd  %xmm1,%xmm0
  addsd  D44(%rip),%xmm0
  cvtsd2ss %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  ucomiss %xmm0,%xmm1
  ja     L49
  sqrtss %xmm0,%xmm0
  movss  %xmm0,0x8(%rsp)
L16:
  movslq %r12d,%rax
  pxor   %xmm0,%xmm0
  cvtss2sd 0x8(%rsp),%xmm0
  mulsd  D31(%rip),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  mov    %r13d,%esi
  mov    %r14d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r15
  mov    %r14d,%esi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  movss  D15(%rip),%xmm0
  divss  0x8(%rsp),%xmm0
  pxor   %xmm3,%xmm3
  cvtss2sd %xmm0,%xmm3
  cltq
  movq   %r15,%xmm0
  subsd  (%rbx,%rax,8),%xmm0
  movsd  %xmm3,0x8(%rsp)
  mulsd  %xmm3,%xmm0
  movsd  %xmm0,0x18(%rbp)
  mov    %r12d,%esi
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r15
  mov    %r13d,%esi
  mov    %r12d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  movslq %r13d,%r13
  cltq
  movq   %r15,%xmm0
  addsd  (%rbx,%rax,8),%xmm0
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x0(%rbp,%r13,8)
  mov    %r12d,%esi
  mov    %r14d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  cltq
  mov    (%rbx,%rax,8),%r13
  mov    %r14d,%esi
  mov    %r12d,%edi
  mov    $0x0,%eax
  call   <mat3_getIndex@plt>
  movslq %r14d,%r14
  cltq
  movq   %r13,%xmm0
  addsd  (%rbx,%rax,8),%xmm0
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x0(%rbp,%r14,8)
  jmp    L69
L49:
  call   <sqrtf@plt>
  movss  %xmm0,0x8(%rsp)
  jmp    L16
L53:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D34
data_type: f64[2]
name: parse_data
arguments: data_label: D44
data_type: f64
name: parse_data
arguments: data_label: D31
data_type: f64
name: parse_data
arguments: data_label: D15
data_type: byte[4]

tool: {"D34": [0.0,1.0]}

tool: D44: 1

tool: D31: 0.5

tool: {"D15": [0x00,0x00,0x00,0x3f]}

assistant: ```c
void quatd_from_mat3d(double quat[4], const double matrix[9]) {
  int X = 0, Y = 1, Z = 2, W = 3;
  double trace = matrix[0] + matrix[4] + matrix[8];
  if (trace > 0.0) {
    double s = sqrtf(trace + 1.0);
    quat[W] = s * 0.5;
    s = 0.5 / s;
    quat[X] = (matrix[mat3_getIndex(Z, Y)] - matrix[mat3_getIndex(Y, Z)]) * s;
    quat[Y] = (matrix[mat3_getIndex(X, Z)] - matrix[mat3_getIndex(Z, X)]) * s;
    quat[Z] = (matrix[mat3_getIndex(Y, Z)] - matrix[mat3_getIndex(X, Y)]) * s;
  } else {
    int next[3] = {Y, Z, X};
    int i = X;
    if (matrix[mat3_getIndex(Y, Y)] > matrix[mat3_getIndex(X, X)])
      i = Y;
    if (matrix[mat3_getIndex(Z, Z)] > matrix[mat3_getIndex(i, i)])
      i = Z;
    int j = next[i];
    int k = next[j];
    float s = sqrtf((matrix[mat3_getIndex(i, i)] - (matrix[mat3_getIndex(j, j)] + matrix[mat3_getIndex(k, k)])) + 1.0);
    quat[i] = s * 0.5;
    s = 0.5 / s;
    quat[W] = (matrix[mat3_getIndex(k, j)] - matrix[mat3_getIndex(j, k)]) * s;
    quat[j] = (matrix[mat3_getIndex(j, i)] + matrix[mat3_getIndex(i, j)]) * s;
    quat[k] = (matrix[mat3_getIndex(k, i)] + matrix[mat3_getIndex(i, k)]) * s;
  }
}
```