#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 */
double *allocateDoubleVector(int);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ memoryCheck();
double **allocateDoubleMatrix(int i, int j) {
  int k, n, m;
  double **matrix;
  if ((matrix = (double **)calloc(i, sizeof(double *))) == NULL)
    memoryCheck();
  for (k = 0; k < i; k++)
    matrix[k] = allocateDoubleVector(j);
  for (n = 0; n < i; n++)
    for (m = 0; m < j; m++)
      matrix[n][m] = 0;
  return matrix;
}


x86 assembly (clang, -O0):
<allocateDoubleMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1160 <allocateDoubleMatrix+0x30>
mov    $0x0,%al
call   1050 <memoryCheck@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1198 <allocateDoubleMatrix+0x68>
mov    -0x8(%rbp),%edi
call   1030 <allocateDoubleVector@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <allocateDoubleMatrix+0x37>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f7 <allocateDoubleMatrix+0xc7>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e4 <allocateDoubleMatrix+0xb4>
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b2 <allocateDoubleMatrix+0x82>
jmp    11e9 <allocateDoubleMatrix+0xb9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119f <allocateDoubleMatrix+0x6f>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocateDoubleMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %edi,%r14d
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%r13
test   %rax,%rax
je     116d <allocateDoubleMatrix+0x2d>
test   %r14d,%r14d
jg     1179 <allocateDoubleMatrix+0x39>
jmp    11ee <allocateDoubleMatrix+0xae>
xor    %eax,%eax
call   1060 <memoryCheck@plt>
test   %r14d,%r14d
jle    11ee <allocateDoubleMatrix+0xae>
mov    %r14d,%ebp
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %r12d,%edi
call   1030 <allocateDoubleVector@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1180 <allocateDoubleMatrix+0x40>
test   %r14d,%r14d
jle    11ee <allocateDoubleMatrix+0xae>
mov    %r12d,%r14d
shl    $0x3,%r14
lea    -0x1(%rbp),%rax
mov    %ebp,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
jae    1200 <allocateDoubleMatrix+0xc0>
xor    %ebx,%ebx
test   %r15,%r15
je     11ee <allocateDoubleMatrix+0xae>
lea    0x0(,%rbx,8),%rbx
add    %r13,%rbx
xor    %ebp,%ebp
jmp    11d9 <allocateDoubleMatrix+0x99>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %rbp,%r15
je     11ee <allocateDoubleMatrix+0xae>
test   %r12d,%r12d
jle    11d0 <allocateDoubleMatrix+0x90>
mov    (%rbx,%rbp,8),%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
jmp    11d0 <allocateDoubleMatrix+0x90>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0xfffffffc,%ebp
xor    %ebx,%ebx
jmp    1219 <allocateDoubleMatrix+0xd9>
nopw   0x0(%rax,%rax,1)
add    $0x4,%rbx
cmp    %rbx,%rbp
je     11b5 <allocateDoubleMatrix+0x75>
test   %r12d,%r12d
jle    1210 <allocateDoubleMatrix+0xd0>
mov    0x0(%r13,%rbx,8),%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
mov    0x8(%r13,%rbx,8),%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
mov    0x10(%r13,%rbx,8),%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
mov    0x18(%r13,%rbx,8),%rdi
xor    %esi,%esi
mov    %r14,%rdx
call   1040 <memset@plt>
jmp    1210 <allocateDoubleMatrix+0xd0>

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

LLVM IR (-O2):
define double** @allocateDoubleMatrix(i32 %0, i32 %1) {
%3 = tail call i64 @calloc(i32 %0, i32 8)
%4 = inttoptr i64 %3 to double**
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 (...) @memoryCheck()
br label %8
8: ; preds = %6, %2
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %65
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %22
12: ; preds = %22
br i1 %9, label %13, label %65
13: ; preds = %12
%14 = icmp sgt i32 %1, 0
%15 = zext i32 %1 to i64
%16 = shl nuw nsw i64 %15, 3
%17 = add nsw i64 %11, -1
%18 = and i64 %11, 3
%19 = icmp ult i64 %17, 3
br i1 %19, label %51, label %20
20: ; preds = %13
%21 = and i64 %11, 4294967292
br label %28
22: ; preds = %10, %22
%23 = phi i64 [ 0, %10 ], [ %26, %22 ]
%24 = tail call double* @allocateDoubleVector(i32 %1)
%25 = getelementptr inbounds double*, double** %4, i64 %23
store double* %24, double** %25
%26 = add nuw nsw i64 %23, 1
%27 = icmp eq i64 %26, %11
br i1 %27, label %12, label %22
28: ; preds = %47, %20
%29 = phi i64 [ 0, %20 ], [ %48, %47 ]
%30 = phi i64 [ 0, %20 ], [ %49, %47 ]
br i1 %14, label %31, label %47
31: ; preds = %28
%32 = getelementptr inbounds double*, double** %4, i64 %29
%33 = bitcast double** %32 to i8**
%34 = load i8*, i8** %33
%35 = or i64 %29, 1
%36 = getelementptr inbounds double*, double** %4, i64 %35
%37 = bitcast double** %36 to i8**
%38 = load i8*, i8** %37
%39 = or i64 %29, 2
%40 = getelementptr inbounds double*, double** %4, i64 %39
%41 = bitcast double** %40 to i8**
%42 = load i8*, i8** %41
%43 = or i64 %29, 3
%44 = getelementptr inbounds double*, double** %4, i64 %43
%45 = bitcast double** %44 to i8**
%46 = load i8*, i8** %45
br label %47
47: ; preds = %28, %31
%48 = add nuw nsw i64 %29, 4
%49 = add i64 %30, 4
%50 = icmp eq i64 %49, %21
br i1 %50, label %51, label %28
51: ; preds = %47, %13
%52 = phi i64 [ 0, %13 ], [ %48, %47 ]
%53 = icmp eq i64 %18, 0
br i1 %53, label %65, label %54
54: ; preds = %51, %61
%55 = phi i64 [ %62, %61 ], [ %52, %51 ]
%56 = phi i64 [ %63, %61 ], [ 0, %51 ]
br i1 %14, label %57, label %61
57: ; preds = %54
%58 = getelementptr inbounds double*, double** %4, i64 %55
%59 = bitcast double** %58 to i8**
%60 = load i8*, i8** %59
br label %61
61: ; preds = %57, %54
%62 = add nuw nsw i64 %55, 1
%63 = add i64 %56, 1
%64 = icmp eq i64 %63, %18
br i1 %64, label %65, label %54
65: ; preds = %51, %61, %8, %12
ret double** %4
}