#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*/ arr;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int atoi(char *);
int binsearch(int, int *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int res;
  int test;
  int arr[] = {'1', '4', '6', '7', '8', '9'};
  int size = (int)(sizeof(arr) / sizeof(int));
  res = test = 0;
  if (argc != 2) {
    printf("Usage: %s <num>\n", argv[0]);
    exit(EXIT_FAILURE);
  } else
    test = atoi(argv[1]);
  res = binsearch(test, arr, size);
  printf("RESULT: %d\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x6,-0x34(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1030 <binsearch@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0xec5(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,(%rsp)
cmp    $0x2,%edi
jne    118f <main+0x4f>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x6,%edx
call   1030 <binsearch@plt>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    (%rsi),%rsi
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.main.arr = [6 x i32] [i32 49, i32 52, i32 54, i32 55, i32 56, i32 57]
@.str = [17 x i8] c"Usage: %s <num>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"RESULT: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [6 x i32]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [6 x i32]* %8 to i8*
store i32 6, i32* %9
store i32 0, i32* %7
store i32 0, i32* %6
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %7
br label %25
25: ; preds = %20
%26 = load i32, i32* %7
%27 = getelementptr inbounds [6 x i32], [6 x i32]* %8, i64 0, i64 0
%28 = load i32, i32* %9
%29 = call i32 @binsearch(i32 %26, i32* %27, i32 %28)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [6 x i32] [i32 49, i32 52, i32 54, i32 55, i32 56, i32 57]
@.str = [17 x i8] c"Usage: %s <num>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"RESULT: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%16 = call i32 @binsearch(i32 %14, i32* %15, i32 6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %16)
ret i32 0
}