#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*/ printf(char *, ...);
int /*<<< orphan*/ quickSort(int *, int /*<<< orphan*/, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void sort_test() {
  int i = 0;
  int data[1000];
  srand((unsigned)time(NULL));
  for (i = 0; i < 1000; i++) {
    data[i] = rand() % 1000;
    printf("%d ", data[i]);
  }
  printf("\n");
  printf("\n");
  printf("\n");
  printf("\n");
  quickSort(data, 0, 1000 - 1);
  for (i = 0; i < 1000; i++) {
    printf("%d ", data[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<sort_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfb0,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    11c7 <sort_test+0x77>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x4(%rbp),%rax
mov    %edx,-0xfb0(%rbp,%rax,4)
movslq -0x4(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1179 <sort_test+0x29>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xfb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x3e7,%edx
call   1060 <quickSort@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
jge    124d <sort_test+0xfd>
movslq -0x4(%rbp),%rax
mov    -0xfb0(%rbp,%rax,4),%esi
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1219 <sort_test+0xc9>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0xfb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_test>:
push   %r14
push   %rbx
sub    $0xfa8,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe81(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
movslq %eax,%rsi
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%eax
sub    %eax,%esi
mov    %esi,(%rsp,%rbx,4)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1190 <sort_test+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x3e7,%edx
call   1070 <quickSort@plt>
lea    0xdf2(%rip),%r14
xor    %ebx,%ebx
mov    (%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x3e8,%rbx
jne    1210 <sort_test+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xfa8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @sort_test() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %12, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 1000
%10 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %7
store i32 %9, i32* %10
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, 1000
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 @putchar(i32 10)
%18 = tail call i32 @putchar(i32 10)
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 0
%20 = call i32 @quickSort(i32* %19, i32 0, i32 999)
br label %21
21: ; preds = %14, %21
%22 = phi i64 [ 0, %14 ], [ %26, %21 ]
%23 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = add nuw nsw i64 %22, 1
%27 = icmp eq i64 %26, 1000
br i1 %27, label %28, label %21
28: ; preds = %21
%29 = call i32 @putchar(i32 10)
ret void
}