#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*/ __bitmap_complement(unsigned long *, unsigned long const *,
                                       int);
__attribute__((always_)) void
bitmap_complement(unsigned long *dst, const unsigned long *src, int nbits) {
  if (nbits <= 32)
    *dst = ~(*src) & (((nbits) % 32) ? (1UL << ((nbits) % 32)) - 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)
cmpl   $0x20,-0x14(%rbp)
jg     119b <bitmap_complement+0x8b>
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     1174 <bitmap_complement+0x64>
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    1184 <bitmap_complement+0x74>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    1184 <bitmap_complement+0x74>
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
and    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    11ab <bitmap_complement+0x9b>
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>:
cmp    $0x20,%edx
jg     1147 <bitmap_complement+0x37>
mov    (%rsi),%rax
lea    0x1f(%rdx),%ecx
test   %edx,%edx
cmovns %edx,%ecx
and    $0xffffffe0,%ecx
sub    %ecx,%edx
mov    $0xffffffffffffffff,%rsi
mov    %edx,%ecx
shl    %cl,%rsi
not    %rax
cmp    $0x1,%edx
sbb    %rcx,%rcx
not    %rsi
or     %rsi,%rcx
and    %rax,%rcx
mov    %rcx,(%rdi)
ret
jmp    1030 <__bitmap_complement@plt>

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

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