#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 binsearch(int, int *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int res1, res2;
  int num[6] = {1, 5, 14, 18, 24, 28};
  res1 = binsearch(17, num, 6);
  res2 = binsearch(18, num, 6);
  printf("%d\n", res1);
  printf("%d\n", res2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x11,%edi
mov    $0x6,%edx
call   1030 <binsearch@plt>
mov    %eax,-0x8(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x12,%edi
mov    $0x6,%edx
call   1030 <binsearch@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe92(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    $0x11,%edi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <binsearch@plt>
mov    %eax,%ebp
mov    $0x12,%edi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <binsearch@plt>
mov    %eax,%ebx
lea    0xea7(%rip),%r14
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.num = [6 x i32] [i32 1, i32 5, i32 14, i32 18, i32 24, i32 28]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i32]
store i32 0, i32* %1
%5 = bitcast [6 x i32]* %4 to i8*
%6 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%7 = call i32 @binsearch(i32 17, i32* %6, i32 6)
store i32 %7, i32* %2
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %4, i64 0, i64 0
%9 = call i32 @binsearch(i32 18, i32* %8, i32 6)
store i32 %9, i32* %3
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.num = [6 x i32] [i32 1, i32 5, i32 14, i32 18, i32 24, i32 28]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [6 x i32]
%2 = bitcast [6 x i32]* %1 to i8*
%3 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%4 = call i32 @binsearch(i32 17, i32* %3, i32 6)
%5 = call i32 @binsearch(i32 18, i32* %3, i32 6)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
ret i32 0
}