void mrotate(double theta, double axis[3], double m[3][3]) {
  double c = cos(theta);
  double s = sin(theta);
  m[0][0] = c + (1 - c) * ((axis[0]) * (axis[0]));
  m[0][1] = (1 - c) * axis[0] * axis[1] - s * axis[2];
  m[0][2] = (1 - c) * axis[0] * axis[2] + s * axis[1];
  m[1][0] = (1 - c) * axis[0] * axis[1] + s * axis[2];
  m[1][1] = c + (1 - c) * axis[1] * axis[1];
  m[1][2] = (1 - c) * axis[2] * axis[1] - s * axis[0];
  m[2][0] = (1 - c) * axis[0] * axis[2] - s * axis[1];
  m[2][1] = (1 - c) * axis[1] * axis[2] + s * axis[0];
  m[2][2] = c + (1 - c) * axis[2] * axis[2];
}


x86 assembly (clang, -O0):
<mrotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xea0(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe73(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  0xe1f(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  0xde2(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x20(%rbp),%xmm1
movsd  0xda0(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  0xd70(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  0xd1c(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  0xcc8(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x20(%rbp),%xmm1
movsd  0xc86(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mrotate>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0xeaf(%rip),%xmm1
movsd  0x10(%rsp),%xmm4
subsd  %xmm4,%xmm1
movsd  (%rbx),%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm4,%xmm2
movsd  %xmm2,(%r14)
movsd  (%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x10(%rbx),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0x8(%rbx),%xmm2
subsd  %xmm3,%xmm2
movsd  %xmm2,0x8(%r14)
movsd  (%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x8(%rbx),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0x10(%rbx),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x10(%r14)
movsd  (%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x10(%rbx),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0x8(%rbx),%xmm2
addsd  %xmm3,%xmm2
movsd  %xmm2,0x18(%r14)
movsd  0x8(%rbx),%xmm2
movapd %xmm1,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm4,%xmm3
movsd  %xmm3,0x20(%r14)
movsd  0x10(%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  (%rbx),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0x8(%rbx),%xmm2
subsd  %xmm3,%xmm2
movsd  %xmm2,0x28(%r14)
movsd  (%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x8(%rbx),%xmm3
mulsd  %xmm0,%xmm3
mulsd  0x10(%rbx),%xmm2
subsd  %xmm3,%xmm2
movsd  %xmm2,0x30(%r14)
movsd  0x8(%rbx),%xmm2
mulsd  %xmm1,%xmm2
mulsd  (%rbx),%xmm0
mulsd  0x10(%rbx),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x38(%r14)
movsd  0x10(%rbx),%xmm0
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x40(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @mrotate(double %0, double* %1, [3 x double]* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca [3 x double]*
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double* %1, double** %5
store [3 x double]* %2, [3 x double]** %6
%9 = load double, double* %4
%10 = call double @cos(double %9)
store double %10, double* %7
%11 = load double, double* %4
%12 = call double @sin(double %11)
store double %12, double* %8
%13 = load double, double* %7
%14 = load double, double* %7
%15 = fsub double 1.000000e+00, %14
%16 = load double*, double** %5
%17 = getelementptr inbounds double, double* %16, i64 0
%18 = load double, double* %17
%19 = load double*, double** %5
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = fmul double %18, %21
%23 = call double @llvm.fmuladd.f64(double %15, double %22, double %13)
%24 = load [3 x double]*, [3 x double]** %6
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0
%26 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0, i64 0
store double %23, double* %26
%27 = load double, double* %7
%28 = fsub double 1.000000e+00, %27
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = fmul double %28, %31
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = load double, double* %8
%37 = load double*, double** %5
%38 = getelementptr inbounds double, double* %37, i64 2
%39 = load double, double* %38
%40 = fmul double %36, %39
%41 = fneg double %40
%42 = call double @llvm.fmuladd.f64(double %32, double %35, double %41)
%43 = load [3 x double]*, [3 x double]** %6
%44 = getelementptr inbounds [3 x double], [3 x double]* %43, i64 0
%45 = getelementptr inbounds [3 x double], [3 x double]* %44, i64 0, i64 1
store double %42, double* %45
%46 = load double, double* %7
%47 = fsub double 1.000000e+00, %46
%48 = load double*, double** %5
%49 = getelementptr inbounds double, double* %48, i64 0
%50 = load double, double* %49
%51 = fmul double %47, %50
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 2
%54 = load double, double* %53
%55 = load double, double* %8
%56 = load double*, double** %5
%57 = getelementptr inbounds double, double* %56, i64 1
%58 = load double, double* %57
%59 = fmul double %55, %58
%60 = call double @llvm.fmuladd.f64(double %51, double %54, double %59)
%61 = load [3 x double]*, [3 x double]** %6
%62 = getelementptr inbounds [3 x double], [3 x double]* %61, i64 0
%63 = getelementptr inbounds [3 x double], [3 x double]* %62, i64 0, i64 2
store double %60, double* %63
%64 = load double, double* %7
%65 = fsub double 1.000000e+00, %64
%66 = load double*, double** %5
%67 = getelementptr inbounds double, double* %66, i64 0
%68 = load double, double* %67
%69 = fmul double %65, %68
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 1
%72 = load double, double* %71
%73 = load double, double* %8
%74 = load double*, double** %5
%75 = getelementptr inbounds double, double* %74, i64 2
%76 = load double, double* %75
%77 = fmul double %73, %76
%78 = call double @llvm.fmuladd.f64(double %69, double %72, double %77)
%79 = load [3 x double]*, [3 x double]** %6
%80 = getelementptr inbounds [3 x double], [3 x double]* %79, i64 1
%81 = getelementptr inbounds [3 x double], [3 x double]* %80, i64 0, i64 0
store double %78, double* %81
%82 = load double, double* %7
%83 = load double, double* %7
%84 = fsub double 1.000000e+00, %83
%85 = load double*, double** %5
%86 = getelementptr inbounds double, double* %85, i64 1
%87 = load double, double* %86
%88 = fmul double %84, %87
%89 = load double*, double** %5
%90 = getelementptr inbounds double, double* %89, i64 1
%91 = load double, double* %90
%92 = call double @llvm.fmuladd.f64(double %88, double %91, double %82)
%93 = load [3 x double]*, [3 x double]** %6
%94 = getelementptr inbounds [3 x double], [3 x double]* %93, i64 1
%95 = getelementptr inbounds [3 x double], [3 x double]* %94, i64 0, i64 1
store double %92, double* %95
%96 = load double, double* %7
%97 = fsub double 1.000000e+00, %96
%98 = load double*, double** %5
%99 = getelementptr inbounds double, double* %98, i64 2
%100 = load double, double* %99
%101 = fmul double %97, %100
%102 = load double*, double** %5
%103 = getelementptr inbounds double, double* %102, i64 1
%104 = load double, double* %103
%105 = load double, double* %8
%106 = load double*, double** %5
%107 = getelementptr inbounds double, double* %106, i64 0
%108 = load double, double* %107
%109 = fmul double %105, %108
%110 = fneg double %109
%111 = call double @llvm.fmuladd.f64(double %101, double %104, double %110)
%112 = load [3 x double]*, [3 x double]** %6
%113 = getelementptr inbounds [3 x double], [3 x double]* %112, i64 1
%114 = getelementptr inbounds [3 x double], [3 x double]* %113, i64 0, i64 2
store double %111, double* %114
%115 = load double, double* %7
%116 = fsub double 1.000000e+00, %115
%117 = load double*, double** %5
%118 = getelementptr inbounds double, double* %117, i64 0
%119 = load double, double* %118
%120 = fmul double %116, %119
%121 = load double*, double** %5
%122 = getelementptr inbounds double, double* %121, i64 2
%123 = load double, double* %122
%124 = load double, double* %8
%125 = load double*, double** %5
%126 = getelementptr inbounds double, double* %125, i64 1
%127 = load double, double* %126
%128 = fmul double %124, %127
%129 = fneg double %128
%130 = call double @llvm.fmuladd.f64(double %120, double %123, double %129)
%131 = load [3 x double]*, [3 x double]** %6
%132 = getelementptr inbounds [3 x double], [3 x double]* %131, i64 2
%133 = getelementptr inbounds [3 x double], [3 x double]* %132, i64 0, i64 0
store double %130, double* %133
%134 = load double, double* %7
%135 = fsub double 1.000000e+00, %134
%136 = load double*, double** %5
%137 = getelementptr inbounds double, double* %136, i64 1
%138 = load double, double* %137
%139 = fmul double %135, %138
%140 = load double*, double** %5
%141 = getelementptr inbounds double, double* %140, i64 2
%142 = load double, double* %141
%143 = load double, double* %8
%144 = load double*, double** %5
%145 = getelementptr inbounds double, double* %144, i64 0
%146 = load double, double* %145
%147 = fmul double %143, %146
%148 = call double @llvm.fmuladd.f64(double %139, double %142, double %147)
%149 = load [3 x double]*, [3 x double]** %6
%150 = getelementptr inbounds [3 x double], [3 x double]* %149, i64 2
%151 = getelementptr inbounds [3 x double], [3 x double]* %150, i64 0, i64 1
store double %148, double* %151
%152 = load double, double* %7
%153 = load double, double* %7
%154 = fsub double 1.000000e+00, %153
%155 = load double*, double** %5
%156 = getelementptr inbounds double, double* %155, i64 2
%157 = load double, double* %156
%158 = fmul double %154, %157
%159 = load double*, double** %5
%160 = getelementptr inbounds double, double* %159, i64 2
%161 = load double, double* %160
%162 = call double @llvm.fmuladd.f64(double %158, double %161, double %152)
%163 = load [3 x double]*, [3 x double]** %6
%164 = getelementptr inbounds [3 x double], [3 x double]* %163, i64 2
%165 = getelementptr inbounds [3 x double], [3 x double]* %164, i64 0, i64 2
store double %162, double* %165
ret void
}

LLVM IR (-O2):
define void @mrotate(double %0, double* nocapture %1, [3 x double]* nocapture writeonly %2) {
%4 = tail call double @cos(double %0)
%5 = tail call double @sin(double %0)
%6 = fsub double 1.000000e+00, %4
%7 = load double, double* %1
%8 = fmul double %7, %7
%9 = tail call double @llvm.fmuladd.f64(double %6, double %8, double %4)
%10 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
store double %9, double* %10
%11 = load double, double* %1
%12 = fmul double %6, %11
%13 = getelementptr inbounds double, double* %1, i64 1
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 2
%16 = load double, double* %15
%17 = fneg double %5
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %12, double %14, double %18)
%20 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
store double %19, double* %20
%21 = load double, double* %1
%22 = fmul double %6, %21
%23 = load double, double* %15
%24 = load double, double* %13
%25 = fmul double %5, %24
%26 = tail call double @llvm.fmuladd.f64(double %22, double %23, double %25)
%27 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
store double %26, double* %27
%28 = load double, double* %1
%29 = fmul double %6, %28
%30 = load double, double* %13
%31 = load double, double* %15
%32 = fmul double %5, %31
%33 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %32)
%34 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 0
store double %33, double* %34
%35 = load double, double* %13
%36 = fmul double %6, %35
%37 = tail call double @llvm.fmuladd.f64(double %36, double %35, double %4)
%38 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 1
store double %37, double* %38
%39 = load double, double* %15
%40 = fmul double %6, %39
%41 = load double, double* %13
%42 = load double, double* %1
%43 = fmul double %42, %17
%44 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %43)
%45 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 2
store double %44, double* %45
%46 = load double, double* %1
%47 = fmul double %6, %46
%48 = load double, double* %15
%49 = load double, double* %13
%50 = fmul double %49, %17
%51 = tail call double @llvm.fmuladd.f64(double %47, double %48, double %50)
%52 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 0
store double %51, double* %52
%53 = load double, double* %13
%54 = fmul double %6, %53
%55 = load double, double* %15
%56 = load double, double* %1
%57 = fmul double %5, %56
%58 = tail call double @llvm.fmuladd.f64(double %54, double %55, double %57)
%59 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 1
store double %58, double* %59
%60 = load double, double* %15
%61 = fmul double %6, %60
%62 = tail call double @llvm.fmuladd.f64(double %61, double %60, double %4)
%63 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 2
store double %62, double* %63
ret void
}