#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);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double, int);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stoogesort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int n = atoi(argv[1]);
  int *a = (int *)malloc(sizeof(int) * n);
  int i, j, m, flag;
  srand(time(NULL));
  for (i = 0; i < n; i++) {
    a[i] = rand() % n;
  }
  time_t t = clock();
  stoogesort(a, 0, n);
  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   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1210 <main+0x80>
mov    $0x0,%al
call   10b0 <rand@plt>
cltd
idivl  -0x14(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e0 <main+0x50>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %esi,%esi
call   1030 <stoogesort@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
cvtsi2sdq -0x38(%rbp),%xmm0
mov    0x2da3(%rip),%rax
divsd  (%rax),%xmm0
mov    -0x14(%rbp),%esi
lea    0xdad(%rip),%rdi
call   1050 <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   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
lea    0x0(,%r12,4),%edi
call   1080 <malloc@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
test   %r12d,%r12d
jle    11e8 <main+0x58>
mov    %r12d,%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   10b0 <rand@plt>
cltd
idiv   %r12d
mov    %edx,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11d0 <main+0x40>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r15
mov    %r14,%rdi
xor    %esi,%esi
mov    %r12d,%edx
call   1030 <stoogesort@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r15,%rax
cvtsi2sd %rax,%xmm0
mov    0x2dd3(%rip),%rax
divsd  (%rax),%xmm0
lea    0xde0(%rip),%rdi
mov    %r12d,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r12d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1090 <isSane@plt>

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 i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = mul i64 4, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %7
%23 = call i32 @time(i32* null)
%24 = call i32 @srand(i32 %23)
store i32 0, i32* %8
br label %25
25: ; preds = %37, %2
%26 = load i32, i32* %8
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = call i32 (...) @rand()
%31 = load i32, i32* %6
%32 = srem i32 %30, %31
%33 = load i32*, i32** %7
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %32, i32* %36
br label %37
37: ; preds = %29
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
br label %25
40: ; preds = %25
%41 = call i64 (...) @clock()
store i64 %41, i64* %12
%42 = load i32*, i32** %7
%43 = load i32, i32* %6
%44 = call i32 @stoogesort(i32* %42, i32 0, i32 %43)
%45 = call i64 (...) @clock()
%46 = load i64, i64* %12
%47 = sub nsw i64 %45, %46
store i64 %47, i64* %12
%48 = load i64, i64* %12
%49 = sitofp i64 %48 to double
%50 = load double, double* @CLOCKS_PER_SEC
%51 = fdiv double %49, %50
%52 = load i32, i32* %6
%53 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %51, i32 %52)
%54 = load i32*, i32** %7
%55 = load i32, i32* %6
%56 = call i32 @isSane(i32* %54, i32 %55)
ret i32 %56
}

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 = shl i32 %5, 2
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i32*
%9 = tail call i32 @time(i32* null)
%10 = tail call i32 @srand(i32 %9)
%11 = icmp sgt i32 %5, 0
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = zext i32 %5 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %19, %14 ]
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, %5
%18 = getelementptr inbounds i32, i32* %8, i64 %15
store i32 %17, i32* %18
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %13
br i1 %20, label %21, label %14
21: ; preds = %14, %2
%22 = tail call i64 (...) @clock()
%23 = tail call i32 @stoogesort(i32* %8, i32 0, i32 %5)
%24 = tail call i64 (...) @clock()
%25 = sub nsw i64 %24, %22
%26 = sitofp i64 %25 to double
%27 = load double, double* @CLOCKS_PER_SEC
%28 = fdiv double %26, %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %28, i32 %5)
%30 = tail call i32 @isSane(i32* %8, i32 %5)
ret i32 %30
}