#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 */
typedef int /*<<< orphan*/ list;

/* Variables and functions */
int /*<<< orphan*/ printList(int *, int);
int recursiveBinarySearch(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ showResult(int, int);
int main(void) {
  int key = 0;
  int list[10] = {1, 3, 4, 5, 6, 7, 8, 9, 12, 20};
  int size = ((int)sizeof(list) / sizeof(int));
  int pos;
  printList(list, size);
  key = 3;
  pos = recursiveBinarySearch(list, 0, size - 1, key);
  showResult(pos, key);
  key = 20;
  pos = recursiveBinarySearch(list, 0, size - 1, key);
  showResult(pos, key);
  key = 10;
  pos = recursiveBinarySearch(list, 0, size - 1, key);
  showResult(pos, key);
  key = -1;
  pos = recursiveBinarySearch(list, 0, size - 1, key);
  showResult(pos, key);
  int list1[1] = {2};
  key = 1;
  pos = recursiveBinarySearch(list1, 0, 0, key);
  showResult(pos, key);
  int list2[2] = {1, 3};
  key = 1;
  pos = recursiveBinarySearch(list2, 0, 1, key);
  showResult(pos, key);
  key = 3;
  pos = recursiveBinarySearch(list, 0, 1, key);
  showResult(pos, key);
  key = 0;
  pos = recursiveBinarySearch(list, 0, 1, key);
  showResult(pos, key);
  key = 4;
  pos = recursiveBinarySearch(list, 0, 1, key);
  showResult(pos, key);
  key = 2;
  pos = recursiveBinarySearch(list, 0, 1, key);
  showResult(pos, key);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0xa,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <printList@plt>
movl   $0x3,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0x14,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0xa,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
sub    $0x1,%edx
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
mov    0xe00(%rip),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x1,-0x8(%rbp)
lea    -0x3c(%rbp),%rdi
mov    -0x8(%rbp),%ecx
xor    %edx,%edx
mov    %edx,%esi
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
mov    0xdd5(%rip),%rax
mov    %rax,-0x44(%rbp)
movl   $0x1,-0x8(%rbp)
lea    -0x44(%rbp),%rdi
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0x3,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0x0,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0x4,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
movl   $0x2,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
xor    %esi,%esi
mov    $0x1,%edx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <showResult@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xee4(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <printList@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
mov    $0x3,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
mov    $0x14,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x14,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
mov    $0xa,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0xa,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
mov    $0xffffffff,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0xffffffff,%esi
call   1040 <showResult@plt>
movl   $0x2,0x4(%rsp)
lea    0x4(%rsp),%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <showResult@plt>
movabs $0x300000001,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x3,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x3,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
xor    %esi,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x4,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x4,%esi
call   1040 <showResult@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1030 <recursiveBinarySearch@plt>
mov    %eax,%edi
mov    $0x2,%esi
call   1040 <showResult@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.list = [10 x i32] [i32 1, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 12, i32 20]
@__const.main.list1 = [1 x i32] [i32 2]
@__const.main.list2 = [2 x i32] [i32 1, i32 3]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1 x i32]
%7 = alloca [2 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
%8 = bitcast [10 x i32]* %3 to i8*
store i32 10, i32* %4
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%10 = load i32, i32* %4
%11 = call i32 @printList(i32* %9, i32 %10)
store i32 3, i32* %2
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %2
%16 = call i32 @recursiveBinarySearch(i32* %12, i32 0, i32 %14, i32 %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = load i32, i32* %2
%19 = call i32 @showResult(i32 %17, i32 %18)
store i32 20, i32* %2
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%21 = load i32, i32* %4
%22 = sub nsw i32 %21, 1
%23 = load i32, i32* %2
%24 = call i32 @recursiveBinarySearch(i32* %20, i32 0, i32 %22, i32 %23)
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = load i32, i32* %2
%27 = call i32 @showResult(i32 %25, i32 %26)
store i32 10, i32* %2
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, 1
%31 = load i32, i32* %2
%32 = call i32 @recursiveBinarySearch(i32* %28, i32 0, i32 %30, i32 %31)
store i32 %32, i32* %5
%33 = load i32, i32* %5
%34 = load i32, i32* %2
%35 = call i32 @showResult(i32 %33, i32 %34)
store i32 -1, i32* %2
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = load i32, i32* %2
%40 = call i32 @recursiveBinarySearch(i32* %36, i32 0, i32 %38, i32 %39)
store i32 %40, i32* %5
%41 = load i32, i32* %5
%42 = load i32, i32* %2
%43 = call i32 @showResult(i32 %41, i32 %42)
%44 = bitcast [1 x i32]* %6 to i8*
store i32 1, i32* %2
%45 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%46 = load i32, i32* %2
%47 = call i32 @recursiveBinarySearch(i32* %45, i32 0, i32 0, i32 %46)
store i32 %47, i32* %5
%48 = load i32, i32* %5
%49 = load i32, i32* %2
%50 = call i32 @showResult(i32 %48, i32 %49)
%51 = bitcast [2 x i32]* %7 to i8*
store i32 1, i32* %2
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%53 = load i32, i32* %2
%54 = call i32 @recursiveBinarySearch(i32* %52, i32 0, i32 1, i32 %53)
store i32 %54, i32* %5
%55 = load i32, i32* %5
%56 = load i32, i32* %2
%57 = call i32 @showResult(i32 %55, i32 %56)
store i32 3, i32* %2
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%59 = load i32, i32* %2
%60 = call i32 @recursiveBinarySearch(i32* %58, i32 0, i32 1, i32 %59)
store i32 %60, i32* %5
%61 = load i32, i32* %5
%62 = load i32, i32* %2
%63 = call i32 @showResult(i32 %61, i32 %62)
store i32 0, i32* %2
%64 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%65 = load i32, i32* %2
%66 = call i32 @recursiveBinarySearch(i32* %64, i32 0, i32 1, i32 %65)
store i32 %66, i32* %5
%67 = load i32, i32* %5
%68 = load i32, i32* %2
%69 = call i32 @showResult(i32 %67, i32 %68)
store i32 4, i32* %2
%70 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%71 = load i32, i32* %2
%72 = call i32 @recursiveBinarySearch(i32* %70, i32 0, i32 1, i32 %71)
store i32 %72, i32* %5
%73 = load i32, i32* %5
%74 = load i32, i32* %2
%75 = call i32 @showResult(i32 %73, i32 %74)
store i32 2, i32* %2
%76 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%77 = load i32, i32* %2
%78 = call i32 @recursiveBinarySearch(i32* %76, i32 0, i32 1, i32 %77)
store i32 %78, i32* %5
%79 = load i32, i32* %5
%80 = load i32, i32* %2
%81 = call i32 @showResult(i32 %79, i32 %80)
ret i32 0
}

LLVM IR (-O2):
@__const.main.list = [10 x i32] [i32 1, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 12, i32 20]
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [1 x i32]
%3 = alloca i64
%4 = bitcast [10 x i32]* %1 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%6 = call i32 @printList(i32* %5, i32 10)
%7 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 9, i32 3)
%8 = call i32 @showResult(i32 %7, i32 3)
%9 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 9, i32 20)
%10 = call i32 @showResult(i32 %9, i32 20)
%11 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 9, i32 10)
%12 = call i32 @showResult(i32 %11, i32 10)
%13 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 9, i32 -1)
%14 = call i32 @showResult(i32 %13, i32 -1)
%15 = bitcast [1 x i32]* %2 to i8*
%16 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 2, i32* %16
%17 = call i32 @recursiveBinarySearch(i32* %16, i32 0, i32 0, i32 1)
%18 = call i32 @showResult(i32 %17, i32 1)
%19 = bitcast i64* %3 to i8*
store i64 12884901889, i64* %3
%20 = bitcast i64* %3 to i32*
%21 = call i32 @recursiveBinarySearch(i32* %20, i32 0, i32 1, i32 1)
%22 = call i32 @showResult(i32 %21, i32 1)
%23 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 1, i32 3)
%24 = call i32 @showResult(i32 %23, i32 3)
%25 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 1, i32 0)
%26 = call i32 @showResult(i32 %25, i32 0)
%27 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 1, i32 4)
%28 = call i32 @showResult(i32 %27, i32 4)
%29 = call i32 @recursiveBinarySearch(i32* %5, i32 0, i32 1, i32 2)
%30 = call i32 @showResult(i32 %29, i32 2)
ret i32 0
}