void mtx_3x3mult(double out[3][3], double m1[3][3], double m2[3][3]) {
  int i, j, k;
  for (i = 0; i < 3; ++i)
    for (j = 0; j < 3; ++j) {
      out[i][j] = 0.;
      for (k = 0; k < 3; ++k)
        out[i][j] += m1[i][k] * m2[k][j];
    }
}


x86 assembly (clang, -O0):
<mtx_3x3mult>:
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    11e7 <mtx_3x3mult+0xe7>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11d4 <mtx_3x3mult+0xd4>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11c1 <mtx_3x3mult+0xc1>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1154 <mtx_3x3mult+0x54>
jmp    11c6 <mtx_3x3mult+0xc6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1128 <mtx_3x3mult+0x28>
jmp    11d9 <mtx_3x3mult+0xd9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <mtx_3x3mult+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtx_3x3mult>:
mov    $0x10,%eax
xorpd  %xmm0,%xmm0
nopl   0x0(%rax)
movq   $0x0,-0x10(%rdi,%rax,1)
movsd  -0x10(%rsi,%rax,1),%xmm1
mulsd  (%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x10(%rdi,%rax,1)
movsd  -0x8(%rsi,%rax,1),%xmm2
mulsd  0x18(%rdx),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,-0x10(%rdi,%rax,1)
movsd  (%rsi,%rax,1),%xmm1
mulsd  0x30(%rdx),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,-0x10(%rdi,%rax,1)
movq   $0x0,-0x8(%rdi,%rax,1)
movsd  -0x10(%rsi,%rax,1),%xmm1
mulsd  0x8(%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,-0x8(%rdi,%rax,1)
movsd  -0x8(%rsi,%rax,1),%xmm2
mulsd  0x20(%rdx),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,-0x8(%rdi,%rax,1)
movsd  (%rsi,%rax,1),%xmm1
mulsd  0x38(%rdx),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,-0x8(%rdi,%rax,1)
movq   $0x0,(%rdi,%rax,1)
movsd  -0x10(%rsi,%rax,1),%xmm1
mulsd  0x10(%rdx),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi,%rax,1)
movsd  -0x8(%rsi,%rax,1),%xmm2
mulsd  0x28(%rdx),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rdi,%rax,1)
movsd  (%rsi,%rax,1),%xmm1
mulsd  0x40(%rdx),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,(%rdi,%rax,1)
add    $0x18,%rax
cmp    $0x58,%rax
jne    1110 <mtx_3x3mult+0x10>
ret

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

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