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


x86 assembly (clang, -O0):
<aml_array_dbl_3d_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    11ae <aml_array_dbl_3d_variable_2nd_free+0x9e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1178 <aml_array_dbl_3d_variable_2nd_free+0x68>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <aml_array_dbl_3d_variable_2nd_free+0x2d>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     119b <aml_array_dbl_3d_variable_2nd_free+0x8b>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    11a0 <aml_array_dbl_3d_variable_2nd_free+0x90>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <aml_array_dbl_3d_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_3d_variable_2nd_free>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
jle    1179 <aml_array_dbl_3d_variable_2nd_free+0x69>
mov    %rdx,%r12
mov    %esi,%r15d
xor    %r13d,%r13d
jmp    1139 <aml_array_dbl_3d_variable_2nd_free+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r15,%r13
je     1179 <aml_array_dbl_3d_variable_2nd_free+0x69>
mov    (%r12,%r13,4),%eax
test   %eax,%eax
jle    116a <aml_array_dbl_3d_variable_2nd_free+0x5a>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14,%r13,8),%rax
mov    (%rax,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq (%r12,%r13,4),%rax
cmp    %rax,%rbx
jl     1150 <aml_array_dbl_3d_variable_2nd_free+0x40>
test   %eax,%eax
je     1130 <aml_array_dbl_3d_variable_2nd_free+0x20>
mov    (%r14,%r13,8),%rdi
call   1030 <free@plt>
jmp    1130 <aml_array_dbl_3d_variable_2nd_free+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @aml_array_dbl_3d_variable_2nd_free(double*** %0, i32 %1, i32* %2) {
%4 = alloca double***
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store double*** %0, double**** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
br label %9
9: ; preds = %51, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %54
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %33, %13
%15 = load i32, i32* %8
%16 = load i32*, i32** %6
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = icmp slt i32 %15, %20
br i1 %21, label %22, label %36
22: ; preds = %14
%23 = load double***, double**** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double**, double*** %23, i64 %25
%27 = load double**, double*** %26
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double*, double** %27, i64 %29
%31 = load double*, double** %30
%32 = bitcast double* %31 to i8*
br label %33
33: ; preds = %22
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %14
36: ; preds = %14
%37 = load i32*, i32** %6
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %37, i64 %39
%41 = load i32, i32* %40
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %36
%44 = load double***, double**** %4
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double**, double*** %44, i64 %46
%48 = load double**, double*** %47
%49 = bitcast double** %48 to i8*
br label %50
50: ; preds = %43, %36
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %9
54: ; preds = %9
%55 = load double***, double**** %4
%56 = bitcast double*** %55 to i8*
ret void
}

LLVM IR (-O2):
define void @aml_array_dbl_3d_variable_2nd_free(double*** nocapture %0, i32 %1, i32* nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %34
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %31
%8 = phi i64 [ 0, %5 ], [ %32, %31 ]
%9 = getelementptr inbounds i32, i32* %2, i64 %8
%10 = load i32, i32* %9
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = getelementptr inbounds double**, double*** %0, i64 %8
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %20, %14 ]
%16 = load double**, double*** %13
%17 = getelementptr inbounds double*, double** %16, i64 %15
%18 = bitcast double** %17 to i8**
%19 = load i8*, i8** %18
tail call void @free(i8* %19)
%20 = add nuw nsw i64 %15, 1
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %14, label %24
24: ; preds = %14, %7
%25 = phi i32 [ %10, %7 ], [ %21, %14 ]
%26 = icmp eq i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = getelementptr inbounds double**, double*** %0, i64 %8
%29 = bitcast double*** %28 to i8**
%30 = load i8*, i8** %29
tail call void @free(i8* %30)
br label %31
31: ; preds = %24, %27
%32 = add nuw nsw i64 %8, 1
%33 = icmp eq i64 %32, %6
br i1 %33, label %34, label %7
34: ; preds = %31, %3
%35 = bitcast double*** %0 to i8*
tail call void @free(i8* %35)
ret void
}