#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 p, n, v;
  do {
    scanf("%d", &n);
    scanf("%d", &v);
    scanf("%d", &p);
  } while ((v < 0 || v > 1) || (p < 0 || p > 7));
  int mask = 1;
  mask = mask << p;
  if (v == 0) {
    mask = ~mask;
    n = n & mask;
  } else {
    n = n | mask;
  }
  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    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
jl     119c <main+0x7c>
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x15(%rbp)
jg     119c <main+0x7c>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x16(%rbp)
jl     1196 <main+0x76>
cmpl   $0x7,-0x8(%rbp)
setg   %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    112f <main+0xf>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    %cl,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11da <main+0xba>
mov    -0x14(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11e3 <main+0xc3>
mov    -0xc(%rbp),%eax
or     -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xece(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0x14(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    $0x1,%eax
ja     1150 <main+0x30>
mov    0x14(%rsp),%ecx
cmp    $0x7,%ecx
ja     1150 <main+0x30>
mov    $0x1,%esi
shl    %cl,%esi
test   %eax,%eax
je     1194 <main+0x74>
or     0xc(%rsp),%esi
jmp    119a <main+0x7a>
not    %esi
and    0xc(%rsp),%esi
mov    %esi,0xc(%rsp)
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %24, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %10
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 1
br i1 %15, label %24, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 7
br label %22
22: ; preds = %19, %16
%23 = phi i1 [ true, %16 ], [ %21, %19 ]
br label %24
24: ; preds = %22, %13, %10
%25 = phi i1 [ true, %13 ], [ true, %10 ], [ %23, %22 ]
br i1 %25, label %6, label %26
26: ; preds = %24
store i32 1, i32* %5
%27 = load i32, i32* %5
%28 = load i32, i32* %2
%29 = shl i32 %27, %28
store i32 %29, i32* %5
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %26
%33 = load i32, i32* %5
%34 = xor i32 %33, -1
store i32 %34, i32* %5
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = and i32 %35, %36
store i32 %37, i32* %3
br label %42
38: ; preds = %26
%39 = load i32, i32* %3
%40 = load i32, i32* %5
%41 = or i32 %39, %40
store i32 %41, i32* %3
br label %42
42: ; preds = %38, %32
%43 = load i32, i32* %3
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %43)
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*
br label %7
7: ; preds = %7, %0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %3
%12 = icmp ugt i32 %11, 1
%13 = load i32, i32* %1
%14 = icmp ugt i32 %13, 7
%15 = select i1 %12, i1 true, i1 %14
br i1 %15, label %7, label %16
16: ; preds = %7
%17 = shl nuw nsw i32 1, %13
%18 = icmp eq i32 %11, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = xor i32 %17, -1
%21 = load i32, i32* %2
%22 = and i32 %21, %20
br label %26
23: ; preds = %16
%24 = load i32, i32* %2
%25 = or i32 %24, %17
br label %26
26: ; preds = %23, %19
%27 = phi i32 [ %25, %23 ], [ %22, %19 ]
store i32 %27, i32* %2
%28 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}