#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);
int /*<<< orphan*/ get_mem2Dint(int ***, int, int);
int /*<<< orphan*/ no_mem_exit(char *);
int get_mem3Dint(int ****array3D, int frames, int rows, int columns) {
  int j;
  if (((*array3D) = (int ***)calloc(frames, sizeof(int **))) == NULL)
    no_mem_exit("get_mem3Dint: array3D");
  for (j = 0; j < frames; j++)
    get_mem2Dint((*array3D) + j, rows, columns);
  return frames * rows * columns * sizeof(int);
}


x86 assembly (clang, -O0):
<get_mem3Dint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    116f <get_mem3Dint+0x3f>
lea    0xe96(%rip),%rdi
call   1050 <no_mem_exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ad <get_mem3Dint+0x7d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <get_mem2Dint@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1176 <get_mem3Dint+0x46>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mem3Dint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%r14d
mov    %rdi,%r13
mov    %esi,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
je     1163 <get_mem3Dint+0x33>
test   %r14d,%r14d
jg     1174 <get_mem3Dint+0x44>
jmp    119b <get_mem3Dint+0x6b>
lea    0xe96(%rip),%rdi
call   1050 <no_mem_exit@plt>
test   %r14d,%r14d
jle    119b <get_mem3Dint+0x6b>
mov    %r14d,%ebx
shl    $0x3,%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    0x0(%r13),%rdi
add    %rbp,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1040 <get_mem2Dint@plt>
add    $0x8,%rbp
cmp    %rbp,%rbx
jne    1180 <get_mem3Dint+0x50>
imul   %r12d,%r14d
imul   %r15d,%r14d
shl    $0x2,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"get_mem3Dint: array3D\00"
define i32 @get_mem3Dint(i32**** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32****
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32**** %0, i32***** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %6
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to i32***
%13 = load i32****, i32***** %5
store i32*** %12, i32**** %13
%14 = icmp eq i32*** %12, null
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = call i32 @no_mem_exit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %4
store i32 0, i32* %9
br label %18
18: ; preds = %31, %17
%19 = load i32, i32* %9
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %34
22: ; preds = %18
%23 = load i32****, i32***** %5
%24 = load i32***, i32**** %23
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32**, i32*** %24, i64 %26
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 @get_mem2Dint(i32*** %27, i32 %28, i32 %29)
br label %31
31: ; preds = %22
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %18
34: ; preds = %18
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = mul nsw i32 %35, %36
%38 = load i32, i32* %8
%39 = mul nsw i32 %37, %38
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 4
%42 = trunc i64 %41 to i32
ret i32 %42
}

LLVM IR (-O2):
@.str = [22 x i8] c"get_mem3Dint: array3D\00"
define i32 @get_mem3Dint(i32**** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i64 @calloc(i32 %1, i32 8)
%6 = inttoptr i64 %5 to i32***
store i32*** %6, i32**** %0
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @no_mem_exit(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %21
12: ; preds = %10
%13 = zext i32 %1 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %19, %14 ]
%16 = load i32***, i32**** %0
%17 = getelementptr inbounds i32**, i32*** %16, i64 %15
%18 = tail call i32 @get_mem2Dint(i32*** %17, i32 %2, i32 %3)
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %13
br i1 %20, label %21, label %14
21: ; preds = %14, %10
%22 = shl i32 %1, 2
%23 = mul i32 %22, %2
%24 = mul i32 %23, %3
ret i32 %24
}