#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ z;
typedef scalar_t__ y;
typedef scalar_t__ x;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ matprod_mat_mat_n2(double *, double *, double *, int, int);
int /*<<< orphan*/ matprod_mat_mat_sub_xrows(double *, double *, double *, int,
                                             int, int, int, int);
int /*<<< orphan*/ matprod_mat_mat_sub_xrowscols(double *, double *, double *,
                                                 int, int, int, int, int, int,
                                                 int /*<<< orphan*/);
int /*<<< orphan*/ matprod_mat_vec(double *, double *, double *, int, int);
int /*<<< orphan*/ matprod_outer(double *, double *, double *, int, int);
int /*<<< orphan*/ matprod_vec_mat(double *, double *, double *, int, int);
int /*<<< orphan*/ set_to_zeros(double *, size_t);
void matprod_mat_mat(double *restrict x, double *restrict y, double *restrict z,
                     int n, int k, int m) {
  assert(((uintptr_t)(x) & (1 - 1)) == 0);
  assert(((uintptr_t)(y) & (1 - 1)) == 0);
  assert(((uintptr_t)(z) & (1 - 1)) == 0);
  x = (x);
  y = (y);
  z = (z);
  if (k <= 1) {
    if (k == 1) {
      matprod_outer(x, y, z, n, m);
    } else {
      set_to_zeros(z, (size_t)n * m);
    }
    return;
  }
  if (n <= 2) {
    if (n == 2) {
      matprod_mat_mat_n2(x, y, z, k, m);
    } else if (n == 1) {
      matprod_vec_mat(x, y, z, k, m);
    }
    return;
  }
  if (m <= 1) {
    if (m == 1) {
      matprod_mat_vec(x, y, z, n, k);
    }
    return;
  }
  if (n <= (1024 - 64) && k <= 32) {
    matprod_mat_mat_sub_xrowscols(x, y, z, n, k, m, n, n, k, 0);
    return;
  }
  int cachable =
      n <= (1024 - 64) ? m : 1 + (int)(95000 / ((1024 - 64) + (double)k));
  int mm = m;
  for (;;) {
    double *xx = x;
    double *zz = z;
    int xrows = n;
    int m1 = mm;
    if (m1 > cachable) {
      m1 = mm < 2 * cachable ? mm / 2 : cachable;
      m1 = (m1 + 7) & ~7;
      if (m1 > mm)
        m1 = mm;
    }
    if (xrows > (1024 - 64)) {
      while (xrows >= 2 * (1024 - 64)) {
        matprod_mat_mat_sub_xrows(xx, y, zz, n, k, m1, (1024 - 64), n);
        xx += (1024 - 64);
        zz += (1024 - 64);
        xrows -= (1024 - 64);
      }
      if (xrows > (1024 - 64)) {
        int nr = (((xrows + 3) >> 1) & ~3);
        matprod_mat_mat_sub_xrows(xx, y, zz, n, k, m1, nr, n);
        xx += nr;
        zz += nr;
        xrows -= nr;
      }
    }
    matprod_mat_mat_sub_xrows(xx, y, zz, n, k, m1, xrows, n);
    mm -= m1;
    if (mm == 0)
      break;
    y += (size_t)m1 * k;
    z += (size_t)m1 * n;
  }
}


