#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*/ metal_bitmap_is_bit_clear(unsigned long *, unsigned int);
unsigned int metal_bitmap_next_clear_bit(unsigned long *bitmap,
                                         unsigned int start, unsigned int max) {
  unsigned int bit;
  for (bit = start; bit < max && !metal_bitmap_is_bit_clear(bitmap, bit); bit++)
    ;
  return bit;
}


x86 assembly (clang, -O0):
<metal_bitmap_next_clear_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x10(%rbp),%ecx
mov    %al,-0x15(%rbp)
jae    1150 <metal_bitmap_next_clear_bit+0x40>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <metal_bitmap_is_bit_clear@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1160 <metal_bitmap_next_clear_bit+0x50>
jmp    1173 <metal_bitmap_next_clear_bit+0x63>
jmp    1165 <metal_bitmap_next_clear_bit+0x55>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1128 <metal_bitmap_next_clear_bit+0x18>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<metal_bitmap_next_clear_bit>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
cmp    %edx,%esi
jae    1137 <metal_bitmap_next_clear_bit+0x27>
mov    %edx,%ebp
mov    %rdi,%r14
nop
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <metal_bitmap_is_bit_clear@plt>
test   %eax,%eax
jne    1137 <metal_bitmap_next_clear_bit+0x27>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1120 <metal_bitmap_next_clear_bit+0x10>
mov    %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @metal_bitmap_next_clear_bit(i64* %0, i32 %1, i32 %2) {
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i64* %0, i64** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
store i32 %8, i32* %7
br label %9
9: ; preds = %22, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i64*, i64** %4
%15 = load i32, i32* %7
%16 = call i32 @metal_bitmap_is_bit_clear(i64* %14, i32 %15)
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
br label %19
19: ; preds = %13, %9
%20 = phi i1 [ false, %9 ], [ %18, %13 ]
br i1 %20, label %21, label %25
21: ; preds = %19
br label %22
22: ; preds = %21
%23 = load i32, i32* %7
%24 = add i32 %23, 1
store i32 %24, i32* %7
br label %9
25: ; preds = %19
%26 = load i32, i32* %7
ret i32 %26
}

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