#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, bit;
  printf("Enter an unsingne integer in Hex format\n");
  scanf("%x", &val);
  printf("Enter a bit number\n");
  scanf("%d", &bitNum);
  val = val >> bitNum;
  bit = val & 0x1;
  printf("bit = %x\n", bit);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    %cl,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%cl
shr    %cl,%esi
mov    %esi,(%rsp)
and    $0x1,%esi
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter an unsingne 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 = [10 x i8] c"bit = %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = lshr i32 %8, %9
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = and i32 %11, 1
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%x\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [10 x i8] c"bit = %x\0A\00"
@str = [40 x i8] c"Enter an unsingne integer in Hex format\00"
@str.5 = [19 x i8] c"Enter a bit number\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = lshr i32 %9, %10
store i32 %11, i32* %1
%12 = and i32 %11, 1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %12)
ret i32 0
}