#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*/ init(int *, size_t, int);
int /*<<< orphan*/ output(int *, size_t);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ quicksort_1(int *, size_t);
int /*<<< orphan*/ quicksort_2(int *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ quicksort_iterative(int *, size_t);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ validate(int *, size_t);
int main(int argc, char **argv) {
  int array[32] = {2, 9, 4, 7, 5, 3, 6, 1, 8, 0};
  size_t len = sizeof(array) / sizeof(array[0]);
  srandom(time(NULL));
  init(array, len, 100);
  output(array, len);
  quicksort_1(array, len);
  validate(array, len);
  output(array, len);
  puts("----------------------------");
  init(array, len, 100);
  output(array, len);
  quicksort_2(array, 0, len - 1);
  validate(array, len);
  output(array, len);
  puts("----------------------------");
  init(array, len, 100);
  output(array, len);
  quicksort_iterative(array, len);
  validate(array, len);
  output(array, len);
  puts("----------------------------");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x80,%edx
call   1080 <memcpy@plt>
movq   $0x20,-0x98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10a0 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    $0x64,%edx
call   1090 <init@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <output@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   10c0 <quicksort_1@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   10b0 <validate@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <output@plt>
lea    0xe29(%rip),%rdi
call   1050 <puts@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    $0x64,%edx
call   1090 <init@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <output@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1070 <quicksort_2@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   10b0 <validate@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <output@plt>
lea    0xdb3(%rip),%rdi
call   1050 <puts@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    $0x64,%edx
call   1090 <init@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <output@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1030 <quicksort_iterative@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   10b0 <validate@plt>
lea    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1060 <output@plt>
lea    0xd43(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe5f(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe43(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe27(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe0b(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1040 <srandom@plt>
mov    %rsp,%rbx
mov    $0x20,%esi
mov    %rbx,%rdi
mov    $0x64,%edx
call   1080 <init@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1060 <output@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   10b0 <quicksort_1@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   10a0 <validate@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1060 <output@plt>
lea    0xe29(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
mov    $0x64,%edx
call   1080 <init@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1060 <output@plt>
mov    $0x1f,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <quicksort_2@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   10a0 <validate@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1060 <output@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
mov    $0x64,%edx
call   1080 <init@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1060 <output@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1030 <quicksort_iterative@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   10a0 <validate@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1060 <output@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.array = <{ [9 x i32], [23 x i32] }> <{ [9 x i32] [i32 2, i32 9, i32 4, i32 7, i32 5, i32 3, i32 6, i32 1, i32 8], [23 x i32] zeroinitializer }>
@.str = [29 x i8] c"----------------------------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i32]
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [32 x i32]* %6 to i8*
store i64 32, i64* %7
%9 = call i32 @time(i32* null)
%10 = call i32 @srandom(i32 %9)
%11 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%12 = load i64, i64* %7
%13 = call i32 @init(i32* %11, i64 %12, i32 100)
%14 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%15 = load i64, i64* %7
%16 = call i32 @output(i32* %14, i64 %15)
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%18 = load i64, i64* %7
%19 = call i32 @quicksort_1(i32* %17, i64 %18)
%20 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%21 = load i64, i64* %7
%22 = call i32 @validate(i32* %20, i64 %21)
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%24 = load i64, i64* %7
%25 = call i32 @output(i32* %23, i64 %24)
%26 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%28 = load i64, i64* %7
%29 = call i32 @init(i32* %27, i64 %28, i32 100)
%30 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%31 = load i64, i64* %7
%32 = call i32 @output(i32* %30, i64 %31)
%33 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%34 = load i64, i64* %7
%35 = sub i64 %34, 1
%36 = call i32 @quicksort_2(i32* %33, i32 0, i64 %35)
%37 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%38 = load i64, i64* %7
%39 = call i32 @validate(i32* %37, i64 %38)
%40 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%41 = load i64, i64* %7
%42 = call i32 @output(i32* %40, i64 %41)
%43 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%44 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%45 = load i64, i64* %7
%46 = call i32 @init(i32* %44, i64 %45, i32 100)
%47 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%48 = load i64, i64* %7
%49 = call i32 @output(i32* %47, i64 %48)
%50 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%51 = load i64, i64* %7
%52 = call i32 @quicksort_iterative(i32* %50, i64 %51)
%53 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%54 = load i64, i64* %7
%55 = call i32 @validate(i32* %53, i64 %54)
%56 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%57 = load i64, i64* %7
%58 = call i32 @output(i32* %56, i64 %57)
%59 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.array = <{ [9 x i32], [23 x i32] }> <{ [9 x i32] [i32 2, i32 9, i32 4, i32 7, i32 5, i32 3, i32 6, i32 1, i32 8], [23 x i32] zeroinitializer }>
@.str = [29 x i8] c"----------------------------\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i32]
%4 = bitcast [32 x i32]* %3 to i8*
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srandom(i32 %5)
%7 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%8 = call i32 @init(i32* %7, i64 32, i32 100)
%9 = call i32 @output(i32* %7, i64 32)
%10 = call i32 @quicksort_1(i32* %7, i64 32)
%11 = call i32 @validate(i32* %7, i64 32)
%12 = call i32 @output(i32* %7, i64 32)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @init(i32* %7, i64 32, i32 100)
%15 = call i32 @output(i32* %7, i64 32)
%16 = call i32 @quicksort_2(i32* %7, i32 0, i64 31)
%17 = call i32 @validate(i32* %7, i64 32)
%18 = call i32 @output(i32* %7, i64 32)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @init(i32* %7, i64 32, i32 100)
%21 = call i32 @output(i32* %7, i64 32)
%22 = call i32 @quicksort_iterative(i32* %7, i64 32)
%23 = call i32 @validate(i32* %7, i64 32)
%24 = call i32 @output(i32* %7, i64 32)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
ret i32 0
}