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

/* Variables and functions */
float CLOCKS_PER_SEC;
int atoi(char *);
double clock();
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quickk(int *, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  clock_t t;
  time_t timer;
  srand(time(NULL));
  if (argc < 2) {
    printf("Entre com o tamanho do vetor\n");
    return 1;
  }
  int tmp, i, j, r, n = atoi(argv[1]);
  int *v = (int *)malloc(n * sizeof(int));
  for (i = 0; i < n; i++) {
    r = rand() % n;
    v[i] = r;
  }
  t = clock();
  quickk(v, n);
  printf("%f time \n", t, ((float)t) / CLOCKS_PER_SEC);
  for (i = 0; i < n; i++) {
    printf("%d ", v[i]);
  }
  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)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmpl   $0x2,-0x8(%rbp)
jge    11ca <main+0x4a>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12ae <main+0x12e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x30(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    122a <main+0xaa>
mov    $0x0,%al
call   10a0 <rand@plt>
cltd
idivl  -0x30(%rbp)
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%edx
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f4 <main+0x74>
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1030 <quickk@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
cvtsd2ss %xmm1,%xmm1
mov    0x2d91(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdb8(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12a7 <main+0x127>
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1274 <main+0xf4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
cmp    $0x1,%ebp
jg     11cb <main+0x3b>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
jmp    12cb <main+0x13b>
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r15d
lea    0x0(,%r15,4),%edi
call   1090 <malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    1289 <main+0xf9>
mov    %r15d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10b0 <rand@plt>
cltd
idiv   %r15d
mov    %edx,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <main+0x70>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %r15d,%esi
call   1040 <quickk@plt>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm1
mov    0x2da4(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xdad(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
test   %r15d,%r15d
jle    12cb <main+0x13b>
xor    %r14d,%r14d
lea    0xda1(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1270 <main+0xe0>
jmp    12cb <main+0x13b>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %r15d,%esi
call   1040 <quickk@plt>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm1
mov    0x2d33(%rip),%rax
divss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd3c(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Entre com o tamanho do vetor\0A\00"
@.str.1 = [10 x i8] c"%f time \0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.2 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %74
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %12
%25 = load i32, i32* %12
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i32*
store i32* %30, i32** %13
store i32 0, i32* %9
br label %31
31: ; preds = %44, %20
%32 = load i32, i32* %9
%33 = load i32, i32* %12
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %47
35: ; preds = %31
%36 = call i32 (...) @rand()
%37 = load i32, i32* %12
%38 = srem i32 %36, %37
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = load i32*, i32** %13
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
store i32 %39, i32* %43
br label %44
44: ; preds = %35
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %31
47: ; preds = %31
%48 = call double (...) @clock()
store double %48, double* %6
%49 = load i32*, i32** %13
%50 = load i32, i32* %12
%51 = call i32 @quickk(i32* %49, i32 %50)
%52 = load double, double* %6
%53 = load double, double* %6
%54 = fptrunc double %53 to float
%55 = load float, float* @CLOCKS_PER_SEC
%56 = fdiv float %54, %55
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %52, double %57)
store i32 0, i32* %9
br label %59
59: ; preds = %70, %47
%60 = load i32, i32* %9
%61 = load i32, i32* %12
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %73
63: ; preds = %59
%64 = load i32*, i32** %13
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %63
%71 = load i32, i32* %9
%72 = add nsw i32 %71, 1
store i32 %72, i32* %9
br label %59
73: ; preds = %59
store i32 0, i32* %3
br label %74
74: ; preds = %73, %18
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"%f time \0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
@.str.2 = [4 x i8] c"%d \00"
@str = [29 x i8] c"Entre com o tamanho do vetor\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %50
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = shl i32 %11, 2
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
%15 = icmp sgt i32 %11, 0
br i1 %15, label %16, label %42
16: ; preds = %8
%17 = zext i32 %11 to i64
br label %18
18: ; preds = %16, %18
%19 = phi i64 [ 0, %16 ], [ %23, %18 ]
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, %11
%22 = getelementptr inbounds i32, i32* %14, i64 %19
store i32 %21, i32* %22
%23 = add nuw nsw i64 %19, 1
%24 = icmp eq i64 %23, %17
br i1 %24, label %25, label %18
25: ; preds = %18
%26 = tail call double (...) @clock()
%27 = tail call i32 @quickk(i32* %14, i32 %11)
%28 = fptrunc double %26 to float
%29 = load float, float* @CLOCKS_PER_SEC
%30 = fdiv float %28, %29
%31 = fpext float %30 to double
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %26, double %31)
br i1 %15, label %33, label %50
33: ; preds = %25
%34 = zext i32 %11 to i64
br label %35
35: ; preds = %33, %35
%36 = phi i64 [ 0, %33 ], [ %40, %35 ]
%37 = getelementptr inbounds i32, i32* %14, i64 %36
%38 = load i32, i32* %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = add nuw nsw i64 %36, 1
%41 = icmp eq i64 %40, %34
br i1 %41, label %50, label %35
42: ; preds = %8
%43 = tail call double (...) @clock()
%44 = tail call i32 @quickk(i32* %14, i32 %11)
%45 = fptrunc double %43 to float
%46 = load float, float* @CLOCKS_PER_SEC
%47 = fdiv float %45, %46
%48 = fpext float %47 to double
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %43, double %48)
br label %50
50: ; preds = %35, %42, %25, %6
%51 = phi i32 [ 1, %6 ], [ 0, %25 ], [ 0, %42 ], [ 0, %35 ]
ret i32 %51
}