#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 */
size_t partition(int *, size_t, size_t, size_t);
void quicksort_aux(int arr[], size_t low, size_t high) {
  if (high < low || high - low <= 1)
    return;
  size_t pivot = (low + high) / 2;
  pivot = partition(arr, low, high, pivot);
  quicksort_aux(arr, low, pivot);
  quicksort_aux(arr, pivot + 1, high);
}


x86 assembly (clang, -O0):
<quicksort_aux>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     1154 <quicksort_aux+0x34>
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
cmp    $0x1,%rax
ja     1159 <quicksort_aux+0x39>
jmp    11a8 <quicksort_aux+0x88>
mov    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <partition@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <quicksort_aux@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
call   1040 <quicksort_aux@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort_aux>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rax
sub    %rsi,%rax
jb     117b <quicksort_aux+0x5b>
cmp    $0x2,%rax
jb     117b <quicksort_aux+0x5b>
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
nop
lea    (%rbx,%r15,1),%rcx
shr    %rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1030 <partition@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <quicksort_aux@plt>
mov    %r12,%rbx
add    $0x1,%rbx
mov    %r15,%rax
sub    %rbx,%rax
jb     117b <quicksort_aux+0x5b>
cmp    $0x1,%rax
ja     1140 <quicksort_aux+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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