void matrix_times_vec3(double a[3], double m[3][3], const double v[3]) {
  a[0] = m[0][0] * v[0] + m[0][1] * v[1] + m[0][2] * v[2];
  a[1] = m[1][0] * v[0] + m[1][1] * v[1] + m[1][2] * v[2];
  a[2] = m[2][0] * v[0] + m[2][1] * v[1] + m[2][2] * v[2];
}


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

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

LLVM IR (-O0):
define void @matrix_times_vec3(double* %0, [3 x double]* %1, double* %2) {
%4 = alloca double*
%5 = alloca [3 x double]*
%6 = alloca double*
store double* %0, double** %4
store [3 x double]* %1, [3 x double]** %5
store double* %2, double** %6
%7 = load [3 x double]*, [3 x double]** %5
%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** %6
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load [3 x double]*, [3 x double]** %5
%15 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0
%16 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0, i64 1
%17 = load double, double* %16
%18 = load double*, double** %6
%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]** %5
%24 = getelementptr inbounds [3 x double], [3 x double]* %23, i64 0
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 2
%26 = load double, double* %25
%27 = load double*, double** %6
%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** %4
%32 = getelementptr inbounds double, double* %31, i64 0
store double %30, double* %32
%33 = load [3 x double]*, [3 x double]** %5
%34 = getelementptr inbounds [3 x double], [3 x double]* %33, i64 1
%35 = getelementptr inbounds [3 x double], [3 x double]* %34, i64 0, i64 0
%36 = load double, double* %35
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load [3 x double]*, [3 x double]** %5
%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** %6
%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]** %5
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 1
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 2
%52 = load double, double* %51
%53 = load double*, double** %6
%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** %4
%58 = getelementptr inbounds double, double* %57, i64 1
store double %56, double* %58
%59 = load [3 x double]*, [3 x double]** %5
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 2
%61 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 0, i64 0
%62 = load double, double* %61
%63 = load double*, double** %6
%64 = getelementptr inbounds double, double* %63, i64 0
%65 = load double, double* %64
%66 = load [3 x double]*, [3 x double]** %5
%67 = getelementptr inbounds [3 x double], [3 x double]* %66, i64 2
%68 = getelementptr inbounds [3 x double], [3 x double]* %67, i64 0, i64 1
%69 = load double, double* %68
%70 = load double*, double** %6
%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]** %5
%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** %6
%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** %4
%84 = getelementptr inbounds double, double* %83, i64 2
store double %82, double* %84
ret void
}

LLVM IR (-O2):
define void @matrix_times_vec3(double* nocapture writeonly %0, [3 x double]* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%5 = load double, double* %4
%6 = load double, double* %2
%7 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %2, 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]* %1, i64 0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 2
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %14, double %16, double %12)
store double %17, double* %0
%18 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
%19 = load double, double* %18
%20 = load double, double* %2
%21 = getelementptr inbounds [3 x double], [3 x double]* %1, 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]* %1, i64 1, i64 2
%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* %0, i64 1
store double %29, double* %30
%31 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
%32 = load double, double* %31
%33 = load double, double* %2
%34 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
%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]* %1, 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* %0, i64 2
store double %42, double* %43
ret void
}