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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jle    1164 <main+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <main+0xa3>
cmpl   $0x7,-0x10(%rbp)
jle    117a <main+0x5a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c3 <main+0xa3>
cmpl   $0x1,-0xc(%rbp)
jne    119d <main+0x7d>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <main+0x8d>
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x14(%rsp),%edx
mov    $0xffffffff,%eax
cmp    $0x1,%edx
jg     1179 <main+0x59>
mov    0x10(%rsp),%ecx
cmp    $0x7,%ecx
jg     1179 <main+0x59>
cmp    $0x1,%edx
jne    1164 <main+0x44>
mov    0xc(%rsp),%esi
bts    %ecx,%esi
jmp    116b <main+0x4b>
mov    0xc(%rsp),%esi
btc    %ecx,%esi
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

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