#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
main(void) {
  unsigned int val, bitNum, bVal, maskVal = 0x1;
  int ii;
  printf("Enter an unsingned integer in Hex format\n");
  scanf("%x", &val);
  printf("Enter a bit number\n");
  scanf("%d", &bitNum);
  printf("Enter a bit Value(0 or 1)\n");
  scanf("%d", &bVal);
  maskVal = ~(maskVal << bitNum);
  val = val & maskVal;
  val = val | (bVal << bitNum);
  printf("value = %x\n", val);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x10(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    %cl,%eax
xor    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xee2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0xc(%rsp),%cl
mov    0x8(%rsp),%esi
shl    %cl,%esi
mov    0x4(%rsp),%eax
btr    %ecx,%eax
or     %eax,%esi
mov    %esi,0x4(%rsp)
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter an unsingned integer in Hex format\0A\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [20 x i8] c"Enter a bit number\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [27 x i8] c"Enter a bit Value(0 or 1)\0A\00"
@.str.5 = [12 x i8] c"value = %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = shl i32 %12, %13
%15 = xor i32 %14, -1
store i32 %15, i32* %4
%16 = load i32, i32* %1
%17 = load i32, i32* %4
%18 = and i32 %16, %17
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = load i32, i32* %3
%21 = load i32, i32* %2
%22 = shl i32 %20, %21
%23 = or i32 %19, %22
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%x\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.5 = [12 x i8] c"value = %x\0A\00"
@str = [41 x i8] c"Enter an unsingned integer in Hex format\00"
@str.6 = [19 x i8] c"Enter a bit number\00"
@str.7 = [26 x i8] c"Enter a bit Value(0 or 1)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.7, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %2
%14 = shl nuw i32 1, %13
%15 = xor i32 %14, -1
%16 = load i32, i32* %1
%17 = and i32 %16, %15
%18 = load i32, i32* %3
%19 = shl i32 %18, %13
%20 = or i32 %19, %17
store i32 %20, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %20)
ret i32 0
}