#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 scalar_t__ clock_t;
typedef int /*<<< orphan*/ ar;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ mostrarArreglo(int *, int);
int /*<<< orphan*/ printf(char *, ...);
unsigned long qs(int *, int /*<<< orphan*/, int);
void quicksort(int ar[], int cantidad) {
  int tam;
  unsigned long co;
  tam = sizeof(ar);
  clock_t inicio = clock();
  co = qs(ar, 0, cantidad - 1);
  clock_t fin = clock();
  mostrarArreglo(ar, cantidad);
  printf("\n\nMETODO QUICKSORT");
  printf("\n\nEl tiempo que tardo la ordenacion fue de %Lf milisegundos\n",
         ((double)(fin - inicio)) / CLOCKS_PER_SEC * 1000);
  printf("El numero de comparaciones fue %lu", co);
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1060 <qs@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <mostrarArreglo@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
sub    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2e39(%rip),%rax
divsd  (%rax),%xmm0
movsd  0xe45(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r13
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r12
lea    -0x1(%r15),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1060 <qs@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r15d,%esi
call   1030 <mostrarArreglo@plt>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
sub    %r12,%rbx
cvtsi2sd %rbx,%xmm0
mov    0x2e4c(%rip),%rax
divsd  (%rax),%xmm0
mulsd  0xe58(%rip),%xmm0
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"\0A\0AMETODO QUICKSORT\00"
@.str.1 = [61 x i8] c"\0A\0AEl tiempo que tardo la ordenacion fue de %Lf milisegundos\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [35 x i8] c"El numero de comparaciones fue %lu\00"
define void @quicksort(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 8, i32* %5
%9 = call i64 (...) @clock()
store i64 %9, i64* %7
%10 = load i32*, i32** %3
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = call i64 @qs(i32* %10, i32 0, i32 %12)
store i64 %13, i64* %6
%14 = call i64 (...) @clock()
store i64 %14, i64* %8
%15 = load i32*, i32** %3
%16 = load i32, i32* %4
%17 = call i32 @mostrarArreglo(i32* %15, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%19 = load i64, i64* %8
%20 = load i64, i64* %7
%21 = sub nsw i64 %19, %20
%22 = sitofp i64 %21 to double
%23 = load double, double* @CLOCKS_PER_SEC
%24 = fdiv double %22, %23
%25 = fmul double %24, 1.000000e+03
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = load i64, i64* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i64 %27)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"\0A\0AMETODO QUICKSORT\00"
@.str.1 = [61 x i8] c"\0A\0AEl tiempo que tardo la ordenacion fue de %Lf milisegundos\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [35 x i8] c"El numero de comparaciones fue %lu\00"
define void @quicksort(i32* %0, i32 %1) {
%3 = tail call i64 (...) @clock()
%4 = add nsw i32 %1, -1
%5 = tail call i64 @qs(i32* %0, i32 0, i32 %4)
%6 = tail call i64 (...) @clock()
%7 = tail call i32 @mostrarArreglo(i32* %0, i32 %1)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = sub nsw i64 %6, %3
%10 = sitofp i64 %9 to double
%11 = load double, double* @CLOCKS_PER_SEC
%12 = fdiv double %10, %11
%13 = fmul double %12, 1.000000e+03
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i64 %5)
ret void
}