#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 /*<<< orphan*/ print(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int rand();
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, const char *argv[]) {
  int size = 100;
  int array[size];
  int x = 0;
  srand((int)time(NULL));
  for (x = 0; x < size; ++x) {
    array[x] = rand() % size;
  }
  int *start = array;
  printf("Before sorting... \n");
  print(array, size);
  quick_sort(start, 0, size);
  printf("After sorting... \n");
  print(array, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x64,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f2 <main+0x92>
mov    $0x0,%al
call   1080 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c2 <main+0x62>
mov    -0x40(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <print@plt>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1070 <quick_sort@plt>
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <print@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x190,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1180 <main+0x20>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <print@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <quick_sort@plt>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <print@plt>
xor    %eax,%eax
add    $0x190,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Before sorting... \0A\00"
@.str.1 = [19 x i8] c"After sorting... \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100, i32* %6
%11 = load i32, i32* %6
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i32, i64 %12
store i64 %12, i64* %8
store i32 0, i32* %9
%15 = call i64 @time(i32* null)
%16 = trunc i64 %15 to i32
%17 = call i32 @srand(i32 %16)
store i32 0, i32* %9
br label %18
18: ; preds = %29, %2
%19 = load i32, i32* %9
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = call i32 (...) @rand()
%24 = load i32, i32* %6
%25 = srem i32 %23, %24
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %14, i64 %27
store i32 %25, i32* %28
br label %29
29: ; preds = %22
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %18
32: ; preds = %18
store i32* %14, i32** %10
%33 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* %6
%35 = call i32 @print(i32* %14, i32 %34)
%36 = load i32*, i32** %10
%37 = load i32, i32* %6
%38 = call i32 @quick_sort(i32* %36, i32 0, i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* %6
%41 = call i32 @print(i32* %14, i32 %40)
store i32 0, i32* %3
%42 = load i8*, i8** %7
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@str = [19 x i8] c"Before sorting... \00"
@str.2 = [18 x i8] c"After sorting... \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32]
%4 = tail call i64 @time(i32* null)
%5 = trunc i64 %4 to i32
%6 = tail call i32 @srand(i32 %5)
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 0, %2 ], [ %12, %7 ]
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 100
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %8
store i32 %10, i32* %11
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, 100
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%17 = call i32 @print(i32* %15, i32 100)
%18 = call i32 @quick_sort(i32* %15, i32 0, i32 100)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.2, i64 0, i64 0))
%20 = call i32 @print(i32* %15, i32 100)
ret i32 0
}