#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, v, p;
  scanf("%d", &n);
  do {
    scanf("%d", &v);
  } while (v != 0 && v != 1);
  do {
    scanf("%d", &p);
  } while (p < 0 || p > 7);
  if (v == 1)
    printf("%d\n", n | (1 << p));
  else
    printf("%d\n", n ^ (n & (1 << p)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x11(%rbp)
je     1168 <main+0x48>
cmpl   $0x1,-0xc(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113f <main+0x1f>
jmp    1178 <main+0x58>
lea    0xe81(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x12(%rbp)
jl     11a1 <main+0x81>
cmpl   $0x7,-0x10(%rbp)
setg   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1178 <main+0x58>
cmpl   $0x1,-0xc(%rbp)
jne    11d6 <main+0xb6>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     %eax,%esi
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
jmp    11f8 <main+0xd8>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
xor    %eax,%esi
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xed2(%rip),%r14
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0xc(%rsp)
ja     1140 <main+0x20>
lea    0xea7(%rip),%r14
lea    0x10(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    $0x7,%eax
ja     1160 <main+0x40>
mov    0x14(%rsp),%esi
mov    %esi,%ecx
btr    %eax,%ecx
bts    %eax,%esi
cmpl   $0x1,0xc(%rsp)
cmovne %ecx,%esi
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %14, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %8
8: ; preds = %6
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 1
br label %14
14: ; preds = %11, %8
%15 = phi i1 [ false, %8 ], [ %13, %11 ]
br i1 %15, label %6, label %16
16: ; preds = %14
br label %17
17: ; preds = %25, %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %19
19: ; preds = %17
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 7
br label %25
25: ; preds = %22, %19
%26 = phi i1 [ true, %19 ], [ %24, %22 ]
br i1 %26, label %17, label %27
27: ; preds = %25
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i32, i32* %2
%32 = load i32, i32* %4
%33 = shl i32 1, %32
%34 = or i32 %31, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %44
36: ; preds = %27
%37 = load i32, i32* %2
%38 = load i32, i32* %2
%39 = load i32, i32* %4
%40 = shl i32 1, %39
%41 = and i32 %38, %40
%42 = xor i32 %37, %41
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %36, %30
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\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 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %8
8: ; preds = %8, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp ult i32 %10, 2
br i1 %11, label %12, label %8
12: ; preds = %8, %12
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = icmp ugt i32 %14, 7
br i1 %15, label %12, label %16
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 1
%19 = load i32, i32* %1
%20 = shl nuw nsw i32 1, %14
%21 = xor i32 %20, -1
%22 = and i32 %19, %21
%23 = or i32 %19, %20
%24 = select i1 %18, i32 %23, i32 %22
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
ret i32 0
}