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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x5(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jl     116b <main+0x3b>
cmpl   $0x7,-0x10(%rbp)
jle    1175 <main+0x45>
mov    $0x1,%edi
call   1050 <exit@plt>
cmpl   $0x1,-0xc(%rbp)
jne    1199 <main+0x69>
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
movzbl -0x5(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x5(%rbp)
jmp    11cf <main+0x9f>
cmpl   $0x0,-0xc(%rbp)
jne    11c0 <main+0x90>
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
xor    $0xffffffff,%ecx
movzbl -0x5(%rbp),%eax
and    %ecx,%eax
mov    %al,-0x5(%rbp)
jmp    11ca <main+0x9a>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11cf <main+0x9f>
lea    0xe35(%rip),%rdi
movzbl -0x5(%rbp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
lea    0xf(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x10(%rsp),%ecx
cmp    $0x8,%ecx
jae    1199 <main+0x69>
mov    0x14(%rsp),%eax
test   %eax,%eax
je     1172 <main+0x42>
cmp    $0x1,%eax
jne    1199 <main+0x69>
mov    $0x1,%eax
shl    %cl,%eax
or     0xf(%rsp),%al
jmp    117f <main+0x4f>
mov    $0x1,%eax
shl    %cl,%eax
not    %al
and    0xf(%rsp),%al
mov    %al,0xf(%rsp)
movzbl %al,%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"%hhu %d %d\00"
@.str.1 = [6 x i8] c"%hhu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %2, i32* %3, i32* %4)
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* %4
%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 i32, i32* %3
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %4
%18 = shl i32 1, %17
%19 = load i8, i8* %2
%20 = zext i8 %19 to i32
%21 = or i32 %20, %18
%22 = trunc i32 %21 to i8
store i8 %22, i8* %2
br label %37
23: ; preds = %13
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i32, i32* %4
%28 = shl i32 1, %27
%29 = xor i32 %28, -1
%30 = load i8, i8* %2
%31 = zext i8 %30 to i32
%32 = and i32 %31, %29
%33 = trunc i32 %32 to i8
store i8 %33, i8* %2
br label %36
34: ; preds = %23
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %26
br label %37
37: ; preds = %36, %16
%38 = load i8, i8* %2
%39 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"%hhu %d %d\00"
@.str.1 = [6 x i8] c"%hhu\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1, i32* %2, i32* %3)
%7 = load i32, i32* %3
%8 = icmp ugt i32 %7, 7
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
switch i32 %12, label %24 [
i32 1, label %13
i32 0, label %18
]
13: ; preds = %11
%14 = shl nuw nsw i32 1, %7
%15 = load i8, i8* %1
%16 = trunc i32 %14 to i8
%17 = or i8 %15, %16
br label %26
18: ; preds = %11
%19 = shl nuw nsw i32 1, %7
%20 = load i8, i8* %1
%21 = trunc i32 %19 to i8
%22 = xor i8 %21, -1
%23 = and i8 %20, %22
br label %26
24: ; preds = %11
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %18, %13
%27 = phi i8 [ %23, %18 ], [ %17, %13 ]
store i8 %27, i8* %1
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %27)
ret i32 0
}