#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 atoi(char *);
unsigned int clearBit(unsigned int, int);
unsigned int isBitISet(unsigned int, int);
int /*<<< orphan*/ printResult(int, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
unsigned int setBit(unsigned int, int);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    printf("Usage: %s <number> <bit index>\n", argv[0]);
    return 0;
  }
  unsigned int number = (unsigned int)atoi(argv[1]);
  int i = atoi(argv[2]);
  printf("Number: %d (0x%x)\n", number, number);
  printf("Modifying bit: %d\n", i);
  unsigned int result = isBitISet(number, i);
  printResult(i, number, result);
  number = setBit(number, i);
  result = isBitISet(number, i);
  printResult(i, number, result);
  number = clearBit(number, i);
  result = isBitISet(number, i);
  printResult(i, number, result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a1 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <isBitISet@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <printResult@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <setBit@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <isBitISet@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <printResult@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <clearBit@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <isBitISet@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1030 <printResult@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11fb <main+0x9b>
mov    0x8(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
lea    0xe94(%rip),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe95(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <isBitISet@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printResult@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1070 <setBit@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %ebx,%esi
call   1060 <isBitISet@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printResult@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <clearBit@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %ebx,%esi
call   1060 <isBitISet@plt>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printResult@plt>
jmp    120c <main+0xac>
mov    (%rbx),%rsi
lea    0xdfb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Usage: %s <number> <bit index>\0A\00"
@.str.1 = [19 x i8] c"Number: %d (0x%x)\0A\00"
@.str.2 = [19 x i8] c"Modifying bit: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 0, i32* %3
br label %57
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %6
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %26)
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = call i32 @isBitISet(i32 %30, i32 %31)
store i32 %32, i32* %8
%33 = load i32, i32* %7
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = call i32 @printResult(i32 %33, i32 %34, i32 %35)
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = call i32 @setBit(i32 %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = load i32, i32* %7
%42 = call i32 @isBitISet(i32 %40, i32 %41)
store i32 %42, i32* %8
%43 = load i32, i32* %7
%44 = load i32, i32* %6
%45 = load i32, i32* %8
%46 = call i32 @printResult(i32 %43, i32 %44, i32 %45)
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 @clearBit(i32 %47, i32 %48)
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = call i32 @isBitISet(i32 %50, i32 %51)
store i32 %52, i32* %8
%53 = load i32, i32* %7
%54 = load i32, i32* %6
%55 = load i32, i32* %8
%56 = call i32 @printResult(i32 %53, i32 %54, i32 %55)
store i32 0, i32* %3
br label %57
57: ; preds = %16, %11
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [32 x i8] c"Usage: %s <number> <bit index>\0A\00"
@.str.1 = [19 x i8] c"Number: %d (0x%x)\0A\00"
@.str.2 = [19 x i8] c"Modifying bit: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %24
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %10)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%16 = tail call i32 @isBitISet(i32 %10, i32 %13)
%17 = tail call i32 @printResult(i32 %13, i32 %10, i32 %16)
%18 = tail call i32 @setBit(i32 %10, i32 %13)
%19 = tail call i32 @isBitISet(i32 %18, i32 %13)
%20 = tail call i32 @printResult(i32 %13, i32 %18, i32 %19)
%21 = tail call i32 @clearBit(i32 %18, i32 %13)
%22 = tail call i32 @isBitISet(i32 %21, i32 %13)
%23 = tail call i32 @printResult(i32 %13, i32 %21, i32 %22)
br label %24
24: ; preds = %7, %4
ret i32 0
}