void freedatamask(int n, double **data, int **mask) {
  int i;
  for (i = 0; i < n; i++) {
    free(mask[i]);
    free(data[i]);
  }
  free(mask);
  free(data);
}


x86 assembly (clang, -O0):
<freedatamask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1166 <freedatamask+0x56>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%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    112a <freedatamask+0x1a>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freedatamask>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
test   %edi,%edi
jle    114b <freedatamask+0x3b>
mov    %edi,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
call   1030 <free@plt>
mov    (%r14,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <freedatamask+0x20>
mov    %r15,%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 @freedatamask(i32 %0, double** %1, i32** %2) {
%4 = alloca i32
%5 = alloca double**
%6 = alloca i32**
%7 = alloca i32
store i32 %0, i32* %4
store double** %1, double*** %5
store i32** %2, i32*** %6
store i32 0, i32* %7
br label %8
8: ; preds = %25, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32**, i32*** %6
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32*, i32** %13, i64 %15
%17 = load i32*, i32** %16
%18 = bitcast i32* %17 to i8*
%19 = load double**, double*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double*, double** %19, i64 %21
%23 = load double*, double** %22
%24 = bitcast double* %23 to i8*
br label %25
25: ; preds = %12
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %8
28: ; preds = %8
%29 = load i32**, i32*** %6
%30 = bitcast i32** %29 to i8*
%31 = load double**, double*** %5
%32 = bitcast double** %31 to i8*
ret void
}

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