void freeAll(double *xi, double *pnew, double **hessin, double *hdg, double *g,
             double *dg, int n) {
  int i;
  rax_free(xi);
  rax_free(pnew);
  rax_free(hdg);
  rax_free(g);
  rax_free(dg);
  for (i = 0; i <= n; i++)
    rax_free(hessin[i]);
  rax_free(hessin);
}


x86 assembly (clang, -O0):
<freeAll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
mov    -0x30(%rbp),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x10(%rbp),%eax
jg     119e <freeAll+0x8e>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1171 <freeAll+0x61>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <rax_free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeAll>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r13
mov    0x40(%rsp),%ebp
xor    %eax,%eax
call   1030 <rax_free@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <rax_free@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <rax_free@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <rax_free@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <rax_free@plt>
test   %ebp,%ebp
js     1184 <freeAll+0x74>
add    $0x1,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
xor    %eax,%eax
call   1030 <rax_free@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <freeAll+0x60>
mov    %r14,%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <rax_free@plt>

LLVM IR (-O0):
define void @freeAll(double* %0, double* %1, double** %2, double* %3, double* %4, double* %5, i32 %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca double**
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
store double* %0, double** %8
store double* %1, double** %9
store double** %2, double*** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store i32 %6, i32* %14
%16 = load double*, double** %8
%17 = call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %16)
%18 = load double*, double** %9
%19 = call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %18)
%20 = load double*, double** %11
%21 = call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %20)
%22 = load double*, double** %12
%23 = call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %22)
%24 = load double*, double** %13
%25 = call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %24)
store i32 0, i32* %15
br label %26
26: ; preds = %37, %7
%27 = load i32, i32* %15
%28 = load i32, i32* %14
%29 = icmp sle i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load double**, double*** %10
%32 = load i32, i32* %15
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double*, double** %31, i64 %33
%35 = load double*, double** %34
%36 = call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* %15
%39 = add nsw i32 %38, 1
store i32 %39, i32* %15
br label %26
40: ; preds = %26
%41 = load double**, double*** %10
%42 = call i32 (double**, ...) bitcast (i32 (...)* @rax_free to i32 (double**, ...)*)(double** %41)
ret void
}

LLVM IR (-O2):
define void @freeAll(double* %0, double* %1, double** %2, double* %3, double* %4, double* %5, i32 %6) {
%8 = tail call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %0)
%9 = tail call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %1)
%10 = tail call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %3)
%11 = tail call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %4)
%12 = tail call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %5)
%13 = icmp slt i32 %6, 0
br i1 %13, label %24, label %14
14: ; preds = %7
%15 = add nuw i32 %6, 1
%16 = zext i32 %15 to i64
br label %17
17: ; preds = %14, %17
%18 = phi i64 [ 0, %14 ], [ %22, %17 ]
%19 = getelementptr inbounds double*, double** %2, i64 %18
%20 = load double*, double** %19
%21 = tail call i32 (double*, ...) bitcast (i32 (...)* @rax_free to i32 (double*, ...)*)(double* %20)
%22 = add nuw nsw i64 %18, 1
%23 = icmp eq i64 %22, %16
br i1 %23, label %24, label %17
24: ; preds = %17, %7
%25 = tail call i32 (double**, ...) bitcast (i32 (...)* @rax_free to i32 (double**, ...)*)(double** %2)
ret void
}