#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*/ exit(int);
int /*<<< orphan*/ printf(char *, unsigned long, unsigned long long);
void pc_clear_bit(unsigned long int nr, unsigned long *bitmap,
                  unsigned long long total) {
  if (!bitmap)
    return;
  if (nr >= total) {
    printf("clear block %lu out of boundary(%llu)\n", nr, total);
    exit(1);
  }
  unsigned long offset = nr / ((int)sizeof(unsigned long) * 8);
  unsigned long bit = nr & (((int)sizeof(unsigned long) * 8) - 1);
  bitmap[offset] &= ~(1UL << bit);
}


x86 assembly (clang, -O0):
<pc_clear_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1144 <pc_clear_bit+0x24>
jmp    11a8 <pc_clear_bit+0x88>
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     1170 <pc_clear_bit+0x50>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x8(%rbp),%rax
shr    $0x6,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3f,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    $0x1,%edx
shl    %cl,%rdx
xor    $0xffffffffffffffff,%rdx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
and    (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pc_clear_bit>:
push   %rax
test   %rsi,%rsi
je     1143 <pc_clear_bit+0x23>
mov    %rdi,%rcx
cmp    %rdx,%rdi
jae    1145 <pc_clear_bit+0x25>
mov    %rcx,%rax
mov    $0xfffffffffffffffe,%rdx
rol    %cl,%rdx
shr    $0x6,%rax
and    %rdx,(%rsi,%rax,8)
pop    %rax
ret
lea    0xeb4(%rip),%rdi
mov    %rcx,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"clear block %lu out of boundary(%llu)\0A\00"
define void @pc_clear_bit(i64 %0, i64* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %4
store i64* %1, i64** %5
store i64 %2, i64* %6
%9 = load i64*, i64** %5
%10 = icmp ne i64* %9, null
br i1 %10, label %12, label %11
11: ; preds = %3
br label %34
12: ; preds = %3
%13 = load i64, i64* %4
%14 = load i64, i64* %6
%15 = icmp uge i64 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i64, i64* %4
%18 = load i64, i64* %6
%19 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %17, i64 %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %12
%22 = load i64, i64* %4
%23 = udiv i64 %22, 64
store i64 %23, i64* %7
%24 = load i64, i64* %4
%25 = and i64 %24, 63
store i64 %25, i64* %8
%26 = load i64, i64* %8
%27 = shl i64 1, %26
%28 = xor i64 %27, -1
%29 = load i64*, i64** %5
%30 = load i64, i64* %7
%31 = getelementptr inbounds i64, i64* %29, i64 %30
%32 = load i64, i64* %31
%33 = and i64 %32, %28
store i64 %33, i64* %31
br label %34
34: ; preds = %21, %11
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"clear block %lu out of boundary(%llu)\0A\00"
define void @pc_clear_bit(i64 %0, i64* %1, i64 %2) {
%4 = icmp eq i64* %1, null
br i1 %4, label %18, label %5
5: ; preds = %3
%6 = icmp ult i64 %0, %2
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %2)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %5
%11 = lshr i64 %0, 6
%12 = and i64 %0, 63
%13 = shl nuw i64 1, %12
%14 = xor i64 %13, -1
%15 = getelementptr inbounds i64, i64* %1, i64 %11
%16 = load i64, i64* %15
%17 = and i64 %16, %14
store i64 %17, i64* %15
br label %18
18: ; preds = %3, %10
ret void
}