#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*/ checkBit(unsigned int, int);
int findIndexOfFirstZero(unsigned int *bitVector, int vLength) {
  int i = 0;
  int j = 0;
  int index = 0;
  for (i = 0; i < vLength; i++) {
    for (j = 0; j < 32; j++) {
      if (!checkBit(bitVector[i], j)) {
        index = (32 * i + j);
        return index;
      }
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<findIndexOfFirstZero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b1 <findIndexOfFirstZero+0xa1>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x20,-0x1c(%rbp)
jge    119e <findIndexOfFirstZero+0x8e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x1c(%rbp),%esi
call   1030 <checkBit@plt>
cmp    $0x0,%eax
jne    118b <findIndexOfFirstZero+0x7b>
mov    -0x18(%rbp),%eax
shl    $0x5,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <findIndexOfFirstZero+0xa8>
jmp    1190 <findIndexOfFirstZero+0x80>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114e <findIndexOfFirstZero+0x3e>
jmp    11a3 <findIndexOfFirstZero+0x93>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113b <findIndexOfFirstZero+0x2b>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findIndexOfFirstZero>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %esi,%esi
jle    116d <findIndexOfFirstZero+0x5d>
mov    %rdi,%r13
mov    %esi,%r12d
xor    %r15d,%r15d
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13,%rbx,4),%edi
mov    %ebp,%esi
call   1030 <checkBit@plt>
test   %eax,%eax
je     1167 <findIndexOfFirstZero+0x57>
add    $0x1,%ebp
cmp    $0x20,%ebp
jne    1140 <findIndexOfFirstZero+0x30>
add    $0x1,%rbx
add    $0xffffffe0,%r15d
cmp    %r12,%rbx
jne    1130 <findIndexOfFirstZero+0x20>
jmp    116d <findIndexOfFirstZero+0x5d>
sub    %r15d,%ebp
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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