#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ binSearch(int, int *, int, int *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ getArr(int, int *);
int /*<<< orphan*/ getInt(int, int *, int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ prnArr(int, int *);
int main(int argc, char **argv) {
  int size, num;
  int *arr, *items, *pos;
  getInt(2, &size, &num);
  if ((arr = (int *)malloc(size * sizeof(int))) == NULL) {
    exit(EXIT_FAILURE);
  }
  if ((items = (int *)malloc(num * sizeof(int))) == NULL) {
    exit(EXIT_FAILURE);
  }
  if ((pos = (int *)malloc(num * sizeof(int))) == NULL) {
    exit(EXIT_FAILURE);
  }
  getArr(size, arr);
  getArr(num, items);
  binSearch(size, arr, num, items, pos);
  prnArr(num, pos);
  free(arr);
  free(items);
  free(pos);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2,%edi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <getInt@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11c3 <main+0x53>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11ee <main+0x7e>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1219 <main+0xa9>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <getArr@plt>
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1040 <getArr@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1050 <binSearch@plt>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1070 <prnArr@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    $0x2,%edi
call   1080 <getInt@plt>
mov    0xc(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1232 <main+0xc2>
mov    %rax,%r14
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1232 <main+0xc2>
mov    %rax,%r15
mov    0x8(%rsp),%edi
shl    $0x2,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     1232 <main+0xc2>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1040 <getArr@plt>
mov    0x8(%rsp),%edi
mov    %r15,%rsi
call   1040 <getArr@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%edx
mov    %r14,%rsi
mov    %r15,%rcx
mov    %rbx,%r8
call   1050 <binSearch@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   1070 <prnArr@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @getInt(i32 2, i32* %6, i32* %7)
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 4
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to i32*
store i32* %28, i32** %9
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %22
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 4
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to i32*
store i32* %39, i32** %10
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %33
%45 = load i32, i32* %6
%46 = load i32*, i32** %8
%47 = call i32 @getArr(i32 %45, i32* %46)
%48 = load i32, i32* %7
%49 = load i32*, i32** %9
%50 = call i32 @getArr(i32 %48, i32* %49)
%51 = load i32, i32* %6
%52 = load i32*, i32** %8
%53 = load i32, i32* %7
%54 = load i32*, i32** %9
%55 = load i32*, i32** %10
%56 = call i32 @binSearch(i32 %51, i32* %52, i32 %53, i32* %54, i32* %55)
%57 = load i32, i32* %7
%58 = load i32*, i32** %10
%59 = call i32 @prnArr(i32 %57, i32* %58)
%60 = load i32*, i32** %8
%61 = call i32 @free(i32* %60)
%62 = load i32*, i32** %9
%63 = call i32 @free(i32* %62)
%64 = load i32*, i32** %10
%65 = call i32 @free(i32* %64)
%66 = load i32, i32* @EXIT_SUCCESS
ret i32 %66
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 @getInt(i32 2, i32* %3, i32* %4)
%8 = load i32, i32* %3
%9 = shl i32 %8, 2
%10 = call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i32*
%12 = icmp eq i64 %10, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load i32, i32* %4
%18 = shl i32 %17, 2
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i32*
%21 = icmp eq i64 %19, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %16
%26 = load i32, i32* %4
%27 = shl i32 %26, 2
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i32*
%30 = icmp eq i64 %28, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %25
%35 = load i32, i32* %3
%36 = call i32 @getArr(i32 %35, i32* %11)
%37 = load i32, i32* %4
%38 = call i32 @getArr(i32 %37, i32* %20)
%39 = load i32, i32* %3
%40 = load i32, i32* %4
%41 = call i32 @binSearch(i32 %39, i32* %11, i32 %40, i32* %20, i32* %29)
%42 = load i32, i32* %4
%43 = call i32 @prnArr(i32 %42, i32* %29)
%44 = call i32 @free(i32* %11)
%45 = call i32 @free(i32* %20)
%46 = call i32 @free(i32* %29)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}