void dblarr3free(double ***aaa, const int n1, const int n2, const int n3) {
  int i, j;
  for (i = 0; i < n1; i++) {
    for (j = 0; j < n2; j++)
      free(aaa[i][j]);
    free(aaa[i]);
  }
  free(aaa);
}


x86 assembly (clang, -O0):
<dblarr3free>:
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    1191 <dblarr3free+0x81>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1172 <dblarr3free+0x62>
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 <dblarr3free+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 <dblarr3free+0x1c>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dblarr3free>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
test   %esi,%esi
jle    1168 <dblarr3free+0x58>
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edx,%r13d
xor    %ebx,%ebx
jmp    1142 <dblarr3free+0x32>
nop
mov    (%r12,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
je     1168 <dblarr3free+0x58>
test   %r14d,%r14d
jle    1130 <dblarr3free+0x20>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r12,%rbx,8),%rax
mov    (%rax,%rbp,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1150 <dblarr3free+0x40>
jmp    1130 <dblarr3free+0x20>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @dblarr3free(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
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 %11
11: ; preds = %41, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %44
15: ; preds = %11
store i32 0, i32* %10
br label %16
16: ; preds = %31, %15
%17 = load i32, i32* %10
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load double***, double**** %5
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double**, double*** %21, i64 %23
%25 = load double**, double*** %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
%29 = load double*, double** %28
%30 = bitcast double* %29 to i8*
br label %31
31: ; preds = %20
%32 = load i32, i32* %10
%33 = add nsw i32 %32, 1
store i32 %33, i32* %10
br label %16
34: ; preds = %16
%35 = load double***, double**** %5
%36 = load i32, i32* %9
%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 = %34
%42 = load i32, i32* %9
%43 = add nsw i32 %42, 1
store i32 %43, i32* %9
br label %11
44: ; preds = %11
%45 = load double***, double**** %5
%46 = bitcast double*** %45 to i8*
ret void
}

LLVM IR (-O2):
define void @dblarr3free(double*** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %28
6: ; preds = %4
%7 = icmp sgt i32 %2, 0
%8 = zext i32 %1 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %6, %22
%11 = phi i64 [ 0, %6 ], [ %26, %22 ]
br i1 %7, label %12, label %22
12: ; preds = %10
%13 = getelementptr inbounds double**, double*** %0, i64 %11
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 = icmp eq i64 %20, %9
br i1 %21, label %22, label %14
22: ; preds = %14, %10
%23 = getelementptr inbounds double**, double*** %0, i64 %11
%24 = bitcast double*** %23 to i8**
%25 = load i8*, i8** %24
tail call void @free(i8* %25)
%26 = add nuw nsw i64 %11, 1
%27 = icmp eq i64 %26, %8
br i1 %27, label %28, label %10
28: ; preds = %22, %4
%29 = bitcast double*** %0 to i8*
tail call void @free(i8* %29)
ret void
}