float *block_multiply(float *a, int x0, int y0, float *b, int x1, int y1,
                      int blockDiv) {
  float **a_subs;
  float *b_transpose;
  float **b_subs;
  float **product_subs;
  float *result;
  int i, j, k;
  int x0s = x0 / blockDiv;
  int y0s = y0 / blockDiv;
  int x1s = x1 / blockDiv;
  int y1s = y1 / blockDiv;
  a_subs = malloc(blockDiv * blockDiv * sizeof(float *));
  for (j = 0; j < blockDiv; j++)
    for (i = 0; i < blockDiv; i++)
      a_subs[i * blockDiv + j] = get_sub(a, x0, y0, blockDiv, i, j);
  b_transpose = transpose(b, x1, y1);
  b_subs = malloc(blockDiv * blockDiv * sizeof(float *));
  for (j = 0; j < blockDiv; j++)
    for (i = 0; i < blockDiv; i++)
      b_subs[i * blockDiv + j] = get_sub(b_transpose, y1, x1, blockDiv, i, j);
  product_subs = malloc(blockDiv * blockDiv * sizeof(float *));
  for (i = 0; i < blockDiv * blockDiv; i++) {
    product_subs[i] = malloc(x1s * y0s * sizeof(float));
    for (j = 0; j < x1s * y0s; j++)
      product_subs[i][j] = 0;
  }
  for (k = 0; k < blockDiv; k++)
    for (j = 0; j < blockDiv; j++)
      for (i = 0; i < blockDiv; i++) {
        int idxa = k * blockDiv + i;
        int idxb = j * blockDiv + i;
        mul_subs(a_subs[idxa], x0s, y0s, b_subs[idxb], x1s, y1s,
                 product_subs[idxb]);
      }
  result = combine_subs(product_subs, x1, y0, blockDiv);
  for (i = 0; i < blockDiv * blockDiv; i++) {
    free(a_subs[i]);
    free(b_subs[i]);
    free(product_subs[i]);
  }
  free(a_subs);
  free(b_subs);
  free(product_subs);
  return result;
}


