#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ willus_mem_free(double **, char *);
void vector_nd_free(void **ptr, int *dims, int n) {
  static char *funcname = "vector_nd_free";
  int i;
  void **p2;
  if (n == 1) {
    willus_mem_free((double **)ptr, funcname);
    return;
  }
  p2 = (void **)(*ptr);
  for (i = 0; i < dims[0]; i++)
    vector_nd_free(&p2[i], &dims[1], n - 1);
  willus_mem_free((double **)ptr, funcname);
}


x86 assembly (clang, -O0):
<vector_nd_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1152 <vector_nd_free+0x32>
mov    -0x8(%rbp),%rdi
mov    0x2ee8(%rip),%rsi
call   1040 <willus_mem_free@plt>
jmp    11b3 <vector_nd_free+0x93>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a3 <vector_nd_free+0x83>
mov    -0x20(%rbp),%rdi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
add    $0x4,%rsi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1030 <vector_nd_free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1164 <vector_nd_free+0x44>
mov    -0x8(%rbp),%rdi
mov    0x2e82(%rip),%rsi
call   1040 <willus_mem_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_nd_free>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
cmp    $0x1,%edx
je     116e <vector_nd_free+0x4e>
mov    %rsi,%r15
cmpl   $0x0,(%rsi)
jle    116e <vector_nd_free+0x4e>
mov    %edx,%r12d
mov    (%r14),%rbx
lea    0x4(%r15),%r13
add    $0xffffffff,%r12d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   1030 <vector_nd_free@plt>
add    $0x1,%rbp
movslq (%r15),%rax
add    $0x8,%rbx
cmp    %rax,%rbp
jl     1150 <vector_nd_free+0x30>
lea    0xe8b(%rip),%rsi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <willus_mem_free@plt>

LLVM IR (-O0):
@vector_nd_free.funcname = internal global i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i32 0, i32 0)
@.str = [15 x i8] c"vector_nd_free\00"
define void @vector_nd_free(i8** %0, i32* %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i8**, i8*** %4
%13 = bitcast i8** %12 to double**
%14 = load i8*, i8** @vector_nd_free.funcname
%15 = call i32 @willus_mem_free(double** %13, i8* %14)
br label %43
16: ; preds = %3
%17 = load i8**, i8*** %4
%18 = load i8*, i8** %17
%19 = bitcast i8* %18 to i8**
store i8** %19, i8*** %8
store i32 0, i32* %7
br label %20
20: ; preds = %35, %16
%21 = load i32, i32* %7
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %23
%25 = icmp slt i32 %21, %24
br i1 %25, label %26, label %38
26: ; preds = %20
%27 = load i8**, i8*** %8
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i32*, i32** %5
%32 = getelementptr inbounds i32, i32* %31, i64 1
%33 = load i32, i32* %6
%34 = sub nsw i32 %33, 1
br label %35
35: ; preds = %26
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %20
38: ; preds = %20
%39 = load i8**, i8*** %4
%40 = bitcast i8** %39 to double**
%41 = load i8*, i8** @vector_nd_free.funcname
%42 = call i32 @willus_mem_free(double** %40, i8* %41)
br label %43
43: ; preds = %38, %11
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"vector_nd_free\00"
define void @vector_nd_free(i8** %0, i32* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 1
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = bitcast i8** %0 to i8***
%7 = load i8**, i8*** %6
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = getelementptr inbounds i32, i32* %1, i64 1
%12 = add nsw i32 %2, -1
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %16, %13 ]
%15 = getelementptr inbounds i8*, i8** %7, i64 %14
tail call void @vector_nd_free(i8** %15, i32* %11, i32 %12)
%16 = add nuw nsw i64 %14, 1
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %13, label %20
20: ; preds = %13, %5, %3
%21 = bitcast i8** %0 to double**
%22 = tail call i32 @willus_mem_free(double** %21, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret void
}