#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 bin_search(int *, int, int);
int /*<<< orphan*/ check(int);
int main(int argc, char *argv[]) {
  int t_arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  check(bin_search(t_arr, 10, 4) == 3);
  check(bin_search(t_arr, 10, 10) == 9);
  check(bin_search(t_arr, 10, 1) == 0);
  check(bin_search(t_arr, 10, 8) == 7);
  check(bin_search(t_arr, 10, 11) == -1);
  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)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x28,%edx
call   1030 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
mov    $0x4,%edx
call   1050 <bin_search@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%edx
mov    %edx,%esi
call   1050 <bin_search@plt>
cmp    $0x9,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
mov    $0x1,%edx
call   1050 <bin_search@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
mov    $0x8,%edx
call   1050 <bin_search@plt>
cmp    $0x7,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
mov    $0xb,%edx
call   1050 <bin_search@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <check@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xef4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x4,%edx
call   1040 <bin_search@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1030 <check@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xa,%edx
call   1040 <bin_search@plt>
xor    %edi,%edi
cmp    $0x9,%eax
sete   %dil
call   1030 <check@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x1,%edx
call   1040 <bin_search@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <check@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x8,%edx
call   1040 <bin_search@plt>
xor    %edi,%edi
cmp    $0x7,%eax
sete   %dil
call   1030 <check@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0xb,%edx
call   1040 <bin_search@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <check@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.t_arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [10 x i32]* %6 to i8*
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%9 = call i32 @bin_search(i32* %8, i32 10, i32 4)
%10 = icmp eq i32 %9, 3
%11 = zext i1 %10 to i32
%12 = call i32 @check(i32 %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%14 = call i32 @bin_search(i32* %13, i32 10, i32 10)
%15 = icmp eq i32 %14, 9
%16 = zext i1 %15 to i32
%17 = call i32 @check(i32 %16)
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%19 = call i32 @bin_search(i32* %18, i32 10, i32 1)
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @check(i32 %21)
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%24 = call i32 @bin_search(i32* %23, i32 10, i32 8)
%25 = icmp eq i32 %24, 7
%26 = zext i1 %25 to i32
%27 = call i32 @check(i32 %26)
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%29 = call i32 @bin_search(i32* %28, i32 10, i32 11)
%30 = icmp eq i32 %29, -1
%31 = zext i1 %30 to i32
%32 = call i32 @check(i32 %31)
ret i32 0
}

LLVM IR (-O2):
@__const.main.t_arr = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%6 = call i32 @bin_search(i32* %5, i32 10, i32 4)
%7 = icmp eq i32 %6, 3
%8 = zext i1 %7 to i32
%9 = call i32 @check(i32 %8)
%10 = call i32 @bin_search(i32* %5, i32 10, i32 10)
%11 = icmp eq i32 %10, 9
%12 = zext i1 %11 to i32
%13 = call i32 @check(i32 %12)
%14 = call i32 @bin_search(i32* %5, i32 10, i32 1)
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @check(i32 %16)
%18 = call i32 @bin_search(i32* %5, i32 10, i32 8)
%19 = icmp eq i32 %18, 7
%20 = zext i1 %19 to i32
%21 = call i32 @check(i32 %20)
%22 = call i32 @bin_search(i32* %5, i32 10, i32 11)
%23 = icmp eq i32 %22, -1
%24 = zext i1 %23 to i32
%25 = call i32 @check(i32 %24)
ret i32 0
}