#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*/ bubble_sort_N(int *, int);
int /*<<< orphan*/ input_N(int *);
int /*<<< orphan*/ input_Q(int *);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, int *, int *);
int /*<<< orphan*/ search_Q(int *, int *, int, int, int *);
int main() {
  int N, Q, spp = 0;
  int N_array[100], Q_array[100];
  while (scanf("%d %d", &N, &Q) && (N || Q)) {
    printf("\n");
    for (int i = 0; i < N; i++) {
      input_N(&N_array[0] + i);
    }
    printf("\n");
    for (int i = 0; i < Q; i++) {
      input_Q(&Q_array[0] + i);
    }
    printf("\n");
    bubble_sort_N(&N_array[0], N);
    search_Q(&N_array[0], &Q_array[0], Q, N, &spp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xe80(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1080 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x339(%rbp)
je     11cd <main+0x6d>
mov    $0x1,%al
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x33a(%rbp)
jne    11c1 <main+0x61>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x33a(%rbp)
mov    -0x33a(%rbp),%al
mov    %al,-0x339(%rbp)
mov    -0x339(%rbp),%al
test   $0x1,%al
jne    11e0 <main+0x80>
jmp    12c3 <main+0x163>
lea    0xe1f(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x334(%rbp)
mov    -0x334(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1233 <main+0xd3>
lea    -0x1a0(%rbp),%rdi
movslq -0x334(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <input_N@plt>
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    11f6 <main+0x96>
lea    0xdcc(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x338(%rbp)
mov    -0x338(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1286 <main+0x126>
lea    -0x330(%rbp),%rdi
movslq -0x338(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1070 <input_Q@plt>
mov    -0x338(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x338(%rbp)
jmp    1249 <main+0xe9>
lea    0xd79(%rip),%rdi
call   1060 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1030 <bubble_sort_N@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x330(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    -0x10(%rbp),%r8
call   1040 <search_Q@plt>
jmp    1179 <main+0x19>
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x338,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe80(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1080 <scanf@plt>
test   %rax,%rax
je     127f <main+0x11f>
lea    0x1a0(%rsp),%r15
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r13
jmp    11fb <main+0x9b>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
call   1030 <bubble_sort_N@plt>
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
mov    %r15,%rdi
mov    %r14,%rsi
lea    0xc(%rsp),%r8
call   1040 <search_Q@plt>
lea    0xe1b(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %r13,%rdx
call   1080 <scanf@plt>
test   %rax,%rax
je     127f <main+0x11f>
mov    0x4(%rsp),%eax
or     0x8(%rsp),%eax
je     127f <main+0x11f>
mov    $0xa,%edi
call   1050 <putchar@plt>
cmpl   $0x0,0x4(%rsp)
jle    123a <main+0xda>
mov    %r15,%rbx
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <input_N@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     1220 <main+0xc0>
mov    $0xa,%edi
call   1050 <putchar@plt>
cmpl   $0x0,0x8(%rsp)
jle    11b0 <main+0x50>
mov    %r14,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <input_Q@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1260 <main+0x100>
jmp    11b0 <main+0x50>
xor    %eax,%eax
add    $0x338,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i32]
%5 = alloca [100 x i32]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast [100 x i32]* %4 to i8*
%10 = bitcast [100 x i32]* %5 to i8*
%11 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %55, label %13
13: ; preds = %0
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
br label %16
16: ; preds = %13, %38
%17 = load i32, i32* %1
%18 = icmp ne i32 %17, 0
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 0
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %22, label %55
22: ; preds = %16
%23 = call i32 @putchar(i32 10)
%24 = load i32, i32* %1
%25 = icmp sgt i32 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %30, %22
%27 = call i32 @putchar(i32 10)
%28 = load i32, i32* %2
%29 = icmp sgt i32 %28, 0
br i1 %29, label %47, label %38
30: ; preds = %22, %30
%31 = phi i64 [ %34, %30 ], [ 0, %22 ]
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %31
%33 = call i32 @input_N(i32* %32)
%34 = add nuw nsw i64 %31, 1
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %30, label %26
38: ; preds = %47, %26
%39 = call i32 @putchar(i32 10)
%40 = load i32, i32* %1
%41 = call i32 @bubble_sort_N(i32* %14, i32 %40)
%42 = load i32, i32* %2
%43 = load i32, i32* %1
%44 = call i32 @search_Q(i32* %14, i32* %15, i32 %42, i32 %43, i32* %3)
%45 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%46 = icmp eq i64 %45, 0
br i1 %46, label %55, label %16
47: ; preds = %26, %47
%48 = phi i64 [ %51, %47 ], [ 0, %26 ]
%49 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %48
%50 = call i32 @input_Q(i32* %49)
%51 = add nuw nsw i64 %48, 1
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = icmp slt i64 %51, %53
br i1 %54, label %47, label %38
55: ; preds = %16, %38, %0
ret i32 0
}