#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 /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int n, v, p;
  scanf("%d %d %d", &n, &v, &p);
  if (v < 0 && v > 1) {
    printf("v not in range");
    return -1;
  }
  if (p < 0 && p > 7) {
    printf("p not in range");
    return -1;
  }
  if (v == 1) {
    n = n | (v << p);
  } else {
    n = n & (255 & ~(1 << p));
  }
  printf("%d", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jge    1175 <main+0x55>
cmpl   $0x1,-0xc(%rbp)
jle    1175 <main+0x55>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f9 <main+0xd9>
cmpl   $0x0,-0x10(%rbp)
jge    11a3 <main+0x83>
cmpl   $0x7,-0x10(%rbp)
jle    11a3 <main+0x83>
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f9 <main+0xd9>
cmpl   $0x1,-0xc(%rbp)
jne    11c4 <main+0xa4>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    11e1 <main+0xc1>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    $0xff,%ecx
and    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%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    0x10(%rsp),%al
mov    0xc(%rsp),%ecx
mov    %ecx,%edx
btr    %eax,%edx
bts    %eax,%ecx
cmpl   $0x1,0x14(%rsp)
movzbl %dl,%esi
cmove  %ecx,%esi
mov    %esi,0xc(%rsp)
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [15 x i8] c"v not in range\00"
@.str.2 = [15 x i8] c"p not in range\00"
@.str.3 = [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 ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %40
13: ; preds = %8, %0
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 7
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %40
21: ; preds = %16, %13
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = shl i32 %26, %27
%29 = or i32 %25, %28
store i32 %29, i32* %2
br label %37
30: ; preds = %21
%31 = load i32, i32* %2
%32 = load i32, i32* %4
%33 = shl i32 1, %32
%34 = xor i32 %33, -1
%35 = and i32 255, %34
%36 = and i32 %31, %35
store i32 %36, i32* %2
br label %37
37: ; preds = %30, %24
%38 = load i32, i32* %2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %38)
store i32 0, i32* %1
br label %40
40: ; preds = %37, %19, %11
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.3 = [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 ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = icmp eq i32 %8, 1
%11 = load i32, i32* %1
%12 = shl nuw i32 1, %9
%13 = and i32 %12, 255
%14 = xor i32 %13, 255
%15 = and i32 %11, %14
%16 = or i32 %11, %12
%17 = select i1 %10, i32 %16, i32 %15
store i32 %17, i32* %1
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %17)
ret i32 0
}