#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 Kit_TruthWordNum(int);
int Kit_WordFindFirstBit(unsigned int);
int Kit_TruthFindFirstZero(unsigned *pIn, int nVars) {
  int w;
  for (w = 0; w < Kit_TruthWordNum(nVars); w++)
    if (~pIn[w])
      return 32 * w + Kit_WordFindFirstBit(~pIn[w]);
  return -1;
}


x86 assembly (clang, -O0):
<Kit_TruthFindFirstZero>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <Kit_TruthWordNum@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11a6 <Kit_TruthFindFirstZero+0x86>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
xor    $0xffffffff,%eax
cmp    $0x0,%eax
je     1193 <Kit_TruthFindFirstZero+0x73>
mov    -0x18(%rbp),%eax
shl    $0x5,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
xor    $0xffffffff,%edi
call   1030 <Kit_WordFindFirstBit@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <Kit_TruthFindFirstZero+0x8d>
jmp    1198 <Kit_TruthFindFirstZero+0x78>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <Kit_TruthFindFirstZero+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Kit_TruthFindFirstZero>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r12d
mov    %rdi,%r15
mov    %esi,%edi
call   1040 <Kit_TruthWordNum@plt>
mov    $0xffffffff,%r14d
test   %eax,%eax
jle    117e <Kit_TruthFindFirstZero+0x5e>
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15,%rbp,4),%edi
cmp    $0xffffffff,%edi
jne    1171 <Kit_TruthFindFirstZero+0x51>
add    $0x1,%rbp
mov    %r12d,%edi
call   1040 <Kit_TruthWordNum@plt>
cltq
add    $0x20,%ebx
cmp    %rax,%rbp
jl     1150 <Kit_TruthFindFirstZero+0x30>
jmp    117e <Kit_TruthFindFirstZero+0x5e>
not    %edi
call   1030 <Kit_WordFindFirstBit@plt>
mov    %eax,%r14d
add    %ebx,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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