#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 find_next_zero_bit(void *, int, int);
void *mb_correct_addr_and_bit(int *, void *);
int mb_find_next_zero_bit(void *addr, int max, int start) {
  int fix = 0, ret, tmpmax;
  addr = mb_correct_addr_and_bit(&fix, addr);
  tmpmax = max + fix;
  start += fix;
  ret = find_next_zero_bit(addr, tmpmax, start) - fix;
  if (ret > max)
    return max;
  return ret;
}


x86 assembly (clang, -O0):
<mb_find_next_zero_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
call   1030 <mb_correct_addr_and_bit@plt>
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <find_next_zero_bit@plt>
sub    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1188 <mb_find_next_zero_bit+0x68>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <mb_find_next_zero_bit+0x6e>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mb_find_next_zero_bit>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%r14d
mov    %rdi,%rsi
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <mb_correct_addr_and_bit@plt>
mov    0x4(%rsp),%ecx
lea    (%rcx,%r14,1),%esi
add    %ecx,%ebx
mov    %rax,%rdi
mov    %ebx,%edx
call   1040 <find_next_zero_bit@plt>
sub    0x4(%rsp),%eax
cmp    %r14d,%eax
cmovg  %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @mb_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
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 0, i32* %8
%11 = load i8*, i8** %5
%12 = call i8* @mb_correct_addr_and_bit(i32* %8, i8* %11)
store i8* %12, i8** %5
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = add nsw i32 %13, %14
store i32 %15, i32* %10
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = add nsw i32 %17, %16
store i32 %18, i32* %7
%19 = load i8*, i8** %5
%20 = load i32, i32* %10
%21 = load i32, i32* %7
%22 = call i32 @find_next_zero_bit(i8* %19, i32 %20, i32 %21)
%23 = load i32, i32* %8
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %9
%25 = load i32, i32* %9
%26 = load i32, i32* %6
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %3
%29 = load i32, i32* %6
store i32 %29, i32* %4
br label %32
30: ; preds = %3
%31 = load i32, i32* %9
store i32 %31, i32* %4
br label %32
32: ; preds = %30, %28
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @mb_find_next_zero_bit(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = call i8* @mb_correct_addr_and_bit(i32* %4, i8* %0)
%7 = load i32, i32* %4
%8 = add nsw i32 %7, %1
%9 = add nsw i32 %7, %2
%10 = call i32 @find_next_zero_bit(i8* %6, i32 %8, i32 %9)
%11 = load i32, i32* %4
%12 = sub nsw i32 %10, %11
%13 = icmp sgt i32 %12, %1
%14 = select i1 %13, i32 %1, i32 %12
ret i32 %14
}