void free_mem2Dint_offset(int **array2D, int offset) {
  if (array2D) {
    (*array2D)[0] -= offset;
    if (array2D[0])
      free(array2D[0]);
    else
      error("free_mem2Dint_offset: trying to free unused memory", 100);
    free(array2D);
  } else {
    error("free_mem2Dint_offset: trying to free unused memory", 100);
  }
}


x86 assembly (clang, -O0):
<free_mem2Dint_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118a <free_mem2Dint_offset+0x6a>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1169 <free_mem2Dint_offset+0x49>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    117c <free_mem2Dint_offset+0x5c>
lea    0xe90(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1040 <error@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
jmp    119d <free_mem2Dint_offset+0x7d>
lea    0xe6f(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1040 <error@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mem2Dint_offset>:
test   %rdi,%rdi
je     113a <free_mem2Dint_offset+0x1a>
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>
lea    0xebf(%rip),%rdi
mov    $0x64,%esi
xor    %eax,%eax
jmp    1040 <error@plt>

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

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