#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*/ array;

/* Variables and functions */
int /*<<< orphan*/ bubble_sort(int *, size_t);
int /*<<< orphan*/ insert_sort(int *, size_t);
int /*<<< orphan*/ optimized_bubble_sort(int *, size_t);
int /*<<< orphan*/ optimized_select_sort(int *, size_t);
int /*<<< orphan*/ output(int *, size_t);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ quick_sort_2(int *, int /*<<< orphan*/, size_t);
int main(int argc, char **argv) {
  int array[] = {11, 12, 13, 14, 10, 2, 9, 4, 7, 5, 3, 6, 1, 8, 0};
  size_t len = sizeof(array) / sizeof(array[0]);
  output(array, len);
  insert_sort(array, len);
  output(array, len);
  optimized_select_sort(array, len);
  output(array, len);
  optimized_bubble_sort(array, len);
  output(array, len);
  bubble_sort(array, len);
  puts("before quick_sort -------------------------------");
  output(array, len);
  quick_sort_2(array, 0, len - 1);
  output(array, len);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x3c,%edx
call   1060 <memcpy@plt>
movq   $0xf,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1050 <output@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1080 <insert_sort@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1050 <output@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1070 <optimized_select_sort@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1050 <output@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1090 <optimized_bubble_sort@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1050 <output@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   10a0 <bubble_sort@plt>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1050 <output@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1030 <quick_sort_2@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1050 <output@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movups 0xeb0(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe60(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <output@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1070 <insert_sort@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <output@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1060 <optimized_select_sort@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <output@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1080 <optimized_bubble_sort@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <output@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1090 <bubble_sort@plt>
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <output@plt>
mov    $0xe,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <quick_sort_2@plt>
mov    $0xf,%esi
mov    %rbx,%rdi
call   1050 <output@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array = [15 x i32] [i32 11, i32 12, i32 13, i32 14, i32 10, i32 2, i32 9, i32 4, i32 7, i32 5, i32 3, i32 6, i32 1, i32 8, i32 0]
@.str = [50 x i8] c"before quick_sort -------------------------------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [15 x i32]
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [15 x i32]* %6 to i8*
store i64 15, i64* %7
%9 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%10 = load i64, i64* %7
%11 = call i32 @output(i32* %9, i64 %10)
%12 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%13 = load i64, i64* %7
%14 = call i32 @insert_sort(i32* %12, i64 %13)
%15 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%16 = load i64, i64* %7
%17 = call i32 @output(i32* %15, i64 %16)
%18 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%19 = load i64, i64* %7
%20 = call i32 @optimized_select_sort(i32* %18, i64 %19)
%21 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%22 = load i64, i64* %7
%23 = call i32 @output(i32* %21, i64 %22)
%24 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%25 = load i64, i64* %7
%26 = call i32 @optimized_bubble_sort(i32* %24, i64 %25)
%27 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%28 = load i64, i64* %7
%29 = call i32 @output(i32* %27, i64 %28)
%30 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%31 = load i64, i64* %7
%32 = call i32 @bubble_sort(i32* %30, i64 %31)
%33 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%34 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%35 = load i64, i64* %7
%36 = call i32 @output(i32* %34, i64 %35)
%37 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%38 = load i64, i64* %7
%39 = sub i64 %38, 1
%40 = call i32 @quick_sort_2(i32* %37, i32 0, i64 %39)
%41 = getelementptr inbounds [15 x i32], [15 x i32]* %6, i64 0, i64 0
%42 = load i64, i64* %7
%43 = call i32 @output(i32* %41, i64 %42)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = [15 x i32] [i32 11, i32 12, i32 13, i32 14, i32 10, i32 2, i32 9, i32 4, i32 7, i32 5, i32 3, i32 6, i32 1, i32 8, i32 0]
@.str = [50 x i8] c"before quick_sort -------------------------------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [15 x i32]
%4 = bitcast [15 x i32]* %3 to i8*
%5 = getelementptr inbounds [15 x i32], [15 x i32]* %3, i64 0, i64 0
%6 = call i32 @output(i32* %5, i64 15)
%7 = call i32 @insert_sort(i32* %5, i64 15)
%8 = call i32 @output(i32* %5, i64 15)
%9 = call i32 @optimized_select_sort(i32* %5, i64 15)
%10 = call i32 @output(i32* %5, i64 15)
%11 = call i32 @optimized_bubble_sort(i32* %5, i64 15)
%12 = call i32 @output(i32* %5, i64 15)
%13 = call i32 @bubble_sort(i32* %5, i64 15)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @output(i32* %5, i64 15)
%16 = call i32 @quick_sort_2(i32* %5, i32 0, i64 14)
%17 = call i32 @output(i32* %5, i64 15)
ret i32 0
}