#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 */
float CLOCKS_PER_SEC;
float clock();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quicksort(long *, int /*<<< orphan*/, long);
int rand();
int /*<<< orphan*/ scanf(char *, long *);
int /*<<< orphan*/ srand(long);
int main(int argc, char *argv[]) {
  long int arr[1000000], i, no;
  float start, end;
  printf("Enter no of elements\n");
  scanf("%ld", &no);
  srand(no);
  for (i = 0; i < no; i++)
    arr[i] = rand() % 1000;
  start = clock();
  quicksort(arr, 0, no - 1);
  end = clock();
  for (i = 0; i < no; i++)
    printf("%ld\n", arr[i]);
  printf("Time Complexity %f\n", (end - start) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a1230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x7a1220(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x7a1220(%rbp),%rdi
call   1060 <srand@plt>
movq   $0x0,-0x7a1218(%rbp)
mov    -0x7a1218(%rbp),%rax
cmp    -0x7a1220(%rbp),%rax
jge    11fd <main+0x9d>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
mov    -0x7a1218(%rbp),%rax
mov    %rcx,-0x7a1210(%rbp,%rax,8)
ff
mov    -0x7a1218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7a1218(%rbp)
jmp    11b1 <main+0x51>
mov    $0x0,%al
call   1030 <clock@plt>
movss  %xmm0,-0x7a1224(%rbp)
ff
lea    -0x7a1210(%rbp),%rdi
mov    -0x7a1220(%rbp),%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1040 <quicksort@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movss  %xmm0,-0x7a1228(%rbp)
ff
movq   $0x0,-0x7a1218(%rbp)
mov    -0x7a1218(%rbp),%rax
cmp    -0x7a1220(%rbp),%rax
jge    1287 <main+0x127>
mov    -0x7a1218(%rbp),%rax
mov    -0x7a1210(%rbp,%rax,8),%rsi
ff
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x7a1218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x7a1218(%rbp)
jmp    123f <main+0xdf>
movss  -0x7a1228(%rbp),%xmm0
ff
subss  -0x7a1224(%rbp),%xmm0
ff
mov    0x2d4a(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd72(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x7a1230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x7a1218,%rsp
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe73(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%rdi
call   1070 <srand@plt>
cmpq   $0x0,(%rsp)
jle    11e6 <main+0x76>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
cltq
mov    %rax,0x10(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    (%rsp),%rbx
jl     11b0 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
movss  %xmm0,0xc(%rsp)
mov    (%rsp),%rdx
add    $0xffffffffffffffff,%rdx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <quicksort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movss  %xmm0,0x8(%rsp)
cmpq   $0x0,(%rsp)
jle    1249 <main+0xd9>
lea    0xde2(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    (%rsp),%rbx
jl     1230 <main+0xc0>
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
mov    0x2d8c(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9e(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x7a1218,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter no of elements\0A\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@.str.3 = [20 x i8] c"Time Complexity %f\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000000 x i64]
%7 = alloca i64
%8 = alloca i64
%9 = alloca float
%10 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %8)
%13 = load i64, i64* %8
%14 = call i32 @srand(i64 %13)
store i64 0, i64* %7
br label %15
15: ; preds = %25, %2
%16 = load i64, i64* %7
%17 = load i64, i64* %8
%18 = icmp slt i64 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 1000
%22 = sext i32 %21 to i64
%23 = load i64, i64* %7
%24 = getelementptr inbounds [1000000 x i64], [1000000 x i64]* %6, i64 0, i64 %23
store i64 %22, i64* %24
br label %25
25: ; preds = %19
%26 = load i64, i64* %7
%27 = add nsw i64 %26, 1
store i64 %27, i64* %7
br label %15
28: ; preds = %15
%29 = call float (...) @clock()
store float %29, float* %9
%30 = getelementptr inbounds [1000000 x i64], [1000000 x i64]* %6, i64 0, i64 0
%31 = load i64, i64* %8
%32 = sub nsw i64 %31, 1
%33 = call i32 @quicksort(i64* %30, i32 0, i64 %32)
%34 = call float (...) @clock()
store float %34, float* %10
store i64 0, i64* %7
br label %35
35: ; preds = %44, %28
%36 = load i64, i64* %7
%37 = load i64, i64* %8
%38 = icmp slt i64 %36, %37
br i1 %38, label %39, label %47
39: ; preds = %35
%40 = load i64, i64* %7
%41 = getelementptr inbounds [1000000 x i64], [1000000 x i64]* %6, i64 0, i64 %40
%42 = load i64, i64* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %42)
br label %44
44: ; preds = %39
%45 = load i64, i64* %7
%46 = add nsw i64 %45, 1
store i64 %46, i64* %7
br label %35
47: ; preds = %35
%48 = load float, float* %10
%49 = load float, float* %9
%50 = fsub float %48, %49
%51 = load float, float* @CLOCKS_PER_SEC
%52 = fdiv float %50, %51
%53 = fpext float %52 to double
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %53)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@.str.3 = [20 x i8] c"Time Complexity %f\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@str = [21 x i8] c"Enter no of elements\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000000 x i64]
%4 = alloca i64
%5 = bitcast [1000000 x i64]* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %4)
%9 = load i64, i64* %4
%10 = call i32 @srand(i64 %9)
%11 = load i64, i64* %4
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %2, %13
%14 = phi i64 [ %19, %13 ], [ 0, %2 ]
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 1000
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000000 x i64], [1000000 x i64]* %3, i64 0, i64 %14
store i64 %17, i64* %18
%19 = add nuw nsw i64 %14, 1
%20 = load i64, i64* %4
%21 = icmp slt i64 %19, %20
br i1 %21, label %13, label %22
22: ; preds = %13, %2
%23 = call float (...) @clock()
%24 = getelementptr inbounds [1000000 x i64], [1000000 x i64]* %3, i64 0, i64 0
%25 = load i64, i64* %4
%26 = add nsw i64 %25, -1
%27 = call i32 @quicksort(i64* %24, i32 0, i64 %26)
%28 = call float (...) @clock()
%29 = load i64, i64* %4
%30 = icmp sgt i64 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %22, %31
%32 = phi i64 [ %36, %31 ], [ 0, %22 ]
%33 = getelementptr inbounds [1000000 x i64], [1000000 x i64]* %3, i64 0, i64 %32
%34 = load i64, i64* %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %34)
%36 = add nuw nsw i64 %32, 1
%37 = load i64, i64* %4
%38 = icmp slt i64 %36, %37
br i1 %38, label %31, label %39
39: ; preds = %31, %22
%40 = fsub float %28, %23
%41 = load float, float* @CLOCKS_PER_SEC
%42 = fdiv float %40, %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %43)
ret i32 0
}