#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_mem2Dpel(unsigned char ***, int, int);
scalar_t__ h264_malloc(int);
int /*<<< orphan*/ printf(char *);
int get_mem3Dpel(unsigned char ****array3D, int frames, int rows, int columns) {
  int j;
  if (((*array3D) = (unsigned char ***)h264_malloc(
           frames * sizeof(unsigned char **))) == NULL) {
    printf("get_mem3Dpel: array3D");
    exit(0);
  }
  for (j = 0; j < frames; j++)
    get_mem2Dpel((*array3D) + j, rows, columns);
  return frames * rows * columns * sizeof(unsigned char);
}


x86 assembly (clang, -O0):
<get_mem3Dpel>:
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_mem3Dpel+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_mem3Dpel+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_mem2Dpel@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <get_mem3Dpel+0x4f>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x0,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mem3Dpel>:
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     11d6 <get_mem3Dpel+0x96>
test   %r14d,%r14d
jle    11bc <get_mem3Dpel+0x7c>
mov    %rax,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1040 <get_mem2Dpel@plt>
cmp    $0x1,%r14d
je     11bc <get_mem3Dpel+0x7c>
mov    %r14d,%ebx
add    $0xffffffffffffffff,%rbx
mov    $0x8,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12),%rdi
add    %rbp,%rdi
mov    %r13d,%esi
mov    %r15d,%edx
call   1040 <get_mem2Dpel@plt>
add    $0x8,%rbp
add    $0xffffffffffffffff,%rbx
jne    11a0 <get_mem3Dpel+0x60>
imul   %r14d,%r13d
imul   %r15d,%r13d
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"get_mem3Dpel: array3D\00"
define i32 @get_mem3Dpel(i8**** %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8****
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8**** %0, i8***** %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 i8***
%16 = load i8****, i8***** %5
store i8*** %15, i8**** %16
%17 = icmp eq i8*** %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 i8****, i8***** %5
%28 = load i8***, i8**** %27
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8**, i8*** %28, i64 %30
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 @get_mem2Dpel(i8*** %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, 1
%46 = trunc i64 %45 to i32
ret i32 %46
}

LLVM IR (-O2):
@.str = [22 x i8] c"get_mem3Dpel: array3D\00"
define i32 @get_mem3Dpel(i8**** 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 i8***
store i8*** %7, i8**** %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_mem2Dpel(i8*** %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 i8***, i8**** %0
%21 = getelementptr inbounds i8**, i8*** %20, i64 %19
%22 = tail call i32 @get_mem2Dpel(i8*** %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 = mul nsw i32 %2, %1
%27 = mul nsw i32 %26, %3
ret i32 %27
}