void matrix_multiply_block(double C[], const double A[], const double B[],
                           const unsigned int ldc, const unsigned int lda,
                           const unsigned int ldb) {
  unsigned int i, j, k;
  const double *B_k = B;
  for (k = 0; k < 32; ++k) {
    double *C_i = C;
    const double *Ap = A + k;
    for (i = 0; i < 32; ++i) {
      const double A_i_k = *Ap;
      for (j = 0; j < 32; ++j) {
        C_i[j] += A_i_k * B_k[j];
      }
      C_i += ldc;
      Ap += lda;
    }
    B_k += ldb;
  }
}


x86 assembly (clang, -O0):
<matrix_multiply_block>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x20,-0x30(%rbp)
jae    120d <matrix_multiply_block+0x10d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x20,-0x28(%rbp)
jae    11eb <matrix_multiply_block+0xeb>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x20,-0x2c(%rbp)
jae    11b5 <matrix_multiply_block+0xb5>
movsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x40(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1173 <matrix_multiply_block+0x73>
mov    -0x1c(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1155 <matrix_multiply_block+0x55>
mov    -0x24(%rbp),%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    112a <matrix_multiply_block+0x2a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_multiply_block>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %ecx,%r10d
mov    %r8d,%r14d
mov    %r9d,%r8d
lea    0x0(,%r8,8),%r9
lea    0x0(,%r10,8),%r15
xor    %r11d,%r11d
mov    %rdx,%rbx
jmp    1141 <matrix_multiply_block+0x41>
nopl   0x0(%rax,%rax,1)
add    %r9,%rbx
add    $0x1,%r11
cmp    $0x20,%r11
je     13a5 <matrix_multiply_block+0x2a5>
mov    %r11,%rax
imul   %r8,%rax
lea    (%rdx,%rax,8),%r12
add    $0x100,%r12
lea    (%rsi,%r11,8),%r13
mov    %rdi,%rcx
xor    %eax,%eax
jmp    133e <matrix_multiply_block+0x23e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
unpcklpd %xmm0,%xmm0
movupd (%rbx),%xmm1
mulpd  %xmm0,%xmm1
movupd (%rcx),%xmm2
addpd  %xmm1,%xmm2
movupd 0x10(%rcx),%xmm1
movupd 0x20(%rcx),%xmm3
movupd 0x30(%rcx),%xmm4
movupd %xmm2,(%rcx)
movupd 0x10(%rbx),%xmm2
mulpd  %xmm0,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,0x10(%rcx)
movupd 0x20(%rbx),%xmm1
mulpd  %xmm0,%xmm1
addpd  %xmm3,%xmm1
movupd %xmm1,0x20(%rcx)
movupd 0x30(%rbx),%xmm1
mulpd  %xmm0,%xmm1
addpd  %xmm4,%xmm1
movupd %xmm1,0x30(%rcx)
movupd 0x40(%rbx),%xmm1
movupd 0x40(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x40(%rcx)
movupd 0x50(%rbx),%xmm1
movupd 0x50(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x50(%rcx)
movupd 0x60(%rbx),%xmm1
movupd 0x60(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x60(%rcx)
movupd 0x70(%rbx),%xmm1
movupd 0x70(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x70(%rcx)
movupd 0x80(%rbx),%xmm1
movupd 0x80(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x80(%rcx)
movupd 0x90(%rbx),%xmm1
movupd 0x90(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0x90(%rcx)
movupd 0xa0(%rbx),%xmm1
movupd 0xa0(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0xa0(%rcx)
movupd 0xb0(%rbx),%xmm1
movupd 0xb0(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0xb0(%rcx)
movupd 0xc0(%rbx),%xmm1
movupd 0xc0(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0xc0(%rcx)
movupd 0xd0(%rbx),%xmm1
movupd 0xd0(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0xd0(%rcx)
movupd 0xe0(%rbx),%xmm1
movupd 0xe0(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0xe0(%rcx)
movupd 0xf0(%rbx),%xmm1
movupd 0xf0(%rcx),%xmm2
mulpd  %xmm0,%xmm1
addpd  %xmm2,%xmm1
movupd %xmm1,0xf0(%rcx)
add    %r15,%rcx
lea    0x0(%r13,%r14,8),%r13
add    $0x1,%rax
cmp    $0x20,%eax
je     1130 <matrix_multiply_block+0x30>
movsd  0x0(%r13),%xmm0
cmp    %r12,%rcx
jae    1170 <matrix_multiply_block+0x70>
mov    %rax,%rbp
imul   %r10,%rbp
lea    (%rdi,%rbp,8),%rbp
add    $0x100,%rbp
cmp    %rbp,%rbx
jae    1170 <matrix_multiply_block+0x70>
mov    $0x1,%ebp
nopl   (%rax)
movsd  -0x8(%rbx,%rbp,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  -0x8(%rcx,%rbp,8),%xmm1
movsd  %xmm1,-0x8(%rcx,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rcx,%rbp,8),%xmm1
movsd  %xmm1,(%rcx,%rbp,8)
add    $0x2,%rbp
cmp    $0x21,%rbp
jne    1370 <matrix_multiply_block+0x270>
jmp    1329 <matrix_multiply_block+0x229>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @matrix_multiply_block(double* nocapture %0, double* nocapture %1, double* nocapture %2, i32 %3, i32 %4, i32 %5) {
%7 = zext i32 %3 to i64
%8 = zext i32 %4 to i64
%9 = zext i32 %5 to i64
br label %10
10: ; preds = %6, %179
%11 = phi i64 [ 0, %6 ], [ %181, %179 ]
%12 = phi double* [ %2, %6 ], [ %180, %179 ]
%13 = mul i64 %11, %9
%14 = add i64 %13, 32
%15 = getelementptr double, double* %2, i64 %14
%16 = getelementptr inbounds double, double* %1, i64 %11
%17 = bitcast double* %12 to <2 x double>*
%18 = getelementptr inbounds double, double* %12, i64 2
%19 = bitcast double* %18 to <2 x double>*
%20 = getelementptr inbounds double, double* %12, i64 4
%21 = bitcast double* %20 to <2 x double>*
%22 = getelementptr inbounds double, double* %12, i64 6
%23 = bitcast double* %22 to <2 x double>*
%24 = getelementptr inbounds double, double* %12, i64 8
%25 = bitcast double* %24 to <2 x double>*
%26 = getelementptr inbounds double, double* %12, i64 10
%27 = bitcast double* %26 to <2 x double>*
%28 = getelementptr inbounds double, double* %12, i64 12
%29 = bitcast double* %28 to <2 x double>*
%30 = getelementptr inbounds double, double* %12, i64 14
%31 = bitcast double* %30 to <2 x double>*
%32 = getelementptr inbounds double, double* %12, i64 16
%33 = bitcast double* %32 to <2 x double>*
%34 = getelementptr inbounds double, double* %12, i64 18
%35 = bitcast double* %34 to <2 x double>*
%36 = getelementptr inbounds double, double* %12, i64 20
%37 = bitcast double* %36 to <2 x double>*
%38 = getelementptr inbounds double, double* %12, i64 22
%39 = bitcast double* %38 to <2 x double>*
%40 = getelementptr inbounds double, double* %12, i64 24
%41 = bitcast double* %40 to <2 x double>*
%42 = getelementptr inbounds double, double* %12, i64 26
%43 = bitcast double* %42 to <2 x double>*
%44 = getelementptr inbounds double, double* %12, i64 28
%45 = bitcast double* %44 to <2 x double>*
%46 = getelementptr inbounds double, double* %12, i64 30
%47 = bitcast double* %46 to <2 x double>*
br label %48
48: ; preds = %10, %173
%49 = phi i64 [ 0, %10 ], [ %178, %173 ]
%50 = phi i32 [ 0, %10 ], [ %176, %173 ]
%51 = phi double* [ %16, %10 ], [ %175, %173 ]
%52 = phi double* [ %0, %10 ], [ %174, %173 ]
%53 = load double, double* %51
%54 = mul i64 %49, %7
%55 = add i64 %54, 32
%56 = getelementptr double, double* %0, i64 %55
%57 = icmp ult double* %52, %15
%58 = icmp ult double* %12, %56
%59 = and i1 %57, %58
br i1 %59, label %158, label %60
60: ; preds = %48
%61 = insertelement <2 x double> poison, double %53, i64 0
%62 = shufflevector <2 x double> %61, <2 x double> poison, <2 x i32> zeroinitializer
%63 = load <2 x double>, <2 x double>* %17
%64 = bitcast double* %52 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %63, <2 x double> %65)
%67 = bitcast double* %52 to <2 x double>*
store <2 x double> %66, <2 x double>* %67
%68 = load <2 x double>, <2 x double>* %19
%69 = getelementptr inbounds double, double* %52, i64 2
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %68, <2 x double> %71)
%73 = bitcast double* %69 to <2 x double>*
store <2 x double> %72, <2 x double>* %73
%74 = load <2 x double>, <2 x double>* %21
%75 = getelementptr inbounds double, double* %52, i64 4
%76 = bitcast double* %75 to <2 x double>*
%77 = load <2 x double>, <2 x double>* %76
%78 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %74, <2 x double> %77)
%79 = bitcast double* %75 to <2 x double>*
store <2 x double> %78, <2 x double>* %79
%80 = load <2 x double>, <2 x double>* %23
%81 = getelementptr inbounds double, double* %52, i64 6
%82 = bitcast double* %81 to <2 x double>*
%83 = load <2 x double>, <2 x double>* %82
%84 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %80, <2 x double> %83)
%85 = bitcast double* %81 to <2 x double>*
store <2 x double> %84, <2 x double>* %85
%86 = load <2 x double>, <2 x double>* %25
%87 = getelementptr inbounds double, double* %52, i64 8
%88 = bitcast double* %87 to <2 x double>*
%89 = load <2 x double>, <2 x double>* %88
%90 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %86, <2 x double> %89)
%91 = bitcast double* %87 to <2 x double>*
store <2 x double> %90, <2 x double>* %91
%92 = load <2 x double>, <2 x double>* %27
%93 = getelementptr inbounds double, double* %52, i64 10
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %92, <2 x double> %95)
%97 = bitcast double* %93 to <2 x double>*
store <2 x double> %96, <2 x double>* %97
%98 = load <2 x double>, <2 x double>* %29
%99 = getelementptr inbounds double, double* %52, i64 12
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %98, <2 x double> %101)
%103 = bitcast double* %99 to <2 x double>*
store <2 x double> %102, <2 x double>* %103
%104 = load <2 x double>, <2 x double>* %31
%105 = getelementptr inbounds double, double* %52, i64 14
%106 = bitcast double* %105 to <2 x double>*
%107 = load <2 x double>, <2 x double>* %106
%108 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %104, <2 x double> %107)
%109 = bitcast double* %105 to <2 x double>*
store <2 x double> %108, <2 x double>* %109
%110 = load <2 x double>, <2 x double>* %33
%111 = getelementptr inbounds double, double* %52, i64 16
%112 = bitcast double* %111 to <2 x double>*
%113 = load <2 x double>, <2 x double>* %112
%114 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %110, <2 x double> %113)
%115 = bitcast double* %111 to <2 x double>*
store <2 x double> %114, <2 x double>* %115
%116 = load <2 x double>, <2 x double>* %35
%117 = getelementptr inbounds double, double* %52, i64 18
%118 = bitcast double* %117 to <2 x double>*
%119 = load <2 x double>, <2 x double>* %118
%120 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %116, <2 x double> %119)
%121 = bitcast double* %117 to <2 x double>*
store <2 x double> %120, <2 x double>* %121
%122 = load <2 x double>, <2 x double>* %37
%123 = getelementptr inbounds double, double* %52, i64 20
%124 = bitcast double* %123 to <2 x double>*
%125 = load <2 x double>, <2 x double>* %124
%126 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %122, <2 x double> %125)
%127 = bitcast double* %123 to <2 x double>*
store <2 x double> %126, <2 x double>* %127
%128 = load <2 x double>, <2 x double>* %39
%129 = getelementptr inbounds double, double* %52, i64 22
%130 = bitcast double* %129 to <2 x double>*
%131 = load <2 x double>, <2 x double>* %130
%132 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %128, <2 x double> %131)
%133 = bitcast double* %129 to <2 x double>*
store <2 x double> %132, <2 x double>* %133
%134 = load <2 x double>, <2 x double>* %41
%135 = getelementptr inbounds double, double* %52, i64 24
%136 = bitcast double* %135 to <2 x double>*
%137 = load <2 x double>, <2 x double>* %136
%138 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %134, <2 x double> %137)
%139 = bitcast double* %135 to <2 x double>*
store <2 x double> %138, <2 x double>* %139
%140 = load <2 x double>, <2 x double>* %43
%141 = getelementptr inbounds double, double* %52, i64 26
%142 = bitcast double* %141 to <2 x double>*
%143 = load <2 x double>, <2 x double>* %142
%144 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %140, <2 x double> %143)
%145 = bitcast double* %141 to <2 x double>*
store <2 x double> %144, <2 x double>* %145
%146 = load <2 x double>, <2 x double>* %45
%147 = getelementptr inbounds double, double* %52, i64 28
%148 = bitcast double* %147 to <2 x double>*
%149 = load <2 x double>, <2 x double>* %148
%150 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %146, <2 x double> %149)
%151 = bitcast double* %147 to <2 x double>*
store <2 x double> %150, <2 x double>* %151
%152 = load <2 x double>, <2 x double>* %47
%153 = getelementptr inbounds double, double* %52, i64 30
%154 = bitcast double* %153 to <2 x double>*
%155 = load <2 x double>, <2 x double>* %154
%156 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %152, <2 x double> %155)
%157 = bitcast double* %153 to <2 x double>*
store <2 x double> %156, <2 x double>* %157
br label %173
158: ; preds = %48, %158
%159 = phi i64 [ %171, %158 ], [ 0, %48 ]
%160 = getelementptr inbounds double, double* %12, i64 %159
%161 = load double, double* %160
%162 = getelementptr inbounds double, double* %52, i64 %159
%163 = load double, double* %162
%164 = tail call double @llvm.fmuladd.f64(double %53, double %161, double %163)
store double %164, double* %162
%165 = or i64 %159, 1
%166 = getelementptr inbounds double, double* %12, i64 %165
%167 = load double, double* %166
%168 = getelementptr inbounds double, double* %52, i64 %165
%169 = load double, double* %168
%170 = tail call double @llvm.fmuladd.f64(double %53, double %167, double %169)
store double %170, double* %168
%171 = add nuw nsw i64 %159, 2
%172 = icmp eq i64 %171, 32
br i1 %172, label %173, label %158
173: ; preds = %158, %60
%174 = getelementptr inbounds double, double* %52, i64 %7
%175 = getelementptr inbounds double, double* %51, i64 %8
%176 = add nuw nsw i32 %50, 1
%177 = icmp eq i32 %176, 32
%178 = add i64 %49, 1
br i1 %177, label %179, label %48
179: ; preds = %173
%180 = getelementptr inbounds double, double* %12, i64 %9
%181 = add nuw nsw i64 %11, 1
%182 = icmp eq i64 %181, 32
br i1 %182, label %183, label %10
183: ; preds = %179
ret void
}