#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 clear_bit(unsigned int *, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int set_bit(unsigned int *, unsigned int);
int toggle_bit(unsigned int *, unsigned int);
int main(int argc, char **argv) {
  unsigned int x, operation, bit;
  int value;
  printf("Enter the integer value: ");
  scanf("%d", &x);
  printf("Enter the operation you want to perform:\n\t1. Set nth bit\n\t2. "
         "Clear nth bit\n\t3. Toggle nth bit\n");
  scanf("%d", &operation);
  printf(
      "Enter the bit position where you want to perform the operation[0-7]: ");
  scanf("%d", &bit);
  if (operation == 1) {
    printf("Performing set operation on %dth bit...\n", bit);
    value = set_bit(&x, bit);
    printf("The integer value after set operation on %dth bit is: %d\n", bit,
           value);
  } else if (operation == 2) {
    printf("Performing clear operation on %dth bit...\n", bit);
    value = clear_bit(&x, bit);
    printf("The integer value after clear operation on %dth bit is: %d\n", bit,
           value);
  } else if (operation == 3) {
    printf("Performing toggle operation on %dth bit...\n", bit);
    value = toggle_bit(&x, bit);
    printf("The integer value after toggle operation on %dth bit is: %d\n", bit,
           value);
  } else
    printf(
        "Invalid operation. Please run the program again with proper input.\n");
  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)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <scanf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe63(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1203 <main+0xb3>
mov    -0x1c(%rbp),%esi
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    -0x14(%rbp),%rdi
call   1050 <set_bit@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a1 <main+0x151>
cmpl   $0x2,-0x18(%rbp)
jne    1246 <main+0xf6>
mov    -0x1c(%rbp),%esi
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    -0x14(%rbp),%rdi
call   1040 <clear_bit@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xf16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129c <main+0x14c>
cmpl   $0x3,-0x18(%rbp)
jne    1289 <main+0x139>
mov    -0x1c(%rbp),%esi
lea    0xf32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    -0x14(%rbp),%rdi
call   1060 <toggle_bit@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xf3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1297 <main+0x147>
lea    0xf65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129c <main+0x14c>
jmp    12a1 <main+0x151>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea0(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0x1008(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     11ff <main+0x9f>
cmp    $0x2,%eax
je     122c <main+0xcc>
cmp    $0x1,%eax
jne    1262 <main+0x102>
mov    0x4(%rsp),%esi
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0x8(%rsp),%rdi
call   1060 <set_bit@plt>
mov    0x4(%rsp),%esi
lea    0xe8f(%rip),%rdi
jmp    1257 <main+0xf7>
mov    0x4(%rsp),%esi
lea    0xf23(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0x8(%rsp),%rdi
call   1070 <toggle_bit@plt>
mov    0x4(%rsp),%esi
lea    0xf2f(%rip),%rdi
jmp    1257 <main+0xf7>
mov    0x4(%rsp),%esi
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0x8(%rsp),%rdi
call   1050 <clear_bit@plt>
mov    0x4(%rsp),%esi
lea    0xe9a(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    126e <main+0x10e>
lea    0xf8b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Enter the integer value: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [95 x i8] c"Enter the operation you want to perform:\0A\091. Set nth bit\0A\092. Clear nth bit\0A\093. Toggle nth bit\0A\00"
@.str.3 = [70 x i8] c"Enter the bit position where you want to perform the operation[0-7]: \00"
@.str.4 = [41 x i8] c"Performing set operation on %dth bit...\0A\00"
@.str.5 = [58 x i8] c"The integer value after set operation on %dth bit is: %d\0A\00"
@.str.6 = [43 x i8] c"Performing clear operation on %dth bit...\0A\00"
@.str.7 = [60 x i8] c"The integer value after clear operation on %dth bit is: %d\0A\00"
@.str.8 = [44 x i8] c"Performing toggle operation on %dth bit...\0A\00"
@.str.9 = [61 x i8] c"The integer value after toggle operation on %dth bit is: %d\0A\00"
@.str.10 = [68 x i8] c"Invalid operation. Please run the program again with proper input.\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
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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* %6)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 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* %7)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%16 = load i32, i32* %7
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i32, i32* %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %8
%22 = call i32 @set_bit(i32* %6, i32 %21)
store i32 %22, i32* %9
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %23, i32 %24)
br label %52
26: ; preds = %2
%27 = load i32, i32* %7
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %8
%33 = call i32 @clear_bit(i32* %6, i32 %32)
store i32 %33, i32* %9
%34 = load i32, i32* %8
%35 = load i32, i32* %9
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i32 %34, i32 %35)
br label %51
37: ; preds = %26
%38 = load i32, i32* %7
%39 = icmp eq i32 %38, 3
br i1 %39, label %40, label %48
40: ; preds = %37
%41 = load i32, i32* %8
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %8
%44 = call i32 @toggle_bit(i32* %6, i32 %43)
store i32 %44, i32* %9
%45 = load i32, i32* %8
%46 = load i32, i32* %9
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0), i32 %45, i32 %46)
br label %50
48: ; preds = %37
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.10, i64 0, i64 0))
br label %50
50: ; preds = %48, %40
br label %51
51: ; preds = %50, %29
br label %52
52: ; preds = %51, %18
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Enter the integer value: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [70 x i8] c"Enter the bit position where you want to perform the operation[0-7]: \00"
@.str.4 = [41 x i8] c"Performing set operation on %dth bit...\0A\00"
@.str.5 = [58 x i8] c"The integer value after set operation on %dth bit is: %d\0A\00"
@.str.6 = [43 x i8] c"Performing clear operation on %dth bit...\0A\00"
@.str.7 = [60 x i8] c"The integer value after clear operation on %dth bit is: %d\0A\00"
@.str.8 = [44 x i8] c"Performing toggle operation on %dth bit...\0A\00"
@.str.9 = [61 x i8] c"The integer value after toggle operation on %dth bit is: %d\0A\00"
@str = [94 x i8] c"Enter the operation you want to perform:\0A\091. Set nth bit\0A\092. Clear nth bit\0A\093. Toggle nth bit\00"
@str.11 = [67 x i8] c"Invalid operation. Please run the program again with proper input.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([94 x i8], [94 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* %4)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%15 = load i32, i32* %4
switch i32 %15, label %37 [
i32 1, label %16
i32 2, label %23
i32 3, label %30
]
16: ; preds = %2
%17 = load i32, i32* %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = call i32 @set_bit(i32* %3, i32 %19)
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i32 %21, i32 %20)
br label %39
23: ; preds = %2
%24 = load i32, i32* %5
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %5
%27 = call i32 @clear_bit(i32* %3, i32 %26)
%28 = load i32, i32* %5
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.7, i64 0, i64 0), i32 %28, i32 %27)
br label %39
30: ; preds = %2
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %5
%34 = call i32 @toggle_bit(i32* %3, i32 %33)
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0), i32 %35, i32 %34)
br label %39
37: ; preds = %2
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.11, i64 0, i64 0))
br label %39
39: ; preds = %23, %37, %30, %16
ret i32 0
}