void free_mem2Dshort(short **array2D) {
  if (array2D) {
    if (array2D[0])
      free(array2D[0]);
    else
      error("free_mem2Dshort: trying to free unused memory", 100);
    free(array2D);
  } else {
    error("free_mem2Dshort: trying to free unused memory", 100);
  }
}


x86 assembly (clang, -O0):
<free_mem2Dshort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1177 <free_mem2Dshort+0x57>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1156 <free_mem2Dshort+0x36>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1169 <free_mem2Dshort+0x49>
lea    0xea3(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1040 <error@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
jmp    118a <free_mem2Dshort+0x6a>
lea    0xe82(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1040 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mem2Dshort>:
test   %rdi,%rdi
je     1138 <free_mem2Dshort+0x18>
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114b <free_mem2Dshort+0x2b>
call   1030 <free@plt>
jmp    115e <free_mem2Dshort+0x3e>
lea    0xec1(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
jmp    1040 <error@plt>
lea    0xeae(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
call   1040 <error@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@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 = bitcast i16* %13 to i8*
br label %17
15: ; preds = %5
%16 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @error to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 100)
br label %17
17: ; preds = %15, %10
%18 = load i16**, i16*** %2
%19 = bitcast i16** %18 to i8*
br label %22
20: ; preds = %1
%21 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @error to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 100)
br label %22
22: ; preds = %20, %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 %12, label %3
3: ; preds = %1
%4 = load i16*, i16** %0
%5 = icmp eq i16* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = bitcast i16* %4 to i8*
tail call void @free(i8* %7)
br label %10
8: ; preds = %3
%9 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @error to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 100)
br label %10
10: ; preds = %8, %6
%11 = bitcast i16** %0 to i8*
tail call void @free(i8* %11)
br label %14
12: ; preds = %1
%13 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @error to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 100)
br label %14
14: ; preds = %12, %10
ret void
}