#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 lb(int *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quickSort(int *, int /*<<< orphan*/, int);
int ub(int *, int /*<<< orphan*/, int, int);
void main(void) {
  int i;
  int a[] = {1, -1, 0, 6, 5, 5, 7, 8};
  printf("origin value:{");
  for (i = 0; i < 5; i++) {
    printf(",%d", a[i]);
  }
  printf("}\n");
  quickSort(a, 0, 7);
  printf("sorted value:{");
  for (i = 0; i <= 8; i++) {
    printf(",%d", a[i]);
  }
  printf("}\n");
  int k = 5;
  int val = lb(a, 0, 8, k);
  printf("lb value:%d\n", val);
  val = ub(a, 0, 8, k);
  printf("ub value:%d\n", val);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea8(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x5,-0x4(%rbp)
jge    11b7 <main+0x77>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1189 <main+0x49>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <quickSort@plt>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jg     1218 <main+0xd8>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ea <main+0xaa>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x5,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%ecx
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <lb@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%ecx
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <ub@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaa(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe88(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1060 <quickSort@plt>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
mov    $0x5,%ecx
call   1070 <lb@plt>
lea    0xda6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
mov    $0x5,%ecx
call   1050 <ub@plt>
lea    0xd8f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [8 x i32] [i32 1, i32 -1, i32 0, i32 6, i32 5, i32 5, i32 7, i32 8]
@.str = [15 x i8] c"origin value:{\00"
@.str.1 = [4 x i8] c",%d\00"
@.str.2 = [3 x i8] c"}\0A\00"
@.str.3 = [15 x i8] c"sorted value:{\00"
@.str.4 = [13 x i8] c"lb value:%d\0A\00"
@.str.5 = [13 x i8] c"ub value:%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [8 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [8 x i32]* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %7
7: ; preds = %16, %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
br label %7
19: ; preds = %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%22 = call i32 @quickSort(i32* %21, i32 0, i32 7)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %24
24: ; preds = %33, %19
%25 = load i32, i32* %1
%26 = icmp sle i32 %25, 8
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %1
%35 = add nsw i32 %34, 1
store i32 %35, i32* %1
br label %24
36: ; preds = %24
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 5, i32* %3
%38 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%39 = load i32, i32* %3
%40 = call i32 @lb(i32* %38, i32 0, i32 8, i32 %39)
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%44 = load i32, i32* %3
%45 = call i32 @ub(i32* %43, i32 0, i32 8, i32 %44)
store i32 %45, i32* %4
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %46)
ret void
}

LLVM IR (-O2):
@__const.main.a = [8 x i32] [i32 1, i32 -1, i32 0, i32 6, i32 5, i32 5, i32 7, i32 8]
@.str = [15 x i8] c"origin value:{\00"
@.str.1 = [4 x i8] c",%d\00"
@.str.3 = [15 x i8] c"sorted value:{\00"
@.str.4 = [13 x i8] c"lb value:%d\0A\00"
@.str.5 = [13 x i8] c"ub value:%d\0A\00"
@str.6 = [2 x i8] c"}\00"
define void @main() {
%1 = alloca [8 x i32]
%2 = bitcast [8 x i32]* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 -1)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0)
%10 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 6)
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 4
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 5)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%15 = call i32 @quickSort(i32* %4, i32 0, i32 7)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %8
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %10
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %12
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 5
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 6
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 7
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 0, i64 8
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.6, i64 0, i64 0))
%40 = call i32 @lb(i32* %4, i32 0, i32 8, i32 5)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = call i32 @ub(i32* %4, i32 0, i32 8, i32 5)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %42)
ret void
}