#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 main() {
  int bin[8];
  int n = 0;
  int v = 0;
  int p = 0;
  int counter = 0;
  int base = 1;
  int sum = 0;
  int help = 0;
  for (counter = 0; counter <= 8; counter++) {
    bin[counter] = 0;
  }
  scanf("%d", &n);
  scanf("%d", &v);
  scanf("%d", &p);
  for (counter = 0; n != 0; counter++) {
    if (n % 2 == 0) {
      bin[counter] = 0;
    } else
      bin[counter] = 1;
    n /= 2;
  }
  bin[p] = v;
  for (counter = 0; counter <= 8; counter++) {
    help = bin[counter];
    sum = sum + help * base;
    base = base * 2;
  }
  printf("\n");
  printf("%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x1,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
jg     118b <main+0x6b>
movslq -0x40(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1167 <main+0x47>
lea    0xe6e(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe4e(%rip),%rdi
lea    -0x3c(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x40(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     1219 <main+0xf9>
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11f1 <main+0xd1>
movslq -0x40(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
jmp    11fd <main+0xdd>
movslq -0x40(%rbp),%rax
movl   $0x1,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x38(%rbp),%ecx
movslq -0x3c(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
movl   $0x0,-0x40(%rbp)
cmpl   $0x8,-0x40(%rbp)
jg     1266 <main+0x146>
movslq -0x40(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%eax
mov    -0x4c(%rbp),%ecx
imul   -0x44(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    122b <main+0x10b>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%esi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
lea    0xed7(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11c0 <main+0x90>
lea    0x10(%rsp),%rcx
nopl   (%rax)
mov    %eax,%edx
mov    %eax,%esi
and    $0x1,%esi
mov    %esi,(%rcx)
shr    $0x1f,%eax
add    %edx,%eax
sar    %eax
add    $0x1,%edx
add    $0x4,%rcx
cmp    $0x2,%edx
ja     11a0 <main+0x70>
mov    %eax,0x4(%rsp)
mov    0xc(%rsp),%eax
movslq 0x8(%rsp),%rcx
mov    %eax,0x10(%rsp,%rcx,4)
movdqu 0x14(%rsp),%xmm0
movdqu 0x24(%rsp),%xmm1
movdqa 0xe1f(%rip),%xmm2
pmuludq %xmm1,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pshufd $0xf5,%xmm1,%xmm1
pmuludq 0xe19(%rip),%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm2
pshufd $0xf5,%xmm0,%xmm1
pmuludq 0xe13(%rip),%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq 0xe16(%rip),%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
paddd  %xmm2,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%ebx
add    0x10(%rsp),%ebx
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdf1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %6
br label %10
10: ; preds = %17, %0
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 8
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %10
20: ; preds = %10
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
store i32 0, i32* %6
br label %24
24: ; preds = %42, %20
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %45
27: ; preds = %24
%28 = load i32, i32* %3
%29 = srem i32 %28, 2
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %33
store i32 0, i32* %34
br label %39
35: ; preds = %27
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %37
store i32 1, i32* %38
br label %39
39: ; preds = %35, %31
%40 = load i32, i32* %3
%41 = sdiv i32 %40, 2
store i32 %41, i32* %3
br label %42
42: ; preds = %39
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %24
45: ; preds = %24
%46 = load i32, i32* %4
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %48
store i32 %46, i32* %49
store i32 0, i32* %6
br label %50
50: ; preds = %65, %45
%51 = load i32, i32* %6
%52 = icmp sle i32 %51, 8
br i1 %52, label %53, label %68
53: ; preds = %50
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
store i32 %57, i32* %9
%58 = load i32, i32* %8
%59 = load i32, i32* %9
%60 = load i32, i32* %7
%61 = mul nsw i32 %59, %60
%62 = add nsw i32 %58, %61
store i32 %62, i32* %8
%63 = load i32, i32* %7
%64 = mul nsw i32 %63, 2
store i32 %64, i32* %7
br label %65
65: ; preds = %53
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
br label %50
68: ; preds = %50
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%70 = load i32, i32* %8
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %70)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%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* %4)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %24, label %14
14: ; preds = %0, %14
%15 = phi i64 [ %20, %14 ], [ 0, %0 ]
%16 = phi i32 [ %19, %14 ], [ %12, %0 ]
%17 = and i32 %16, 1
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %15
store i32 %17, i32* %18
%19 = sdiv i32 %16, 2
%20 = add nuw i64 %15, 1
%21 = add i32 %16, 1
%22 = icmp ult i32 %21, 3
br i1 %22, label %23, label %14
23: ; preds = %14
store i32 %19, i32* %3
br label %24
24: ; preds = %23, %0
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 %27
store i32 %25, i32* %28
%29 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%32 = bitcast i32* %31 to <8 x i32>*
%33 = load <8 x i32>, <8 x i32>* %32
%34 = shl nsw <8 x i32> %33, <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>
%35 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %34)
%36 = add nsw i32 %35, %30
%37 = call i32 @putchar(i32 10)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
ret i32 0
}