x86 assembly (clang, -O0):
<block_multiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0xc(%rbp),%eax
cltd
idivl  0x10(%rbp)
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  0x10(%rbp)
mov    %eax,-0x5c(%rbp)
mov    -0x1c(%rbp),%eax
cltd
idivl  0x10(%rbp)
mov    %eax,-0x60(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  0x10(%rbp)
mov    %eax,-0x64(%rbp)
mov    0x10(%rbp),%eax
imul   0x10(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    123e <block_multiply+0xde>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    122b <block_multiply+0xcb>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    $0x0,%al
call   1040 <get_sub@plt>
movslq %eax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11dd <block_multiply+0x7d>
jmp    1230 <block_multiply+0xd0>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11ca <block_multiply+0x6a>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    $0x0,%al
call   1060 <transpose@plt>
cltq
mov    %rax,-0x30(%rbp)
mov    0x10(%rbp),%eax
imul   0x10(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    12e7 <block_multiply+0x187>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    12d4 <block_multiply+0x174>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    -0x4c(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    $0x0,%al
call   1040 <get_sub@plt>
movslq %eax,%rdx
mov    -0x38(%rbp),%rax
mov    -0x4c(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1286 <block_multiply+0x126>
jmp    12d9 <block_multiply+0x179>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1273 <block_multiply+0x113>
mov    0x10(%rbp),%eax
imul   0x10(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x10(%rbp),%ecx
imul   0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    138b <block_multiply+0x22b>
mov    -0x60(%rbp),%eax
imul   -0x5c(%rbp),%eax
movslq %eax,%rdi
shl    $0x2,%rdi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x60(%rbp),%ecx
imul   -0x5c(%rbp),%ecx
cmp    %ecx,%eax
jge    1378 <block_multiply+0x218>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x50(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1340 <block_multiply+0x1e0>
jmp    137d <block_multiply+0x21d>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1305 <block_multiply+0x1a5>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    144f <block_multiply+0x2ef>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    143c <block_multiply+0x2dc>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    1429 <block_multiply+0x2c9>
mov    -0x54(%rbp),%eax
imul   0x10(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x50(%rbp),%eax
imul   0x10(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x58(%rbp),%esi
mov    -0x5c(%rbp),%edx
mov    -0x38(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x60(%rbp),%r8d
mov    -0x64(%rbp),%r9d
mov    -0x40(%rbp),%rax
movslq -0x6c(%rbp),%r10
mov    (%rax,%r10,8),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1080 <mul_subs@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13b8 <block_multiply+0x258>
jmp    142e <block_multiply+0x2ce>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    13a5 <block_multiply+0x245>
jmp    1441 <block_multiply+0x2e1>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1392 <block_multiply+0x232>
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    $0x0,%al
call   1050 <combine_subs@plt>
cltq
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x10(%rbp),%ecx
imul   0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    14c3 <block_multiply+0x363>
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1470 <block_multiply+0x310>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block_multiply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %rcx,0x18(%rsp)
mov    %edx,%ecx
mov    %esi,%eax
mov    %rdi,0x20(%rsp)
mov    0xb0(%rsp),%ebx
mov    %esi,0x60(%rsp)
cltd
idiv   %ebx
mov    %eax,0x6c(%rsp)
mov    %ecx,0x48(%rsp)
mov    %ecx,%eax
cltd
idiv   %ebx
mov    %eax,0x4c(%rsp)
mov    %r8d,0x14(%rsp)
mov    %r8d,%eax
cltd
idiv   %ebx
mov    %eax,0x44(%rsp)
mov    %r9d,0x28(%rsp)
mov    %r9d,%eax
cltd
idiv   %ebx
mov    %eax,0x68(%rsp)
mov    %ebx,%eax
imul   %eax,%eax
mov    %rax,0x58(%rsp)
lea    0x0(,%rax,8),%rdi
mov    %rdi,0x70(%rsp)
call   1080 <malloc@plt>
mov    %rax,0x50(%rsp)
mov    %ebx,%eax
test   %ebx,%ebx
mov    %rax,0x38(%rsp)
jle    1266 <block_multiply+0xf6>
lea    0x0(,%rax,8),%rbp
mov    0x50(%rsp),%rbx
xor    %r14d,%r14d
mov    0x60(%rsp),%r13d
mov    0x20(%rsp),%r15
nop
mov    %rbx,0x30(%rsp)
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13d,%esi
mov    0x48(%rsp),%edx
mov    0xb0(%rsp),%ecx
mov    %r12d,%r8d
mov    %r14d,%r9d
xor    %eax,%eax
call   1040 <get_sub@plt>
cltq
mov    %rax,(%rbx)
mov    0x38(%rsp),%rax
add    $0x1,%r12
add    %rbp,%rbx
cmp    %r12,%rax
jne    1220 <block_multiply+0xb0>
add    $0x1,%r14
mov    0x30(%rsp),%rbx
add    $0x8,%rbx
cmp    %rax,%r14
jne    1210 <block_multiply+0xa0>
mov    0x18(%rsp),%rdi
mov    0x14(%rsp),%esi
mov    0x28(%rsp),%edx
xor    %eax,%eax
call   1070 <transpose@plt>
mov    %eax,%r12d
mov    0x70(%rsp),%rdi
call   1080 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    0x38(%rsp),%rax
mov    0xb0(%rsp),%r14d
mov    %r14,%rcx
test   %ecx,%ecx
jle    1316 <block_multiply+0x1a6>
movslq %r12d,%r15
lea    0x0(,%rax,8),%r14
mov    0x18(%rsp),%rbx
xor    %ebp,%ebp
mov    0x28(%rsp),%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbx,0x30(%rsp)
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13d,%esi
mov    0x14(%rsp),%edx
mov    %r12d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1040 <get_sub@plt>
mov    0xb0(%rsp),%ecx
cltq
mov    %rax,(%rbx)
mov    0x38(%rsp),%rax
add    $0x1,%r12
add    %r14,%rbx
cmp    %r12,%rax
jne    12d0 <block_multiply+0x160>
add    $0x1,%rbp
mov    0x30(%rsp),%rbx
add    $0x8,%rbx
cmp    %rax,%rbp
jne    12c0 <block_multiply+0x150>
mov    0x70(%rsp),%rdi
call   1080 <malloc@plt>
mov    %rax,0x20(%rsp)
cmpq   $0x0,0x58(%rsp)
je     137f <block_multiply+0x20f>
mov    0x44(%rsp),%eax
mov    %eax,%ebx
imul   0x4c(%rsp),%ebx
movslq %ebx,%r12
shl    $0x2,%r12
lea    0x0(,%rbx,4),%r14
xor    %ebp,%ebp
jmp    135b <block_multiply+0x1eb>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,0x58(%rsp)
je     137f <block_multiply+0x20f>
mov    %r12,%rdi
call   1080 <malloc@plt>
mov    0x20(%rsp),%rcx
mov    %rax,(%rcx,%rbp,8)
test   %ebx,%ebx
jle    1350 <block_multiply+0x1e0>
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1050 <memset@plt>
jmp    1350 <block_multiply+0x1e0>
mov    0xb0(%rsp),%eax
test   %eax,%eax
mov    0x38(%rsp),%rax
jle    1454 <block_multiply+0x2e4>
lea    0x0(,%rax,8),%rax
mov    %rax,0x28(%rsp)
mov    0x50(%rsp),%rbp
xor    %ecx,%ecx
mov    0x44(%rsp),%r12d
mov    0x68(%rsp),%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,0x60(%rsp)
mov    0x20(%rsp),%r15
mov    0x18(%rsp),%rbx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdi,0x30(%rsp)
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%rdi
mov    (%rbx,%r14,8),%rcx
mov    (%r15,%r14,8),%rax
mov    %rax,(%rsp)
mov    0x6c(%rsp),%esi
mov    0x4c(%rsp),%edx
mov    %r12d,%r8d
mov    %r13d,%r9d
xor    %eax,%eax
call   1090 <mul_subs@plt>
mov    0x38(%rsp),%rax
add    $0x1,%r14
cmp    %r14,%rax
jne    13f0 <block_multiply+0x280>
mov    0x30(%rsp),%rdi
add    $0x1,%rdi
mov    0x28(%rsp),%rcx
add    %rcx,%rbx
add    %rcx,%r15
cmp    %rax,%rdi
jne    13e0 <block_multiply+0x270>
mov    0x60(%rsp),%rcx
add    $0x1,%rcx
add    0x28(%rsp),%rbp
cmp    %rax,%rcx
jne    13c0 <block_multiply+0x250>
mov    0x20(%rsp),%r13
mov    %r13,%rdi
mov    0x14(%rsp),%esi
mov    0x48(%rsp),%edx
mov    0xb0(%rsp),%ecx
xor    %eax,%eax
call   1060 <combine_subs@plt>
mov    %eax,%r14d
mov    0x58(%rsp),%rbx
test   %ebx,%ebx
mov    0x50(%rsp),%r15
mov    0x18(%rsp),%r12
je     14b5 <block_multiply+0x345>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbp,8),%rdi
call   1030 <free@plt>
mov    (%r12,%rbp,8),%rdi
call   1030 <free@plt>
mov    0x0(%r13,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1490 <block_multiply+0x320>
movslq %r14d,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define float* @block_multiply(float* %0, i32 %1, i32 %2, float* %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca float*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca float**
%16 = alloca float*
%17 = alloca float**
%18 = alloca float**
%19 = alloca float*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
store float* %0, float** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store float* %3, float** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%29 = load i32, i32* %9
%30 = load i32, i32* %14
%31 = sdiv i32 %29, %30
store i32 %31, i32* %23
%32 = load i32, i32* %10
%33 = load i32, i32* %14
%34 = sdiv i32 %32, %33
store i32 %34, i32* %24
%35 = load i32, i32* %12
%36 = load i32, i32* %14
%37 = sdiv i32 %35, %36
store i32 %37, i32* %25
%38 = load i32, i32* %13
%39 = load i32, i32* %14
%40 = sdiv i32 %38, %39
store i32 %40, i32* %26
%41 = load i32, i32* %14
%42 = load i32, i32* %14
%43 = mul nsw i32 %41, %42
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 8
%46 = call i8* @malloc(i64 %45)
%47 = bitcast i8* %46 to float**
store float** %47, float*** %15
store i32 0, i32* %21
br label %48
48: ; preds = %79, %7
%49 = load i32, i32* %21
%50 = load i32, i32* %14
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %82
52: ; preds = %48
store i32 0, i32* %20
br label %53
53: ; preds = %75, %52
%54 = load i32, i32* %20
%55 = load i32, i32* %14
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %78
57: ; preds = %53
%58 = load float*, float** %8
%59 = load i32, i32* %9
%60 = load i32, i32* %10
%61 = load i32, i32* %14
%62 = load i32, i32* %20
%63 = load i32, i32* %21
%64 = call i32 (float*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @get_sub to i32 (float*, i32, i32, i32, i32, i32, ...)*)(float* %58, i32 %59, i32 %60, i32 %61, i32 %62, i32 %63)
%65 = sext i32 %64 to i64
%66 = inttoptr i64 %65 to float*
%67 = load float**, float*** %15
%68 = load i32, i32* %20
%69 = load i32, i32* %14
%70 = mul nsw i32 %68, %69
%71 = load i32, i32* %21
%72 = add nsw i32 %70, %71
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds float*, float** %67, i64 %73
store float* %66, float** %74
br label %75
75: ; preds = %57
%76 = load i32, i32* %20
%77 = add nsw i32 %76, 1
store i32 %77, i32* %20
br label %53
78: ; preds = %53
br label %79
79: ; preds = %78
%80 = load i32, i32* %21
%81 = add nsw i32 %80, 1
store i32 %81, i32* %21
br label %48
82: ; preds = %48
%83 = load float*, float** %11
%84 = load i32, i32* %12
%85 = load i32, i32* %13
%86 = call i32 (float*, i32, i32, ...) bitcast (i32 (...)* @transpose to i32 (float*, i32, i32, ...)*)(float* %83, i32 %84, i32 %85)
%87 = sext i32 %86 to i64
%88 = inttoptr i64 %87 to float*
store float* %88, float** %16
%89 = load i32, i32* %14
%90 = load i32, i32* %14
%91 = mul nsw i32 %89, %90
%92 = sext i32 %91 to i64
%93 = mul i64 %92, 8
%94 = call i8* @malloc(i64 %93)
%95 = bitcast i8* %94 to float**
store float** %95, float*** %17
store i32 0, i32* %21
br label %96
96: ; preds = %127, %82
%97 = load i32, i32* %21
%98 = load i32, i32* %14
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %130
100: ; preds = %96
store i32 0, i32* %20
br label %101
101: ; preds = %123, %100
%102 = load i32, i32* %20
%103 = load i32, i32* %14
%104 = icmp slt i32 %102, %103
br i1 %104, label %105, label %126
105: ; preds = %101
%106 = load float*, float** %16
%107 = load i32, i32* %13
%108 = load i32, i32* %12
%109 = load i32, i32* %14
%110 = load i32, i32* %20
%111 = load i32, i32* %21
%112 = call i32 (float*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @get_sub to i32 (float*, i32, i32, i32, i32, i32, ...)*)(float* %106, i32 %107, i32 %108, i32 %109, i32 %110, i32 %111)
%113 = sext i32 %112 to i64
%114 = inttoptr i64 %113 to float*
%115 = load float**, float*** %17
%116 = load i32, i32* %20
%117 = load i32, i32* %14
%118 = mul nsw i32 %116, %117
%119 = load i32, i32* %21
%120 = add nsw i32 %118, %119
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds float*, float** %115, i64 %121
store float* %114, float** %122
br label %123
123: ; preds = %105
%124 = load i32, i32* %20
%125 = add nsw i32 %124, 1
store i32 %125, i32* %20
br label %101
126: ; preds = %101
br label %127
127: ; preds = %126
%128 = load i32, i32* %21
%129 = add nsw i32 %128, 1
store i32 %129, i32* %21
br label %96
130: ; preds = %96
%131 = load i32, i32* %14
%132 = load i32, i32* %14
%133 = mul nsw i32 %131, %132
%134 = sext i32 %133 to i64
%135 = mul i64 %134, 8
%136 = call i8* @malloc(i64 %135)
%137 = bitcast i8* %136 to float**
store float** %137, float*** %18
store i32 0, i32* %20
br label %138
138: ; preds = %175, %130
%139 = load i32, i32* %20
%140 = load i32, i32* %14
%141 = load i32, i32* %14
%142 = mul nsw i32 %140, %141
%143 = icmp slt i32 %139, %142
br i1 %143, label %144, label %178
144: ; preds = %138
%145 = load i32, i32* %25
%146 = load i32, i32* %24
%147 = mul nsw i32 %145, %146
%148 = sext i32 %147 to i64
%149 = mul i64 %148, 4
%150 = call i8* @malloc(i64 %149)
%151 = bitcast i8* %150 to float*
%152 = load float**, float*** %18
%153 = load i32, i32* %20
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds float*, float** %152, i64 %154
store float* %151, float** %155
store i32 0, i32* %21
br label %156
156: ; preds = %171, %144
%157 = load i32, i32* %21
%158 = load i32, i32* %25
%159 = load i32, i32* %24
%160 = mul nsw i32 %158, %159
%161 = icmp slt i32 %157, %160
br i1 %161, label %162, label %174
162: ; preds = %156
%163 = load float**, float*** %18
%164 = load i32, i32* %20
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds float*, float** %163, i64 %165
%167 = load float*, float** %166
%168 = load i32, i32* %21
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds float, float* %167, i64 %169
store float 0.000000e+00, float* %170
br label %171
171: ; preds = %162
%172 = load i32, i32* %21
%173 = add nsw i32 %172, 1
store i32 %173, i32* %21
br label %156
174: ; preds = %156
br label %175
175: ; preds = %174
%176 = load i32, i32* %20
%177 = add nsw i32 %176, 1
store i32 %177, i32* %20
br label %138
178: ; preds = %138
store i32 0, i32* %22
br label %179
179: ; preds = %232, %178
%180 = load i32, i32* %22
%181 = load i32, i32* %14
%182 = icmp slt i32 %180, %181
br i1 %182, label %183, label %235
183: ; preds = %179
store i32 0, i32* %21
br label %184
184: ; preds = %228, %183
%185 = load i32, i32* %21
%186 = load i32, i32* %14
%187 = icmp slt i32 %185, %186
br i1 %187, label %188, label %231
188: ; preds = %184
store i32 0, i32* %20
br label %189
189: ; preds = %224, %188
%190 = load i32, i32* %20
%191 = load i32, i32* %14
%192 = icmp slt i32 %190, %191
br i1 %192, label %193, label %227
193: ; preds = %189
%194 = load i32, i32* %22
%195 = load i32, i32* %14
%196 = mul nsw i32 %194, %195
%197 = load i32, i32* %20
%198 = add nsw i32 %196, %197
store i32 %198, i32* %27
%199 = load i32, i32* %21
%200 = load i32, i32* %14
%201 = mul nsw i32 %199, %200
%202 = load i32, i32* %20
%203 = add nsw i32 %201, %202
store i32 %203, i32* %28
%204 = load float**, float*** %15
%205 = load i32, i32* %27
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds float*, float** %204, i64 %206
%208 = load float*, float** %207
%209 = load i32, i32* %23
%210 = load i32, i32* %24
%211 = load float**, float*** %17
%212 = load i32, i32* %28
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds float*, float** %211, i64 %213
%215 = load float*, float** %214
%216 = load i32, i32* %25
%217 = load i32, i32* %26
%218 = load float**, float*** %18
%219 = load i32, i32* %28
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds float*, float** %218, i64 %220
%222 = load float*, float** %221
%223 = call i32 (float*, i32, i32, float*, i32, i32, float*, ...) bitcast (i32 (...)* @mul_subs to i32 (float*, i32, i32, float*, i32, i32, float*, ...)*)(float* %208, i32 %209, i32 %210, float* %215, i32 %216, i32 %217, float* %222)
br label %224
224: ; preds = %193
%225 = load i32, i32* %20
%226 = add nsw i32 %225, 1
store i32 %226, i32* %20
br label %189
227: ; preds = %189
br label %228
228: ; preds = %227
%229 = load i32, i32* %21
%230 = add nsw i32 %229, 1
store i32 %230, i32* %21
br label %184
231: ; preds = %184
br label %232
232: ; preds = %231
%233 = load i32, i32* %22
%234 = add nsw i32 %233, 1
store i32 %234, i32* %22
br label %179
235: ; preds = %179
%236 = load float**, float*** %18
%237 = load i32, i32* %12
%238 = load i32, i32* %10
%239 = load i32, i32* %14
%240 = call i32 (float**, i32, i32, i32, ...) bitcast (i32 (...)* @combine_subs to i32 (float**, i32, i32, i32, ...)*)(float** %236, i32 %237, i32 %238, i32 %239)
%241 = sext i32 %240 to i64
%242 = inttoptr i64 %241 to float*
store float* %242, float** %19
store i32 0, i32* %20
br label %243
243: ; preds = %268, %235
%244 = load i32, i32* %20
%245 = load i32, i32* %14
%246 = load i32, i32* %14
%247 = mul nsw i32 %245, %246
%248 = icmp slt i32 %244, %247
br i1 %248, label %249, label %271
249: ; preds = %243
%250 = load float**, float*** %15
%251 = load i32, i32* %20
%252 = sext i32 %251 to i64
%253 = getelementptr inbounds float*, float** %250, i64 %252
%254 = load float*, float** %253
%255 = bitcast float* %254 to i8*
%256 = load float**, float*** %17
%257 = load i32, i32* %20
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds float*, float** %256, i64 %258
%260 = load float*, float** %259
%261 = bitcast float* %260 to i8*
%262 = load float**, float*** %18
%263 = load i32, i32* %20
%264 = sext i32 %263 to i64
%265 = getelementptr inbounds float*, float** %262, i64 %264
%266 = load float*, float** %265
%267 = bitcast float* %266 to i8*
br label %268
268: ; preds = %249
%269 = load i32, i32* %20
%270 = add nsw i32 %269, 1
store i32 %270, i32* %20
br label %243
271: ; preds = %243
%272 = load float**, float*** %15
%273 = bitcast float** %272 to i8*
%274 = load float**, float*** %17
%275 = bitcast float** %274 to i8*
%276 = load float**, float*** %18
%277 = bitcast float** %276 to i8*
%278 = load float*, float** %19
ret float* %278
}

LLVM IR (-O2):
define float* @block_multiply(float* %0, i32 %1, i32 %2, float* %3, i32 %4, i32 %5, i32 %6) {
%8 = sdiv i32 %1, %6
%9 = sdiv i32 %2, %6
%10 = sdiv i32 %4, %6
%11 = sdiv i32 %5, %6
%12 = mul nsw i32 %6, %6
%13 = zext i32 %12 to i64
%14 = shl nuw nsw i64 %13, 3
%15 = tail call i8* @malloc(i64 %14)
%16 = bitcast i8* %15 to float**
%17 = icmp sgt i32 %6, 0
br i1 %17, label %18, label %38
18: ; preds = %7
%19 = zext i32 %6 to i64
%20 = zext i32 %6 to i64
br label %21
21: ; preds = %35, %18
%22 = phi i64 [ 0, %18 ], [ %36, %35 ]
%23 = trunc i64 %22 to i32
br label %24
24: ; preds = %21, %24
%25 = phi i64 [ 0, %21 ], [ %33, %24 ]
%26 = trunc i64 %25 to i32
%27 = tail call i32 (float*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @get_sub to i32 (float*, i32, i32, i32, i32, i32, ...)*)(float* %0, i32 %1, i32 %2, i32 %6, i32 %26, i32 %23)
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to float*
%30 = mul nsw i64 %25, %19
%31 = add nuw nsw i64 %30, %22
%32 = getelementptr inbounds float*, float** %16, i64 %31
store float* %29, float** %32
%33 = add nuw nsw i64 %25, 1
%34 = icmp eq i64 %33, %20
br i1 %34, label %35, label %24
35: ; preds = %24
%36 = add nuw nsw i64 %22, 1
%37 = icmp eq i64 %36, %20
br i1 %37, label %38, label %21
38: ; preds = %35, %7
%39 = tail call i32 (float*, i32, i32, ...) bitcast (i32 (...)* @transpose to i32 (float*, i32, i32, ...)*)(float* %3, i32 %4, i32 %5)
%40 = sext i32 %39 to i64
%41 = inttoptr i64 %40 to float*
%42 = tail call i8* @malloc(i64 %14)
%43 = bitcast i8* %42 to float**
br i1 %17, label %44, label %64
44: ; preds = %38
%45 = zext i32 %6 to i64
%46 = zext i32 %6 to i64
br label %47
47: ; preds = %61, %44
%48 = phi i64 [ 0, %44 ], [ %62, %61 ]
%49 = trunc i64 %48 to i32
br label %50
50: ; preds = %47, %50
%51 = phi i64 [ 0, %47 ], [ %59, %50 ]
%52 = trunc i64 %51 to i32
%53 = tail call i32 (float*, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @get_sub to i32 (float*, i32, i32, i32, i32, i32, ...)*)(float* %41, i32 %5, i32 %4, i32 %6, i32 %52, i32 %49)
%54 = sext i32 %53 to i64
%55 = inttoptr i64 %54 to float*
%56 = mul nsw i64 %51, %45
%57 = add nuw nsw i64 %56, %48
%58 = getelementptr inbounds float*, float** %43, i64 %57
store float* %55, float** %58
%59 = add nuw nsw i64 %51, 1
%60 = icmp eq i64 %59, %46
br i1 %60, label %61, label %50
61: ; preds = %50
%62 = add nuw nsw i64 %48, 1
%63 = icmp eq i64 %62, %46
br i1 %63, label %64, label %47
64: ; preds = %61, %38
%65 = tail call i8* @malloc(i64 %14)
%66 = bitcast i8* %65 to float**
%67 = icmp eq i32 %12, 0
br i1 %67, label %75, label %68
68: ; preds = %64
%69 = mul nsw i32 %10, %9
%70 = sext i32 %69 to i64
%71 = shl nsw i64 %70, 2
%72 = icmp sgt i32 %69, 0
%73 = zext i32 %69 to i64
%74 = shl nuw nsw i64 %73, 2
br label %79
75: ; preds = %85, %64
br i1 %17, label %76, label %113
76: ; preds = %75
%77 = zext i32 %6 to i64
%78 = zext i32 %6 to i64
br label %88
79: ; preds = %68, %85
%80 = phi i64 [ 0, %68 ], [ %86, %85 ]
%81 = tail call i8* @malloc(i64 %71)
%82 = getelementptr inbounds float*, float** %66, i64 %80
%83 = bitcast float** %82 to i8**
store i8* %81, i8** %83
br i1 %72, label %84, label %85
84: ; preds = %79
br label %85
85: ; preds = %84, %79
%86 = add nuw nsw i64 %80, 1
%87 = icmp eq i64 %86, %13
br i1 %87, label %75, label %79
88: ; preds = %110, %76
%89 = phi i64 [ 0, %76 ], [ %111, %110 ]
%90 = mul nsw i64 %89, %77
br label %91
91: ; preds = %107, %88
%92 = phi i64 [ 0, %88 ], [ %108, %107 ]
%93 = mul nsw i64 %92, %77
br label %94
94: ; preds = %91, %94
%95 = phi i64 [ 0, %91 ], [ %105, %94 ]
%96 = add nuw nsw i64 %95, %90
%97 = add nuw nsw i64 %95, %93
%98 = getelementptr inbounds float*, float** %16, i64 %96
%99 = load float*, float** %98
%100 = getelementptr inbounds float*, float** %43, i64 %97
%101 = load float*, float** %100
%102 = getelementptr inbounds float*, float** %66, i64 %97
%103 = load float*, float** %102
%104 = tail call i32 (float*, i32, i32, float*, i32, i32, float*, ...) bitcast (i32 (...)* @mul_subs to i32 (float*, i32, i32, float*, i32, i32, float*, ...)*)(float* %99, i32 %8, i32 %9, float* %101, i32 %10, i32 %11, float* %103)
%105 = add nuw nsw i64 %95, 1
%106 = icmp eq i64 %105, %78
br i1 %106, label %107, label %94
107: ; preds = %94
%108 = add nuw nsw i64 %92, 1
%109 = icmp eq i64 %108, %78
br i1 %109, label %110, label %91
110: ; preds = %107
%111 = add nuw nsw i64 %89, 1
%112 = icmp eq i64 %111, %78
br i1 %112, label %113, label %88
113: ; preds = %110, %75
%114 = tail call i32 (float**, i32, i32, i32, ...) bitcast (i32 (...)* @combine_subs to i32 (float**, i32, i32, i32, ...)*)(float** %66, i32 %4, i32 %2, i32 %6)
br i1 %67, label %128, label %115
115: ; preds = %113, %115
%116 = phi i64 [ %126, %115 ], [ 0, %113 ]
%117 = getelementptr inbounds float*, float** %16, i64 %116
%118 = bitcast float** %117 to i8**
%119 = load i8*, i8** %118
tail call void @free(i8* %119)
%120 = getelementptr inbounds float*, float** %43, i64 %116
%121 = bitcast float** %120 to i8**
%122 = load i8*, i8** %121
tail call void @free(i8* %122)
%123 = getelementptr inbounds float*, float** %66, i64 %116
%124 = bitcast float** %123 to i8**
%125 = load i8*, i8** %124
tail call void @free(i8* %125)
%126 = add nuw nsw i64 %116, 1
%127 = icmp eq i64 %126, %13
br i1 %127, label %128, label %115
128: ; preds = %115, %113
%129 = sext i32 %114 to i64
%130 = inttoptr i64 %129 to float*
tail call void @free(i8* %15)
tail call void @free(i8* %42)
tail call void @free(i8* %65)
ret float* %130
}