#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*/ printTheDebugOutput(unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main() {
  unsigned int bit_position, setOrUnsetBit, ch;
  unsigned char bit_Map_array_index, shift_index;
  unsigned char bit_map[2] = {0};
  do {
    printf("Enter the Bit position (bit starts from 1 and Ends at 16) \n");
    scanf("%d", &bit_position);
    printf(" Do you want to set/unset the Bit (1 or 0) \n");
    scanf("%d", &setOrUnsetBit);
    bit_Map_array_index = (bit_position - 1) / 8;
    shift_index = (bit_position - 1) % 8;
    printf("The bit_position : %d shift Index : %d\n", bit_position,
           shift_index);
    if (setOrUnsetBit) {
      bit_map[bit_Map_array_index] |= 1 << shift_index;
    } else {
      bit_map[bit_Map_array_index] &= ~(1 << shift_index);
    }
    printf(" The Bit MAP Array : %d\n", bit_map[bit_Map_array_index]);
    printTheDebugOutput(bit_map);
    printf(" Do You want to Continue then Enter any Number"
           "and for Exit then enter 100\n");
    scanf("%d", &ch);
  } while (ch != 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <memset@plt>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
shr    $0x3,%eax
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
and    $0x7,%eax
mov    %al,-0x12(%rbp)
mov    -0x8(%rbp),%esi
movzbl -0x12(%rbp),%edx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11f1 <main+0xb1>
movzbl -0x12(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
movzbl -0x11(%rbp),%eax
movzbl -0x14(%rbp,%rax,1),%ecx
or     %edx,%ecx
mov    %cl,-0x14(%rbp,%rax,1)
jmp    120e <main+0xce>
movzbl -0x12(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
xor    $0xffffffff,%edx
movzbl -0x11(%rbp),%eax
movzbl -0x14(%rbp,%rax,1),%ecx
and    %edx,%ecx
mov    %cl,-0x14(%rbp,%rax,1)
movzbl -0x11(%rbp),%eax
movzbl -0x14(%rbp,%rax,1),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1060 <printTheDebugOutput@plt>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf9(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x64,-0x10(%rbp)
jne    115f <main+0x1f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movw   $0x0,0xa(%rsp)
lea    0xea4(%rip),%r15
lea    0xf48(%rip),%r12
lea    0xc(%rsp),%r13
nopl   0x0(%rax,%rax,1)
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
lea    0x14(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%esi
lea    -0x1(%rsi),%ebp
mov    %ebp,%r14d
shr    $0x3,%r14d
and    $0x7,%ebp
lea    0xe49(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
mov    %ebp,%ecx
shl    %cl,%eax
movzbl %r14b,%ecx
movzbl 0xa(%rsp,%rcx,1),%edx
mov    %eax,%ebx
not    %bl
and    %dl,%bl
or     %al,%dl
cmpl   $0x0,0x10(%rsp)
movzbl %bl,%eax
movzbl %dl,%edx
cmove  %eax,%edx
mov    %dl,0xa(%rsp,%rcx,1)
movzbl %dl,%esi
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xa(%rsp),%rdi
call   1060 <printTheDebugOutput@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmpl   $0x64,0xc(%rsp)
jne    1170 <main+0x30>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [60 x i8] c"Enter the Bit position (bit starts from 1 and Ends at 16) \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c" Do you want to set/unset the Bit (1 or 0) \0A\00"
@.str.3 = [40 x i8] c"The bit_position : %d shift Index : %d\0A\00"
@.str.4 = [25 x i8] c" The Bit MAP Array : %d\0A\00"
@.str.5 = [75 x i8] c" Do You want to Continue then Enter any Numberand for Exit then enter 100\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
%7 = alloca [2 x i8]
store i32 0, i32* %1
%8 = bitcast [2 x i8]* %7 to i8*
br label %9
9: ; preds = %62, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %2
%15 = sub i32 %14, 1
%16 = udiv i32 %15, 8
%17 = trunc i32 %16 to i8
store i8 %17, i8* %5
%18 = load i32, i32* %2
%19 = sub i32 %18, 1
%20 = urem i32 %19, 8
%21 = trunc i32 %20 to i8
store i8 %21, i8* %6
%22 = load i32, i32* %2
%23 = load i8, i8* %6
%24 = zext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %24)
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %39
28: ; preds = %9
%29 = load i8, i8* %6
%30 = zext i8 %29 to i32
%31 = shl i32 1, %30
%32 = load i8, i8* %5
%33 = zext i8 %32 to i64
%34 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = or i32 %36, %31
%38 = trunc i32 %37 to i8
store i8 %38, i8* %34
br label %51
39: ; preds = %9
%40 = load i8, i8* %6
%41 = zext i8 %40 to i32
%42 = shl i32 1, %41
%43 = xor i32 %42, -1
%44 = load i8, i8* %5
%45 = zext i8 %44 to i64
%46 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = and i32 %48, %43
%50 = trunc i32 %49 to i8
store i8 %50, i8* %46
br label %51
51: ; preds = %39, %28
%52 = load i8, i8* %5
%53 = zext i8 %52 to i64
%54 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%59 = call i32 @printTheDebugOutput(i8* %58)
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.5, i64 0, i64 0))
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
br label %62
62: ; preds = %51
%63 = load i32, i32* %4
%64 = icmp ne i32 %63, 100
br i1 %64, label %9, label %65
65: ; preds = %62
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [40 x i8] c"The bit_position : %d shift Index : %d\0A\00"
@.str.4 = [25 x i8] c" The Bit MAP Array : %d\0A\00"
@str = [59 x i8] c"Enter the Bit position (bit starts from 1 and Ends at 16) \00"
@str.6 = [44 x i8] c" Do you want to set/unset the Bit (1 or 0) \00"
@str.7 = [74 x i8] c" Do You want to Continue then Enter any Numberand for Exit then enter 100\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i16
%5 = bitcast i16* %4 to [2 x i8]*
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i16* %4 to i8*
store i16 0, i16* %4
br label %10
10: ; preds = %10, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.6, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %1
%16 = add i32 %15, -1
%17 = lshr i32 %16, 3
%18 = and i32 %16, 7
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %18)
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
%22 = shl nuw nsw i32 1, %18
%23 = and i32 %17, 255
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = trunc i32 %22 to i8
%28 = xor i8 %27, -1
%29 = and i8 %26, %28
%30 = or i8 %26, %27
%31 = select i1 %21, i8 %29, i8 %30
store i8 %31, i8* %25
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = call i32 @printTheDebugOutput(i8* %9)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.7, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 100
br i1 %38, label %39, label %10
39: ; preds = %10
ret i32 0
}