#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 abs(int);
int binaryLookup(int, int, int *);
int /*<<< orphan*/ bubbleSortArray(int, int *);
int /*<<< orphan*/ getRandomArray(int, int *);
int /*<<< orphan*/ printArray(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[100];
  int n, i;
  getRandomArray(100, a);
  bubbleSortArray(100, a);
  puts("Array after sort:");
  printArray(100, a);
  do {
    printf("Enter number in range [-99..99]: ");
    scanf("%d", &n);
    i = binaryLookup(n, 100, a);
    if (abs(n) < 100) {
      if (i > -1)
        printf("a[ %d ] = %d\n", i, a[i]);
      else
        printf("The number isn't found.\n");
    }
  } while (abs(n) < 100);
  printf("The end.");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rsi
mov    $0x64,%edi
call   1070 <getRandomArray@plt>
lea    -0x1a0(%rbp),%rsi
mov    $0x64,%edi
call   1060 <bubbleSortArray@plt>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1a0(%rbp),%rsi
mov    $0x64,%edi
call   1090 <printArray@plt>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4e(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x1a4(%rbp),%edi
lea    -0x1a0(%rbp),%rdx
mov    $0x64,%esi
call   10a0 <binaryLookup@plt>
mov    %eax,-0x1a8(%rbp)
mov    -0x1a4(%rbp),%edi
call   1040 <abs@plt>
cmp    $0x64,%eax
jge    126a <main+0xea>
cmpl   $0xffffffff,-0x1a8(%rbp)
jle    1257 <main+0xd7>
mov    -0x1a8(%rbp),%esi
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1265 <main+0xe5>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    126a <main+0xea>
jmp    126f <main+0xef>
mov    -0x1a4(%rbp),%edi
call   1040 <abs@plt>
cmp    $0x64,%eax
jl     11d1 <main+0x51>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0x10(%rsp),%r14
mov    $0x64,%edi
mov    %r14,%rsi
call   1060 <getRandomArray@plt>
mov    $0x64,%edi
mov    %r14,%rsi
call   1050 <bubbleSortArray@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    $0x64,%edi
mov    %r14,%rsi
call   1080 <printArray@plt>
lea    0xe52(%rip),%r15
lea    0xe6d(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0xe64(%rip),%r13
lea    0xe74(%rip),%rbp
jmp    1200 <main+0x90>
mov    %rbp,%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
cmp    $0x64,%ecx
jae    124e <main+0xde>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x64,%esi
mov    %r14,%rdx
call   1090 <binaryLookup@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
cmp    $0x63,%edx
ja     11f0 <main+0x80>
test   %eax,%eax
js     11dc <main+0x6c>
mov    %eax,%ecx
mov    0x10(%rsp,%rcx,4),%edx
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f0 <main+0x80>
lea    0xdf0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Array after sort:\00"
@.str.1 = [34 x i8] c"Enter number in range [-99..99]: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"a[ %d ] = %d\0A\00"
@.str.4 = [25 x i8] c"The number isn't found.\0A\00"
@.str.5 = [9 x i8] c"The end.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%6 = call i32 @getRandomArray(i32 100, i32* %5)
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%8 = call i32 @bubbleSortArray(i32 100, i32* %7)
%9 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%11 = call i32 @printArray(i32 100, i32* %10)
br label %12
12: ; preds = %35, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%17 = call i32 @binaryLookup(i32 %15, i32 100, i32* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = call i32 @abs(i32 %18)
%20 = icmp slt i32 %19, 100
br i1 %20, label %21, label %34
21: ; preds = %12
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, -1
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i32, i32* %4
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %29)
br label %33
31: ; preds = %21
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %24
br label %34
34: ; preds = %33, %12
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = call i32 @abs(i32 %36)
%38 = icmp slt i32 %37, 100
br i1 %38, label %12, label %39
39: ; preds = %35
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [18 x i8] c"Array after sort:\00"
@.str.1 = [34 x i8] c"Enter number in range [-99..99]: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"a[ %d ] = %d\0A\00"
@.str.5 = [9 x i8] c"The end.\00"
@str = [24 x i8] c"The number isn't found.\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = bitcast [100 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%6 = call i32 @getRandomArray(i32 100, i32* %5)
%7 = call i32 @bubbleSortArray(i32 100, i32* %5)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @printArray(i32 100, i32* %5)
br label %10
10: ; preds = %27, %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%13 = load i32, i32* %2
%14 = call i32 @binaryLookup(i32 %13, i32 100, i32* %5)
%15 = load i32, i32* %2
%16 = call i32 @llvm.abs.i32(i32 %15, i1 true)
%17 = icmp ult i32 %16, 100
br i1 %17, label %18, label %27
18: ; preds = %10
%19 = icmp sgt i32 %14, -1
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = zext i32 %14 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %14, i32 %23)
br label %27
25: ; preds = %18
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %10, %25, %20
%28 = load i32, i32* %2
%29 = call i32 @llvm.abs.i32(i32 %28, i1 true)
%30 = icmp ult i32 %29, 100
br i1 %30, label %10, label %31
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}