#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 */

/* Variables and functions */
int /*<<< orphan*/ zero_product(double **);
void mm(double **A, double **B, double **C) {
  int i, j, k;
  zero_product(C);
#pragma omp for schedule(static)
  for (i = 0; i < 2048; i++) {
    for (k = 0; k < 2048; k++) {
      for (j = 0; j < 2048; j++) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
}


x86 assembly (clang, -O0):
<mm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <zero_product@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x800,-0x1c(%rbp)
jge    11e9 <mm+0xd9>
movl   $0x0,-0x24(%rbp)
cmpl   $0x800,-0x24(%rbp)
jge    11d6 <mm+0xc6>
movl   $0x0,-0x20(%rbp)
cmpl   $0x800,-0x20(%rbp)
jge    11c3 <mm+0xb3>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115c <mm+0x4c>
jmp    11c8 <mm+0xb8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1148 <mm+0x38>
jmp    11db <mm+0xcb>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <mm+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %rdx,%rdi
call   1030 <zero_product@plt>
xor    %r8d,%r8d
jmp    1141 <mm+0x31>
xchg   %ax,%ax
add    $0x1,%r8
cmp    $0x800,%r8
je     125d <mm+0x14d>
mov    (%r15,%r8,8),%rcx
mov    (%r14,%r8,8),%rdx
lea    0x4000(%rdx),%r10
xor    %edi,%edi
jmp    116d <mm+0x5d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rdi
cmp    $0x800,%rdi
je     1130 <mm+0x20>
mov    (%r12,%rdi,8),%rax
lea    (%rcx,%rdi,8),%rbx
add    $0x8,%rbx
lea    (%rcx,%rdi,8),%rsi
lea    0x4000(%rax),%r9
cmp    %rbx,%rdx
setb   %r11b
cmp    %r10,%rsi
setb   %sil
cmp    %r9,%rdx
setb   %bl
cmp    %r10,%rax
setb   %r9b
test   %sil,%r11b
jne    1210 <mm+0x100>
and    %r9b,%bl
jne    1210 <mm+0x100>
movsd  (%rcx,%rdi,8),%xmm0
unpcklpd %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movupd (%rax,%rbx,8),%xmm1
movupd 0x10(%rax,%rbx,8),%xmm2
movupd (%rdx,%rbx,8),%xmm3
movupd 0x10(%rdx,%rbx,8),%xmm4
mulpd  %xmm0,%xmm1
addpd  %xmm3,%xmm1
mulpd  %xmm0,%xmm2
addpd  %xmm4,%xmm2
movupd %xmm1,(%rdx,%rbx,8)
movupd %xmm2,0x10(%rdx,%rbx,8)
add    $0x4,%rbx
cmp    $0x800,%rbx
jne    11c0 <mm+0xb0>
jmp    1160 <mm+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rcx,%rdi,8),%xmm0
mulsd  (%rax,%rbx,8),%xmm0
addsd  (%rdx,%rbx,8),%xmm0
movsd  %xmm0,(%rdx,%rbx,8)
movsd  (%rcx,%rdi,8),%xmm0
mulsd  0x8(%rax,%rbx,8),%xmm0
addsd  0x8(%rdx,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rdx,%rbx,8)
add    $0x2,%rbx
cmp    $0x800,%rbx
jne    1220 <mm+0x110>
jmp    1160 <mm+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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