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


x86 assembly (clang, -O0):
<free_mem2Ddouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1177 <free_mem2Ddouble+0x57>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1156 <free_mem2Ddouble+0x36>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1169 <free_mem2Ddouble+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_mem2Ddouble+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_mem2Ddouble>:
test   %rdi,%rdi
je     1138 <free_mem2Ddouble+0x18>
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     114b <free_mem2Ddouble+0x2b>
call   1030 <free@plt>
jmp    115e <free_mem2Ddouble+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 = [47 x i8] c"free_mem2Ddouble: trying to free unused memory\00"
define void @free_mem2Ddouble(double** %0) {
%2 = alloca double**
store double** %0, double*** %2
%3 = load double**, double*** %2
%4 = icmp ne double** %3, null
br i1 %4, label %5, label %20
5: ; preds = %1
%6 = load double**, double*** %2
%7 = getelementptr inbounds double*, double** %6, i64 0
%8 = load double*, double** %7
%9 = icmp ne double* %8, null
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load double**, double*** %2
%12 = getelementptr inbounds double*, double** %11, i64 0
%13 = load double*, double** %12
%14 = bitcast double* %13 to i8*
br label %17
15: ; preds = %5
%16 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @error to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 100)
br label %17
17: ; preds = %15, %10
%18 = load double**, double*** %2
%19 = bitcast double** %18 to i8*
br label %22
20: ; preds = %1
%21 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @error to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 100)
br label %22
22: ; preds = %20, %17
ret void
}

LLVM IR (-O2):
@.str = [47 x i8] c"free_mem2Ddouble: trying to free unused memory\00"
define void @free_mem2Ddouble(double** %0) {
%2 = icmp eq double** %0, null
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = load double*, double** %0
%5 = icmp eq double* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = bitcast double* %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 ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 100)
br label %10
10: ; preds = %8, %6
%11 = bitcast double** %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 ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 100)
br label %14
14: ; preds = %12, %10
ret void
}