#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int *arrGen(int);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printArray(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quickSort(int *, int);
int /*<<< orphan*/ srand(int);
int strtol(char *, int /*<<< orphan*/ *, int);
int time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("need a positive integer\n");
    return EXIT_FAILURE;
  }
  if (argc == 3) {
    srand(strtol(argv[2], NULL, 10));
  } else {
    srand(time(NULL));
  }
  int num = strtol(argv[1], NULL, 10);
  if (num <= 0) {
    printf("need a positive integer\n");
    return EXIT_FAILURE;
  }
  int *arr = arrGen(num);
  printArray(arr, num);
  quickSort(arr, num);
  printArray(arr, num);
  free(arr);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bd <main+0x3d>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127e <main+0xfe>
cmpl   $0x3,-0x8(%rbp)
jne    11e9 <main+0x69>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,%edi
call   1060 <srand@plt>
jmp    11f9 <main+0x79>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     1239 <main+0xb9>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127e <main+0xfe>
mov    -0x14(%rbp),%edi
call   1050 <arrGen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <printArray@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <quickSort@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <printArray@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    1200 <main+0x80>
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11a3 <main+0x23>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
jmp    11aa <main+0x2a>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
test   %eax,%eax
jle    1200 <main+0x80>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <arrGen@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %ebx,%esi
call   10a0 <printArray@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1090 <quickSort@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   10a0 <printArray@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2dda(%rip),%rax
jmp    1213 <main+0x93>
lea    0xdf9(%rip),%rdi
call   1040 <puts@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"need a positive integer\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = 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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %3
br label %50
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 3
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @strtol(i8* %19, i32* null, i32 10)
%21 = call i32 @srand(i32 %20)
br label %25
22: ; preds = %13
%23 = call i32 @time(i32* null)
%24 = call i32 @srand(i32 %23)
br label %25
25: ; preds = %22, %16
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strtol(i8* %28, i32* null, i32 10)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp sle i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %50
35: ; preds = %25
%36 = load i32, i32* %6
%37 = call i32* @arrGen(i32 %36)
store i32* %37, i32** %7
%38 = load i32*, i32** %7
%39 = load i32, i32* %6
%40 = call i32 @printArray(i32* %38, i32 %39)
%41 = load i32*, i32** %7
%42 = load i32, i32* %6
%43 = call i32 @quickSort(i32* %41, i32 %42)
%44 = load i32*, i32** %7
%45 = load i32, i32* %6
%46 = call i32 @printArray(i32* %44, i32 %45)
%47 = load i32*, i32** %7
%48 = call i32 @free(i32* %47)
%49 = load i32, i32* @EXIT_SUCCESS
store i32 %49, i32* %3
br label %50
50: ; preds = %35, %32, %10
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str.1 = [24 x i8] c"need a positive integer\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 ([24 x i8], [24 x i8]* @str.1, i64 0, i64 0))
br label %29
6: ; preds = %2
%7 = icmp eq i32 %0, 3
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = tail call i32 @strtol(i8* nocapture %10, i32* null, i32 10)
br label %14
12: ; preds = %6
%13 = tail call i32 @time(i32* null)
br label %14
14: ; preds = %12, %8
%15 = phi i32 [ %13, %12 ], [ %11, %8 ]
%16 = tail call i32 @srand(i32 %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @strtol(i8* nocapture %18, i32* null, i32 10)
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.1, i64 0, i64 0))
br label %29
23: ; preds = %14
%24 = tail call i32* @arrGen(i32 %19)
%25 = tail call i32 @printArray(i32* %24, i32 %19)
%26 = tail call i32 @quickSort(i32* %24, i32 %19)
%27 = tail call i32 @printArray(i32* %24, i32 %19)
%28 = tail call i32 @free(i32* %24)
br label %29
29: ; preds = %21, %23, %4
%30 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %21 ], [ @EXIT_SUCCESS, %23 ]
%31 = load i32, i32* %30
ret i32 %31
}