#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 */
typedef int /*<<< orphan*/ A;

/* Variables and functions */
int /*<<< orphan*/ divConqInsert(int *, int, int, int);
int divConqSearch(int *, int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int A[10] = {1, 3, 5, 6, 7, 9};
  int n = sizeof(A) / sizeof(A[0]);
  int start = 0, end = n - 1;
  int key = 5;
  int sol = divConqSearch(A, n, start, end, key);
  sol == -1 ? printf("Sorry, key was not found!\n")
            : printf("They key was found and the index is: %d\n", sol);
  int capacity = sizeof(A) / sizeof(A[0]);
  divConqInsert(A, 6, 4, capacity);
  for (int i = 0; i < n + 1; i++)
    printf("%d ", A[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x3,-0x2c(%rbp)
movl   $0x5,-0x28(%rbp)
movl   $0x6,-0x24(%rbp)
movl   $0x7,-0x20(%rbp)
movl   $0x9,-0x1c(%rbp)
movl   $0xa,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movl   $0x5,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
call   1050 <divConqSearch@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    11dd <main+0x9d>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ee <main+0xae>
mov    -0x44(%rbp),%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%ecx
mov    $0x6,%esi
mov    $0x4,%edx
call   1060 <divConqInsert@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1247 <main+0x107>
movslq -0x4c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1212 <main+0xd2>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x900000007,%rax
mov    %rax,0x10(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
xor    %edx,%edx
mov    $0x9,%ecx
mov    $0x5,%r8d
call   1060 <divConqSearch@plt>
cmp    $0xffffffff,%eax
je     11b1 <main+0x61>
lea    0xe6a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11bd <main+0x6d>
lea    0xe85(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
mov    $0x6,%esi
mov    $0x4,%edx
mov    $0xa,%ecx
call   1070 <divConqInsert@plt>
mov    (%rsp),%esi
lea    0xe5b(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Sorry, key was not found!\0A\00"
@.str.1 = [41 x i8] c"They key was found and the index is: %d\0A\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [10 x i32]* %2 to i8*
%11 = bitcast i8* %10 to [10 x i32]*
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 0
store i32 1, i32* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 1
store i32 3, i32* %13
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 2
store i32 5, i32* %14
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 3
store i32 6, i32* %15
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 4
store i32 7, i32* %16
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %11, i32 0, i32 5
store i32 9, i32* %17
store i32 10, i32* %3
store i32 0, i32* %4
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %5
store i32 5, i32* %6
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = call i32 @divConqSearch(i32* %20, i32 %21, i32 %22, i32 %23, i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %33
30: ; preds = %0
%31 = load i32, i32* %7
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %28
%34 = phi i32 [ %29, %28 ], [ %32, %30 ]
store i32 10, i32* %8
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%36 = load i32, i32* %8
%37 = call i32 @divConqInsert(i32* %35, i32 6, i32 4, i32 %36)
store i32 0, i32* %9
br label %38
38: ; preds = %49, %33
%39 = load i32, i32* %9
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %52
43: ; preds = %38
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %43
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %38
52: ; preds = %38
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [41 x i8] c"They key was found and the index is: %d\0A\00"
@.str.2 = [4 x i8] c"%d \00"
@str = [26 x i8] c"Sorry, key was not found!\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%6 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 3, i32 5, i32 6>, <4 x i32>* %6
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 7, i32* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
store i32 9, i32* %8
%9 = call i32 @divConqSearch(i32* %5, i32 10, i32 0, i32 9, i32 5)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %15
15: ; preds = %13, %11
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%19 = call i32 @divConqInsert(i32* %5, i32 6, i32 4, i32 10)
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %18
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %17
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %16
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 10
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = call i32 @putchar(i32 10)
ret i32 0
}