void unload_data(double **trainX, double *trainY, double **testX,
                 double *testY) {
  if (trainX)
    free(trainX[0]);
  free(trainX);
  free(trainY);
  if (testX)
    free(testX[0]);
  free(testX);
  free(testY);
}


x86 assembly (clang, -O0):
<unload_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     113f <unload_data+0x2f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x18(%rbp)
je     1168 <unload_data+0x58>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unload_data>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rdi,%rdi
je     1131 <unload_data+0x21>
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
test   %r12,%r12
je     114f <unload_data+0x3f>
mov    (%r12),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @unload_data(double** %0, double* %1, double** %2, double* %3) {
%5 = alloca double**
%6 = alloca double*
%7 = alloca double**
%8 = alloca double*
store double** %0, double*** %5
store double* %1, double** %6
store double** %2, double*** %7
store double* %3, double** %8
%9 = load double**, double*** %5
%10 = icmp ne double** %9, null
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load double**, double*** %5
%13 = getelementptr inbounds double*, double** %12, i64 0
%14 = load double*, double** %13
%15 = bitcast double* %14 to i8*
br label %16
16: ; preds = %11, %4
%17 = load double**, double*** %5
%18 = bitcast double** %17 to i8*
%19 = load double*, double** %6
%20 = bitcast double* %19 to i8*
%21 = load double**, double*** %7
%22 = icmp ne double** %21, null
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load double**, double*** %7
%25 = getelementptr inbounds double*, double** %24, i64 0
%26 = load double*, double** %25
%27 = bitcast double* %26 to i8*
br label %28
28: ; preds = %23, %16
%29 = load double**, double*** %7
%30 = bitcast double** %29 to i8*
%31 = load double*, double** %8
%32 = bitcast double* %31 to i8*
ret void
}

LLVM IR (-O2):
define void @unload_data(double** %0, double* nocapture %1, double** %2, double* nocapture %3) {
%5 = icmp eq double** %0, null
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = bitcast double** %0 to i8**
%8 = load i8*, i8** %7
tail call void @free(i8* %8)
br label %9
9: ; preds = %6, %4
%10 = bitcast double** %0 to i8*
tail call void @free(i8* %10)
%11 = bitcast double* %1 to i8*
tail call void @free(i8* %11)
%12 = icmp eq double** %2, null
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = bitcast double** %2 to i8**
%15 = load i8*, i8** %14
tail call void @free(i8* %15)
br label %16
16: ; preds = %13, %9
%17 = bitcast double** %2 to i8*
tail call void @free(i8* %17)
%18 = bitcast double* %3 to i8*
tail call void @free(i8* %18)
ret void
}