#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*/ check_intInput(int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fill_array(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int recursive_binary_search(int *, int, int /*<<< orphan*/, int);
int main() {
  int n;
  printf("Enter n: ");
  check_intInput(&n);
  if (n <= 0) {
    printf("n > 0 !");
    exit(EXIT_FAILURE);
  }
  int buffer[n];
  printf("Enter %d numbers : ", n);
  fill_array(buffer, n);
  int result, searchNum;
  printf("Enter number to search: ");
  check_intInput(&searchNum);
  result = recursive_binary_search(buffer, searchNum, 0, n);
  printf("%d", result);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1030 <check_intInput@plt>
cmpl   $0x0,-0x8(%rbp)
jg     119c <main+0x4c>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <fill_array@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <check_intInput@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%ecx
xor    %edx,%edx
call   1070 <recursive_binary_search@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1030 <check_intInput@plt>
mov    -0x14(%rbp),%eax
test   %eax,%eax
jle    11fd <main+0xad>
mov    %rsp,%r14
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x14(%rbp),%esi
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    %rbx,%rdi
call   1050 <fill_array@plt>
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1030 <check_intInput@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%ecx
mov    %rbx,%rdi
xor    %edx,%edx
call   1070 <recursive_binary_search@plt>
lea    0xe60(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    %r14,%rsp
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe06(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Enter n: \00"
@.str.1 = [8 x i8] c"n > 0 !\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [20 x i8] c"Enter %d numbers : \00"
@.str.3 = [25 x i8] c"Enter number to search: \00"
@.str.4 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @check_intInput(i32* %2)
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %0
%16 = load i32, i32* %2
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %3
%19 = alloca i32, i64 %17
store i64 %17, i64* %4
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = call i32 @fill_array(i32* %19, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @check_intInput(i32* %6)
%26 = load i32, i32* %6
%27 = load i32, i32* %2
%28 = call i32 @recursive_binary_search(i32* %19, i32 %26, i32 0, i32 %27)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @EXIT_SUCCESS
store i32 %31, i32* %1
%32 = load i8*, i8** %3
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [10 x i8] c"Enter n: \00"
@.str.1 = [8 x i8] c"n > 0 !\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [20 x i8] c"Enter %d numbers : \00"
@.str.3 = [25 x i8] c"Enter number to search: \00"
@.str.4 = [3 x i8] c"%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @check_intInput(i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = zext i32 %6 to i64
%14 = call i8* @llvm.stacksave()
%15 = alloca i32, i64 %13
%16 = load i32, i32* %1
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = call i32 @fill_array(i32* %15, i32 %18)
%20 = bitcast i32* %2 to i8*
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @check_intInput(i32* %2)
%23 = load i32, i32* %2
%24 = load i32, i32* %1
%25 = call i32 @recursive_binary_search(i32* %15, i32 %23, i32 0, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}