#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_set_bit(unsigned long int nr, unsigned long *bitmap,
                unsigned long long total) {
  if (!bitmap)
    return;
  if (nr >= total) {
    printf("set 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_set_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_set_bit+0x24>
jmp    11a4 <pc_set_bit+0x84>
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
jb     1170 <pc_set_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
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
or     (%rax,%rcx,8),%rdx
mov    %rdx,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pc_set_bit>:
push   %rax
test   %rsi,%rsi
je     1141 <pc_set_bit+0x21>
mov    %rdi,%rcx
cmp    %rdx,%rdi
jae    1143 <pc_set_bit+0x23>
mov    %rcx,%rax
mov    $0x1,%edx
shl    %cl,%rdx
shr    $0x6,%rax
or     %rdx,(%rsi,%rax,8)
pop    %rax
ret
lea    0xeb6(%rip),%rdi
mov    %rcx,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"set block %lu out of boundary(%llu)\0A\00"
define void @pc_set_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 %33
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 ([37 x i8], [37 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 = load i64*, i64** %5
%29 = load i64, i64* %7
%30 = getelementptr inbounds i64, i64* %28, i64 %29
%31 = load i64, i64* %30
%32 = or i64 %31, %27
store i64 %32, i64* %30
br label %33
33: ; preds = %21, %11
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"set block %lu out of boundary(%llu)\0A\00"
define void @pc_set_bit(i64 %0, i64* %1, i64 %2) {
%4 = icmp eq i64* %1, null
br i1 %4, label %17, 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 ([37 x i8], [37 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 = getelementptr inbounds i64, i64* %1, i64 %11
%15 = load i64, i64* %14
%16 = or i64 %15, %13
store i64 %16, i64* %14
br label %17
17: ; preds = %3, %10
ret void
}