#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_empty(unsigned long const *, int);
int bitmap_empty(const unsigned long *src, int nbits) {
  if (nbits <= ((int)sizeof(unsigned long) * 8))
    return !(*src &
             (((nbits) % ((int)sizeof(unsigned long) * 8))
                  ? (1UL << ((nbits) % ((int)sizeof(unsigned long) * 8))) - 1
                  : ~0UL));
  else
    return __bitmap_empty(src, nbits);
}


x86 assembly (clang, -O0):
<bitmap_empty>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jg     119d <bitmap_empty+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     116c <bitmap_empty+0x5c>
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117c <bitmap_empty+0x6c>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    117c <bitmap_empty+0x6c>
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    11ac <bitmap_empty+0x9c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <__bitmap_empty@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitmap_empty>:
cmp    $0x40,%esi
jg     1143 <bitmap_empty+0x33>
lea    0x3f(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
and    $0xffffffc0,%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   %rcx,(%rdi)
sete   %al
ret
jmp    1030 <__bitmap_empty@plt>

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

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