x86 assembly (clang, -O0):
<matprod_mat_mat>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x20(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x28(%rbp)
jg     124e <matprod_mat_mat+0xce>
cmpl   $0x1,-0x28(%rbp)
jne    1234 <matprod_mat_mat+0xb4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1030 <matprod_outer@plt>
jmp    1249 <matprod_mat_mat+0xc9>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rsi
movslq -0x2c(%rbp),%rax
imul   %rax,%rsi
call   1080 <set_to_zeros@plt>
jmp    156c <matprod_mat_mat+0x3ec>
cmpl   $0x2,-0x24(%rbp)
jg     12ab <matprod_mat_mat+0x12b>
cmpl   $0x2,-0x24(%rbp)
jne    127f <matprod_mat_mat+0xff>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   10a0 <matprod_mat_mat_n2@plt>
jmp    12a6 <matprod_mat_mat+0x126>
cmpl   $0x1,-0x24(%rbp)
jne    12a1 <matprod_mat_mat+0x121>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1040 <matprod_vec_mat@plt>
jmp    12a6 <matprod_mat_mat+0x126>
jmp    156c <matprod_mat_mat+0x3ec>
cmpl   $0x1,-0x2c(%rbp)
jg     12dc <matprod_mat_mat+0x15c>
cmpl   $0x1,-0x2c(%rbp)
jne    12d7 <matprod_mat_mat+0x157>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1090 <matprod_mat_vec@plt>
jmp    156c <matprod_mat_mat+0x3ec>
cmpl   $0x3c0,-0x24(%rbp)
jg     1336 <matprod_mat_mat+0x1b6>
cmpl   $0x20,-0x28(%rbp)
jg     1336 <matprod_mat_mat+0x1b6>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x2c(%rbp),%r9d
mov    -0x24(%rbp),%r11d
mov    -0x24(%rbp),%r10d
mov    -0x28(%rbp),%eax
xor    %ebx,%ebx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
movl   $0x0,0x18(%rsp)
call   1070 <matprod_mat_mat_sub_xrowscols@plt>
jmp    156c <matprod_mat_mat+0x3ec>
cmpl   $0x3c0,-0x24(%rbp)
jg     134e <matprod_mat_mat+0x1ce>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    1375 <matprod_mat_mat+0x1f5>
cvtsi2sdl -0x28(%rbp),%xmm0
movsd  0xcad(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xc99(%rip),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x30(%rbp),%eax
jle    13fc <matprod_mat_mat+0x27c>
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    13cd <matprod_mat_mat+0x24d>
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x5c(%rbp)
jmp    13d3 <matprod_mat_mat+0x253>
mov    -0x30(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
add    $0x7,%eax
and    $0xfffffff8,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x34(%rbp),%eax
jle    13f7 <matprod_mat_mat+0x277>
mov    -0x34(%rbp),%eax
mov    %eax,-0x50(%rbp)
jmp    13fc <matprod_mat_mat+0x27c>
cmpl   $0x3c0,-0x4c(%rbp)
jle    14f2 <matprod_mat_mat+0x372>
jmp    140e <matprod_mat_mat+0x28e>
cmpl   $0x780,-0x4c(%rbp)
jl     1471 <matprod_mat_mat+0x2f1>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    -0x24(%rbp),%eax
movl   $0x3c0,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <matprod_mat_mat_sub_xrows@plt>
mov    -0x40(%rbp),%rax
add    $0x1e00,%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1e00,%rax
mov    %rax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
sub    $0x3c0,%eax
mov    %eax,-0x4c(%rbp)
jmp    140e <matprod_mat_mat+0x28e>
cmpl   $0x3c0,-0x4c(%rbp)
jle    14ed <matprod_mat_mat+0x36d>
mov    -0x4c(%rbp),%eax
add    $0x3,%eax
sar    $0x1,%eax
and    $0xfffffffc,%eax
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    -0x54(%rbp),%r10d
mov    -0x24(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <matprod_mat_mat_sub_xrows@plt>
mov    -0x54(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x54(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x54(%rbp),%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4c(%rbp)
jmp    14f2 <matprod_mat_mat+0x372>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x50(%rbp),%r9d
mov    -0x4c(%rbp),%r10d
mov    -0x24(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1060 <matprod_mat_mat_sub_xrows@plt>
mov    -0x50(%rbp),%ecx
mov    -0x34(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    1537 <matprod_mat_mat+0x3b7>
jmp    156c <matprod_mat_mat+0x3ec>
movslq -0x50(%rbp),%rax
movslq -0x28(%rbp),%rcx
imul   %rcx,%rax
shl    $0x3,%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
movslq -0x50(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
shl    $0x3,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1381 <matprod_mat_mat+0x201>
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<matprod_mat_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,(%rsp)
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r12
mov    $0x1,%edi
call   1050 <assert@plt>
mov    $0x1,%edi
call   1050 <assert@plt>
mov    $0x1,%edi
call   1050 <assert@plt>
cmp    $0x1,%r14d
jg     11ea <matprod_mat_mat+0x6a>
jne    1228 <matprod_mat_mat+0xa8>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
mov    (%rsp),%r8d
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <matprod_outer@plt>
cmp    $0x2,%r15d
mov    %r15,%rcx
jg     1249 <matprod_mat_mat+0xc9>
cmp    $0x1,%ecx
je     12a6 <matprod_mat_mat+0x126>
cmp    $0x2,%ecx
jne    149e <matprod_mat_mat+0x31e>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
mov    (%rsp),%r8d
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <matprod_mat_mat_n2@plt>
movslq %r15d,%rax
movslq (%rsp),%rsi
imul   %rax,%rsi
mov    %rbx,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <set_to_zeros@plt>
cmpl   $0x1,(%rsp)
jg     1274 <matprod_mat_mat+0xf4>
jne    149e <matprod_mat_mat+0x31e>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14d,%r8d
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <matprod_mat_vec@plt>
cmp    $0x3c0,%ecx
ja     12c9 <matprod_mat_mat+0x149>
cmp    $0x20,%r14d
ja     12c9 <matprod_mat_mat+0x149>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14d,%r8d
mov    (%rsp),%r9d
push   $0x0
push   %r14
push   %rcx
push   %rcx
call   1070 <matprod_mat_mat_sub_xrowscols@plt>
add    $0x68,%rsp
jmp    14a2 <matprod_mat_mat+0x322>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
mov    (%rsp),%r8d
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <matprod_vec_mat@plt>
mov    (%rsp),%eax
mov    %eax,%esi
cmp    $0x3c1,%ecx
mov    %rbx,%rdx
jb     12f9 <matprod_mat_mat+0x179>
cvtsi2sd %r14d,%xmm0
addsd  0xd1a(%rip),%xmm0
movsd  0xd1a(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
add    $0x1,%esi
lea    (%rsi,%rsi,1),%eax
mov    %eax,0x1c(%rsp)
mov    %r14d,%eax
mov    %rax,0x38(%rsp)
mov    %ecx,%eax
mov    %rax,0x30(%rsp)
mov    %r14,0x8(%rsp)
mov    %r12,0x28(%rsp)
mov    %rsi,0x40(%rsp)
xchg   %ax,%ax
mov    (%rsp),%eax
mov    %eax,%edi
cmp    %esi,%eax
jle    134e <matprod_mat_mat+0x1ce>
mov    %esi,%edi
mov    0x1c(%rsp),%eax
cmp    %eax,(%rsp)
jge    1340 <matprod_mat_mat+0x1c0>
mov    (%rsp),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
add    $0x7,%edi
and    $0xfffffff8,%edi
mov    (%rsp),%eax
cmp    %eax,%edi
cmovg  %eax,%edi
mov    %edi,0x4(%rsp)
mov    %rbp,0x10(%rsp)
mov    %r12,%r14
mov    %rdx,%r15
mov    %ecx,%eax
cmp    $0x3c1,%ecx
jb     1439 <matprod_mat_mat+0x2b9>
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %r12,%r14
cmp    $0x780,%ecx
mov    %rdx,0x20(%rsp)
jb     13fa <matprod_mat_mat+0x27a>
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %r12,%r14
mov    0x8(%rsp),%rbp
mov    %rcx,%r13
mov    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r13d,%ecx
mov    %ebp,%r8d
mov    0x4(%rsp),%r9d
push   %r13
push   $0x3c0
call   1060 <matprod_mat_mat_sub_xrows@plt>
add    $0x10,%rsp
add    $0x1e00,%r14
add    $0x1e00,%r15
add    $0xfffffc40,%ebx
cmp    $0x77f,%ebx
ja     13a0 <matprod_mat_mat+0x220>
mov    $0x3c0,%eax
cmp    $0x3c1,%ebx
mov    0x20(%rsp),%rdx
mov    %r13,%rcx
mov    0x28(%rsp),%r12
jb     1439 <matprod_mat_mat+0x2b9>
lea    0x3(%rbx),%ebp
shr    %ebp
and    $0xfffffffc,%ebp
mov    %r14,%rdi
mov    0x10(%rsp),%rsi
mov    %r15,%rdx
mov    0x8(%rsp),%r8
mov    0x4(%rsp),%r9d
push   %rcx
push   %rbp
mov    %rcx,%r13
call   1060 <matprod_mat_mat_sub_xrows@plt>
mov    %r13,%rcx
add    $0x10,%rsp
lea    (%r14,%rbp,8),%r14
lea    (%r15,%rbp,8),%r15
sub    %ebp,%ebx
mov    0x20(%rsp),%rdx
mov    %ebx,%eax
mov    %r12,%r13
mov    %rdx,%r12
mov    %r14,%rdi
mov    0x10(%rsp),%rbp
mov    %rbp,%rsi
mov    %r15,%rdx
mov    0x8(%rsp),%r14
mov    %r14d,%r8d
mov    0x4(%rsp),%r9d
push   %rcx
push   %rax
mov    %rcx,%rbx
call   1060 <matprod_mat_mat_sub_xrows@plt>
mov    0x14(%rsp),%eax
add    $0x10,%rsp
sub    %eax,(%rsp)
je     149e <matprod_mat_mat+0x31e>
mov    %rbx,%rcx
cltq
mov    %rax,%rdx
imul   0x38(%rsp),%rdx
lea    0x0(%rbp,%rdx,8),%rbp
imul   0x30(%rsp),%rax
mov    %r12,%rdx
lea    (%r12,%rax,8),%rdx
mov    %r13,%r12
mov    0x40(%rsp),%rsi
jmp    1320 <matprod_mat_mat+0x1a0>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @matprod_mat_mat(double* noalias %0, double* noalias %1, double* noalias %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 double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
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** %7
%21 = ptrtoint double* %20 to i64
%22 = and i64 %21, 0
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load double*, double** %8
%27 = ptrtoint double* %26 to i64
%28 = and i64 %27, 0
%29 = icmp eq i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load double*, double** %9
%33 = ptrtoint double* %32 to i64
%34 = and i64 %33, 0
%35 = icmp eq i64 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load double*, double** %7
store double* %38, double** %7
%39 = load double*, double** %8
store double* %39, double** %8
%40 = load double*, double** %9
store double* %40, double** %9
%41 = load i32, i32* %11
%42 = icmp sle i32 %41, 1
br i1 %42, label %43, label %62
43: ; preds = %6
%44 = load i32, i32* %11
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %53
46: ; preds = %43
%47 = load double*, double** %7
%48 = load double*, double** %8
%49 = load double*, double** %9
%50 = load i32, i32* %10
%51 = load i32, i32* %12
%52 = call i32 @matprod_outer(double* %47, double* %48, double* %49, i32 %50, i32 %51)
br label %61
53: ; preds = %43
%54 = load double*, double** %9
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = mul i64 %56, %58
%60 = call i32 @set_to_zeros(double* %54, i64 %59)
br label %61
61: ; preds = %53, %46
br label %244
62: ; preds = %6
%63 = load i32, i32* %10
%64 = icmp sle i32 %63, 2
br i1 %64, label %65, label %87
65: ; preds = %62
%66 = load i32, i32* %10
%67 = icmp eq i32 %66, 2
br i1 %67, label %68, label %75
68: ; preds = %65
%69 = load double*, double** %7
%70 = load double*, double** %8
%71 = load double*, double** %9
%72 = load i32, i32* %11
%73 = load i32, i32* %12
%74 = call i32 @matprod_mat_mat_n2(double* %69, double* %70, double* %71, i32 %72, i32 %73)
br label %86
75: ; preds = %65
%76 = load i32, i32* %10
%77 = icmp eq i32 %76, 1
br i1 %77, label %78, label %85
78: ; preds = %75
%79 = load double*, double** %7
%80 = load double*, double** %8
%81 = load double*, double** %9
%82 = load i32, i32* %11
%83 = load i32, i32* %12
%84 = call i32 @matprod_vec_mat(double* %79, double* %80, double* %81, i32 %82, i32 %83)
br label %85
85: ; preds = %78, %75
br label %86
86: ; preds = %85, %68
br label %244
87: ; preds = %62
%88 = load i32, i32* %12
%89 = icmp sle i32 %88, 1
br i1 %89, label %90, label %101
90: ; preds = %87
%91 = load i32, i32* %12
%92 = icmp eq i32 %91, 1
br i1 %92, label %93, label %100
93: ; preds = %90
%94 = load double*, double** %7
%95 = load double*, double** %8
%96 = load double*, double** %9
%97 = load i32, i32* %10
%98 = load i32, i32* %11
%99 = call i32 @matprod_mat_vec(double* %94, double* %95, double* %96, i32 %97, i32 %98)
br label %100
100: ; preds = %93, %90
br label %244
101: ; preds = %87
%102 = load i32, i32* %10
%103 = icmp sle i32 %102, 960
br i1 %103, label %104, label %118
104: ; preds = %101
%105 = load i32, i32* %11
%106 = icmp sle i32 %105, 32
br i1 %106, label %107, label %118
107: ; preds = %104
%108 = load double*, double** %7
%109 = load double*, double** %8
%110 = load double*, double** %9
%111 = load i32, i32* %10
%112 = load i32, i32* %11
%113 = load i32, i32* %12
%114 = load i32, i32* %10
%115 = load i32, i32* %10
%116 = load i32, i32* %11
%117 = call i32 @matprod_mat_mat_sub_xrowscols(double* %108, double* %109, double* %110, i32 %111, i32 %112, i32 %113, i32 %114, i32 %115, i32 %116, i32 0)
br label %244
118: ; preds = %104, %101
%119 = load i32, i32* %10
%120 = icmp sle i32 %119, 960
br i1 %120, label %121, label %123
121: ; preds = %118
%122 = load i32, i32* %12
br label %130
123: ; preds = %118
%124 = load i32, i32* %11
%125 = sitofp i32 %124 to double
%126 = fadd double 9.600000e+02, %125
%127 = fdiv double 9.500000e+04, %126
%128 = fptosi double %127 to i32
%129 = add nsw i32 1, %128
br label %130
130: ; preds = %123, %121
%131 = phi i32 [ %122, %121 ], [ %129, %123 ]
store i32 %131, i32* %13
%132 = load i32, i32* %12
store i32 %132, i32* %14
br label %133
133: ; preds = %229, %130
%134 = load double*, double** %7
store double* %134, double** %15
%135 = load double*, double** %9
store double* %135, double** %16
%136 = load i32, i32* %10
store i32 %136, i32* %17
%137 = load i32, i32* %14
store i32 %137, i32* %18
%138 = load i32, i32* %18
%139 = load i32, i32* %13
%140 = icmp sgt i32 %138, %139
br i1 %140, label %141, label %162
141: ; preds = %133
%142 = load i32, i32* %14
%143 = load i32, i32* %13
%144 = mul nsw i32 2, %143
%145 = icmp slt i32 %142, %144
br i1 %145, label %146, label %149
146: ; preds = %141
%147 = load i32, i32* %14
%148 = sdiv i32 %147, 2
br label %151
149: ; preds = %141
%150 = load i32, i32* %13
br label %151
151: ; preds = %149, %146
%152 = phi i32 [ %148, %146 ], [ %150, %149 ]
store i32 %152, i32* %18
%153 = load i32, i32* %18
%154 = add nsw i32 %153, 7
%155 = and i32 %154, -8
store i32 %155, i32* %18
%156 = load i32, i32* %18
%157 = load i32, i32* %14
%158 = icmp sgt i32 %156, %157
br i1 %158, label %159, label %161
159: ; preds = %151
%160 = load i32, i32* %14
store i32 %160, i32* %18
br label %161
161: ; preds = %159, %151
br label %162
162: ; preds = %161, %133
%163 = load i32, i32* %17
%164 = icmp sgt i32 %163, 960
br i1 %164, label %165, label %213
165: ; preds = %162
br label %166
166: ; preds = %169, %165
%167 = load i32, i32* %17
%168 = icmp sge i32 %167, 1920
br i1 %168, label %169, label %184
169: ; preds = %166
%170 = load double*, double** %15
%171 = load double*, double** %8
%172 = load double*, double** %16
%173 = load i32, i32* %10
%174 = load i32, i32* %11
%175 = load i32, i32* %18
%176 = load i32, i32* %10
%177 = call i32 @matprod_mat_mat_sub_xrows(double* %170, double* %171, double* %172, i32 %173, i32 %174, i32 %175, i32 960, i32 %176)
%178 = load double*, double** %15
%179 = getelementptr inbounds double, double* %178, i64 960
store double* %179, double** %15
%180 = load double*, double** %16
%181 = getelementptr inbounds double, double* %180, i64 960
store double* %181, double** %16
%182 = load i32, i32* %17
%183 = sub nsw i32 %182, 960
store i32 %183, i32* %17
br label %166
184: ; preds = %166
%185 = load i32, i32* %17
%186 = icmp sgt i32 %185, 960
br i1 %186, label %187, label %212
187: ; preds = %184
%188 = load i32, i32* %17
%189 = add nsw i32 %188, 3
%190 = ashr i32 %189, 1
%191 = and i32 %190, -4
store i32 %191, i32* %19
%192 = load double*, double** %15
%193 = load double*, double** %8
%194 = load double*, double** %16
%195 = load i32, i32* %10
%196 = load i32, i32* %11
%197 = load i32, i32* %18
%198 = load i32, i32* %19
%199 = load i32, i32* %10
%200 = call i32 @matprod_mat_mat_sub_xrows(double* %192, double* %193, double* %194, i32 %195, i32 %196, i32 %197, i32 %198, i32 %199)
%201 = load i32, i32* %19
%202 = load double*, double** %15
%203 = sext i32 %201 to i64
%204 = getelementptr inbounds double, double* %202, i64 %203
store double* %204, double** %15
%205 = load i32, i32* %19
%206 = load double*, double** %16
%207 = sext i32 %205 to i64
%208 = getelementptr inbounds double, double* %206, i64 %207
store double* %208, double** %16
%209 = load i32, i32* %19
%210 = load i32, i32* %17
%211 = sub nsw i32 %210, %209
store i32 %211, i32* %17
br label %212
212: ; preds = %187, %184
br label %213
213: ; preds = %212, %162
%214 = load double*, double** %15
%215 = load double*, double** %8
%216 = load double*, double** %16
%217 = load i32, i32* %10
%218 = load i32, i32* %11
%219 = load i32, i32* %18
%220 = load i32, i32* %17
%221 = load i32, i32* %10
%222 = call i32 @matprod_mat_mat_sub_xrows(double* %214, double* %215, double* %216, i32 %217, i32 %218, i32 %219, i32 %220, i32 %221)
%223 = load i32, i32* %18
%224 = load i32, i32* %14
%225 = sub nsw i32 %224, %223
store i32 %225, i32* %14
%226 = load i32, i32* %14
%227 = icmp eq i32 %226, 0
br i1 %227, label %228, label %229
228: ; preds = %213
br label %244
229: ; preds = %213
%230 = load i32, i32* %18
%231 = sext i32 %230 to i64
%232 = load i32, i32* %11
%233 = sext i32 %232 to i64
%234 = mul i64 %231, %233
%235 = load double*, double** %8
%236 = getelementptr inbounds double, double* %235, i64 %234
store double* %236, double** %8
%237 = load i32, i32* %18
%238 = sext i32 %237 to i64
%239 = load i32, i32* %10
%240 = sext i32 %239 to i64
%241 = mul i64 %238, %240
%242 = load double*, double** %9
%243 = getelementptr inbounds double, double* %242, i64 %241
store double* %243, double** %9
br label %133
244: ; preds = %61, %86, %100, %107, %228
ret void
}

LLVM IR (-O2):
define void @matprod_mat_mat(double* noalias %0, double* noalias %1, double* noalias %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call i32 @assert(i32 1)
%8 = tail call i32 @assert(i32 1)
%9 = tail call i32 @assert(i32 1)
%10 = icmp slt i32 %4, 2
br i1 %10, label %11, label %20
11: ; preds = %6
%12 = icmp eq i32 %4, 1
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @matprod_outer(double* %0, double* %1, double* %2, i32 %3, i32 %5)
br label %105
15: ; preds = %11
%16 = sext i32 %3 to i64
%17 = sext i32 %5 to i64
%18 = mul nsw i64 %17, %16
%19 = tail call i32 @set_to_zeros(double* %2, i64 %18)
br label %105
20: ; preds = %6
%21 = icmp slt i32 %3, 3
br i1 %21, label %22, label %27
22: ; preds = %20
switch i32 %3, label %105 [
i32 2, label %23
i32 1, label %25
]
23: ; preds = %22
%24 = tail call i32 @matprod_mat_mat_n2(double* %0, double* %1, double* %2, i32 %4, i32 %5)
br label %105
25: ; preds = %22
%26 = tail call i32 @matprod_vec_mat(double* %0, double* %1, double* %2, i32 %4, i32 %5)
br label %105
27: ; preds = %20
%28 = icmp slt i32 %5, 2
br i1 %28, label %29, label %33
29: ; preds = %27
%30 = icmp eq i32 %5, 1
br i1 %30, label %31, label %105
31: ; preds = %29
%32 = tail call i32 @matprod_mat_vec(double* %0, double* %1, double* %2, i32 %3, i32 %4)
br label %105
33: ; preds = %27
%34 = icmp ult i32 %3, 961
%35 = icmp ult i32 %4, 33
%36 = and i1 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = tail call i32 @matprod_mat_mat_sub_xrowscols(double* %0, double* %1, double* %2, i32 %3, i32 %4, i32 %5, i32 %3, i32 %3, i32 %4, i32 0)
br label %105
39: ; preds = %33
br i1 %34, label %46, label %40
40: ; preds = %39
%41 = sitofp i32 %4 to double
%42 = fadd double %41, 9.600000e+02
%43 = fdiv double 9.500000e+04, %42
%44 = fptosi double %43 to i32
%45 = add nsw i32 %44, 1
br label %46
46: ; preds = %39, %40
%47 = phi i32 [ %45, %40 ], [ %5, %39 ]
%48 = icmp ugt i32 %3, 960
%49 = shl nsw i32 %47, 1
%50 = icmp ugt i32 %3, 1919
%51 = zext i32 %4 to i64
%52 = zext i32 %3 to i64
br label %53
53: ; preds = %99, %46
%54 = phi double* [ %2, %46 ], [ %104, %99 ]
%55 = phi double* [ %1, %46 ], [ %102, %99 ]
%56 = phi i32 [ %5, %46 ], [ %97, %99 ]
%57 = icmp sgt i32 %56, %47
br i1 %57, label %58, label %66
58: ; preds = %53
%59 = icmp slt i32 %56, %49
%60 = sdiv i32 %56, 2
%61 = select i1 %59, i32 %60, i32 %47
%62 = add nsw i32 %61, 7
%63 = and i32 %62, -8
%64 = icmp sgt i32 %63, %56
%65 = select i1 %64, i32 %56, i32 %63
br label %66
66: ; preds = %58, %53
%67 = phi i32 [ %56, %53 ], [ %65, %58 ]
br i1 %48, label %68, label %92
68: ; preds = %66
br i1 %50, label %69, label %80
69: ; preds = %68, %69
%70 = phi i32 [ %76, %69 ], [ %3, %68 ]
%71 = phi double* [ %75, %69 ], [ %54, %68 ]
%72 = phi double* [ %74, %69 ], [ %0, %68 ]
%73 = tail call i32 @matprod_mat_mat_sub_xrows(double* %72, double* %55, double* %71, i32 %3, i32 %4, i32 %67, i32 960, i32 %3)
%74 = getelementptr inbounds double, double* %72, i64 960
%75 = getelementptr inbounds double, double* %71, i64 960
%76 = add nsw i32 %70, -960
%77 = icmp ugt i32 %76, 1919
br i1 %77, label %69, label %78
78: ; preds = %69
%79 = icmp ugt i32 %76, 960
br i1 %79, label %80, label %92
80: ; preds = %68, %78
%81 = phi i32 [ %76, %78 ], [ %3, %68 ]
%82 = phi double* [ %75, %78 ], [ %54, %68 ]
%83 = phi double* [ %74, %78 ], [ %0, %68 ]
%84 = add nuw nsw i32 %81, 3
%85 = lshr i32 %84, 1
%86 = and i32 %85, 2147483644
%87 = tail call i32 @matprod_mat_mat_sub_xrows(double* %83, double* %55, double* %82, i32 %3, i32 %4, i32 %67, i32 %86, i32 %3)
%88 = zext i32 %86 to i64
%89 = getelementptr inbounds double, double* %83, i64 %88
%90 = getelementptr inbounds double, double* %82, i64 %88
%91 = sub nuw nsw i32 %81, %86
br label %92
92: ; preds = %78, %80, %66
%93 = phi double* [ %89, %80 ], [ %74, %78 ], [ %0, %66 ]
%94 = phi double* [ %90, %80 ], [ %75, %78 ], [ %54, %66 ]
%95 = phi i32 [ %91, %80 ], [ 960, %78 ], [ %3, %66 ]
%96 = tail call i32 @matprod_mat_mat_sub_xrows(double* %93, double* %55, double* %94, i32 %3, i32 %4, i32 %67, i32 %95, i32 %3)
%97 = sub nsw i32 %56, %67
%98 = icmp eq i32 %97, 0
br i1 %98, label %105, label %99
99: ; preds = %92
%100 = sext i32 %67 to i64
%101 = mul nsw i64 %100, %51
%102 = getelementptr inbounds double, double* %55, i64 %101
%103 = mul nsw i64 %100, %52
%104 = getelementptr inbounds double, double* %54, i64 %103
br label %53
105: ; preds = %92, %22, %29, %31, %23, %25, %13, %15, %37
ret void
}