#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*/ bin_converter(int, int *);
int dec_converter(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, v, p, bin[8] = {0, 0, 0, 0, 0, 0, 0, 0};
  scanf("%d", &n);
  do {
    scanf("%d", &v);
  } while (v < 0 || v > 1);
  do {
    scanf("%d", &p);
  } while (p < 0 || p > 7);
  bin_converter(n, bin);
  bin[7 - p] = v;
  printf("%d \n", dec_converter(bin));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe7a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x31(%rbp)
jl     11a8 <main+0x58>
cmpl   $0x1,-0xc(%rbp)
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    117f <main+0x2f>
jmp    11b8 <main+0x68>
lea    0xe41(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x32(%rbp)
jl     11e1 <main+0x91>
cmpl   $0x7,-0x10(%rbp)
setg   %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    11b8 <main+0x68>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1070 <bin_converter@plt>
mov    -0xc(%rbp),%ecx
mov    $0x7,%eax
sub    -0x10(%rbp),%eax
cltq
mov    %ecx,-0x30(%rbp,%rax,4)
lea    -0x30(%rbp),%rdi
call   1050 <dec_converter@plt>
mov    %eax,%esi
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0xea5(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x8(%rsp)
ja     1170 <main+0x30>
lea    0xe77(%rip),%r14
lea    0x4(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmpl   $0x7,0x4(%rsp)
ja     1190 <main+0x50>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <bin_converter@plt>
mov    0x8(%rsp),%eax
movslq 0x4(%rsp),%rcx
mov    $0x7,%edx
sub    %rcx,%rdx
mov    %eax,0x10(%rsp,%rdx,4)
mov    %rbx,%rdi
call   1040 <dec_converter@plt>
lea    0xe2c(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [8 x i32]
store i32 0, i32* %1
%6 = bitcast [8 x i32]* %5 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %16, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %10
10: ; preds = %8
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 1
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %8, label %18
18: ; preds = %16
br label %19
19: ; preds = %27, %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %21
21: ; preds = %19
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 7
br label %27
27: ; preds = %24, %21
%28 = phi i1 [ true, %21 ], [ %26, %24 ]
br i1 %28, label %19, label %29
29: ; preds = %27
%30 = load i32, i32* %2
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%32 = call i32 @bin_converter(i32 %30, i32* %31)
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = sub nsw i32 7, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %36
store i32 %33, i32* %37
%38 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%39 = call i32 @dec_converter(i32* %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast [8 x i32]* %4 to i8*
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %10
10: ; preds = %10, %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp ugt i32 %12, 1
br i1 %13, label %10, label %14
14: ; preds = %10, %14
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
%17 = icmp ugt i32 %16, 7
br i1 %17, label %14, label %18
18: ; preds = %14
%19 = load i32, i32* %1
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%21 = call i32 @bin_converter(i32 %19, i32* %20)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = sub nsw i32 7, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %25
store i32 %22, i32* %26
%27 = call i32 @dec_converter(i32* %20)
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
ret i32 0
}