#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*/ convert(int, int *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, n, v, p;
  int bin[8] = {-1};
  for (i = 0; i < 8; i++) {
    bin[i] = (0);
  }
  scanf("%d", &n);
  do {
    scanf("%d", &v);
  } while (v != 1 && v != 0);
  do {
    scanf("%d", &p);
  } while (p < 0 || p > 7);
  convert(n, bin, v, p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1186 <main+0x66>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x42>
lea    0xe93(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe83(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x41(%rbp)
je     11bf <main+0x9f>
cmpl   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    1196 <main+0x76>
jmp    11cf <main+0xaf>
lea    0xe4a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x42(%rbp)
jl     11f8 <main+0xd8>
cmpl   $0x7,-0x14(%rbp)
setg   %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
test   $0x1,%al
jne    11cf <main+0xaf>
mov    -0xc(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <convert@plt>
xor    %eax,%eax
add    $0x50,%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    0xec5(%rip),%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
ja     1150 <main+0x30>
lea    0xe97(%rip),%r14
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%ecx
cmp    $0x7,%ecx
ja     1170 <main+0x50>
mov    0xc(%rsp),%edi
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
call   1030 <convert@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.bin = [8 x i32] [i32 -1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
@.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
%6 = alloca [8 x i32]
store i32 0, i32* %1
%7 = bitcast [8 x i32]* %6 to i8*
store i32 0, i32* %2
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %13
store i32 0, i32* %14
br label %15
15: ; preds = %11
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %8
18: ; preds = %8
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %20
20: ; preds = %28, %18
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
br label %22
22: ; preds = %20
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %25, %22
%29 = phi i1 [ false, %22 ], [ %27, %25 ]
br i1 %29, label %20, label %30
30: ; preds = %28
br label %31
31: ; preds = %39, %30
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
br label %33
33: ; preds = %31
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i32, i32* %5
%38 = icmp sgt i32 %37, 7
br label %39
39: ; preds = %36, %33
%40 = phi i1 [ true, %33 ], [ %38, %36 ]
br i1 %40, label %31, label %41
41: ; preds = %39
%42 = load i32, i32* %3
%43 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
%44 = load i32, i32* %4
%45 = load i32, i32* %5
%46 = call i32 @convert(i32 %42, i32* %43, i32 %44, i32 %45)
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 = alloca [8 x i32]
%5 = bitcast [8 x i32]* %4 to i8*
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 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 ult i32 %12, 2
br i1 %13, label %14, label %10
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 = load i32, i32* %2
%22 = call i32 @convert(i32 %19, i32* %20, i32 %21, i32 %16)
ret i32 0
}