#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 *generateRandomArrayOfInts(int);
scalar_t__ isArraySorted(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksortIntArray(int *, int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int arraySize = 10;
  int *sortArray = generateRandomArrayOfInts(arraySize);
  printf("start work\n");
  quicksortIntArray(sortArray, arraySize);
  printf("end\n");
  if (isArraySorted(sortArray, arraySize)) {
    printf("SUCCEEDED!\n");
  } else {
    printf("FAILED\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <generateRandomArrayOfInts@plt>
mov    %rax,-0x10(%rbp)
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <quicksortIntArray@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <isArraySorted@plt>
cmp    $0x0,%rax
je     11dd <main+0x7d>
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
jmp    11e9 <main+0x89>
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0xa,%edi
call   1040 <generateRandomArrayOfInts@plt>
mov    %rax,%rbx
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1060 <quicksortIntArray@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1080 <isArraySorted@plt>
test   %rax,%rax
lea    0xe57(%rip),%rax
lea    0xe57(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"start work\0A\00"
@.str.1 = [5 x i8] c"end\0A\00"
@.str.2 = [12 x i8] c"SUCCEEDED!\0A\00"
@.str.3 = [8 x i8] c"FAILED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32 @time(i32* null)
%5 = call i32 @srand(i32 %4)
store i32 10, i32* %2
%6 = load i32, i32* %2
%7 = call i32* @generateRandomArrayOfInts(i32 %6)
store i32* %7, i32** %3
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%9 = load i32*, i32** %3
%10 = load i32, i32* %2
%11 = call i32 @quicksortIntArray(i32* %9, i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32*, i32** %3
%14 = load i32, i32* %2
%15 = call i64 @isArraySorted(i32* %13, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret i32 0
}

LLVM IR (-O2):
@str = [11 x i8] c"start work\00"
@str.4 = [4 x i8] c"end\00"
@str.5 = [7 x i8] c"FAILED\00"
@str.6 = [11 x i8] c"SUCCEEDED!\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = tail call i32* @generateRandomArrayOfInts(i32 10)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @quicksortIntArray(i32* %3, i32 10)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0))
%7 = tail call i64 @isArraySorted(i32* %3, i32 10)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0)
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 0
}