void aml_array_dbl_4d_free(double ****arr, int s1, int s2, int s3) {
  int i, j, k;
  for (i = 0; i < s1; i++) {
    for (j = 0; j < s2; 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_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d3 <aml_array_dbl_4d_free+0xc3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b4 <aml_array_dbl_4d_free+0xa4>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    118d <aml_array_dbl_4d_free+0x7d>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%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    1152 <aml_array_dbl_4d_free+0x42>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <aml_array_dbl_4d_free+0x2f>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <aml_array_dbl_4d_free+0x1c>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aml_array_dbl_4d_free>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %rdi,%rbp
test   %esi,%esi
jle    11cd <aml_array_dbl_4d_free+0xbd>
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%r13d
mov    0xc(%rsp),%ebx
xor    %r14d,%r14d
jmp    1165 <aml_array_dbl_4d_free+0x55>
cs nopw 0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%rdi
call   1030 <free@plt>
add    $0x1,%r14
cmp    0x10(%rsp),%r14
je     11cd <aml_array_dbl_4d_free+0xbd>
cmpl   $0x0,0x8(%rsp)
jle    1150 <aml_array_dbl_4d_free+0x40>
xor    %r15d,%r15d
jmp    1197 <aml_array_dbl_4d_free+0x87>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%rax
mov    (%rax,%r15,8),%rdi
call   1030 <free@plt>
add    $0x1,%r15
cmp    %r13,%r15
je     1150 <aml_array_dbl_4d_free+0x40>
cmpl   $0x0,0xc(%rsp)
jle    1180 <aml_array_dbl_4d_free+0x70>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r14,8),%rax
mov    (%rax,%r15,8),%rax
mov    (%rax,%r12,8),%rdi
call   1030 <free@plt>
add    $0x1,%r12
cmp    %r12,%rbx
jne    11b0 <aml_array_dbl_4d_free+0xa0>
jmp    1180 <aml_array_dbl_4d_free+0x70>
mov    %rbp,%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_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 = %65, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %6
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %68
16: ; preds = %12
store i32 0, i32* %10
br label %17
17: ; preds = %55, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %7
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %58
21: ; preds = %17
store i32 0, i32* %11
br label %22
22: ; preds = %41, %21
%23 = load i32, i32* %11
%24 = load i32, i32* %8
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = load double****, double***** %5
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double***, double**** %27, i64 %29
%31 = load double***, double**** %30
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double**, double*** %31, i64 %33
%35 = load double**, double*** %34
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double*, double** %35, i64 %37
%39 = load double*, double** %38
%40 = bitcast double* %39 to i8*
br label %41
41: ; preds = %26
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %22
44: ; preds = %22
%45 = load double****, double***** %5
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double***, double**** %45, i64 %47
%49 = load double***, double**** %48
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double**, double*** %49, i64 %51
%53 = load double**, double*** %52
%54 = bitcast double** %53 to i8*
br label %55
55: ; preds = %44
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %17
58: ; preds = %17
%59 = load double****, double***** %5
%60 = load i32, i32* %9
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double***, double**** %59, i64 %61
%63 = load double***, double**** %62
%64 = bitcast double*** %63 to i8*
br label %65
65: ; preds = %58
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %12
68: ; preds = %12
%69 = load double****, double***** %5
%70 = bitcast double**** %69 to i8*
ret void
}

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