#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 HoarePartition(void *, size_t, size_t, size_t,
                      int (*)(void const *, void const *));
void QuickSortR(void *arr, size_t l, size_t r, size_t data_size,
                int (*cmp)(const void *a, const void *b)) {
  size_t q;
  if (r <= l) {
    return;
  }
  q = HoarePartition(arr, l, r, data_size, cmp);
  QuickSortR(arr, l, q - 1, data_size, cmp);
  QuickSortR(arr, q + 1, r, data_size, cmp);
  return;
}


x86 assembly (clang, -O0):
<QuickSortR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     114f <QuickSortR+0x2f>
jmp    11a6 <QuickSortR+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <HoarePartition@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
sub    $0x1,%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <QuickSortR@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <QuickSortR@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuickSortR>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    %rsi,%rdx
jbe    1178 <QuickSortR+0x58>
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r13
nop
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1030 <HoarePartition@plt>
mov    %rax,%rbp
lea    -0x1(%rax),%rdx
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15,%rcx
mov    %r14,%r8
call   1040 <QuickSortR@plt>
add    $0x1,%rbp
mov    %rbp,%rbx
cmp    %r12,%rbp
jb     1140 <QuickSortR+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @QuickSortR(i8* %0, i64 %1, i64 %2, i64 %3, i32 (i8*, i8*)* %4) {
%6 = icmp ugt i64 %2, %1
br i1 %6, label %7, label %13
7: ; preds = %5, %7
%8 = phi i64 [ %11, %7 ], [ %1, %5 ]
%9 = tail call i64 @HoarePartition(i8* %0, i64 %8, i64 %2, i64 %3, i32 (i8*, i8*)* %4)
%10 = add i64 %9, -1
tail call void @QuickSortR(i8* %0, i64 %8, i64 %10, i64 %3, i32 (i8*, i8*)* %4)
%11 = add i64 %9, 1
%12 = icmp ult i64 %11, %2
br i1 %12, label %7, label %13
13: ; preds = %7, %5
ret void
}