#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 */
scalar_t__ calloc(unsigned int, int);
int /*<<< orphan*/ errorHandler(char *);
scalar_t__ malloc(unsigned int);
double ***doubleTensor(unsigned int ROWS, unsigned int COLS, unsigned int DEPTH,
                       unsigned int INIT) {
  unsigned int i, j;
  double ***T;
  if (!INIT) {
    if ((T = (double ***)malloc(ROWS * sizeof(double **))) == NULL)
      errorHandler("Error - In doubleTensor(): Can't allocate memory");
    for (i = 0; i < ROWS; i++) {
      if ((T[i] = (double **)malloc(COLS * sizeof(double *))) == NULL)
        errorHandler("Error - In doubleTensor(): Can't allocate memory");
      for (j = 0; j < COLS; j++)
        if ((T[i][j] = (double *)malloc(DEPTH * sizeof(double))) == NULL)
          errorHandler("Error - In doubleTensor(): Can't allocate memory");
    }
  } else {
    if ((T = (double ***)calloc(ROWS, sizeof(double **))) == NULL)
      errorHandler("Error - In doubleTensor(): Can't allocate memory");
    for (i = 0; i < ROWS; i++) {
      if ((T[i] = (double **)calloc(COLS, sizeof(double *))) == NULL)
        errorHandler("Error - In doubleTensor(): Can't allocate memory");
      for (j = 0; j < COLS; j++)
        if ((T[i][j] = (double *)calloc(DEPTH, sizeof(double))) == NULL)
          errorHandler("Error - In doubleTensor(): Can't allocate memory");
    }
  }
  return T;
}


