#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*/ exit(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, char *);
int main() {
  int position;
  signed char number;
  scanf("%d %hhd", &position, &number);
  if ((position < 0) || (position > 7)) {
    exit(1);
  }
  int bit = (number & ((unsigned char)1 << position)) >> position;
  printf("%d\n", bit);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x9(%rbp),%rdx
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1167 <main+0x37>
cmpl   $0x7,-0x8(%rbp)
jle    1171 <main+0x41>
mov    $0x1,%edi
call   1050 <exit@plt>
movsbl -0x9(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
mov    -0x8(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x3(%rsp),%rdx
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x8,%ecx
jae    1170 <main+0x40>
movsbl 0x3(%rsp),%eax
mov    $0x1,%esi
shl    %cl,%esi
and    %eax,%esi
shr    %cl,%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%d %hhd\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %2, i8* %3)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 7
br i1 %10, label %11, label %13
11: ; preds = %8, %0
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %8
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = load i32, i32* %2
%17 = shl i32 1, %16
%18 = and i32 %15, %17
%19 = load i32, i32* %2
%20 = ashr i32 %18, %19
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d %hhd\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %1, i8* %2)
%5 = load i32, i32* %1
%6 = icmp ugt i32 %5, 7
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = shl nuw nsw i32 1, %5
%13 = and i32 %12, %11
%14 = lshr i32 %13, %5
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
ret i32 0
}