#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 */
scalar_t__ binarySearch(int *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int key;
  int arr[10] = {1, 13, 24, 39, 41, 56, 68, 73, 82, 95};
  printf("Enter The Key To Search: ");
  scanf("%d", &key);
  if (binarySearch(arr, &key))
    printf("Found!!! \n");
  else
    printf("Not Found!!!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <binarySearch@plt>
cmp    $0x0,%rax
je     11a8 <main+0x68>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <main+0x74>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0xed4(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe9c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <binarySearch@plt>
test   %rax,%rax
lea    0xea5(%rip),%rax
lea    0xeab(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [10 x i32] [i32 1, i32 13, i32 24, i32 39, i32 41, i32 56, i32 68, i32 73, i32 82, i32 95]
@.str = [26 x i8] c"Enter The Key To Search: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Found!!! \0A\00"
@.str.3 = [14 x i8] c"Not Found!!!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
store i32 0, i32* %1
%4 = bitcast [10 x i32]* %3 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%8 = call i64 @binarySearch(i32* %7, i32* %2)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [10 x i32] [i32 1, i32 13, i32 24, i32 39, i32 41, i32 56, i32 68, i32 73, i32 82, i32 95]
@.str = [26 x i8] c"Enter The Key To Search: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [13 x i8] c"Not Found!!!\00"
@str.4 = [10 x i8] c"Found!!! \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%8 = call i64 @binarySearch(i32* %7, i32* %1)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0)
%11 = call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}