#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 */
typedef int /*<<< orphan*/ A;

/* Variables and functions */
int /*<<< orphan*/ printArray(char *, int *, int);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int main() {
  int A[] = {9, 2, 1, 4,  8,  6,  7,  2,  3, 5,  6, 2,
             3, 1, 9, 10, 15, 13, 12, 17, 0, 99, 20};
  int numberOfElements = sizeof(A) / sizeof(A[0]);
  printArray("Original array: ", A, numberOfElements);
  quick_sort(A, 0, numberOfElements - 1);
  printArray("Sorted array: ", A, numberOfElements);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x5c,%edx
call   1030 <memcpy@plt>
movl   $0x17,-0x64(%rbp)
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xef3(%rip),%rdi
call   1050 <printArray@plt>
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <quick_sort@plt>
lea    -0x60(%rbp),%rsi
mov    -0x64(%rbp),%edx
lea    0xee0(%rip),%rdi
call   1050 <printArray@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
movups 0xf20(%rip),%xmm0
movups %xmm0,0x4c(%rsp)
movaps 0xf08(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeec(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee9(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x17,%edx
call   1040 <printArray@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x16,%edx
call   1030 <quick_sort@plt>
lea    0xed4(%rip),%rdi
mov    %rbx,%rsi
mov    $0x17,%edx
call   1040 <printArray@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A = [23 x i32] [i32 9, i32 2, i32 1, i32 4, i32 8, i32 6, i32 7, i32 2, i32 3, i32 5, i32 6, i32 2, i32 3, i32 1, i32 9, i32 10, i32 15, i32 13, i32 12, i32 17, i32 0, i32 99, i32 20]
@.str = [17 x i8] c"Original array: \00"
@.str.1 = [15 x i8] c"Sorted array: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [23 x i32]* %2 to i8*
store i32 23, i32* %3
%5 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 0
%6 = load i32, i32* %3
%7 = call i32 @printArray(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* %5, i32 %6)
%8 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 0
%9 = load i32, i32* %3
%10 = sub nsw i32 %9, 1
%11 = call i32 @quick_sort(i32* %8, i32 0, i32 %10)
%12 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call i32 @printArray(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %12, i32 %13)
ret i32 0
}

LLVM IR (-O2):
@__const.main.A = [23 x i32] [i32 9, i32 2, i32 1, i32 4, i32 8, i32 6, i32 7, i32 2, i32 3, i32 5, i32 6, i32 2, i32 3, i32 1, i32 9, i32 10, i32 15, i32 13, i32 12, i32 17, i32 0, i32 99, i32 20]
@.str = [17 x i8] c"Original array: \00"
@.str.1 = [15 x i8] c"Sorted array: \00"
define i32 @main() {
%1 = alloca [23 x i32]
%2 = bitcast [23 x i32]* %1 to i8*
%3 = getelementptr inbounds [23 x i32], [23 x i32]* %1, i64 0, i64 0
%4 = call i32 @printArray(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32* %3, i32 23)
%5 = call i32 @quick_sort(i32* %3, i32 0, i32 22)
%6 = call i32 @printArray(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32 23)
ret i32 0
}