#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(int, int);
double ***allocateArrayD3(int dim1, int dim2, int dim3) {
  int i, j;
  double ***array = (double ***)calloc(dim1, sizeof(double **));
  for (i = 0; i < dim1; i++) {
    array[i] = (double **)calloc(dim2, sizeof(double *));
    for (j = 0; j < dim2; j++)
      array[i][j] = (double *)calloc(dim3, sizeof(double));
  }
  return (double ***)array;
}


x86 assembly (clang, -O0):
<allocateArrayD3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b9 <allocateArrayD3+0xa9>
mov    -0x8(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a6 <allocateArrayD3+0x96>
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1168 <allocateArrayD3+0x58>
jmp    11ab <allocateArrayD3+0x9b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1139 <allocateArrayD3+0x29>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocateArrayD3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%r15d
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r13
test   %r15d,%r15d
jle    11a1 <allocateArrayD3+0x91>
mov    %r15d,%eax
mov    %rax,(%rsp)
mov    %r14d,%ebx
xor    %ebp,%ebp
jmp    115a <allocateArrayD3+0x4a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    (%rsp),%rbp
je     11a1 <allocateArrayD3+0x91>
mov    %r14d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
test   %r14d,%r14d
jle    1150 <allocateArrayD3+0x40>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    0x0(%r13,%rbp,8),%rcx
mov    %rax,(%rcx,%r15,8)
add    $0x1,%r15
cmp    %r15,%rbx
jne    1180 <allocateArrayD3+0x70>
jmp    1150 <allocateArrayD3+0x40>
mov    %r13,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double*** @allocateArrayD3(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double***
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to double***
store double*** %12, double**** %9
store i32 0, i32* %7
br label %13
13: ; preds = %45, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %48
17: ; preds = %13
%18 = load i32, i32* %5
%19 = call i64 @calloc(i32 %18, i32 8)
%20 = inttoptr i64 %19 to double**
%21 = load double***, double**** %9
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double**, double*** %21, i64 %23
store double** %20, double*** %24
store i32 0, i32* %8
br label %25
25: ; preds = %41, %17
%26 = load i32, i32* %8
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %44
29: ; preds = %25
%30 = load i32, i32* %6
%31 = call i64 @calloc(i32 %30, i32 8)
%32 = inttoptr i64 %31 to double*
%33 = load double***, double**** %9
%34 = load i32, i32* %7
%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
store double* %32, double** %40
br label %41
41: ; preds = %29
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %25
44: ; preds = %25
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %13
48: ; preds = %13
%49 = load double***, double**** %9
ret double*** %49
}

LLVM IR (-O2):
define double*** @allocateArrayD3(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @calloc(i32 %0, i32 8)
%5 = inttoptr i64 %4 to double***
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %27
7: ; preds = %3
%8 = icmp sgt i32 %1, 0
%9 = zext i32 %0 to i64
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %7, %24
%12 = phi i64 [ 0, %7 ], [ %25, %24 ]
%13 = tail call i64 @calloc(i32 %1, i32 8)
%14 = inttoptr i64 %13 to double**
%15 = getelementptr inbounds double**, double*** %5, i64 %12
store double** %14, double*** %15
br i1 %8, label %16, label %24
16: ; preds = %11, %16
%17 = phi i64 [ %22, %16 ], [ 0, %11 ]
%18 = tail call i64 @calloc(i32 %2, i32 8)
%19 = inttoptr i64 %18 to double*
%20 = load double**, double*** %15
%21 = getelementptr inbounds double*, double** %20, i64 %17
store double* %19, double** %21
%22 = add nuw nsw i64 %17, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %16
24: ; preds = %16, %11
%25 = add nuw nsw i64 %12, 1
%26 = icmp eq i64 %25, %9
br i1 %26, label %27, label %11
27: ; preds = %24, %3
ret double*** %5
}