void rotate(double M[3][3], double v[3], double r[3]) {
  r[0] = M[0][0] * v[0] + M[1][0] * v[1] + M[2][0] * v[2];
  r[1] = M[0][1] * v[0] + M[1][1] * v[1] + M[2][1] * v[2];
  r[2] = M[0][2] * v[0] + M[1][2] * v[1] + M[2][2] * v[2];
}


x86 assembly (clang, -O0):
<rotate>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate>:
movsd  (%rdi),%xmm0
movsd  0x18(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x30(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx)
movsd  0x8(%rdi),%xmm0
movsd  0x20(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x38(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rdx)
movsd  0x10(%rdi),%xmm0
movsd  0x28(%rdi),%xmm1
mulsd  0x8(%rsi),%xmm1
mulsd  (%rsi),%xmm0
addsd  %xmm1,%xmm0
movsd  0x40(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rdx)
ret

LLVM IR (-O0):
define void @rotate([3 x double]* %0, double* %1, double* %2) {
%4 = alloca [3 x double]*
%5 = alloca double*
%6 = alloca double*
store [3 x double]* %0, [3 x double]** %4
store double* %1, double** %5
store double* %2, double** %6
%7 = load [3 x double]*, [3 x double]** %4
%8 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0
%9 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%10 = load double, double* %9
%11 = load double*, double** %5
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load [3 x double]*, [3 x double]** %4
%15 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 1
%16 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 0
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = call double @llvm.fmuladd.f64(double %10, double %13, double %21)
%23 = load [3 x double]*, [3 x double]** %4
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 2
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 0
%26 = load double, double* %25
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 2
%29 = load double, double* %28
%30 = call double @llvm.fmuladd.f64(double %26, double %29, double %22)
%31 = load double*, double** %6
%32 = getelementptr inbounds double, double* %31, i64 0
store double %30, double* %32
%33 = load [3 x double]*, [3 x double]** %4
%34 = getelementptr inbounds [3 x double], [3 x double]* %33, i64 0
%35 = getelementptr inbounds [3 x double], [3 x double]* %34, i64 0, i64 1
%36 = load double, double* %35
%37 = load double*, double** %5
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load [3 x double]*, [3 x double]** %4
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 1
%42 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 1
%43 = load double, double* %42
%44 = load double*, double** %5
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double, double* %45
%47 = fmul double %43, %46
%48 = call double @llvm.fmuladd.f64(double %36, double %39, double %47)
%49 = load [3 x double]*, [3 x double]** %4
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 2
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 1
%52 = load double, double* %51
%53 = load double*, double** %5
%54 = getelementptr inbounds double, double* %53, i64 2
%55 = load double, double* %54
%56 = call double @llvm.fmuladd.f64(double %52, double %55, double %48)
%57 = load double*, double** %6
%58 = getelementptr inbounds double, double* %57, i64 1
store double %56, double* %58
%59 = load [3 x double]*, [3 x double]** %4
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 0
%61 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 0, i64 2
%62 = load double, double* %61
%63 = load double*, double** %5
%64 = getelementptr inbounds double, double* %63, i64 0
%65 = load double, double* %64
%66 = load [3 x double]*, [3 x double]** %4
%67 = getelementptr inbounds [3 x double], [3 x double]* %66, i64 1
%68 = getelementptr inbounds [3 x double], [3 x double]* %67, i64 0, i64 2
%69 = load double, double* %68
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 1
%72 = load double, double* %71
%73 = fmul double %69, %72
%74 = call double @llvm.fmuladd.f64(double %62, double %65, double %73)
%75 = load [3 x double]*, [3 x double]** %4
%76 = getelementptr inbounds [3 x double], [3 x double]* %75, i64 2
%77 = getelementptr inbounds [3 x double], [3 x double]* %76, i64 0, i64 2
%78 = load double, double* %77
%79 = load double*, double** %5
%80 = getelementptr inbounds double, double* %79, i64 2
%81 = load double, double* %80
%82 = call double @llvm.fmuladd.f64(double %78, double %81, double %74)
%83 = load double*, double** %6
%84 = getelementptr inbounds double, double* %83, i64 2
store double %82, double* %84
ret void
}

LLVM IR (-O2):
define void @rotate([3 x double]* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%5 = load double, double* %4
%6 = load double, double* %1
%7 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = fmul double %8, %10
%12 = tail call double @llvm.fmuladd.f64(double %5, double %6, double %11)
%13 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 2
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %14, double %16, double %12)
store double %17, double* %2
%18 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%19 = load double, double* %18
%20 = load double, double* %1
%21 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%22 = load double, double* %21
%23 = load double, double* %9
%24 = fmul double %22, %23
%25 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %24)
%26 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%27 = load double, double* %26
%28 = load double, double* %15
%29 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %25)
%30 = getelementptr inbounds double, double* %2, i64 1
store double %29, double* %30
%31 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%32 = load double, double* %31
%33 = load double, double* %1
%34 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%35 = load double, double* %34
%36 = load double, double* %9
%37 = fmul double %35, %36
%38 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %37)
%39 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%40 = load double, double* %39
%41 = load double, double* %15
%42 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %38)
%43 = getelementptr inbounds double, double* %2, i64 2
store double %42, double* %43
ret void
}