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


x86 assembly (clang, -O0):
<aml_array_dbl_4d_variable_2nd_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11dc <aml_array_dbl_4d_variable_2nd_free+0xcc>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11bd <aml_array_dbl_4d_variable_2nd_free+0xad>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1196 <aml_array_dbl_4d_variable_2nd_free+0x86>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115b <aml_array_dbl_4d_variable_2nd_free+0x4b>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1140 <aml_array_dbl_4d_variable_2nd_free+0x30>
mov    -0x8(%rbp),%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    112d <aml_array_dbl_4d_variable_2nd_free+0x1d>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_4d_variable_2nd_free>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0xc(%rsp)
mov    %rdi,%r13
test   %esi,%esi
jle    11bd <aml_array_dbl_4d_variable_2nd_free+0xad>
mov    %rdx,%r12
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%ebx
xor    %ebp,%ebp
jmp    1155 <aml_array_dbl_4d_variable_2nd_free+0x45>
nop
mov    0x0(%r13,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     11bd <aml_array_dbl_4d_variable_2nd_free+0xad>
cmpl   $0x0,(%r12,%rbp,4)
jle    1140 <aml_array_dbl_4d_variable_2nd_free+0x30>
xor    %r15d,%r15d
jmp    118b <aml_array_dbl_4d_variable_2nd_free+0x7b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%r15,8),%rdi
call   1030 <free@plt>
add    $0x1,%r15
movslq (%r12,%rbp,4),%rax
cmp    %rax,%r15
jge    1140 <aml_array_dbl_4d_variable_2nd_free+0x30>
cmpl   $0x0,0xc(%rsp)
jle    1170 <aml_array_dbl_4d_variable_2nd_free+0x60>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%r15,8),%rax
mov    (%rax,%r14,8),%rdi
call   1030 <free@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    11a0 <aml_array_dbl_4d_variable_2nd_free+0x90>
jmp    1170 <aml_array_dbl_4d_variable_2nd_free+0x60>
mov    %r13,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

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