#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_mem3Dshort(short ****, int, int, int);
int /*<<< orphan*/ no_mem_exit(char *);
int get_mem4Dshort(short *****array4D, int idx, int frames, int rows,
                   int columns) {
  int j;
  if (((*array4D) = (short ****)calloc(idx, sizeof(short **))) == NULL)
    no_mem_exit("get_mem4Dshort: array4D");
  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   1040 <calloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    1173 <get_mem4Dshort+0x43>
lea    0xe92(%rip),%rdi
call   1050 <no_mem_exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b4 <get_mem4Dshort+0x84>
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   1030 <get_mem3Dshort@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <get_mem4Dshort+0x4a>
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,%r13d
mov    %esi,%ebx
mov    %rdi,%rbp
mov    %esi,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,0x0(%rbp)
test   %rax,%rax
jne    116a <get_mem4Dshort+0x3a>
lea    0xe9b(%rip),%rdi
call   1050 <no_mem_exit@plt>
mov    %ebx,0x4(%rsp)
test   %ebx,%ebx
jle    119e <get_mem4Dshort+0x6e>
mov    0x4(%rsp),%ebx
shl    $0x3,%rbx
xor    %r14d,%r14d
nopl   (%rax)
mov    0x0(%rbp),%rdi
add    %r14,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1030 <get_mem3Dshort@plt>
add    $0x8,%r14
cmp    %r14,%rbx
jne    1180 <get_mem4Dshort+0x50>
mov    0x4(%rsp),%eax
imul   %r13d,%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

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

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