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

/* Variables and functions */
int EXIT_SUCCESS;
int binsearch(int, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int a[] = {4, 12, 32, 65, 87, 90, 103, 112, 114, 123, 156};
  int pos;
  pos = binsearch(32, a, (sizeof(a) / sizeof(a[0])));
  if (pos == -1) {
    printf("never finded\n");
  } else {
    printf("position:%d\n", pos);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x2c,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rsi
mov    $0x20,%edi
mov    $0xb,%edx
call   1030 <binsearch@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1187 <main+0x57>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1198 <main+0x68>
mov    -0x34(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movups 0xee1(%rip),%xmm0
movups %xmm0,0x1c(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x20,%edi
mov    $0xb,%edx
call   1030 <binsearch@plt>
cmp    $0xffffffff,%eax
je     1180 <main+0x50>
lea    0xeb7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    118c <main+0x5c>
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [11 x i32] [i32 4, i32 12, i32 32, i32 65, i32 87, i32 90, i32 103, i32 112, i32 114, i32 123, i32 156]
@.str = [14 x i8] c"never finded\0A\00"
@.str.1 = [13 x i8] c"position:%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [11 x i32]* %2 to i8*
%5 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 0
%6 = call i32 @binsearch(i32 32, i32* %5, i32 11)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %14
11: ; preds = %0
%12 = load i32, i32* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %11, %9
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}

LLVM IR (-O2):
@__const.main.a = [11 x i32] [i32 4, i32 12, i32 32, i32 65, i32 87, i32 90, i32 103, i32 112, i32 114, i32 123, i32 156]
@.str.1 = [13 x i8] c"position:%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [13 x i8] c"never finded\00"
define i32 @main() {
%1 = alloca [11 x i32]
%2 = bitcast [11 x i32]* %1 to i8*
%3 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 0
%4 = call i32 @binsearch(i32 32, i32* %3, i32 11)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %10
10: ; preds = %8, %6
%11 = load i32, i32* @EXIT_SUCCESS
ret i32 %11
}