#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 */

/* Variables and functions */
int INT_MAX;
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(long);
int /*<<< orphan*/ printf(char *);
int quickSort(int *, long);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
long strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int *arr;
  int i;
  long size;
  bool ret;
  if (argc < 2) {
    printf("Wrong number.\n");
    return 42;
  }
  size = strtol(argv[1], NULL, 10);
  arr = (int *)malloc(size * sizeof(int));
  srand(time(NULL));
  for (int i = 0; i < size; i++)
    arr[i] = rand() % INT_MAX;
  ret = quickSort(arr, size - 1);
  free(arr);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    11b8 <main+0x38>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
movl   $0x2a,-0x4(%rbp)
jmp    124f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
shl    $0x2,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x30(%rbp)
movslq -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    1232 <main+0xb2>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    0x2dd2(%rip),%rcx
cltd
idivl  (%rcx)
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11fa <main+0x7a>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
sub    $0x1,%rsi
call   1090 <quickSort@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x1,%edi
jg     11a2 <main+0x22>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x2a,%r14d
jmp    1220 <main+0xa0>
mov    0x8(%rsi),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
mov    %rax,%r13
lea    0x0(,%rax,4),%rdi
call   1080 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
test   %r13,%r13
jle    1209 <main+0x89>
mov    0x2e06(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   10a0 <rand@plt>
cltd
idivl  (%r12)
mov    %edx,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11f0 <main+0x70>
add    $0xffffffffffffffff,%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   1090 <quickSort@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Wrong number.\0A\00"
@INT_MAX = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 42, i32* %3
br label %49
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @strtol(i8* %18, i32* null, i32 10)
store i64 %19, i64* %8
%20 = load i64, i64* %8
%21 = mul i64 %20, 4
%22 = call i64 @malloc(i64 %21)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %6
%24 = call i32 @time(i32* null)
%25 = call i32 @srand(i32 %24)
store i32 0, i32* %10
br label %26
26: ; preds = %39, %15
%27 = load i32, i32* %10
%28 = sext i32 %27 to i64
%29 = load i64, i64* %8
%30 = icmp slt i64 %28, %29
br i1 %30, label %31, label %42
31: ; preds = %26
%32 = call i32 (...) @rand()
%33 = load i32, i32* @INT_MAX
%34 = srem i32 %32, %33
%35 = load i32*, i32** %6
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
store i32 %34, i32* %38
br label %39
39: ; preds = %31
%40 = load i32, i32* %10
%41 = add nsw i32 %40, 1
store i32 %41, i32* %10
br label %26
42: ; preds = %26
%43 = load i32*, i32** %6
%44 = load i64, i64* %8
%45 = sub nsw i64 %44, 1
%46 = call i32 @quickSort(i32* %43, i64 %45)
store i32 %46, i32* %9
%47 = load i32*, i32** %6
%48 = call i32 @free(i32* %47)
br label %49
49: ; preds = %42, %13
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@INT_MAX = global i32 0
@str = [14 x i8] c"Wrong number.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %28
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strtol(i8* nocapture %8, i32* null, i32 10)
%10 = shl i64 %9, 2
%11 = tail call i64 @malloc(i64 %10)
%12 = inttoptr i64 %11 to i32*
%13 = tail call i32 @time(i32* null)
%14 = tail call i32 @srand(i32 %13)
%15 = icmp sgt i64 %9, 0
br i1 %15, label %20, label %16
16: ; preds = %20, %6
%17 = add nsw i64 %9, -1
%18 = tail call i32 @quickSort(i32* %12, i64 %17)
%19 = tail call i32 @free(i32* %12)
br label %28
20: ; preds = %6, %20
%21 = phi i64 [ %26, %20 ], [ 0, %6 ]
%22 = tail call i32 (...) @rand()
%23 = load i32, i32* @INT_MAX
%24 = srem i32 %22, %23
%25 = getelementptr inbounds i32, i32* %12, i64 %21
store i32 %24, i32* %25
%26 = add nuw nsw i64 %21, 1
%27 = icmp eq i64 %26, %9
br i1 %27, label %16, label %20
28: ; preds = %16, %4
%29 = phi i32 [ 42, %4 ], [ 0, %16 ]
ret i32 %29
}