user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<apply_rotate>:
  endbr64
  mov    %rdi,%rax
  mov    %rsi,%rdi
  mov    %edx,%esi
  cmp    $0x3,%esi
  je     L79
  cmp    $0x2,%esi
  je     L6
  test   %esi,%esi
  jle    L74
  lea    0x8(%rax),%rdx
  cmp    %rdx,%r8
  je     L42
  lea    -0x1(%rsi),%edx
  cmp    $0x1,%edx
  jbe    L42
  mov    %esi,%ecx
  xor    %edx,%edx
  shr    %ecx
  shl    $0x4,%rcx
  nopl   (%rax)
L44:
  movupd (%r8,%rdx,1),%xmm0
  movupd (%rax,%rdx,1),%xmm5
  addpd  %xmm5,%xmm0
  movups %xmm0,(%r8,%rdx,1)
  add    $0x10,%rdx
  cmp    %rdx,%rcx
  jne    L44
  mov    %esi,%edx
  and    $0xfffffffe,%edx
  and    $0x1,%esi
  je     L27
  lea    (%r8,%rdx,8),%rcx
  movsd  (%rcx),%xmm0
  addsd  (%rax,%rdx,8),%xmm0
  movsd  %xmm0,(%rcx)
  ret
  nopl   (%rax)
L6:
  movsd  (%rdi),%xmm0
  mulsd  (%rax),%xmm0
  addsd  (%r8),%xmm0
  movsd  0x8(%rax),%xmm1
  movsd  0x8(%r8),%xmm2
  test   %ecx,%ecx
  je     L80
  mulsd  0x10(%rdi),%xmm1
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%r8)
  movsd  0x8(%rdi),%xmm0
L5:
  mulsd  (%rax),%xmm0
  movsd  0x18(%rdi),%xmm1
  mulsd  0x8(%rax),%xmm1
  addsd  %xmm2,%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  ret
  nopl   0x0(%rax,%rax,1)
L42:
  xor    %edx,%edx
  nopw   0x0(%rax,%rax,1)
L83:
  movsd  (%r8,%rdx,8),%xmm0
  addsd  (%rax,%rdx,8),%xmm0
  movsd  %xmm0,(%r8,%rdx,8)
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  jne    L83
L27:
  ret
  nopl   0x0(%rax,%rax,1)
L79:
  movsd  (%rax),%xmm0
  mulsd  (%rdi),%xmm0
  movsd  (%r8),%xmm1
  movsd  0x10(%rax),%xmm3
  movsd  0x10(%r8),%xmm2
  movsd  0x8(%r8),%xmm4
  addsd  %xmm0,%xmm1
  movsd  0x8(%rax),%xmm0
  test   %ecx,%ecx
  je     L30
  mulsd  0x18(%rdi),%xmm0
  mulsd  0x30(%rdi),%xmm3
  addsd  %xmm1,%xmm0
  addsd  %xmm3,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x8(%rdi),%xmm0
  mulsd  (%rax),%xmm0
  movsd  0x20(%rdi),%xmm1
  mulsd  0x8(%rax),%xmm1
  addsd  %xmm4,%xmm0
  addsd  %xmm1,%xmm0
  movsd  0x38(%rdi),%xmm1
  mulsd  0x10(%rax),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  movsd  0x10(%rdi),%xmm0
  mulsd  (%rax),%xmm0
  movsd  0x28(%rdi),%xmm1
  addsd  %xmm2,%xmm0
L101:
  mulsd  0x8(%rax),%xmm1
  addsd  %xmm1,%xmm0
  movsd  0x40(%rdi),%xmm1
  mulsd  0x10(%rax),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x10(%r8)
  ret
  nopl   0x0(%rax)
L30:
  mulsd  0x8(%rdi),%xmm0
  mulsd  0x10(%rdi),%xmm3
  addsd  %xmm1,%xmm0
  addsd  %xmm3,%xmm0
  movsd  %xmm0,(%r8)
  movsd  0x18(%rdi),%xmm0
  mulsd  (%rax),%xmm0
  movsd  0x20(%rdi),%xmm1
  mulsd  0x8(%rax),%xmm1
  addsd  %xmm4,%xmm0
  addsd  %xmm1,%xmm0
  movsd  0x28(%rdi),%xmm1
  mulsd  0x10(%rax),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r8)
  movsd  0x30(%rdi),%xmm0
  mulsd  (%rax),%xmm0
  movsd  0x38(%rdi),%xmm1
  addsd  %xmm2,%xmm0
  jmp    L101
  nopw   0x0(%rax,%rax,1)
L80:
  mulsd  0x8(%rdi),%xmm1
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%r8)
  movsd  0x10(%rdi),%xmm0
  jmp    L5
  nopl   0x0(%rax,%rax,1)
L74:
  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];
  }
}
```