void mtx_vect3mult(double out[3], double m[3][3], const double v[3]) {
  int i, k;
  for (i = 0; i < 3; ++i) {
    out[i] = 0.;
    for (k = 0; k < 3; ++k)
      out[i] += m[i][k] * v[k];
  }
}


x86 assembly (clang, -O0):
<mtx_vect3mult>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11a2 <mtx_vect3mult+0xa2>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    118f <mtx_vect3mult+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1138 <mtx_vect3mult+0x38>
jmp    1194 <mtx_vect3mult+0x94>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <mtx_vect3mult+0x17>
pop    %rbp
ret

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

LLVM IR (-O0):
define void @mtx_vect3mult(double* %0, [3 x double]* %1, double* %2) {
%4 = alloca double*
%5 = alloca [3 x double]*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
store double* %0, double** %4
store [3 x double]* %1, [3 x double]** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %9
9: ; preds = %44, %3
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %47
12: ; preds = %9
%13 = load double*, double** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
store double 0.000000e+00, double* %16
store i32 0, i32* %8
br label %17
17: ; preds = %40, %12
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %43
20: ; preds = %17
%21 = load [3 x double]*, [3 x double]** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 %26
%28 = load double, double* %27
%29 = load double*, double** %6
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = call double @llvm.fmuladd.f64(double %28, double %33, double %38)
store double %39, double* %37
br label %40
40: ; preds = %20
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %17
43: ; preds = %17
br label %44
44: ; preds = %43
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %9
47: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @mtx_vect3mult(double* nocapture %0, [3 x double]* nocapture %1, double* nocapture %2) {
store double 0.000000e+00, double* %0
%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 = tail call double @llvm.fmuladd.f64(double %5, double %6, double 0.000000e+00)
store double %7, double* %0
%8 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %2, i64 1
%11 = load double, double* %10
%12 = tail call double @llvm.fmuladd.f64(double %9, double %11, double %7)
store double %12, double* %0
%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 double, double* %0, i64 1
store double 0.000000e+00, double* %18
%19 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
%20 = load double, double* %19
%21 = load double, double* %2
%22 = tail call double @llvm.fmuladd.f64(double %20, double %21, double 0.000000e+00)
store double %22, double* %18
%23 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%24 = load double, double* %23
%25 = load double, double* %10
%26 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %22)
store double %26, double* %18
%27 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
%28 = load double, double* %27
%29 = load double, double* %15
%30 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %26)
store double %30, double* %18
%31 = getelementptr inbounds double, double* %0, i64 2
store double 0.000000e+00, double* %31
%32 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
%33 = load double, double* %32
%34 = load double, double* %2
%35 = tail call double @llvm.fmuladd.f64(double %33, double %34, double 0.000000e+00)
store double %35, double* %31
%36 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
%37 = load double, double* %36
%38 = load double, double* %10
%39 = tail call double @llvm.fmuladd.f64(double %37, double %38, double %35)
store double %39, double* %31
%40 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%41 = load double, double* %40
%42 = load double, double* %15
%43 = tail call double @llvm.fmuladd.f64(double %41, double %42, double %39)
store double %43, double* %31
ret void
}