void glmMultMatrix3d(double result[9], const double m1[9], const double m2[9]) {
  double sum;
  int x, y, i;
  for (x = 0; x < 3; x++) {
    for (y = 0; y < 3; y++) {
      sum = 0;
      for (i = 0; i < 3; i++)
        sum += m1[y + 3 * i] * m2[3 * x + i];
      result[y + 3 * x] = sum;
    }
  }
}


x86 assembly (clang, -O0):
<glmMultMatrix3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11ce <glmMultMatrix3d+0xce>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11bb <glmMultMatrix3d+0xbb>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1193 <glmMultMatrix3d+0x93>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   $0x3,-0x2c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
imul   $0x3,-0x24(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1141 <glmMultMatrix3d+0x41>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   $0x3,-0x24(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1128 <glmMultMatrix3d+0x28>
jmp    11c0 <glmMultMatrix3d+0xc0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1117 <glmMultMatrix3d+0x17>
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @glmMultMatrix3d(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = getelementptr inbounds double, double* %1, i64 2
%5 = load double, double* %1
%6 = load double, double* %2
%7 = tail call double @llvm.fmuladd.f64(double %5, double %6, double 0.000000e+00)
%8 = getelementptr inbounds double, double* %1, i64 3
%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)
%13 = getelementptr inbounds double, double* %1, i64 6
%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* %1, i64 1
%19 = load double, double* %18
%20 = load double, double* %2
%21 = tail call double @llvm.fmuladd.f64(double %19, double %20, double 0.000000e+00)
%22 = getelementptr inbounds double, double* %1, i64 4
%23 = load double, double* %22
%24 = load double, double* %10
%25 = tail call double @llvm.fmuladd.f64(double %23, double %24, double %21)
%26 = getelementptr inbounds double, double* %1, i64 7
%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 = load double, double* %4
%32 = load double, double* %2
%33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double 0.000000e+00)
%34 = getelementptr inbounds double, double* %1, i64 5
%35 = load double, double* %34
%36 = load double, double* %10
%37 = tail call double @llvm.fmuladd.f64(double %35, double %36, double %33)
%38 = getelementptr inbounds double, double* %1, i64 8
%39 = load double, double* %38
%40 = load double, double* %15
%41 = tail call double @llvm.fmuladd.f64(double %39, double %40, double %37)
%42 = getelementptr inbounds double, double* %0, i64 2
store double %41, double* %42
%43 = load double, double* %1
%44 = getelementptr inbounds double, double* %2, i64 3
%45 = load double, double* %44
%46 = tail call double @llvm.fmuladd.f64(double %43, double %45, double 0.000000e+00)
%47 = load double, double* %8
%48 = getelementptr inbounds double, double* %2, i64 4
%49 = load double, double* %48
%50 = tail call double @llvm.fmuladd.f64(double %47, double %49, double %46)
%51 = load double, double* %13
%52 = getelementptr inbounds double, double* %2, i64 5
%53 = load double, double* %52
%54 = tail call double @llvm.fmuladd.f64(double %51, double %53, double %50)
%55 = getelementptr inbounds double, double* %0, i64 3
store double %54, double* %55
%56 = load double, double* %18
%57 = load double, double* %44
%58 = tail call double @llvm.fmuladd.f64(double %56, double %57, double 0.000000e+00)
%59 = load double, double* %22
%60 = load double, double* %48
%61 = tail call double @llvm.fmuladd.f64(double %59, double %60, double %58)
%62 = load double, double* %26
%63 = load double, double* %52
%64 = tail call double @llvm.fmuladd.f64(double %62, double %63, double %61)
%65 = getelementptr inbounds double, double* %0, i64 4
store double %64, double* %65
%66 = load double, double* %4
%67 = load double, double* %44
%68 = tail call double @llvm.fmuladd.f64(double %66, double %67, double 0.000000e+00)
%69 = load double, double* %34
%70 = load double, double* %48
%71 = tail call double @llvm.fmuladd.f64(double %69, double %70, double %68)
%72 = load double, double* %38
%73 = load double, double* %52
%74 = tail call double @llvm.fmuladd.f64(double %72, double %73, double %71)
%75 = getelementptr inbounds double, double* %0, i64 5
store double %74, double* %75
%76 = load double, double* %1
%77 = getelementptr inbounds double, double* %2, i64 6
%78 = load double, double* %77
%79 = tail call double @llvm.fmuladd.f64(double %76, double %78, double 0.000000e+00)
%80 = load double, double* %8
%81 = getelementptr inbounds double, double* %2, i64 7
%82 = load double, double* %81
%83 = tail call double @llvm.fmuladd.f64(double %80, double %82, double %79)
%84 = load double, double* %13
%85 = getelementptr inbounds double, double* %2, i64 8
%86 = load double, double* %85
%87 = tail call double @llvm.fmuladd.f64(double %84, double %86, double %83)
%88 = getelementptr inbounds double, double* %0, i64 6
store double %87, double* %88
%89 = load double, double* %18
%90 = load double, double* %77
%91 = tail call double @llvm.fmuladd.f64(double %89, double %90, double 0.000000e+00)
%92 = load double, double* %22
%93 = load double, double* %81
%94 = tail call double @llvm.fmuladd.f64(double %92, double %93, double %91)
%95 = load double, double* %26
%96 = load double, double* %85
%97 = tail call double @llvm.fmuladd.f64(double %95, double %96, double %94)
%98 = getelementptr inbounds double, double* %0, i64 7
store double %97, double* %98
%99 = load double, double* %4
%100 = load double, double* %77
%101 = tail call double @llvm.fmuladd.f64(double %99, double %100, double 0.000000e+00)
%102 = load double, double* %34
%103 = load double, double* %81
%104 = tail call double @llvm.fmuladd.f64(double %102, double %103, double %101)
%105 = load double, double* %38
%106 = load double, double* %85
%107 = tail call double @llvm.fmuladd.f64(double %105, double %106, double %104)
%108 = getelementptr inbounds double, double* %0, i64 8
store double %107, double* %108
ret void
}