#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 */
char **malloc(long);
int /*<<< orphan*/ printArray(char **, int /*<<< orphan*/, long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(char **, long);
void main() {
  long n;
  n = 6;
  char **a;
  a = malloc(n * 8);
  a[0] = "Rachael";
  a[1] = "Monica";
  a[2] = "Phoebe";
  a[3] = "Joey";
  a[4] = "Ross";
  a[5] = "Chandler";
  printf("-------- Before -------\n");
  printArray(a, 0, n - 1);
  quicksort(a, n);
  printf("-------- After -------\n");
  printArray(a, 0, n - 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x6,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
shl    $0x3,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xe94(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
lea    0xe8e(%rip),%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
lea    0xe86(%rip),%rcx
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
lea    0xe7e(%rip),%rcx
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
lea    0xe74(%rip),%rcx
mov    %rcx,0x20(%rax)
mov    -0x10(%rbp),%rax
lea    0xe6a(%rip),%rcx
mov    %rcx,0x28(%rax)
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1060 <printArray@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <quicksort@plt>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
sub    $0x1,%rdx
xor    %esi,%esi
call   1060 <printArray@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x30,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rax
mov    %rax,(%rbx)
lea    0xea9(%rip),%rax
mov    %rax,0x8(%rbx)
lea    0xea5(%rip),%rax
mov    %rax,0x10(%rbx)
lea    0xea1(%rip),%rax
mov    %rax,0x18(%rbx)
lea    0xe9b(%rip),%rax
mov    %rax,0x20(%rbx)
lea    0xe95(%rip),%rax
mov    %rax,0x28(%rbx)
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <printArray@plt>
mov    $0x6,%esi
mov    %rbx,%rdi
call   1040 <quicksort@plt>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edx
mov    %rbx,%rdi
xor    %esi,%esi
pop    %rbx
jmp    1060 <printArray@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Rachael\00"
@.str.1 = [7 x i8] c"Monica\00"
@.str.2 = [7 x i8] c"Phoebe\00"
@.str.3 = [5 x i8] c"Joey\00"
@.str.4 = [5 x i8] c"Ross\00"
@.str.5 = [9 x i8] c"Chandler\00"
@.str.6 = [25 x i8] c"-------- Before -------\0A\00"
@.str.7 = [24 x i8] c"-------- After -------\0A\00"
define void @main() {
%1 = alloca i64
%2 = alloca i8**
store i64 6, i64* %1
%3 = load i64, i64* %1
%4 = mul nsw i64 %3, 8
%5 = call i8** @malloc(i64 %4)
store i8** %5, i8*** %2
%6 = load i8**, i8*** %2
%7 = getelementptr inbounds i8*, i8** %6, i64 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = load i8**, i8*** %2
%9 = getelementptr inbounds i8*, i8** %8, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = load i8**, i8*** %2
%11 = getelementptr inbounds i8*, i8** %10, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = load i8**, i8*** %2
%13 = getelementptr inbounds i8*, i8** %12, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %13
%14 = load i8**, i8*** %2
%15 = getelementptr inbounds i8*, i8** %14, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %15
%16 = load i8**, i8*** %2
%17 = getelementptr inbounds i8*, i8** %16, i64 5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %17
%18 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
%19 = load i8**, i8*** %2
%20 = load i64, i64* %1
%21 = sub nsw i64 %20, 1
%22 = call i32 @printArray(i8** %19, i32 0, i64 %21)
%23 = load i8**, i8*** %2
%24 = load i64, i64* %1
%25 = call i32 @quicksort(i8** %23, i64 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
%27 = load i8**, i8*** %2
%28 = load i64, i64* %1
%29 = sub nsw i64 %28, 1
%30 = call i32 @printArray(i8** %27, i32 0, i64 %29)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"Rachael\00"
@.str.1 = [7 x i8] c"Monica\00"
@.str.2 = [7 x i8] c"Phoebe\00"
@.str.3 = [5 x i8] c"Joey\00"
@.str.4 = [5 x i8] c"Ross\00"
@.str.5 = [9 x i8] c"Chandler\00"
@str = [24 x i8] c"-------- Before -------\00"
@str.8 = [23 x i8] c"-------- After -------\00"
define void @main() {
%1 = tail call i8** @malloc(i64 48)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %1
%2 = getelementptr inbounds i8*, i8** %1, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
%3 = getelementptr inbounds i8*, i8** %1, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds i8*, i8** %1, i64 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds i8*, i8** %1, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds i8*, i8** %1, i64 5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %6
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @printArray(i8** %1, i32 0, i64 5)
%9 = tail call i32 @quicksort(i8** %1, i64 6)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%11 = tail call i32 @printArray(i8** %1, i32 0, i64 5)
ret void
}