#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 hoarepartition(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
void quicksort(int *values, int start, int end) {
  int pivot;
  if ((end - start) > 1) {
    pivot = hoarepartition(values, start, end);
    printf("%d\n", pivot);
    quicksort(values, start, pivot);
    quicksort(values, pivot + 1, end);
  }
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
cmp    $0x1,%eax
jle    1193 <quicksort+0x63>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <hoarepartition@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <quicksort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
call   1030 <quicksort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%eax
sub    %esi,%eax
cmp    $0x2,%eax
jl     1184 <quicksort+0x54>
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
lea    0xeb0(%rip),%r14
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
call   1050 <hoarepartition@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <quicksort@plt>
add    $0x1,%ebp
mov    %r15d,%eax
sub    %ebp,%eax
mov    %ebp,%ebx
cmp    $0x1,%eax
jg     1150 <quicksort+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @quicksort(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = sub nsw i32 %8, %9
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %26
12: ; preds = %3
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = call i32 @hoarepartition(i32* %13, i32 %14, i32 %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = load i32, i32* %7
%22 = load i32*, i32** %4
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = load i32, i32* %6
br label %26
26: ; preds = %12, %3
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @quicksort(i32* %0, i32 %1, i32 %2) {
%4 = sub nsw i32 %2, %1
%5 = icmp sgt i32 %4, 1
br i1 %5, label %6, label %13
6: ; preds = %3, %6
%7 = phi i32 [ %10, %6 ], [ %1, %3 ]
%8 = tail call i32 @hoarepartition(i32* %0, i32 %7, i32 %2)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
tail call void @quicksort(i32* %0, i32 %7, i32 %8)
%10 = add nsw i32 %8, 1
%11 = sub nsw i32 %2, %10
%12 = icmp sgt i32 %11, 1
br i1 %12, label %6, label %13
13: ; preds = %6, %3
ret void
}