user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<apply_rotate>:
  endbr64
  mov    %rsi,%rax
  cmp    $0x3,%edx
  je     L32
  cmp    $0x2,%edx
  je     L61
  movslq %edx,%rcx
  xor    %eax,%eax
  test   %edx,%edx
  jle    L49
  nopw   0x0(%rax,%rax,1)
L30:
  movsd  (%r8,%rax,8),%xmm0
  addsd  (%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%r8,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L30
  ret
  nopl   0x0(%rax,%rax,1)
L61:
  movsd  (%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  addsd  (%r8),%xmm0
  movsd  0x8(%rdi),%xmm1
  movsd  0x8(%r8),%xmm2
  test   %ecx,%ecx
  je     L47
  mulsd  0x10(%rsi),%xmm1
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%r8)
  movsd  0x8(%rsi),%xmm0
L52:
  mulsd  (%rdi),%xmm0
  movsd  0x18(%rax),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm2,%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  ret
  nopl   0x0(%rax,%rax,1)
L32:
  movsd  (%rdi),%xmm0
  mulsd  (%rsi),%xmm0
  movsd  (%r8),%xmm1
  movsd  0x10(%rdi),%xmm3
  movsd  0x10(%r8),%xmm2
  movsd  0x8(%r8),%xmm4
  addsd  %xmm0,%xmm1
  movsd  0x8(%rdi),%xmm0
  test   %ecx,%ecx
  je     L41
  mulsd  0x18(%rsi),%xmm0
  mulsd  0x30(%rsi),%xmm3
  addsd  %xmm1,%xmm0
  addsd  %xmm3,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x8(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  movsd  0x20(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm4,%xmm0
  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
  movsd  0x28(%rsi),%xmm1
  addsd  %xmm2,%xmm0
L46:
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x40(%rax),%xmm1
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x10(%r8)
  ret
  nopl   0x0(%rax)
L41:
  mulsd  0x8(%rsi),%xmm0
  mulsd  0x10(%rsi),%xmm3
  addsd  %xmm1,%xmm0
  addsd  %xmm3,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x18(%rsi),%xmm0
  mulsd  (%rdi),%xmm0
  movsd  0x20(%rsi),%xmm1
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm4,%xmm0
  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
  movsd  0x38(%rsi),%xmm1
  addsd  %xmm2,%xmm0
  jmp    L46
  nopw   0x0(%rax,%rax,1)
L47:
  mulsd  0x8(%rsi),%xmm1
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%r8)
  movsd  0x10(%rsi),%xmm0
  jmp    L52
L49:
  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];
  }
}
```