#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 __bitmap_full(unsigned long const *, int);
__attribute__((always_)) int bitmap_full(const unsigned long *src, int nbits) {
  if (nbits <= 32)
    return !(~(*src) & (((nbits) % 32) ? (1UL << ((nbits) % 32)) - 1 : ~0UL));
  else
    return __bitmap_full(src, nbits);
}


x86 assembly (clang, -O0):
<bitmap_full>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jg     11a1 <bitmap_full+0x91>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1170 <bitmap_full+0x60>
mov    -0x14(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1180 <bitmap_full+0x70>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    1180 <bitmap_full+0x70>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11b0 <bitmap_full+0xa0>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <__bitmap_full@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitmap_full>:
cmp    $0x20,%esi
jg     1149 <bitmap_full+0x39>
mov    (%rdi),%rdx
not    %rdx
lea    0x1f(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0xffffffe0,%eax
sub    %eax,%esi
mov    $0xffffffffffffffff,%rax
mov    %esi,%ecx
shl    %cl,%rax
not    %rax
cmp    $0x1,%esi
sbb    %rcx,%rcx
or     %rax,%rcx
xor    %eax,%eax
test   %rdx,%rcx
sete   %al
ret
jmp    1030 <__bitmap_full@plt>

LLVM IR (-O0):
define i32 @bitmap_full(i64* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64*
%5 = alloca i32
store i64* %0, i64** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp sle i32 %6, 32
br i1 %7, label %8, label %28
8: ; preds = %2
%9 = load i64*, i64** %4
%10 = load i64, i64* %9
%11 = xor i64 %10, -1
%12 = load i32, i32* %5
%13 = srem i32 %12, 32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %8
%16 = load i32, i32* %5
%17 = srem i32 %16, 32
%18 = zext i32 %17 to i64
%19 = shl i64 1, %18
%20 = sub i64 %19, 1
br label %22
21: ; preds = %8
br label %22
22: ; preds = %21, %15
%23 = phi i64 [ %20, %15 ], [ -1, %21 ]
%24 = and i64 %11, %23
%25 = icmp ne i64 %24, 0
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
store i32 %27, i32* %3
br label %32
28: ; preds = %2
%29 = load i64*, i64** %4
%30 = load i32, i32* %5
%31 = call i32 @__bitmap_full(i64* %29, i32 %30)
store i32 %31, i32* %3
br label %32
32: ; preds = %28, %22
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @bitmap_full(i64* %0, i32 %1) {
%3 = icmp slt i32 %1, 33
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = load i64, i64* %0
%6 = xor i64 %5, -1
%7 = srem i32 %1, 32
%8 = icmp eq i32 %7, 0
%9 = zext i32 %7 to i64
%10 = shl nsw i64 -1, %9
%11 = xor i64 %10, -1
%12 = select i1 %8, i64 -1, i64 %11
%13 = and i64 %12, %6
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
br label %18
16: ; preds = %2
%17 = tail call i32 @__bitmap_full(i64* %0, i32 %1)
br label %18
18: ; preds = %16, %4
%19 = phi i32 [ %15, %4 ], [ %17, %16 ]
ret i32 %19
}