#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 binSearch(char **, char *, int /*<<< orphan*/, int);
void *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  char **a;
  char str[100];
  int n, i, k;
  scanf("%d", &n);
  a = malloc(sizeof(char *) * n);
  for (i = 0; i < n; i++) {
    a[i] = malloc(sizeof(char) * 100);
    scanf("%s", a[i]);
  }
  scanf("%d", &k);
  while (k > 0) {
    scanf("%s", str);
    printf("%d\n", binSearch(a, str, 0, n));
    scanf("%d", &k);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x84(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
movslq -0x84(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x84(%rbp),%eax
jge    11e6 <main+0xa6>
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1187 <main+0x47>
lea    0xe13(%rip),%rdi
lea    -0x8c(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x0,-0x8c(%rbp)
jle    1257 <main+0x117>
lea    -0x80(%rbp),%rsi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x84(%rbp),%ecx
xor    %edx,%edx
call   1040 <binSearch@plt>
mov    %eax,%esi
lea    0xdce(%rip),%rdi
call   1030 <printf@plt>
lea    0xdbc(%rip),%rdi
lea    -0x8c(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
jmp    11fb <main+0xbb>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebp
lea    0x0(,%rbp,8),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11b9 <main+0x79>
lea    0xe84(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rax
cmp    %rax,%rbp
jl     1190 <main+0x50>
lea    0xe40(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    123c <main+0xfc>
lea    0xe29(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe20(%rip),%r12
lea    0xe13(%rip),%r13
lea    0x8(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0xc(%rsp),%ecx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1040 <binSearch@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jg     1200 <main+0xc0>
xor    %eax,%eax
add    $0x78,%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 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8**
%3 = alloca [100 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = mul i64 8, %9
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
%13 = bitcast i8* %12 to i8**
store i8** %13, i8*** %2
store i32 0, i32* %5
br label %14
14: ; preds = %30, %0
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = call i8* @malloc(i32 100)
%20 = load i8**, i8*** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
store i8* %19, i8** %23
%24 = load i8**, i8*** %2
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %18
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %14
33: ; preds = %14
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %35
35: ; preds = %38, %33
%36 = load i32, i32* %6
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %47
38: ; preds = %35
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %39)
%41 = load i8**, i8*** %2
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%43 = load i32, i32* %4
%44 = call i32 @binSearch(i8** %41, i8* %42, i32 0, i32 %43)
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %35
47: ; preds = %35
ret i32 0
}

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