#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*/ test_bit(int, void *);
int find_next_zero_bit(void *addr, int size, int offset) {
  int i;
  for (i = offset; i < size; i++) {
    if (!test_bit(i, addr)) {
      return i;
    }
  }
  return size;
}


x86 assembly (clang, -O0):
<find_next_zero_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1167 <find_next_zero_bit+0x57>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_bit@plt>
cmp    $0x0,%eax
jne    1154 <find_next_zero_bit+0x44>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    116d <find_next_zero_bit+0x5d>
jmp    1159 <find_next_zero_bit+0x49>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1128 <find_next_zero_bit+0x18>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_next_zero_bit>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
cmp    %esi,%edx
jge    113b <find_next_zero_bit+0x2b>
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1030 <test_bit@plt>
test   %eax,%eax
je     1138 <find_next_zero_bit+0x28>
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1120 <find_next_zero_bit+0x10>
jmp    113b <find_next_zero_bit+0x2b>
mov    %ebp,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_next_zero_bit(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
store i32 %9, i32* %8
br label %10
10: ; preds = %22, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i32, i32* %8
%16 = load i8*, i8** %5
%17 = call i32 @test_bit(i32 %15, i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %14
%20 = load i32, i32* %8
store i32 %20, i32* %4
br label %27
21: ; preds = %14
br label %22
22: ; preds = %21
%23 = load i32, i32* %8
%24 = add nsw i32 %23, 1
store i32 %24, i32* %8
br label %10
25: ; preds = %10
%26 = load i32, i32* %6
store i32 %26, i32* %4
br label %27
27: ; preds = %25, %19
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
define i32 @find_next_zero_bit(i8* %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %2, %1
br i1 %4, label %5, label %12
5: ; preds = %3, %9
%6 = phi i32 [ %10, %9 ], [ %2, %3 ]
%7 = tail call i32 @test_bit(i32 %6, i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = add i32 %6, 1
%11 = icmp eq i32 %10, %1
br i1 %11, label %12, label %5
12: ; preds = %5, %9, %3
%13 = phi i32 [ %1, %3 ], [ %1, %9 ], [ %6, %5 ]
ret i32 %13
}