#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;

/* Variables and functions */
int CLOCKS_PER_SEC;
int /*<<< orphan*/ bubblesort(int *, int);
scalar_t__ clock();
int *create_vec_rand(int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ quick(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int *b, *q, n;
  clock_t t;
  scanf("%d", &n);
  b = create_vec_rand(n);
  t = clock();
  bubblesort(b, n);
  t = clock() - 1;
  printf("tempo - bubblesort - vetor desordenado: %lf\n",
         ((double)t) / ((CLOCKS_PER_SEC / 1000)));
  t = clock();
  bubblesort(b, n);
  t = clock() - 1;
  printf("tempo - bubblesort - vetor ordenado: %lf\n",
         ((double)t) / ((CLOCKS_PER_SEC / 1000)));
  free(b);
  q = create_vec_rand(n);
  t = clock();
  quick(q, 0, n - 1);
  t = clock() - 1;
  printf("tempo - quicksort - vetor desordenado: %lf\n",
         ((double)t) / ((CLOCKS_PER_SEC / 1000)));
  t = clock();
  quick(q, 0, n - 1);
  t = clock() - 1;
  printf("tempo - quicksort - vetor ordenado: %lf\n",
         ((double)t) / ((CLOCKS_PER_SEC / 1000)));
  free(q);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe73(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x24(%rbp),%edi
call   1070 <create_vec_rand@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <bubblesort@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <bubblesort@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xdf1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%edi
call   1070 <create_vec_rand@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1080 <quick@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xdb0(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1080 <quick@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
cvtsi2sdq -0x30(%rbp),%xmm0
mov    0x2d01(%rip),%rax
mov    (%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xd86(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe85(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
call   1070 <create_vec_rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1090 <bubblesort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
add    $0xffffffffffffffff,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e2d(%rip),%r14
movslq (%r14),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1090 <bubblesort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
add    $0xffffffffffffffff,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movslq (%r14),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xdfb(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%edi
call   1070 <create_vec_rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
mov    0x4(%rsp),%edx
add    $0xffffffff,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <quick@plt>
xor    %eax,%eax
call   1040 <clock@plt>
add    $0xffffffffffffffff,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movslq (%r14),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xdb8(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    0x4(%rsp),%edx
add    $0xffffffff,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <quick@plt>
xor    %eax,%eax
call   1040 <clock@plt>
add    $0xffffffffffffffff,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movslq (%r14),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
lea    0xd8b(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"tempo - bubblesort - vetor desordenado: %lf\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [42 x i8] c"tempo - bubblesort - vetor ordenado: %lf\0A\00"
@.str.3 = [44 x i8] c"tempo - quicksort - vetor desordenado: %lf\0A\00"
@.str.4 = [41 x i8] c"tempo - quicksort - vetor ordenado: %lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%11 = load i32, i32* %8
%12 = call i32* @create_vec_rand(i32 %11)
store i32* %12, i32** %6
%13 = call i64 (...) @clock()
store i64 %13, i64* %9
%14 = load i32*, i32** %6
%15 = load i32, i32* %8
%16 = call i32 @bubblesort(i32* %14, i32 %15)
%17 = call i64 (...) @clock()
%18 = sub nsw i64 %17, 1
store i64 %18, i64* %9
%19 = load i64, i64* %9
%20 = sitofp i64 %19 to double
%21 = load i32, i32* @CLOCKS_PER_SEC
%22 = sdiv i32 %21, 1000
%23 = sitofp i32 %22 to double
%24 = fdiv double %20, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %24)
%26 = call i64 (...) @clock()
store i64 %26, i64* %9
%27 = load i32*, i32** %6
%28 = load i32, i32* %8
%29 = call i32 @bubblesort(i32* %27, i32 %28)
%30 = call i64 (...) @clock()
%31 = sub nsw i64 %30, 1
store i64 %31, i64* %9
%32 = load i64, i64* %9
%33 = sitofp i64 %32 to double
%34 = load i32, i32* @CLOCKS_PER_SEC
%35 = sdiv i32 %34, 1000
%36 = sitofp i32 %35 to double
%37 = fdiv double %33, %36
%38 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %37)
%39 = load i32*, i32** %6
%40 = call i32 @free(i32* %39)
%41 = load i32, i32* %8
%42 = call i32* @create_vec_rand(i32 %41)
store i32* %42, i32** %7
%43 = call i64 (...) @clock()
store i64 %43, i64* %9
%44 = load i32*, i32** %7
%45 = load i32, i32* %8
%46 = sub nsw i32 %45, 1
%47 = call i32 @quick(i32* %44, i32 0, i32 %46)
%48 = call i64 (...) @clock()
%49 = sub nsw i64 %48, 1
store i64 %49, i64* %9
%50 = load i64, i64* %9
%51 = sitofp i64 %50 to double
%52 = load i32, i32* @CLOCKS_PER_SEC
%53 = sdiv i32 %52, 1000
%54 = sitofp i32 %53 to double
%55 = fdiv double %51, %54
%56 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), double %55)
%57 = call i64 (...) @clock()
store i64 %57, i64* %9
%58 = load i32*, i32** %7
%59 = load i32, i32* %8
%60 = sub nsw i32 %59, 1
%61 = call i32 @quick(i32* %58, i32 0, i32 %60)
%62 = call i64 (...) @clock()
%63 = sub nsw i64 %62, 1
store i64 %63, i64* %9
%64 = load i64, i64* %9
%65 = sitofp i64 %64 to double
%66 = load i32, i32* @CLOCKS_PER_SEC
%67 = sdiv i32 %66, 1000
%68 = sitofp i32 %67 to double
%69 = fdiv double %65, %68
%70 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), double %69)
%71 = load i32*, i32** %7
%72 = call i32 @free(i32* %71)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [45 x i8] c"tempo - bubblesort - vetor desordenado: %lf\0A\00"
@CLOCKS_PER_SEC = global i32 0
@.str.2 = [42 x i8] c"tempo - bubblesort - vetor ordenado: %lf\0A\00"
@.str.3 = [44 x i8] c"tempo - quicksort - vetor desordenado: %lf\0A\00"
@.str.4 = [41 x i8] c"tempo - quicksort - vetor ordenado: %lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = call i32* @create_vec_rand(i32 %6)
%8 = call i64 (...) @clock()
%9 = load i32, i32* %3
%10 = call i32 @bubblesort(i32* %7, i32 %9)
%11 = call i64 (...) @clock()
%12 = add nsw i64 %11, -1
%13 = sitofp i64 %12 to double
%14 = load i32, i32* @CLOCKS_PER_SEC
%15 = sdiv i32 %14, 1000
%16 = sitofp i32 %15 to double
%17 = fdiv double %13, %16
%18 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), double %17)
%19 = call i64 (...) @clock()
%20 = load i32, i32* %3
%21 = call i32 @bubblesort(i32* %7, i32 %20)
%22 = call i64 (...) @clock()
%23 = add nsw i64 %22, -1
%24 = sitofp i64 %23 to double
%25 = load i32, i32* @CLOCKS_PER_SEC
%26 = sdiv i32 %25, 1000
%27 = sitofp i32 %26 to double
%28 = fdiv double %24, %27
%29 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), double %28)
%30 = call i32 @free(i32* %7)
%31 = load i32, i32* %3
%32 = call i32* @create_vec_rand(i32 %31)
%33 = call i64 (...) @clock()
%34 = load i32, i32* %3
%35 = add nsw i32 %34, -1
%36 = call i32 @quick(i32* %32, i32 0, i32 %35)
%37 = call i64 (...) @clock()
%38 = add nsw i64 %37, -1
%39 = sitofp i64 %38 to double
%40 = load i32, i32* @CLOCKS_PER_SEC
%41 = sdiv i32 %40, 1000
%42 = sitofp i32 %41 to double
%43 = fdiv double %39, %42
%44 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), double %43)
%45 = call i64 (...) @clock()
%46 = load i32, i32* %3
%47 = add nsw i32 %46, -1
%48 = call i32 @quick(i32* %32, i32 0, i32 %47)
%49 = call i64 (...) @clock()
%50 = add nsw i64 %49, -1
%51 = sitofp i64 %50 to double
%52 = load i32, i32* @CLOCKS_PER_SEC
%53 = sdiv i32 %52, 1000
%54 = sitofp i32 %53 to double
%55 = fdiv double %51, %54
%56 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), double %55)
%57 = call i32 @free(i32* %32)
ret i32 0
}