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


x86 assembly (clang, -O0):
<get_mem4Dint>:
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)
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    118c <get_mem4Dint+0x4c>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <get_mem4Dint+0x8d>
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_mem3Dint@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1193 <get_mem4Dint+0x53>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mem4Dint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r13
lea    0x0(,%rbp,8),%edi
call   1050 <h264_malloc@plt>
mov    %rax,0x0(%r13)
test   %rax,%rax
je     11df <get_mem4Dint+0x9f>
mov    %rbp,(%rsp)
test   %ebp,%ebp
jle    11be <get_mem4Dint+0x7e>
mov    %rax,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1030 <get_mem3Dint@plt>
cmpl   $0x1,(%rsp)
je     11be <get_mem4Dint+0x7e>
mov    (%rsp),%ebp
add    $0xffffffffffffffff,%rbp
mov    $0x8,%r14d
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%rdi
add    %r14,%rdi
mov    %ebx,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1030 <get_mem3Dint@plt>
add    $0x8,%r14
add    $0xffffffffffffffff,%rbp
jne    11a0 <get_mem4Dint+0x60>
mov    (%rsp),%rax
imul   %ebx,%eax
imul   %r12d,%eax
imul   %r15d,%eax
shl    $0x2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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

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