#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 partition(int, int, int, int *);
void quickSort(int left, int right, int *numbers) {
  if (right - left <= 0) {
    return;
  } else {
    int pivot = numbers[right];
    int partitionPoint = partition(left, right, pivot, numbers);
    quickSort(left, partitionPoint - 1, numbers);
    quickSort(partitionPoint + 1, right, numbers);
  }
}


x86 assembly (clang, -O0):
<quickSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
cmp    $0x0,%eax
jg     1146 <quickSort+0x26>
jmp    118d <quickSort+0x6d>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rcx
call   1030 <partition@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%rdx
call   1040 <quickSort@plt>
mov    -0x18(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <quickSort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickSort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %edi,%esi
jle    116a <quickSort+0x4a>
mov    %rdx,%r15
mov    %esi,%r14d
mov    %edi,%ebp
movslq %esi,%r12
nopw   0x0(%rax,%rax,1)
mov    (%r15,%r12,4),%edx
mov    %ebp,%edi
mov    %r14d,%esi
mov    %r15,%rcx
call   1030 <partition@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%esi
mov    %ebp,%edi
mov    %r15,%rdx
call   1040 <quickSort@plt>
add    $0x1,%ebx
mov    %ebx,%ebp
cmp    %r14d,%ebx
jl     1140 <quickSort+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @quickSort(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = sub nsw i32 %9, %10
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
br label %33
14: ; preds = %3
%15 = load i32*, i32** %6
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
store i32 %19, i32* %7
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = load i32*, i32** %6
%24 = call i32 @partition(i32 %20, i32 %21, i32 %22, i32* %23)
store i32 %24, i32* %8
%25 = load i32, i32* %4
%26 = load i32, i32* %8
%27 = sub nsw i32 %26, 1
%28 = load i32*, i32** %6
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %5
%32 = load i32*, i32** %6
br label %33
33: ; preds = %13, %14
ret void
}

LLVM IR (-O2):
define void @quickSort(i32 %0, i32 %1, i32* %2) {
%4 = icmp sgt i32 %1, %0
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = sext i32 %1 to i64
%7 = getelementptr inbounds i32, i32* %2, i64 %6
br label %8
8: ; preds = %5, %8
%9 = phi i32 [ %0, %5 ], [ %13, %8 ]
%10 = load i32, i32* %7
%11 = tail call i32 @partition(i32 %9, i32 %1, i32 %10, i32* %2)
%12 = add nsw i32 %11, -1
tail call void @quickSort(i32 %9, i32 %12, i32* %2)
%13 = add nsw i32 %11, 1
%14 = icmp slt i32 %13, %1
br i1 %14, label %8, label %15
15: ; preds = %8, %3
ret void
}