void bot_matrix_multiply_4x4_4x4(const double a[16], const double b[16],
                                 double r[16]) {
  int i, j, k;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      double acc = 0;
      for (k = 0; k < 4; k++)
        acc += a[4 * i + k] * b[j + 4 * k];
      r[i * 4 + j] = acc;
    }
  }
}


x86 assembly (clang, -O0):
<bot_matrix_multiply_4x4_4x4>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11d2 <bot_matrix_multiply_4x4_4x4+0xd2>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    11bf <bot_matrix_multiply_4x4_4x4+0xbf>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1197 <bot_matrix_multiply_4x4_4x4+0x97>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    -0x24(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%edx
shl    $0x2,%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <bot_matrix_multiply_4x4_4x4+0x41>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1128 <bot_matrix_multiply_4x4_4x4+0x28>
jmp    11c4 <bot_matrix_multiply_4x4_4x4+0xc4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <bot_matrix_multiply_4x4_4x4+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_matrix_multiply_4x4_4x4>:
xor    %eax,%eax
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
movsd  (%rdi,%rax,1),%xmm1
movsd  0x8(%rdi,%rax,1),%xmm2
mulsd  (%rsi),%xmm1
mulsd  0x20(%rsi),%xmm2
addsd  %xmm0,%xmm1
movsd  0x10(%rdi,%rax,1),%xmm3
mulsd  0x40(%rsi),%xmm3
addsd  %xmm1,%xmm2
movsd  0x18(%rdi,%rax,1),%xmm1
mulsd  0x60(%rsi),%xmm1
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm1
movsd  %xmm1,(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm1
movsd  0x8(%rdi,%rax,1),%xmm2
mulsd  0x8(%rsi),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x28(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  0x10(%rdi,%rax,1),%xmm1
mulsd  0x48(%rsi),%xmm1
addsd  %xmm2,%xmm1
movsd  0x18(%rdi,%rax,1),%xmm2
mulsd  0x68(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm1
movsd  0x8(%rdi,%rax,1),%xmm2
mulsd  0x10(%rsi),%xmm1
addsd  %xmm0,%xmm1
mulsd  0x30(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  0x10(%rdi,%rax,1),%xmm1
mulsd  0x50(%rsi),%xmm1
addsd  %xmm2,%xmm1
movsd  0x18(%rdi,%rax,1),%xmm2
mulsd  0x70(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rdx,%rax,1)
movsd  (%rdi,%rax,1),%xmm1
mulsd  0x18(%rsi),%xmm1
movsd  0x8(%rdi,%rax,1),%xmm2
addsd  %xmm0,%xmm1
mulsd  0x38(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  0x10(%rdi,%rax,1),%xmm1
mulsd  0x58(%rsi),%xmm1
addsd  %xmm2,%xmm1
movsd  0x18(%rdi,%rax,1),%xmm2
mulsd  0x78(%rsi),%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rdx,%rax,1)
add    $0x20,%rax
cmp    $0x80,%rax
jne    1110 <bot_matrix_multiply_4x4_4x4+0x10>
ret

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

LLVM IR (-O2):
define void @bot_matrix_multiply_4x4_4x4(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %1, i64 4
%5 = getelementptr inbounds double, double* %1, i64 8
%6 = getelementptr inbounds double, double* %1, i64 12
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = getelementptr inbounds double, double* %1, i64 5
%9 = getelementptr inbounds double, double* %1, i64 9
%10 = getelementptr inbounds double, double* %1, i64 13
%11 = getelementptr inbounds double, double* %1, i64 2
%12 = getelementptr inbounds double, double* %1, i64 6
%13 = getelementptr inbounds double, double* %1, i64 10
%14 = getelementptr inbounds double, double* %1, i64 14
%15 = getelementptr inbounds double, double* %1, i64 3
%16 = getelementptr inbounds double, double* %1, i64 7
%17 = getelementptr inbounds double, double* %1, i64 11
%18 = getelementptr inbounds double, double* %1, i64 15
br label %19
19: ; preds = %3, %19
%20 = phi i64 [ 0, %3 ], [ %81, %19 ]
%21 = shl nsw i64 %20, 2
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = load double, double* %1
%25 = tail call double @llvm.fmuladd.f64(double %23, double %24, double 0.000000e+00)
%26 = or i64 %21, 1
%27 = getelementptr inbounds double, double* %0, i64 %26
%28 = load double, double* %27
%29 = load double, double* %4
%30 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %25)
%31 = or i64 %21, 2
%32 = getelementptr inbounds double, double* %0, i64 %31
%33 = load double, double* %32
%34 = load double, double* %5
%35 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %30)
%36 = or i64 %21, 3
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = load double, double* %6
%40 = tail call double @llvm.fmuladd.f64(double %38, double %39, double %35)
%41 = getelementptr inbounds double, double* %2, i64 %21
store double %40, double* %41
%42 = load double, double* %22
%43 = load double, double* %7
%44 = tail call double @llvm.fmuladd.f64(double %42, double %43, double 0.000000e+00)
%45 = load double, double* %27
%46 = load double, double* %8
%47 = tail call double @llvm.fmuladd.f64(double %45, double %46, double %44)
%48 = load double, double* %32
%49 = load double, double* %9
%50 = tail call double @llvm.fmuladd.f64(double %48, double %49, double %47)
%51 = load double, double* %37
%52 = load double, double* %10
%53 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %50)
%54 = getelementptr inbounds double, double* %2, i64 %26
store double %53, double* %54
%55 = load double, double* %22
%56 = load double, double* %11
%57 = tail call double @llvm.fmuladd.f64(double %55, double %56, double 0.000000e+00)
%58 = load double, double* %27
%59 = load double, double* %12
%60 = tail call double @llvm.fmuladd.f64(double %58, double %59, double %57)
%61 = load double, double* %32
%62 = load double, double* %13
%63 = tail call double @llvm.fmuladd.f64(double %61, double %62, double %60)
%64 = load double, double* %37
%65 = load double, double* %14
%66 = tail call double @llvm.fmuladd.f64(double %64, double %65, double %63)
%67 = getelementptr inbounds double, double* %2, i64 %31
store double %66, double* %67
%68 = load double, double* %22
%69 = load double, double* %15
%70 = tail call double @llvm.fmuladd.f64(double %68, double %69, double 0.000000e+00)
%71 = load double, double* %27
%72 = load double, double* %16
%73 = tail call double @llvm.fmuladd.f64(double %71, double %72, double %70)
%74 = load double, double* %32
%75 = load double, double* %17
%76 = tail call double @llvm.fmuladd.f64(double %74, double %75, double %73)
%77 = load double, double* %37
%78 = load double, double* %18
%79 = tail call double @llvm.fmuladd.f64(double %77, double %78, double %76)
%80 = getelementptr inbounds double, double* %2, i64 %36
store double %79, double* %80
%81 = add nuw nsw i64 %20, 1
%82 = icmp eq i64 %81, 4
br i1 %82, label %83, label %19
83: ; preds = %19
ret void
}