user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<R2Quaternion>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x38(%rbp),%rax
  movss  (%rax),%xmm1
  movss  D112(%rip),%xmm0
  addss  %xmm0,%xmm1
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x4(%rax),%xmm0
  addss  %xmm0,%xmm1
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x8(%rax),%xmm0
  addss  %xmm1,%xmm0
  movss  %xmm0,-0x20(%rbp)
  mov    -0x38(%rbp),%rax
  movss  (%rax),%xmm1
  movss  D112(%rip),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x4(%rax),%xmm1
  subss  %xmm1,%xmm0
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x8(%rax),%xmm1
  subss  %xmm1,%xmm0
  movss  %xmm0,-0x1c(%rbp)
  mov    -0x38(%rbp),%rax
  movss  (%rax),%xmm2
  movss  D112(%rip),%xmm0
  movaps %xmm0,%xmm1
  subss  %xmm2,%xmm1
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x4(%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x8(%rax),%xmm1
  subss  %xmm1,%xmm0
  movss  %xmm0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  movss  (%rax),%xmm1
  movss  D112(%rip),%xmm0
  subss  %xmm1,%xmm0
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x4(%rax),%xmm2
  movaps %xmm0,%xmm1
  subss  %xmm2,%xmm1
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x8(%rax),%xmm0
  addss  %xmm1,%xmm0
  movss  %xmm0,-0x14(%rbp)
  movl   $0x0,-0x28(%rbp)
  movss  -0x20(%rbp),%xmm0
  movss  %xmm0,-0x2c(%rbp)
  movl   $0x1,-0x24(%rbp)
  jmp    L100
L64:
  mov    -0x24(%rbp),%eax
  cltq
  movss  -0x20(%rbp,%rax,4),%xmm0
  comiss -0x2c(%rbp),%xmm0
  jbe    L34
  mov    -0x24(%rbp),%eax
  cltq
  movss  -0x20(%rbp,%rax,4),%xmm0
  movss  %xmm0,-0x2c(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x28(%rbp)
L34:
  addl   $0x1,-0x24(%rbp)
L100:
  cmpl   $0x3,-0x24(%rbp)
  jle    L64
  mov    -0x2c(%rbp),%eax
  movd   %eax,%xmm0
  call   <sqrtf@plt>
  add    %eax,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movss  %xmm0,-0x2c(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  jne    L46
  movss  -0x2c(%rbp),%xmm0
  movss  D74(%rip),%xmm1
  divss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x8(%rax),%xmm0
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x4(%rax),%xmm1
  subss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x4,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  (%rax),%xmm0
  mov    -0x38(%rbp),%rax
  movss  0x8(%rax),%xmm1
  subss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  0x4(%rax),%xmm0
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  (%rax),%xmm1
  subss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0xc,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  jmp    L50
L46:
  cmpl   $0x1,-0x28(%rbp)
  jne    L18
  mov    -0x40(%rbp),%rax
  add    $0x4,%rax
  movss  -0x2c(%rbp),%xmm0
  movss  D74(%rip),%xmm1
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x8(%rax),%xmm0
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x4(%rax),%xmm1
  subss  %xmm1,%xmm0
  divss  -0x2c(%rbp),%xmm0
  mov    -0x40(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  0x4(%rax),%xmm1
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  (%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  0x8(%rax),%xmm1
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  (%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0xc,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  jmp    L50
L18:
  cmpl   $0x2,-0x28(%rbp)
  jne    L81
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  movss  -0x2c(%rbp),%xmm0
  movss  D74(%rip),%xmm1
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  (%rax),%xmm0
  mov    -0x38(%rbp),%rax
  movss  0x8(%rax),%xmm1
  subss  %xmm1,%xmm0
  divss  -0x2c(%rbp),%xmm0
  mov    -0x40(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  0x4(%rax),%xmm1
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  (%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x4,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x8(%rax),%xmm1
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x4(%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0xc,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  jmp    L50
L81:
  mov    -0x40(%rbp),%rax
  add    $0xc,%rax
  movss  -0x2c(%rbp),%xmm0
  movss  D74(%rip),%xmm1
  divss  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  0x4(%rax),%xmm0
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  (%rax),%xmm1
  subss  %xmm1,%xmm0
  divss  -0x2c(%rbp),%xmm0
  mov    -0x40(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  movss  0x8(%rax),%xmm1
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  (%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x4,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x38(%rbp),%rax
  add    $0xc,%rax
  movss  0x8(%rax),%xmm1
  mov    -0x38(%rbp),%rax
  add    $0x18,%rax
  movss  0x4(%rax),%xmm0
  addss  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  divss  -0x2c(%rbp),%xmm0
  movss  %xmm0,(%rax)
L50:
  mov    -0x40(%rbp),%rax
  movss  (%rax),%xmm1
  pxor   %xmm0,%xmm0
  comiss %xmm1,%xmm0
  ja     L82
  jmp    L95
L82:
  mov    -0x40(%rbp),%rax
  movss  (%rax),%xmm0
  movss  D16(%rip),%xmm1
  xorps  %xmm1,%xmm0
  mov    -0x40(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    -0x40(%rbp),%rax
  add    $0x4,%rax
  movss  (%rax),%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x4,%rax
  movss  D16(%rip),%xmm1
  xorps  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  movss  (%rax),%xmm0
  mov    -0x40(%rbp),%rax
  add    $0x8,%rax
  movss  D16(%rip),%xmm1
  xorps  %xmm1,%xmm0
  movss  %xmm0,(%rax)
  mov    -0x40(%rbp),%rax
  add    $0xc,%rax
  movss  (%rax),%xmm0
  mov    -0x40(%rbp),%rax
  add    $0xc,%rax
  movss  D16(%rip),%xmm1
  xorps  %xmm1,%xmm0
  movss  %xmm0,(%rax)
L95:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L29
  call   <__stack_chk_fail@plt>
L29:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D112
datatype: byte[4]
name: retrieve_data
arguments: data_tag: D74
datatype: byte[4]
name: retrieve_data
arguments: data_tag: D16
datatype: byte[4]

tool: {"D112": [0x00,0x00,0x80,0x3f]}

tool: {"D74": [0x00,0x00,0x80,0x40]}

tool: {"D16": [0x00,0x00,0x00,0x80]}

assistant: ```c
void R2Quaternion(float R[3][3], float q[4]) {
  float m[4], mag;
  uint8_t index, i;
  m[0] = 1 + R[0][0] + R[1][1] + R[2][2];
  m[1] = 1 + R[0][0] - R[1][1] - R[2][2];
  m[2] = 1 - R[0][0] + R[1][1] - R[2][2];
  m[3] = 1 - R[0][0] - R[1][1] + R[2][2];
  index = 0;
  mag = m[0];
  for (i = 1; i < 4; i++) {
    if (m[i] > mag) {
      mag = m[i];
      index = i;
    }
  }
  mag = 2 * sqrtf(mag);
  if (index == 0) {
    q[0] = mag / 4;
    q[1] = (R[1][2] - R[2][1]) / mag;
    q[2] = (R[2][0] - R[0][2]) / mag;
    q[3] = (R[0][1] - R[1][0]) / mag;
  } else if (index == 1) {
    q[1] = mag / 4;
    q[0] = (R[1][2] - R[2][1]) / mag;
    q[2] = (R[0][1] + R[1][0]) / mag;
    q[3] = (R[0][2] + R[2][0]) / mag;
  } else if (index == 2) {
    q[2] = mag / 4;
    q[0] = (R[2][0] - R[0][2]) / mag;
    q[1] = (R[0][1] + R[1][0]) / mag;
    q[3] = (R[1][2] + R[2][1]) / mag;
  } else {
    q[3] = mag / 4;
    q[0] = (R[0][1] - R[1][0]) / mag;
    q[1] = (R[0][2] + R[2][0]) / mag;
    q[2] = (R[1][2] + R[2][1]) / mag;
  }
  if (q[0] < 0) {
    q[0] = -q[0];
    q[1] = -q[1];
    q[2] = -q[2];
    q[3] = -q[3];
  }
}
```