void free_mem2Dshort(short **array2D) {
  if (array2D) {
    if (array2D[0]) {
      h264_free(array2D[0]);
    } else {
      printf("free_mem2Dshort: trying to free unused memory");
      exit(0);
    }
    h264_free(array2D);
  } else {
    printf("free_mem2Dshort: trying to free unused memory");
    exit(0);
  }
}


x86 assembly (clang, -O0):
<free_mem2Dshort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118d <free_mem2Dshort+0x5d>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1168 <free_mem2Dshort+0x38>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   1040 <h264_free@plt>
jmp    117d <free_mem2Dshort+0x4d>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1040 <h264_free@plt>
jmp    11a2 <free_mem2Dshort+0x72>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mem2Dshort>:
push   %rbx
test   %rdi,%rdi
je     1153 <free_mem2Dshort+0x23>
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1153 <free_mem2Dshort+0x23>
xor    %eax,%eax
call   1040 <h264_free@plt>
mov    %rbx,%rdi
xor    %eax,%eax
pop    %rbx
jmp    1040 <h264_free@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [46 x i8] c"free_mem2Dshort: trying to free unused memory\00"
define void @free_mem2Dshort(i16** %0) {
%2 = alloca i16**
store i16** %0, i16*** %2
%3 = load i16**, i16*** %2
%4 = icmp ne i16** %3, null
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = load i16**, i16*** %2
%7 = getelementptr inbounds i16*, i16** %6, i64 0
%8 = load i16*, i16** %7
%9 = icmp ne i16* %8, null
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i16**, i16*** %2
%12 = getelementptr inbounds i16*, i16** %11, i64 0
%13 = load i16*, i16** %12
%14 = call i32 (i16*, ...) bitcast (i32 (...)* @h264_free to i32 (i16*, ...)*)(i16* %13)
br label %17
15: ; preds = %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
unreachable
17: ; preds = %10
%18 = load i16**, i16*** %2
%19 = call i32 (i16**, ...) bitcast (i32 (...)* @h264_free to i32 (i16**, ...)*)(i16** %18)
br label %22
20: ; preds = %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
unreachable
22: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"free_mem2Dshort: trying to free unused memory\00"
define void @free_mem2Dshort(i16** %0) {
%2 = icmp eq i16** %0, null
br i1 %2, label %11, label %3
3: ; preds = %1
%4 = load i16*, i16** %0
%5 = icmp eq i16* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 (i16*, ...) bitcast (i32 (...)* @h264_free to i32 (i16*, ...)*)(i16* %4)
%8 = tail call i32 (i16**, ...) bitcast (i32 (...)* @h264_free to i32 (i16**, ...)*)(i16** %0)
ret void
9: ; preds = %3
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
11: ; preds = %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
tail call void @exit(i32 0)
unreachable
}