#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*/ read_array(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ shellsort(int *, int);
int main() {
  int charNum = 10;
  int array[charNum];
  int searched = 0;
  int position = 0;
  for (int i = 0; i < charNum; ++i) {
    array[i] = 0;
  }
  read_array(array, charNum);
  scanf("%d", &searched);
  shellsort(array, charNum);
  position = binsearch(searched, array, charNum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bb <main+0x7b>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1192 <main+0x52>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <read_array@plt>
lea    0xe32(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <shellsort@plt>
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%edx
call   1030 <binsearch@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movl   $0x0,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <read_array@plt>
lea    0xe84(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <shellsort@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <binsearch@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %12
12: ; preds = %20, %0
%13 = load i32, i32* %7
%14 = load i32, i32* %2
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %11, i64 %18
store i32 0, i32* %19
br label %20
20: ; preds = %16
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %12
23: ; preds = %12
%24 = load i32, i32* %2
%25 = call i32 @read_array(i32* %11, i32 %24)
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%27 = load i32, i32* %2
%28 = call i32 @shellsort(i32* %11, i32 %27)
%29 = load i32, i32* %5
%30 = load i32, i32* %2
%31 = call i32 @binsearch(i32 %29, i32* %11, i32 %30)
store i32 %31, i32* %6
store i32 0, i32* %1
%32 = load i8*, i8** %3
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %2 to i8*
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%6 = call i32 @read_array(i32* %5, i32 10)
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = call i32 @shellsort(i32* %5, i32 10)
%9 = load i32, i32* %1
%10 = call i32 @binsearch(i32 %9, i32* %5, i32 10)
ret i32 0
}