#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*/ free(void **);
void freeArrayofPointers(void **pointer, int index) {
  int i = 0;
  if (pointer) {
    for (i = 0; i < index; i++) {
      if (pointer[i])
        free(pointer[i]);
    }
    free(pointer);
  }
}


x86 assembly (clang, -O0):
<freeArrayofPointers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1184 <freeArrayofPointers+0x74>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    117b <freeArrayofPointers+0x6b>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1168 <freeArrayofPointers+0x58>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
jmp    116d <freeArrayofPointers+0x5d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1138 <freeArrayofPointers+0x28>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freeArrayofPointers>:
test   %rdi,%rdi
je     1156 <freeArrayofPointers+0x46>
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %esi,%esi
jle    1149 <freeArrayofPointers+0x39>
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    1139 <freeArrayofPointers+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1149 <freeArrayofPointers+0x39>
mov    (%r14,%rbx,8),%rdi
test   %rdi,%rdi
je     1130 <freeArrayofPointers+0x20>
call   1030 <free@plt>
jmp    1130 <freeArrayofPointers+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
ret

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

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