#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 /*<<< orphan*/ insertionSort(long *, long, long);
long partition(long *, long, long);
void quickSort(long a[], long l, long r) {
  if (r - l < 10) {
    insertionSort(a, l, r);
    return;
  }
  long j;
  if (l < r) {
    j = partition(a, l, r);
    quickSort(a, l, j - 1);
    quickSort(a, j + 1, r);
  }
}


x86 assembly (clang, -O0):
<quickSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cmp    $0xa,%rax
jge    116c <quickSort+0x3c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <insertionSort@plt>
jmp    11b9 <quickSort+0x89>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    11b9 <quickSort+0x89>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <partition@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
sub    $0x1,%rdx
call   1050 <quickSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
call   1050 <quickSort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickSort>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rdx,%rax
sub    %rsi,%rax
cmp    $0xa,%rax
jge    1160 <quickSort+0x30>
mov    %r12,%rbx
jmp    1198 <quickSort+0x68>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r15,%r12
jge    11b1 <quickSort+0x81>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1030 <partition@plt>
mov    %rax,%rbx
lea    -0x1(%rax),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <quickSort@plt>
add    $0x1,%rbx
mov    %r15,%rax
sub    %rbx,%rax
mov    %rbx,%r12
cmp    $0xa,%rax
jge    1160 <quickSort+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <insertionSort@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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