#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 atoi(char *);
scalar_t__ binsearch(int *, int const, int);
int /*<<< orphan*/ printf(char *, int, char *);
int main(int argv, char **argc) {
  const int numN = argv - 1;
  int nums[numN];
  int i;
  for (i = 1; i < argv; ++i)
    nums[i - 1] = atoi(argc[i]);
  int target = nums[0];
  printf("%d %sfound.\n", target,
         binsearch(nums + 1, numN - 1, target) ? "" : "not ");
}


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    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <main+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    117d <main+0x4d>
mov    -0x38(%rbp),%rdi
mov    (%rdi),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
add    $0x4,%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x30(%rbp),%edx
call   1030 <binsearch@plt>
mov    -0x3c(%rbp),%esi
mov    %rax,%rcx
lea    0xe25(%rip),%rdx
lea    0xe1d(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
lea    -0x1(%r14),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %edi,%r13d
add    $0xffffffffffffffff,%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    0x8(%r15,%rbx,8),%rdi
call   1050 <atoi@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <main+0x40>
mov    (%r12),%r15d
add    $0x4,%r12
add    $0xfffffffe,%r14d
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   1030 <binsearch@plt>
test   %rax,%rax
lea    0xe62(%rip),%rax
lea    0xe5a(%rip),%rdx
cmove  %rax,%rdx
lea    0xe43(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%d %sfound.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"not \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %7
%16 = alloca i32, i64 %14
store i64 %14, i64* %8
store i32 1, i32* %9
br label %17
17: ; preds = %32, %2
%18 = load i32, i32* %9
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @atoi(i8* %26)
%28 = load i32, i32* %9
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %16, i64 %30
store i32 %27, i32* %31
br label %32
32: ; preds = %21
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %17
35: ; preds = %17
%36 = getelementptr inbounds i32, i32* %16, i64 0
%37 = load i32, i32* %36
store i32 %37, i32* %10
%38 = load i32, i32* %10
%39 = getelementptr inbounds i32, i32* %16, i64 1
%40 = load i32, i32* %6
%41 = sub nsw i32 %40, 1
%42 = load i32, i32* %10
%43 = call i64 @binsearch(i32* %39, i32 %41, i32 %42)
%44 = icmp ne i64 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%47 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %38, i8* %46)
%48 = load i8*, i8** %7
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d %sfound.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"not \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -1
%4 = zext i32 %3 to i64
%5 = alloca i32, i64 %4
%6 = icmp sgt i32 %0, 1
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %2, %8
%9 = phi i64 [ 1, %2 ], [ %15, %8 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = add nsw i64 %9, -1
%14 = getelementptr inbounds i32, i32* %5, i64 %13
store i32 %12, i32* %14
%15 = add nuw nsw i64 %9, 1
%16 = icmp eq i64 %15, %7
br i1 %16, label %17, label %8
17: ; preds = %8
%18 = load i32, i32* %5
%19 = getelementptr inbounds i32, i32* %5, i64 1
%20 = add nsw i32 %0, -2
%21 = call i64 @binsearch(i32* %19, i32 %20, i32 %18)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %18, i8* %23)
ret i32 0
}