void mat_mul_3(double Out[3][3], double A[3][3], double B[3][3]) {
  int i, j, k;
  for (j = 0; j < 3; j++)
    for (k = 0; k < 3; k++) {
      Out[j][k] = 0.0;
      for (i = 0; i < 3; i++)
        Out[j][k] += A[i][k] * B[j][i];
    }
  return;
}


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

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

LLVM IR (-O0):
define void @mat_mul_3([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* %8
br label %10
10: ; preds = %62, %3
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %65
13: ; preds = %10
store i32 0, i32* %9
br label %14
14: ; preds = %58, %13
%15 = load i32, i32* %9
%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* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 %20
%22 = load i32, i32* %9
%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* %7
br label %25
25: ; preds = %54, %17
%26 = load i32, i32* %7
%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* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 %39
%41 = load i32, i32* %7
%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* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 %47
%49 = load i32, i32* %9
%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* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %25
57: ; preds = %25
br label %58
58: ; preds = %57
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %14
61: ; preds = %14
br label %62
62: ; preds = %61
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
store i32 %64, i32* %8
br label %10
65: ; preds = %10
ret void
}

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