#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__ malloc(int);
double ***Make3DDoubleArray(int arraySizeX, int arraySizeY, int arraySizeZ) {
  double ***theArray;
  int i, j;
  theArray = (double ***)malloc(arraySizeX * sizeof(double **));
  for (i = 0; i < arraySizeX; i++) {
    theArray[i] = (double **)malloc(arraySizeY * sizeof(double *));
    for (j = 0; j < arraySizeY; i++) {
      theArray[i][j] = (double *)malloc(arraySizeZ * sizeof(double));
    }
  }
  return theArray;
}


x86 assembly (clang, -O0):
<Make3DDoubleArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bf <Make3DDoubleArray+0xaf>
movslq -0x8(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <Make3DDoubleArray+0x9c>
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116c <Make3DDoubleArray+0x5c>
jmp    11b1 <Make3DDoubleArray+0xa1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <Make3DDoubleArray+0x2b>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Make3DDoubleArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%r15d
lea    0x0(,%r15,8),%edi
call   1030 <malloc@plt>
mov    %rax,(%rsp)
test   %r15d,%r15d
jle    116e <Make3DDoubleArray+0x5e>
lea    0x0(,%r14,8),%r13d
shl    $0x3,%ebx
xor    %r12d,%r12d
mov    (%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   1030 <malloc@plt>
mov    %rax,0x0(%rbp)
test   %r14d,%r14d
jg     1190 <Make3DDoubleArray+0x80>
add    $0x1,%r12d
add    $0x8,%rbp
cmp    %r15d,%r12d
jl     1150 <Make3DDoubleArray+0x40>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <malloc@plt>
mov    0x0(%rbp),%rcx
mov    %rax,(%rcx)
add    $0x8,%rbp
jmp    1190 <Make3DDoubleArray+0x80>

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

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