#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*/ free_mem2Dint(int **);
int /*<<< orphan*/ h264_free(int ***);
int /*<<< orphan*/ printf(char *);
void free_mem3Dint(int ***array3D, int frames) {
  int i;
  if (array3D) {
    for (i = 0; i < frames; i++) {
      free_mem2Dint(array3D[i]);
    }
    h264_free(array3D);
  } else {
    printf("free_mem3D: trying to free unused memory");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<free_mem3Dint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     119a <free_mem3Dint+0x5a>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118c <free_mem3Dint+0x4c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <free_mem2Dint@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1161 <free_mem3Dint+0x21>
mov    -0x8(%rbp),%rdi
call   1040 <h264_free@plt>
jmp    11ad <free_mem3Dint+0x6d>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mem3Dint>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     117f <free_mem3Dint+0x3f>
mov    %rdi,%r14
test   %esi,%esi
jle    1172 <free_mem3Dint+0x32>
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1050 <free_mem2Dint@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <free_mem3Dint+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <h264_free@plt>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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

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