void free_mat4D_double(double ****mat4D_double, int w, int x, int y) {
  unsigned int h, i, j;
  for (h = 0; h < w; ++h) {
    for (i = 0; i < x; ++i) {
      for (j = 0; j < y; ++j)
        free(mat4D_double[h][i][j]);
      free(mat4D_double[h][i]);
    }
    free(mat4D_double[h]);
  }
  free(mat4D_double);
}


x86 assembly (clang, -O0):
<free_mat4D_double>:
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
jae    11cd <free_mat4D_double+0xbd>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11af <free_mat4D_double+0x9f>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    118a <free_mat4D_double+0x7a>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x20(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1152 <free_mat4D_double+0x42>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <free_mat4D_double+0x2f>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <free_mat4D_double+0x1c>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_mat4D_double>:
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
je     11cd <free_mat4D_double+0xbd>
mov    %esi,%eax
mov    %rax,0x10(%rsp)
mov    0x8(%rsp),%r13d
mov    0xc(%rsp),%ebx
xor    %r14d,%r14d
jmp    1165 <free_mat4D_double+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 <free_mat4D_double+0xbd>
cmpl   $0x0,0x8(%rsp)
je     1150 <free_mat4D_double+0x40>
xor    %r15d,%r15d
jmp    1197 <free_mat4D_double+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 <free_mat4D_double+0x40>
cmpl   $0x0,0xc(%rsp)
je     1180 <free_mat4D_double+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 <free_mat4D_double+0xa0>
jmp    1180 <free_mat4D_double+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 @free_mat4D_double(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 ult 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 ult 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 ult i32 %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = load double****, double***** %5
%28 = load i32, i32* %9
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds double***, double**** %27, i64 %29
%31 = load double***, double**** %30
%32 = load i32, i32* %10
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds double**, double*** %31, i64 %33
%35 = load double**, double*** %34
%36 = load i32, i32* %11
%37 = zext 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 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 = zext i32 %46 to i64
%48 = getelementptr inbounds double***, double**** %45, i64 %47
%49 = load double***, double**** %48
%50 = load i32, i32* %10
%51 = zext 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 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 = zext 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 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 @free_mat4D_double(double**** nocapture %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %1, 0
br i1 %5, label %41, label %6
6: ; preds = %4
%7 = icmp eq i32 %2, 0
%8 = icmp eq 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 %35, label %14
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 %28, label %18
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
}