#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(short ***);
int /*<<< orphan*/ free_mem2Dshort(short **);
void free_mem3Dshort(short ***array3D, int frames) {
  int i;
  if (array3D) {
    for (i = 0; i < frames; i++) {
      free_mem2Dshort(array3D[i]);
    }
    free(array3D);
  } else {
    error("free_mem3Dshort: trying to free unused memory", 100);
  }
}


x86 assembly (clang, -O0):
<free_mem3Dshort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118a <free_mem3Dshort+0x5a>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117c <free_mem3Dshort+0x4c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <free_mem2Dshort@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1151 <free_mem3Dshort+0x21>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
jmp    119b <free_mem3Dshort+0x6b>
lea    0xe6f(%rip),%rdi
mov    $0x64,%esi
call   1050 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mem3Dshort>:
test   %rdi,%rdi
je     116f <free_mem3Dshort+0x3f>
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
jle    1162 <free_mem3Dshort+0x32>
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1040 <free_mem2Dshort@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1150 <free_mem3Dshort+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    0xe8a(%rip),%rdi
mov    $0x64,%esi
jmp    1050 <error@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"free_mem3Dshort: trying to free unused memory\00"
define void @free_mem3Dshort(i16*** %0, i32 %1) {
%3 = alloca i16***
%4 = alloca i32
%5 = alloca i32
store i16*** %0, i16**** %3
store i32 %1, i32* %4
%6 = load i16***, i16**** %3
%7 = icmp ne i16*** %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 i16***, i16**** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i16**, i16*** %14, i64 %16
%18 = load i16**, i16*** %17
%19 = call i32 @free_mem2Dshort(i16** %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 i16***, i16**** %3
%25 = call i32 @free(i16*** %24)
br label %28
26: ; preds = %2
%27 = call i32 @error(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 100)
br label %28
28: ; preds = %26, %23
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"free_mem3Dshort: trying to free unused memory\00"
define void @free_mem3Dshort(i16*** %0, i32 %1) {
%3 = icmp eq i16*** %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 i16**, i16*** %0, i64 %9
%11 = load i16**, i16*** %10
%12 = tail call i32 @free_mem2Dshort(i16** %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 @free(i16*** %0)
br label %19
17: ; preds = %2
%18 = tail call i32 @error(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 100)
br label %19
19: ; preds = %17, %15
ret void
}