user: 下面的汇编指令对应的C源代码是什么：

```asm
<apply_rotate>:
  endbr64
  cmp    $0x3,%edx
  je     L6
  cmp    $0x2,%edx
  je     L42
  mov    %edx,%ecx
  mov    $0x0,%eax
  test   %edx,%edx
  jle    L16
L1:
  movsd  (%r8,%rax,8),%xmm0
  addsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%r8,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L1
  ret
L6:
  test   %ecx,%ecx
  jne    L9
  movsd  (%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  (%r8),%xmm0
  movsd  0x8(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x10(%rsi),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x18(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  0x8(%r8),%xmm0
  movsd  0x20(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x28(%rsi),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  movsd  0x30(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  0x10(%r8),%xmm0
  movsd  0x38(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x40(%rsi),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x10(%r8)
  ret
L9:
  movsd  (%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  (%r8),%xmm0
  movsd  0x18(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x30(%rsi),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x8(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  0x8(%r8),%xmm0
  movsd  0x20(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x38(%rsi),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  movsd  0x10(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  0x10(%r8),%xmm0
  movsd  0x28(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x40(%rsi),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x10(%r8)
  ret
L16:
  ret
L42:
  test   %ecx,%ecx
  jne    L12
  movsd  (%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  (%r8),%xmm0
  movsd  0x8(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x10(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  0x8(%r8),%xmm0
  movsd  0x18(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  ret
L12:
  movsd  (%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  (%r8),%xmm0
  movsd  0x10(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x8(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  0x8(%r8),%xmm0
  movsd  0x18(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  ret
```

assistant: ```c
void apply_rotate(double *q_in, double *R, int n_dim, int transpose, double *q_out) {
  if (n_dim == 3) {
    if (transpose == 0) {
      q_out[0] = q_out[0] + R[0] * q_in[0] + R[1] * q_in[1] + R[2] * q_in[2];
      q_out[1] = q_out[1] + R[3] * q_in[0] + R[4] * q_in[1] + R[5] * q_in[2];
      q_out[2] = q_out[2] + R[6] * q_in[0] + R[7] * q_in[1] + R[8] * q_in[2];
    } else {
      q_out[0] = q_out[0] + R[0] * q_in[0] + R[3] * q_in[1] + R[6] * q_in[2];
      q_out[1] = q_out[1] + R[1] * q_in[0] + R[4] * q_in[1] + R[7] * q_in[2];
      q_out[2] = q_out[2] + R[2] * q_in[0] + R[5] * q_in[1] + R[8] * q_in[2];
    }
  } else if (n_dim == 2) {
    if (transpose == 0) {
      q_out[0] = q_out[0] + R[0] * q_in[0] + R[1] * q_in[1];
      q_out[1] = q_out[1] + R[2] * q_in[0] + R[3] * q_in[1];
    } else {
      q_out[0] = q_out[0] + R[0] * q_in[0] + R[2] * q_in[1];
      q_out[1] = q_out[1] + R[1] * q_in[0] + R[3] * q_in[1];
    }
  } else {
    for (int j = 0; j < n_dim; j++)
      q_out[j] = q_out[j] + q_in[j];
  }
}
```