#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 partition(int, int *);
int /*<<< orphan*/ print_arr(int, int *);
void quickSort(int ar_size, int *ar) {
  if (ar_size > 1) {
    int p = partition(ar_size, ar);
    quickSort(p, ar);
    int *temp_ar;
    temp_ar = &ar[p + 1];
    quickSort(ar_size - p - 1, temp_ar);
    print_arr(ar_size, ar);
  }
}


x86 assembly (clang, -O0):
<quickSort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    119a <quickSort+0x6a>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <partition@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <quickSort@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
sub    -0x14(%rbp),%edi
sub    $0x1,%edi
mov    -0x20(%rbp),%rsi
call   1050 <quickSort@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <print_arr@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickSort>:
cmp    $0x1,%edi
jle    1172 <quickSort+0x42>
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <partition@plt>
mov    %eax,%r14d
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <quickSort@plt>
movslq %r14d,%rdi
lea    (%rbx,%rdi,4),%rsi
add    $0x4,%rsi
not    %edi
add    %ebp,%edi
call   1050 <quickSort@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <print_arr@plt>
ret

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* %3
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %28
9: ; preds = %2
%10 = load i32, i32* %3
%11 = load i32*, i32** %4
%12 = call i32 @partition(i32 %10, i32* %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = load i32*, i32** %4
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
store i32* %19, i32** %6
%20 = load i32, i32* %3
%21 = load i32, i32* %5
%22 = sub nsw i32 %20, %21
%23 = sub nsw i32 %22, 1
%24 = load i32*, i32** %6
%25 = load i32, i32* %3
%26 = load i32*, i32** %4
%27 = call i32 @print_arr(i32 %25, i32* %26)
br label %28
28: ; preds = %9, %2
ret void
}

LLVM IR (-O2):
define void @quickSort(i32 %0, i32* %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %5, label %4
4: ; preds = %2, %5
ret void
5: ; preds = %2
%6 = tail call i32 @partition(i32 %0, i32* %1)
tail call void @quickSort(i32 %6, i32* %1)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = xor i32 %6, -1
%11 = add i32 %10, %0
tail call void @quickSort(i32 %11, i32* %9)
%12 = tail call i32 @print_arr(i32 %0, i32* %1)
br label %4
}