#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int *init_array(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ verify_array(int *, int);
int main(int argc, char **argv) {
  int *array, N;
  if (argc < 2) {
    printf("Usage: ./qsort <N>\n");
    exit(0);
  }
  if ((N = atoi(argv[1])) < 2) {
    printf("<N> must be greater than 2\n");
    exit(0);
  }
  array = init_array(N);
  quicksort(array, 0, N - 1);
  verify_array(array, N);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    118c <main+0x2c>
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x2,%eax
jge    11b8 <main+0x58>
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x1c(%rbp),%edi
call   1050 <init_array@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <quicksort@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <verify_array@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jle    11a6 <main+0x46>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
cmp    $0x1,%eax
jle    11af <main+0x4f>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <init_array@plt>
mov    %rax,%r14
mov    %ebx,%edx
add    $0xffffffff,%edx
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <quicksort@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <verify_array@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe6e(%rip),%rdi
jmp    11b6 <main+0x56>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Usage: ./qsort <N>\0A\00"
@.str.1 = [28 x i8] c"<N> must be greater than 2\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %4
%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 = icmp slt i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %12
%22 = load i32, i32* %6
%23 = call i32* @init_array(i32 %22)
store i32* %23, i32** %5
%24 = load i32*, i32** %5
%25 = load i32, i32* %6
%26 = sub nsw i32 %25, 1
%27 = call i32 @quicksort(i32* %24, i32 0, i32 %26)
%28 = load i32*, i32** %5
%29 = load i32, i32* %6
%30 = call i32 @verify_array(i32* %28, i32 %29)
ret i32 0
}

LLVM IR (-O2):
@str = [27 x i8] c"<N> must be greater than 2\00"
@str.2 = [19 x i8] c"Usage: ./qsort <N>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.2, i64 0, i64 0))
%6 = tail call i32 @exit(i32 0)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %7
%16 = tail call i32* @init_array(i32 %10)
%17 = add nsw i32 %10, -1
%18 = tail call i32 @quicksort(i32* %16, i32 0, i32 %17)
%19 = tail call i32 @verify_array(i32* %16, i32 %10)
ret i32 0
}