#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*/ error(char *, int);
int /*<<< orphan*/ free(int ****);
int /*<<< orphan*/ free_mem3Dint(int ***, int);
void free_mem4Dint(int ****array4D, int idx, int frames) {
  int j;
  if (array4D) {
    for (j = 0; j < idx; j++)
      free_mem3Dint(array4D[j], frames);
    free(array4D);
  } else {
    error("free_mem4Dint: trying to free unused memory", 100);
  }
}


x86 assembly (clang, -O0):
<free_mem4Dint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1190 <free_mem4Dint+0x60>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1182 <free_mem4Dint+0x52>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%esi
call   1040 <free_mem3Dint@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <free_mem4Dint+0x24>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
jmp    11a1 <free_mem4Dint+0x71>
lea    0xe69(%rip),%rdi
mov    $0x64,%esi
call   1050 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mem4Dint>:
test   %rdi,%rdi
je     1177 <free_mem4Dint+0x47>
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
test   %esi,%esi
jle    1165 <free_mem4Dint+0x35>
mov    %edx,%r14d
mov    %esi,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
mov    %r14d,%esi
call   1040 <free_mem3Dint@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <free_mem4Dint+0x20>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xe82(%rip),%rdi
mov    $0x64,%esi
jmp    1050 <error@plt>

LLVM IR (-O0):
@.str = [44 x i8] c"free_mem4Dint: trying to free unused memory\00"
define void @free_mem4Dint(i32**** %0, i32 %1, i32 %2) {
%4 = alloca i32****
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32**** %0, i32***** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32****, i32***** %4
%9 = icmp ne i32**** %8, null
br i1 %9, label %10, label %29
10: ; preds = %3
store i32 0, i32* %7
br label %11
11: ; preds = %23, %10
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = load i32****, i32***** %4
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32***, i32**** %16, i64 %18
%20 = load i32***, i32**** %19
%21 = load i32, i32* %6
%22 = call i32 @free_mem3Dint(i32*** %20, i32 %21)
br label %23
23: ; preds = %15
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %11
26: ; preds = %11
%27 = load i32****, i32***** %4
%28 = call i32 @free(i32**** %27)
br label %31
29: ; preds = %3
%30 = call i32 @error(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 100)
br label %31
31: ; preds = %29, %26
ret void
}

LLVM IR (-O2):
@.str = [44 x i8] c"free_mem4Dint: trying to free unused memory\00"
define void @free_mem4Dint(i32**** %0, i32 %1, i32 %2) {
%4 = icmp eq i32**** %0, null
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %16
7: ; preds = %5
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = getelementptr inbounds i32***, i32**** %0, i64 %10
%12 = load i32***, i32**** %11
%13 = tail call i32 @free_mem3Dint(i32*** %12, i32 %2)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %5
%17 = tail call i32 @free(i32**** %0)
br label %20
18: ; preds = %3
%19 = tail call i32 @error(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 100)
br label %20
20: ; preds = %18, %16
ret void
}