#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*/ swap(int *, int *);
void quicksort(int *begin, int *end) {
  int *ptr;
  int *split;
  if (end - begin <= 1)
    return;
  ptr = begin;
  split = begin + 1;
  while (++ptr <= end) {
    if (*ptr < *begin) {
      swap(ptr, split);
      ++split;
    }
  }
  swap(begin, split - 1);
  quicksort(begin, split - 1);
  quicksort(split, end);
}


x86 assembly (clang, -O0):
<quicksort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
cmp    $0x1,%rax
jg     114e <quicksort+0x2e>
jmp    11d7 <quicksort+0xb7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
cmp    -0x10(%rbp),%rax
ja     11a8 <quicksort+0x88>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a3 <quicksort+0x83>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <swap@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1162 <quicksort+0x42>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0xfffffffffffffffc,%rsi
call   1040 <swap@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0xfffffffffffffffc,%rsi
call   1030 <quicksort@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <quicksort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quicksort>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rax
sub    %rdi,%rax
cmp    $0x8,%rax
jge    1140 <quicksort+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsi,%r14
mov    %rdi,%r15
jmp    117d <quicksort+0x5d>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%r12
lea    -0x4(%r12),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <swap@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <quicksort@plt>
mov    %r14,%rax
sub    %r12,%rax
mov    %r12,%r15
cmp    $0x7,%rax
jle    1134 <quicksort+0x14>
lea    0x4(%r15),%rbx
cmp    %r14,%rbx
ja     1150 <quicksort+0x30>
mov    %rbx,%r12
jmp    1199 <quicksort+0x79>
nopl   0x0(%rax,%rax,1)
add    $0x4,%rbx
cmp    %r14,%rbx
ja     1153 <quicksort+0x33>
mov    (%rbx),%eax
cmp    (%r15),%eax
jge    1190 <quicksort+0x70>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <swap@plt>
add    $0x4,%r12
jmp    1190 <quicksort+0x70>

LLVM IR (-O0):
define void @quicksort(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%7 = load i32*, i32** %4
%8 = load i32*, i32** %3
%9 = ptrtoint i32* %7 to i64
%10 = ptrtoint i32* %8 to i64
%11 = sub i64 %9, %10
%12 = sdiv exact i64 %11, 4
%13 = icmp sle i64 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %2
br label %47
15: ; preds = %2
%16 = load i32*, i32** %3
store i32* %16, i32** %5
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 1
store i32* %18, i32** %6
br label %19
19: ; preds = %36, %15
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i32 1
store i32* %21, i32** %5
%22 = load i32*, i32** %4
%23 = icmp ule i32* %21, %22
br i1 %23, label %24, label %37
24: ; preds = %19
%25 = load i32*, i32** %5
%26 = load i32, i32* %25
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i32*, i32** %5
%32 = load i32*, i32** %6
%33 = call i32 @swap(i32* %31, i32* %32)
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i32 1
store i32* %35, i32** %6
br label %36
36: ; preds = %30, %24
br label %19
37: ; preds = %19
%38 = load i32*, i32** %3
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i64 -1
%41 = call i32 @swap(i32* %38, i32* %40)
%42 = load i32*, i32** %3
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 -1
%45 = load i32*, i32** %6
%46 = load i32*, i32** %4
br label %47
47: ; preds = %37, %14
ret void
}

LLVM IR (-O2):
define void @quicksort(i32* %0, i32* %1) {
%3 = ptrtoint i32* %1 to i64
%4 = ptrtoint i32* %0 to i64
%5 = sub i64 %3, %4
%6 = icmp slt i64 %5, 8
br i1 %6, label %31, label %7
7: ; preds = %2, %24
%8 = phi i32* [ %25, %24 ], [ %0, %2 ]
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = icmp ugt i32* %9, %1
br i1 %10, label %24, label %11
11: ; preds = %7, %20
%12 = phi i32* [ %22, %20 ], [ %9, %7 ]
%13 = phi i32* [ %21, %20 ], [ %9, %7 ]
%14 = load i32, i32* %12
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = tail call i32 @swap(i32* %12, i32* %13)
%19 = getelementptr inbounds i32, i32* %13, i64 1
br label %20
20: ; preds = %17, %11
%21 = phi i32* [ %19, %17 ], [ %13, %11 ]
%22 = getelementptr inbounds i32, i32* %12, i64 1
%23 = icmp ugt i32* %22, %1
br i1 %23, label %24, label %11
24: ; preds = %20, %7
%25 = phi i32* [ %9, %7 ], [ %21, %20 ]
%26 = getelementptr inbounds i32, i32* %25, i64 -1
%27 = tail call i32 @swap(i32* %8, i32* %26)
tail call void @quicksort(i32* %8, i32* %26)
%28 = ptrtoint i32* %25 to i64
%29 = sub i64 %3, %28
%30 = icmp slt i64 %29, 8
br i1 %30, label %31, label %7
31: ; preds = %24, %2
ret void
}