#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 binary_search(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int main() {
  int a[100];
  a[0] = 15;
  a[1] = 2;
  a[2] = 8;
  a[3] = 7;
  a[4] = 3;
  a[5] = 6;
  a[6] = 9;
  a[7] = 17;
  int n = 8;
  quick_sort(a, 0, n - 1);
  printf("%d\n", binary_search(a, 0, n - 1, 10));
  printf("%d\n", binary_search(a, 0, n - 1, 8));
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0xf,-0x190(%rbp)
movl   $0x2,-0x18c(%rbp)
movl   $0x8,-0x188(%rbp)
movl   $0x7,-0x184(%rbp)
movl   $0x3,-0x180(%rbp)
movl   $0x6,-0x17c(%rbp)
movl   $0x9,-0x178(%rbp)
movl   $0x11,-0x174(%rbp)
movl   $0x8,-0x194(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1050 <quick_sort@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
mov    $0xa,%ecx
call   1040 <binary_search@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
mov    $0x8,%ecx
call   1040 <binary_search@plt>
mov    %eax,%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1060 <quick_sort@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x7,%edx
mov    $0xa,%ecx
call   1050 <binary_search@plt>
lea    0xe92(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x7,%edx
mov    $0x8,%ecx
call   1050 <binary_search@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
store i32 15, i32* %3
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 1
store i32 2, i32* %4
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 2
store i32 8, i32* %5
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 3
store i32 7, i32* %6
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 4
store i32 3, i32* %7
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 5
store i32 6, i32* %8
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 6
store i32 9, i32* %9
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 7
store i32 17, i32* %10
store i32 8, i32* %2
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%12 = load i32, i32* %2
%13 = sub nsw i32 %12, 1
%14 = call i32 @quick_sort(i32* %11, i32 0, i32 %13)
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%16 = load i32, i32* %2
%17 = sub nsw i32 %16, 1
%18 = call i32 @binary_search(i32* %15, i32 0, i32 %17, i32 10)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%21 = load i32, i32* %2
%22 = sub nsw i32 %21, 1
%23 = call i32 @binary_search(i32* %20, i32 0, i32 %22, i32 8)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%4 = bitcast [100 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 15, i32 2, i32 8, i32 7>, <4 x i32>* %4
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 4
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 3, i32 6, i32 9, i32 17>, <4 x i32>* %6
%7 = call i32 @quick_sort(i32* %3, i32 0, i32 7)
%8 = call i32 @binary_search(i32* %3, i32 0, i32 7, i32 10)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @binary_search(i32* %3, i32 0, i32 7, i32 8)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i32 @putchar(i32 10)
ret i32 0
}