#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_mem2Dshort(short ***, int, int);
scalar_t__ h264_calloc(int, int);
int /*<<< orphan*/ printf(char *);
int get_mem3Dshort(short ****array3D, int frames, int rows, int columns) {
  int j;
  if (((*array3D) = (short ***)h264_calloc(frames, sizeof(short **))) == NULL) {
    printf("get_mem3Dshort: array3D");
    exit(0);
  }
  for (j = 0; j < frames; j++) {
    get_mem2Dshort((*array3D) + j, rows, columns);
  }
  return frames * rows * columns * sizeof(short);
}


x86 assembly (clang, -O0):
<get_mem3Dshort>:
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   1050 <h264_calloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    1186 <get_mem3Dshort+0x46>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c4 <get_mem3Dshort+0x84>
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   1030 <get_mem2Dshort@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <get_mem3Dshort+0x4d>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

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

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

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