#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 binarysearch(int *, int, int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num_int, A[65536], num_search, search;
  int i, low, high;
  scanf("%d", &num_int);
  for (i = 0; i < num_int; i++) {
    scanf("%d", &A[i]);
  }
  low = 0;
  high = num_int - 1;
  scanf("%d", &num_search);
  for (i = 0; i < num_search; i++) {
    scanf("%d", &search);
    printf("%d\n", binarysearch(A, search, low, high));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40030,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x4001c(%rbp)
mov    -0x4001c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a0 <main+0x70>
movslq -0x4001c(%rbp),%rax
lea    -0x40010(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe79(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x4001c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4001c(%rbp)
jmp    115c <main+0x2c>
movl   $0x0,-0x40020(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x40024(%rbp)
lea    0xe43(%rip),%rdi
lea    -0x40014(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x4001c(%rbp)
mov    -0x4001c(%rbp),%eax
cmp    -0x40014(%rbp),%eax
jge    1238 <main+0x108>
lea    0xe14(%rip),%rdi
lea    -0x40018(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x40010(%rbp),%rdi
mov    -0x40018(%rbp),%esi
mov    -0x40020(%rbp),%edx
mov    -0x40024(%rbp),%ecx
call   1030 <binarysearch@plt>
mov    %eax,%esi
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4001c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4001c(%rbp)
jmp    11d3 <main+0xa3>
xor    %eax,%eax
add    $0x40030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40018,%rsp
lea    0xeb8(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%r15d
test   %r15d,%r15d
jle    118d <main+0x5d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe96(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%r15
add    $0x4,%rbx
cmp    %r15,%rbp
jl     1170 <main+0x40>
lea    0xe6c(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11ff <main+0xcf>
add    $0xffffffff,%r15d
xor    %ebx,%ebx
lea    0xe4e(%rip),%r14
lea    0xc(%rsp),%rbp
lea    0x10(%rsp),%r12
lea    0xe40(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %r12,%rdi
xor    %edx,%edx
mov    %r15d,%ecx
call   1030 <binarysearch@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
jl     11d0 <main+0xa0>
xor    %eax,%eax
add    $0x40018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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