x86 assembly (clang, -O0):
<doubleTensor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    122c <doubleTensor+0xfc>
mov    -0x4(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1176 <doubleTensor+0x46>
lea    0xe8f(%rip),%rdi
call   1050 <errorHandler@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1227 <doubleTensor+0xf7>
mov    -0x8(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%edx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    11b8 <doubleTensor+0x88>
lea    0xe4d(%rip),%rdi
call   1050 <errorHandler@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1214 <doubleTensor+0xe4>
mov    -0xc(%rbp),%eax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%edx
mov    (%rcx,%rdx,8),%rcx
mov    -0x18(%rbp),%edx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    1201 <doubleTensor+0xd1>
lea    0xe04(%rip),%rdi
call   1050 <errorHandler@plt>
jmp    1206 <doubleTensor+0xd6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11bf <doubleTensor+0x8f>
jmp    1219 <doubleTensor+0xe9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <doubleTensor+0x4d>
jmp    1307 <doubleTensor+0x1d7>
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1253 <doubleTensor+0x123>
lea    0xdb2(%rip),%rdi
call   1050 <errorHandler@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1302 <doubleTensor+0x1d2>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%edx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    1294 <doubleTensor+0x164>
lea    0xd71(%rip),%rdi
call   1050 <errorHandler@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    12ef <doubleTensor+0x1bf>
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%edx
mov    (%rcx,%rdx,8),%rcx
mov    -0x18(%rbp),%edx
mov    %rax,(%rcx,%rdx,8)
cmp    $0x0,%rax
jne    12dc <doubleTensor+0x1ac>
lea    0xd29(%rip),%rdi
call   1050 <errorHandler@plt>
jmp    12e1 <doubleTensor+0x1b1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    129b <doubleTensor+0x16b>
jmp    12f4 <doubleTensor+0x1c4>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    125a <doubleTensor+0x12a>
jmp    1307 <doubleTensor+0x1d7>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubleTensor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%r12d
test   %ecx,%ecx
mov    %rbx,0x8(%rsp)
je     120d <doubleTensor+0xdd>
mov    %r12d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1174 <doubleTensor+0x44>
lea    0xe91(%rip),%rdi
call   1050 <errorHandler@plt>
test   %r12d,%r12d
je     12d8 <doubleTensor+0x1a8>
mov    %r12d,%eax
mov    %rax,(%rsp)
mov    %ebx,%ebp
xor    %r12d,%r12d
jmp    11a3 <doubleTensor+0x73>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    (%rsp),%r12
mov    0x8(%rsp),%rbx
je     12d8 <doubleTensor+0x1a8>
mov    %ebx,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,(%r15,%r12,8)
test   %rax,%rax
jne    11c4 <doubleTensor+0x94>
lea    0xe41(%rip),%rdi
call   1050 <errorHandler@plt>
test   %ebx,%ebx
lea    0xe33(%rip),%rbx
je     1190 <doubleTensor+0x60>
xor    %r14d,%r14d
jmp    11e9 <doubleTensor+0xb9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
cmp    %r14,%rbp
je     1190 <doubleTensor+0x60>
mov    %r13d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    (%r15,%r12,8),%rcx
mov    %rax,(%rcx,%r14,8)
test   %rax,%rax
jne    11e0 <doubleTensor+0xb0>
mov    %rbx,%rdi
call   1050 <errorHandler@plt>
jmp    11e0 <doubleTensor+0xb0>
lea    0x0(,%r12,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    122e <doubleTensor+0xfe>
lea    0xdd7(%rip),%rdi
call   1050 <errorHandler@plt>
test   %r12d,%r12d
je     12d8 <doubleTensor+0x1a8>
lea    0x0(,%rbx,8),%eax
mov    %eax,(%rsp)
shl    $0x3,%r13d
mov    %r12d,%eax
mov    %rax,0x10(%rsp)
mov    %ebx,%r14d
xor    %ebp,%ebp
lea    0xda7(%rip),%r12
jmp    126b <doubleTensor+0x13b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     12d8 <doubleTensor+0x1a8>
mov    (%rsp),%edi
call   1040 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
test   %rax,%rax
je     1290 <doubleTensor+0x160>
cmpl   $0x0,0x8(%rsp)
jne    129f <doubleTensor+0x16f>
jmp    1260 <doubleTensor+0x130>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1050 <errorHandler@plt>
cmpl   $0x0,0x8(%rsp)
je     1260 <doubleTensor+0x130>
xor    %ebx,%ebx
jmp    12b9 <doubleTensor+0x189>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     1260 <doubleTensor+0x130>
mov    %r13d,%edi
call   1040 <malloc@plt>
mov    (%r15,%rbp,8),%rcx
mov    %rax,(%rcx,%rbx,8)
test   %rax,%rax
jne    12b0 <doubleTensor+0x180>
mov    %r12,%rdi
call   1050 <errorHandler@plt>
jmp    12b0 <doubleTensor+0x180>
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [49 x i8] c"Error - In doubleTensor(): Can't allocate memory\00"
define double*** @doubleTensor(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %6, label %45
6: ; preds = %4
%7 = shl i32 %0, 3
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double***
%10 = icmp eq i64 %8, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @errorHandler(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
%14 = icmp eq i32 %0, 0
br i1 %14, label %81, label %15
15: ; preds = %13
%16 = shl i32 %1, 3
%17 = icmp eq i32 %1, 0
%18 = shl i32 %2, 3
%19 = zext i32 %0 to i64
%20 = zext i32 %1 to i64
br label %21
21: ; preds = %15, %42
%22 = phi i64 [ 0, %15 ], [ %43, %42 ]
%23 = tail call i64 @malloc(i32 %16)
%24 = inttoptr i64 %23 to double**
%25 = getelementptr inbounds double**, double*** %9, i64 %22
store double** %24, double*** %25
%26 = icmp eq i64 %23, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = tail call i32 @errorHandler(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %29
29: ; preds = %27, %21
br i1 %17, label %42, label %30
30: ; preds = %29, %39
%31 = phi i64 [ %40, %39 ], [ 0, %29 ]
%32 = tail call i64 @malloc(i32 %18)
%33 = inttoptr i64 %32 to double*
%34 = load double**, double*** %25
%35 = getelementptr inbounds double*, double** %34, i64 %31
store double* %33, double** %35
%36 = icmp eq i64 %32, 0
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = tail call i32 @errorHandler(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %30, %37
%40 = add nuw nsw i64 %31, 1
%41 = icmp eq i64 %40, %20
br i1 %41, label %42, label %30
42: ; preds = %39, %29
%43 = add nuw nsw i64 %22, 1
%44 = icmp eq i64 %43, %19
br i1 %44, label %81, label %21
45: ; preds = %4
%46 = tail call i64 @calloc(i32 %0, i32 8)
%47 = inttoptr i64 %46 to double***
%48 = icmp eq i64 %46, 0
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = tail call i32 @errorHandler(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
%52 = icmp eq i32 %0, 0
br i1 %52, label %81, label %53
53: ; preds = %51
%54 = icmp eq i32 %1, 0
%55 = zext i32 %0 to i64
%56 = zext i32 %1 to i64
br label %57
57: ; preds = %53, %78
%58 = phi i64 [ 0, %53 ], [ %79, %78 ]
%59 = tail call i64 @calloc(i32 %1, i32 8)
%60 = inttoptr i64 %59 to double**
%61 = getelementptr inbounds double**, double*** %47, i64 %58
store double** %60, double*** %61
%62 = icmp eq i64 %59, 0
br i1 %62, label %63, label %65
63: ; preds = %57
%64 = tail call i32 @errorHandler(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %65
65: ; preds = %63, %57
br i1 %54, label %78, label %66
66: ; preds = %65, %75
%67 = phi i64 [ %76, %75 ], [ 0, %65 ]
%68 = tail call i64 @calloc(i32 %2, i32 8)
%69 = inttoptr i64 %68 to double*
%70 = load double**, double*** %61
%71 = getelementptr inbounds double*, double** %70, i64 %67
store double* %69, double** %71
%72 = icmp eq i64 %68, 0
br i1 %72, label %73, label %75
73: ; preds = %66
%74 = tail call i32 @errorHandler(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %75
75: ; preds = %66, %73
%76 = add nuw nsw i64 %67, 1
%77 = icmp eq i64 %76, %56
br i1 %77, label %78, label %66
78: ; preds = %75, %65
%79 = add nuw nsw i64 %58, 1
%80 = icmp eq i64 %79, %55
br i1 %80, label %81, label %57
81: ; preds = %78, %42, %51, %13
%82 = phi double*** [ %9, %13 ], [ %47, %51 ], [ %9, %42 ], [ %47, %78 ]
ret double*** %82
}