#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 ((n >> p) == 0 && v == 1)
    n = n + (1 << p);
  if ((n >> p) == 1 && v == 0)
    n = n - (1 << p);
  printf("%d", n);
  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>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    %cl,%eax
cmp    $0x0,%eax
jne    11db <main+0xbb>
cmpl   $0x1,-0xc(%rbp)
jne    11db <main+0xbb>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    %cl,%eax
cmp    $0x1,%eax
jne    120a <main+0xea>
cmpl   $0x0,-0xc(%rbp)
jne    120a <main+0xea>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdec(%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    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0x10(%rsp)
ja     1140 <main+0x20>
lea    0xea7(%rip),%r14
lea    0x14(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x14(%rsp),%ecx
cmp    $0x7,%ecx
ja     1160 <main+0x40>
mov    0xc(%rsp),%esi
mov    %esi,%eax
sar    %cl,%eax
mov    0x10(%rsp),%edx
test   %eax,%eax
jne    1190 <main+0x70>
cmp    $0x1,%edx
jne    1190 <main+0x70>
mov    $0x1,%eax
jmp    119e <main+0x7e>
cmp    $0x1,%eax
jne    11a6 <main+0x86>
test   %edx,%edx
jne    11a6 <main+0x86>
mov    $0xffffffff,%eax
shl    %cl,%eax
add    %eax,%esi
mov    %esi,0xc(%rsp)
lea    0xe53(%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"
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* %2
%29 = load i32, i32* %4
%30 = ashr i32 %28, %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %27
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i32, i32* %2
%37 = load i32, i32* %4
%38 = shl i32 1, %37
%39 = add nsw i32 %36, %38
store i32 %39, i32* %2
br label %40
40: ; preds = %35, %32, %27
%41 = load i32, i32* %2
%42 = load i32, i32* %4
%43 = ashr i32 %41, %42
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %53
45: ; preds = %40
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = load i32, i32* %2
%50 = load i32, i32* %4
%51 = shl i32 1, %50
%52 = sub nsw i32 %49, %51
store i32 %52, i32* %2
br label %53
53: ; preds = %48, %45, %40
%54 = load i32, i32* %2
%55 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %54)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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* %1
%18 = ashr i32 %17, %14
%19 = icmp eq i32 %18, 0
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 1
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = shl nuw nsw i32 1, %14
%25 = add nsw i32 %17, %24
store i32 %25, i32* %1
br label %33
26: ; preds = %16
%27 = icmp eq i32 %18, 1
%28 = icmp eq i32 %20, 0
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = shl nsw i32 -1, %14
%32 = add i32 %17, %31
store i32 %32, i32* %1
br label %33
33: ; preds = %23, %30, %26
%34 = phi i32 [ %25, %23 ], [ %32, %30 ], [ %17, %26 ]
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %34)
ret i32 0
}