#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 */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ get_mem2Dint(int ***, int, int);
scalar_t__ h264_malloc(int);
int /*<<< orphan*/ printf(char *);
int get_mem3Dint(int ****array3D, int frames, int rows, int columns) {
  int j;
  if (((*array3D) = (int ***)h264_malloc(frames * sizeof(int **))) == NULL) {
    printf("get_mem3Dint: array3D");
    exit(0);
  }
  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)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <h264_malloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    1188 <get_mem3Dint+0x48>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c6 <get_mem3Dint+0x86>
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    118f <get_mem3Dint+0x4f>
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,%r13d
mov    %esi,%r14d
mov    %rdi,%r12
lea    0x0(,%r14,8),%edi
call   1050 <h264_malloc@plt>
mov    %rax,(%r12)
test   %rax,%rax
je     11da <get_mem3Dint+0x9a>
test   %r14d,%r14d
jle    11bc <get_mem3Dint+0x7c>
mov    %rax,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1040 <get_mem2Dint@plt>
cmp    $0x1,%r14d
je     11bc <get_mem3Dint+0x7c>
mov    %r14d,%ebp
add    $0xffffffffffffffff,%rbp
mov    $0x8,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%rdi
add    %rbx,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1040 <get_mem2Dint@plt>
add    $0x8,%rbx
add    $0xffffffffffffffff,%rbp
jne    11a0 <get_mem3Dint+0x60>
imul   %r13d,%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
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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 = sext i32 %10 to i64
%12 = mul i64 %11, 8
%13 = trunc i64 %12 to i32
%14 = call i64 @h264_malloc(i32 %13)
%15 = inttoptr i64 %14 to i32***
%16 = load i32****, i32***** %5
store i32*** %15, i32**** %16
%17 = icmp eq i32*** %15, null
br i1 %17, label %18, label %21
18: ; preds = %4
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %4
store i32 0, i32* %9
br label %22
22: ; preds = %35, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i32****, i32***** %5
%28 = load i32***, i32**** %27
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32**, i32*** %28, i64 %30
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 @get_mem2Dint(i32*** %31, i32 %32, i32 %33)
br label %35
35: ; preds = %26
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %22
38: ; preds = %22
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = mul nsw i32 %39, %40
%42 = load i32, i32* %8
%43 = mul nsw i32 %41, %42
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 4
%46 = trunc i64 %45 to i32
ret i32 %46
}

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 = shl i32 %1, 3
%6 = tail call i64 @h264_malloc(i32 %5)
%7 = inttoptr i64 %6 to i32***
store i32*** %7, i32**** %0
%8 = icmp eq i64 %6, 0
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %25
11: ; preds = %9
%12 = zext i32 %1 to i64
%13 = tail call i32 @get_mem2Dint(i32*** %7, i32 %2, i32 %3)
%14 = icmp eq i32 %1, 1
br i1 %14, label %25, label %18
15: ; preds = %4
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @exit(i32 0)
unreachable
18: ; preds = %11, %18
%19 = phi i64 [ %23, %18 ], [ 1, %11 ]
%20 = load i32***, i32**** %0
%21 = getelementptr inbounds i32**, i32*** %20, i64 %19
%22 = tail call i32 @get_mem2Dint(i32*** %21, i32 %2, i32 %3)
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %12
br i1 %24, label %25, label %18
25: ; preds = %18, %11, %9
%26 = shl i32 %1, 2
%27 = mul i32 %26, %2
%28 = mul i32 %27, %3
ret i32 %28
}