#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 */
unsigned int **allocArray2D(size_t, size_t);
scalar_t__ malloc(size_t);
int ***allocArray3D(size_t rows, size_t cols, size_t lines) {
  unsigned int ***arr = (int ***)malloc(rows * sizeof(int **)), i;
  for (i = 0; i < rows; i++)
    arr[i] = allocArray2D(cols, lines);
  return arr;
}


x86 assembly (clang, -O0):
<allocArray3D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%rax
jae    1182 <allocArray3D+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <allocArray2D@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114c <allocArray3D+0x2c>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<allocArray3D>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
lea    0x0(,%rdi,8),%rdi
call   1040 <malloc@plt>
mov    %rax,%r13
test   %r12,%r12
je     1168 <allocArray3D+0x48>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <allocArray2D@plt>
mov    %rax,0x0(%r13,%rbx,8)
add    $0x1,%ebx
cmp    %r12,%rbx
jb     1150 <allocArray3D+0x30>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32*** @allocArray3D(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32***
%8 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i64, i64* %4
%10 = mul i64 %9, 8
%11 = call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i32***
store i32*** %12, i32**** %7
store i32 0, i32* %8
br label %13
13: ; preds = %26, %3
%14 = load i32, i32* %8
%15 = zext i32 %14 to i64
%16 = load i64, i64* %4
%17 = icmp ult i64 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %13
%19 = load i64, i64* %5
%20 = load i64, i64* %6
%21 = call i32** @allocArray2D(i64 %19, i64 %20)
%22 = load i32***, i32**** %7
%23 = load i32, i32* %8
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32**, i32*** %22, i64 %24
store i32** %21, i32*** %25
br label %26
26: ; preds = %18
%27 = load i32, i32* %8
%28 = add i32 %27, 1
store i32 %28, i32* %8
br label %13
29: ; preds = %13
%30 = load i32***, i32**** %7
ret i32*** %30
}

LLVM IR (-O2):
define i32*** @allocArray3D(i64 %0, i64 %1, i64 %2) {
%4 = shl i64 %0, 3
%5 = tail call i64 @malloc(i64 %4)
%6 = inttoptr i64 %5 to i32***
%7 = icmp eq i64 %0, 0
br i1 %7, label %15, label %8
8: ; preds = %3, %8
%9 = phi i64 [ %13, %8 ], [ 0, %3 ]
%10 = tail call i32** @allocArray2D(i64 %1, i64 %2)
%11 = getelementptr inbounds i32**, i32*** %6, i64 %9
store i32** %10, i32*** %11
%12 = add nuw nsw i64 %9, 1
%13 = and i64 %12, 4294967295
%14 = icmp ult i64 %13, %0
br i1 %14, label %8, label %15
15: ; preds = %8, %3
ret i32*** %6
}