#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 __WORDSIZE;
int /*<<< orphan*/ __bitmap_complement(unsigned long *, unsigned long const *,
                                       int);
void bitmap_complement(unsigned long *dst, const unsigned long *src,
                       int nbits) {
  if (nbits <= __WORDSIZE)
    *dst =
        ~(*src) &
        (((nbits) % __WORDSIZE) ? (1UL << ((nbits) % __WORDSIZE)) - 1 : ~0UL);
  else
    __bitmap_complement(dst, src, nbits);
}


x86 assembly (clang, -O0):
<bitmap_complement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ebb(%rip),%rcx
cmp    (%rcx),%eax
jg     11a7 <bitmap_complement+0x97>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9a(%rip),%rcx
cltd
idivl  (%rcx)
cmp    $0x0,%edx
je     1180 <bitmap_complement+0x70>
mov    -0x14(%rbp),%eax
mov    0x2e84(%rip),%rcx
cltd
idivl  (%rcx)
mov    %edx,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
sub    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1190 <bitmap_complement+0x80>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    1190 <bitmap_complement+0x80>
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
and    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    11b7 <bitmap_complement+0xa7>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <__bitmap_complement@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitmap_complement>:
mov    0x2ed1(%rip),%rax
mov    (%rax),%ecx
cmp    %edx,%ecx
jge    1122 <bitmap_complement+0x12>
jmp    1030 <__bitmap_complement@plt>
mov    (%rsi),%rsi
mov    %edx,%eax
cltd
idiv   %ecx
mov    %edx,%ecx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
not    %rsi
cmp    $0x1,%edx
sbb    %rcx,%rcx
not    %rax
or     %rax,%rcx
and    %rsi,%rcx
mov    %rcx,(%rdi)
ret

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

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