void aml_array_dbl_2d_variable_2nd_free(double **arr, int s1, int *s2) {
  int i;
  for (i = 0; i < s1; i++)
    if (arr[i])
      free(arr[i]);
  free(arr);
}


x86 assembly (clang, -O0):
<aml_array_dbl_2d_variable_2nd_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116d <aml_array_dbl_2d_variable_2nd_free+0x5d>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     115a <aml_array_dbl_2d_variable_2nd_free+0x4a>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    115f <aml_array_dbl_2d_variable_2nd_free+0x4f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <aml_array_dbl_2d_variable_2nd_free+0x1a>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_2d_variable_2nd_free>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
jle    1149 <aml_array_dbl_2d_variable_2nd_free+0x39>
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    1139 <aml_array_dbl_2d_variable_2nd_free+0x29>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1149 <aml_array_dbl_2d_variable_2nd_free+0x39>
mov    (%r14,%rbx,8),%rdi
test   %rdi,%rdi
je     1130 <aml_array_dbl_2d_variable_2nd_free+0x20>
call   1030 <free@plt>
jmp    1130 <aml_array_dbl_2d_variable_2nd_free+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @aml_array_dbl_2d_variable_2nd_free(double** %0, i32 %1, i32* %2) {
%4 = alloca double**
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store double** %0, double*** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %8
8: ; preds = %27, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load double**, double*** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double*, double** %13, i64 %15
%17 = load double*, double** %16
%18 = icmp ne double* %17, null
br i1 %18, label %19, label %26
19: ; preds = %12
%20 = load double**, double*** %4
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double*, double** %20, i64 %22
%24 = load double*, double** %23
%25 = bitcast double* %24 to i8*
br label %26
26: ; preds = %19, %12
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %8
30: ; preds = %8
%31 = load double**, double*** %4
%32 = bitcast double** %31 to i8*
ret void
}

LLVM IR (-O2):
define void @aml_array_dbl_2d_variable_2nd_free(double** nocapture %0, i32 %1, i32* nocapture readnone %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %14
%8 = phi i64 [ 0, %5 ], [ %15, %14 ]
%9 = getelementptr inbounds double*, double** %0, i64 %8
%10 = load double*, double** %9
%11 = icmp eq double* %10, null
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = bitcast double* %10 to i8*
tail call void @free(i8* %13)
br label %14
14: ; preds = %7, %12
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %17, label %7
17: ; preds = %14, %3
%18 = bitcast double** %0 to i8*
tail call void @free(i8* %18)
ret void
}