#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*/ clearbit(int);
int /*<<< orphan*/ compbit(int);
int getchar();
int /*<<< orphan*/ print(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reversebit(int);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ setbit(int);
int /*<<< orphan*/ testbit(int);
main() {
  int data;
  char choice;
  while (1) {
    printf("MENU:\nI/i:Input again\nT/t:Test the bit\nS/s:Set the "
           "bit\nC/c:clear the bit\nM/m:Compliment the bit\n:R/r:Reverse the "
           "bits\nP/p:Print data\nQ/q:Quit\n");
    scanf("%c", &choice);
    choice |= (1 << 5);
    switch (choice) {
    Input:
    case 'i':
      printf("Enter the data:\n");
      scanf("%d", &data);
      if (data == 0) {
        printf("Invalid data!!\n");
        goto Input;
      }
      printf("The data entered is:%d\n", data);
      break;
    case 't':
      testbit(data);
      break;
    case 's':
      setbit(data);
      break;
    case 'c':
      clearbit(data);
      break;
    case 'm':
      compbit(data);
      break;
    case 'r':
      reversebit(data);
      break;
    case 'p':
      print(data);
      break;
    case 'q':
      return 0;
      break;
    }
    while (getchar() != 10)
      ;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf1d(%rip),%rdi
lea    -0x9(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x9(%rbp),%al
or     $0x20,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffff9d,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x11,%eax
ja     12a3 <main+0x113>
mov    -0x18(%rbp),%rax
lea    0xe14(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    11fa <main+0x6a>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   10a0 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1237 <main+0xa7>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f5 <main+0x65>
mov    -0x8(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a3 <main+0x113>
mov    -0x8(%rbp),%edi
call   1060 <testbit@plt>
jmp    12a3 <main+0x113>
mov    -0x8(%rbp),%edi
call   1090 <setbit@plt>
jmp    12a3 <main+0x113>
mov    -0x8(%rbp),%edi
call   1040 <clearbit@plt>
jmp    12a3 <main+0x113>
mov    -0x8(%rbp),%edi
call   1080 <compbit@plt>
jmp    12a3 <main+0x113>
mov    -0x8(%rbp),%edi
call   10b0 <reversebit@plt>
jmp    12a3 <main+0x113>
mov    -0x8(%rbp),%edi
call   1050 <print@plt>
jmp    12a3 <main+0x113>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    12a8 <main+0x118>
mov    $0x0,%al
call   1070 <getchar@plt>
cmp    $0xa,%eax
je     12bd <main+0x12d>
jmp    12a8 <main+0x118>
jmp    119f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x3(%rsp),%r12
lea    0xe49(%rip),%r15
lea    0xf36(%rip),%r13
lea    0xe86(%rip),%rbx
lea    0x4(%rsp),%rbp
lea    0xf33(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe55(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
movsbl 0x3(%rsp),%eax
or     $0x20,%eax
mov    %al,0x3(%rsp)
add    $0xffffff9d,%eax
cmp    $0x11,%eax
ja     12a0 <main+0x100>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
mov    0x4(%rsp),%edi
call   1050 <clearbit@plt>
jmp    12a0 <main+0x100>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1230 <main+0x90>
lea    0xdf2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12a0 <main+0x100>
mov    0x4(%rsp),%edi
call   1090 <compbit@plt>
jmp    12a0 <main+0x100>
mov    0x4(%rsp),%edi
call   1060 <print@plt>
jmp    12a0 <main+0x100>
mov    0x4(%rsp),%edi
call   10c0 <reversebit@plt>
jmp    12a0 <main+0x100>
mov    0x4(%rsp),%edi
call   10a0 <setbit@plt>
jmp    12a0 <main+0x100>
mov    0x4(%rsp),%edi
call   1070 <testbit@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <getchar@plt>
cmp    $0xa,%eax
jne    12a0 <main+0x100>
jmp    11e0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [143 x i8] c"MENU:\0AI/i:Input again\0AT/t:Test the bit\0AS/s:Set the bit\0AC/c:clear the bit\0AM/m:Compliment the bit\0A:R/r:Reverse the bits\0AP/p:Print data\0AQ/q:Quit\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [17 x i8] c"Enter the data:\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [16 x i8] c"Invalid data!!\0A\00"
@.str.5 = [24 x i8] c"The data entered is:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
br label %4
4: ; preds = %0, %48
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = load i8, i8* %3
%8 = sext i8 %7 to i32
%9 = or i32 %8, 32
%10 = trunc i32 %9 to i8
store i8 %10, i8* %3
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
switch i32 %12, label %43 [
i32 105, label %14
i32 116, label %24
i32 115, label %27
i32 99, label %30
i32 109, label %33
i32 114, label %36
i32 112, label %39
i32 113, label %42
]
13: ; preds = %19
br label %14
14: ; preds = %4, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %13
21: ; preds = %14
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %43
24: ; preds = %4
%25 = load i32, i32* %2
%26 = call i32 @testbit(i32 %25)
br label %43
27: ; preds = %4
%28 = load i32, i32* %2
%29 = call i32 @setbit(i32 %28)
br label %43
30: ; preds = %4
%31 = load i32, i32* %2
%32 = call i32 @clearbit(i32 %31)
br label %43
33: ; preds = %4
%34 = load i32, i32* %2
%35 = call i32 @compbit(i32 %34)
br label %43
36: ; preds = %4
%37 = load i32, i32* %2
%38 = call i32 @reversebit(i32 %37)
br label %43
39: ; preds = %4
%40 = load i32, i32* %2
%41 = call i32 @print(i32 %40)
br label %43
42: ; preds = %4
ret i32 0
43: ; preds = %4, %39, %36, %33, %30, %27, %24, %21
br label %44
44: ; preds = %47, %43
%45 = call i32 (...) @getchar()
%46 = icmp ne i32 %45, 10
br i1 %46, label %47, label %48
47: ; preds = %44
br label %44
48: ; preds = %44
br label %4
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"The data entered is:%d\0A\00"
@str = [142 x i8] c"MENU:\0AI/i:Input again\0AT/t:Test the bit\0AS/s:Set the bit\0AC/c:clear the bit\0AM/m:Compliment the bit\0A:R/r:Reverse the bits\0AP/p:Print data\0AQ/q:Quit\00"
@str.6 = [16 x i8] c"Enter the data:\00"
@str.7 = [15 x i8] c"Invalid data!!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
br label %4
4: ; preds = %44, %0
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([142 x i8], [142 x i8]* @str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = load i8, i8* %2
%8 = or i8 %7, 32
store i8 %8, i8* %2
%9 = sext i8 %8 to i32
switch i32 %9, label %24 [
i32 105, label %10
i32 116, label %25
i32 115, label %28
i32 99, label %31
i32 109, label %34
i32 114, label %37
i32 112, label %40
i32 113, label %43
]
10: ; preds = %4
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10, %15
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 0
br i1 %20, label %15, label %21
21: ; preds = %15, %10
%22 = phi i32 [ %13, %10 ], [ %19, %15 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %4, %40, %37, %34, %31, %28, %25, %21
br label %44
25: ; preds = %4
%26 = load i32, i32* %1
%27 = call i32 @testbit(i32 %26)
br label %24
28: ; preds = %4
%29 = load i32, i32* %1
%30 = call i32 @setbit(i32 %29)
br label %24
31: ; preds = %4
%32 = load i32, i32* %1
%33 = call i32 @clearbit(i32 %32)
br label %24
34: ; preds = %4
%35 = load i32, i32* %1
%36 = call i32 @compbit(i32 %35)
br label %24
37: ; preds = %4
%38 = load i32, i32* %1
%39 = call i32 @reversebit(i32 %38)
br label %24
40: ; preds = %4
%41 = load i32, i32* %1
%42 = call i32 @print(i32 %41)
br label %24
43: ; preds = %4
ret i32 0
44: ; preds = %24, %44
%45 = call i32 (...) @getchar()
%46 = icmp eq i32 %45, 10
br i1 %46, label %4, label %44
}