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


x86 assembly (clang, -O0):
<get_mem4Dshort>:
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    %r8d,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   1050 <h264_calloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    118a <get_mem4Dshort+0x4a>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cb <get_mem4Dshort+0x8b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1040 <get_mem3Dshort@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <get_mem4Dshort+0x51>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x1,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mem4Dshort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r13
mov    %esi,%edi
mov    $0x8,%esi
call   1050 <h264_calloc@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
je     11de <get_mem4Dshort+0x9e>
mov    %ebx,0x4(%rsp)
test   %ebx,%ebx
jle    11be <get_mem4Dshort+0x7e>
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1040 <get_mem3Dshort@plt>
cmpl   $0x1,0x4(%rsp)
je     11be <get_mem4Dshort+0x7e>
mov    0x4(%rsp),%ebx
add    $0xffffffffffffffff,%rbx
mov    $0x8,%r14d
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%rdi
add    %r14,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1040 <get_mem3Dshort@plt>
add    $0x8,%r14
add    $0xffffffffffffffff,%rbx
jne    11a0 <get_mem4Dshort+0x60>
mov    0x4(%rsp),%eax
imul   %ebp,%eax
imul   %r12d,%eax
imul   %r15d,%eax
add    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1b(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@.str = [24 x i8] c"get_mem4Dshort: array4D\00"
define i32 @get_mem4Dshort(i16***** nocapture %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i64 @h264_calloc(i32 %1, i32 8)
%7 = inttoptr i64 %6 to i16****
store i16**** %7, i16***** %0
%8 = icmp eq i64 %6, 0
br i1 %8, label %15, label %9
9: ; preds = %5
%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_mem3Dshort(i16**** %7, i32 %2, i32 %3, i32 %4)
%14 = icmp eq i32 %1, 1
br i1 %14, label %25, label %18
15: ; preds = %5
%16 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 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 i16****, i16***** %0
%21 = getelementptr inbounds i16***, i16**** %20, i64 %19
%22 = tail call i32 @get_mem3Dshort(i16**** %21, i32 %2, i32 %3, i32 %4)
%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, 1
%27 = mul i32 %26, %2
%28 = mul i32 %27, %3
%29 = mul i32 %28, %4
ret i32 %29
}