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

/* Variables and functions */
double CLOCKS_PER_SEC;
int atoi(char *);
scalar_t__ clock();
int isSane(int *, int);
int /*<<< orphan*/ printf(char *, double, int);
int /*<<< orphan*/ quickSort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int *vector_fill_almost_sorted(int);
int *vector_fill_few_unique(int);
int *vector_fill_reverse(int);
int *vector_fill_unique(int);
int main(int argc, char *argv[]) {
  int n = atoi(argv[1]);
  int *a = vector_fill_almost_sorted(n);
  int i, j, m, flag;
  srand(time(NULL));
  if (argc > 2) {
    int k = atoi(argv[2]);
    if (k == 1) {
      a = vector_fill_almost_sorted(n);
    } else if (k == 2) {
      a = vector_fill_few_unique(n);
    } else if (k == 3) {
      a = vector_fill_reverse(n);
    } else if (k == 4) {
      a = vector_fill_unique(n);
    }
  } else {
    a = vector_fill_unique(n);
  }
  time_t t = clock();
  quickSort(a, 0, n - 1);
  t = clock() - t;
  printf("%f %d\n", (double)t / CLOCKS_PER_SEC, n);
  return isSane(a, n);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <vector_fill_almost_sorted@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmpl   $0x2,-0x8(%rbp)
jle    1287 <main+0xd7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jne    1227 <main+0x77>
mov    -0x14(%rbp),%edi
call   1060 <vector_fill_almost_sorted@plt>
mov    %rax,-0x20(%rbp)
jmp    1282 <main+0xd2>
cmpl   $0x2,-0x34(%rbp)
jne    1242 <main+0x92>
mov    -0x14(%rbp),%edi
call   10d0 <vector_fill_few_unique@plt>
mov    %rax,-0x20(%rbp)
jmp    127d <main+0xcd>
cmpl   $0x3,-0x34(%rbp)
jne    125d <main+0xad>
mov    -0x14(%rbp),%edi
call   10c0 <vector_fill_reverse@plt>
mov    %rax,-0x20(%rbp)
jmp    1278 <main+0xc8>
cmpl   $0x4,-0x34(%rbp)
jne    1273 <main+0xc3>
mov    -0x14(%rbp),%edi
call   1080 <vector_fill_unique@plt>
mov    %rax,-0x20(%rbp)
jmp    1278 <main+0xc8>
jmp    127d <main+0xcd>
jmp    1282 <main+0xd2>
jmp    1293 <main+0xe3>
mov    -0x14(%rbp),%edi
call   1080 <vector_fill_unique@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   10a0 <quickSort@plt>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
cvtsi2sdq -0x40(%rbp),%xmm0
mov    0x2d1d(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x14(%rbp),%esi
lea    0xd27(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <isSane@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r15d
mov    %eax,%edi
call   1060 <vector_fill_almost_sorted@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmp    $0x3,%ebp
jl     1210 <main+0x60>
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     121b <main+0x6b>
lea    0xe03(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %r15d,%edi
call   1060 <vector_fill_almost_sorted@plt>
jmp    1218 <main+0x68>
mov    %r15d,%edi
call   1080 <vector_fill_unique@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
mov    %r15d,%edx
add    $0xffffffff,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   10a0 <quickSort@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2d9d(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdba(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <isSane@plt>
mov    %r15d,%edi
call   10d0 <vector_fill_few_unique@plt>
jmp    1218 <main+0x68>
mov    %r15d,%edi
call   10c0 <vector_fill_reverse@plt>
jmp    1218 <main+0x68>

LLVM IR (-O0):
@.str = [7 x i8] c"%f %d\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i32* @vector_fill_almost_sorted(i32 %18)
store i32* %19, i32** %7
%20 = call i32 @time(i32* null)
%21 = call i32 @srand(i32 %20)
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 2
br i1 %23, label %24, label %56
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %12
%29 = load i32, i32* %12
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %6
%33 = call i32* @vector_fill_almost_sorted(i32 %32)
store i32* %33, i32** %7
br label %55
34: ; preds = %24
%35 = load i32, i32* %12
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %6
%39 = call i32* @vector_fill_few_unique(i32 %38)
store i32* %39, i32** %7
br label %54
40: ; preds = %34
%41 = load i32, i32* %12
%42 = icmp eq i32 %41, 3
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %6
%45 = call i32* @vector_fill_reverse(i32 %44)
store i32* %45, i32** %7
br label %53
46: ; preds = %40
%47 = load i32, i32* %12
%48 = icmp eq i32 %47, 4
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32, i32* %6
%51 = call i32* @vector_fill_unique(i32 %50)
store i32* %51, i32** %7
br label %52
52: ; preds = %49, %46
br label %53
53: ; preds = %52, %43
br label %54
54: ; preds = %53, %37
br label %55
55: ; preds = %54, %31
br label %59
56: ; preds = %2
%57 = load i32, i32* %6
%58 = call i32* @vector_fill_unique(i32 %57)
store i32* %58, i32** %7
br label %59
59: ; preds = %56, %55
%60 = call i64 (...) @clock()
store i64 %60, i64* %13
%61 = load i32*, i32** %7
%62 = load i32, i32* %6
%63 = sub nsw i32 %62, 1
%64 = call i32 @quickSort(i32* %61, i32 0, i32 %63)
%65 = call i64 (...) @clock()
%66 = load i64, i64* %13
%67 = sub nsw i64 %65, %66
store i64 %67, i64* %13
%68 = load i64, i64* %13
%69 = sitofp i64 %68 to double
%70 = load double, double* @CLOCKS_PER_SEC
%71 = fdiv double %69, %70
%72 = load i32, i32* %6
%73 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %71, i32 %72)
%74 = load i32*, i32** %7
%75 = load i32, i32* %6
%76 = call i32 @isSane(i32* %74, i32 %75)
ret i32 %76
}

LLVM IR (-O2):
@.str = [7 x i8] c"%f %d\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call i32* @vector_fill_almost_sorted(i32 %5)
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand(i32 %7)
%9 = icmp sgt i32 %0, 2
br i1 %9, label %10, label %22
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
switch i32 %13, label %24 [
i32 1, label %14
i32 2, label %16
i32 3, label %18
i32 4, label %20
]
14: ; preds = %10
%15 = tail call i32* @vector_fill_almost_sorted(i32 %5)
br label %24
16: ; preds = %10
%17 = tail call i32* @vector_fill_few_unique(i32 %5)
br label %24
18: ; preds = %10
%19 = tail call i32* @vector_fill_reverse(i32 %5)
br label %24
20: ; preds = %10
%21 = tail call i32* @vector_fill_unique(i32 %5)
br label %24
22: ; preds = %2
%23 = tail call i32* @vector_fill_unique(i32 %5)
br label %24
24: ; preds = %14, %18, %20, %16, %10, %22
%25 = phi i32* [ %23, %22 ], [ %15, %14 ], [ %17, %16 ], [ %19, %18 ], [ %21, %20 ], [ %6, %10 ]
%26 = tail call i64 (...) @clock()
%27 = add nsw i32 %5, -1
%28 = tail call i32 @quickSort(i32* %25, i32 0, i32 %27)
%29 = tail call i64 (...) @clock()
%30 = sub nsw i64 %29, %26
%31 = sitofp i64 %30 to double
%32 = load double, double* @CLOCKS_PER_SEC
%33 = fdiv double %31, %32
%34 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %33, i32 %5)
%35 = tail call i32 @isSane(i32* %25, i32 %5)
ret i32 %35
}