#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 */
long long partition(long long **, long long, long long, long long);
void quickSort(long long arr[1000][3], long long low, long long high,
               long long pos) {
  if (low < high) {
    long long pi = partition(arr, low, high, pos);
    quickSort(arr, low, pi - 1, pos);
    quickSort(arr, pi + 1, high, pos);
  }
}


x86 assembly (clang, -O0):
<quickSort>:
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    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1191 <quickSort+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1030 <partition@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
mov    -0x20(%rbp),%rcx
call   1040 <quickSort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <quickSort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quickSort>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    %rdx,%rsi
jge    1172 <quickSort+0x52>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1030 <partition@plt>
mov    %rax,%rbx
lea    -0x1(%rax),%rdx
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r14,%rcx
call   1040 <quickSort@plt>
add    $0x1,%rbx
mov    %rbx,%r13
cmp    %r15,%rbx
jl     1140 <quickSort+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @quickSort([3 x i64]* %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca [3 x i64]*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store [3 x i64]* %0, [3 x i64]** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %6
%11 = load i64, i64* %7
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %4
%14 = load [3 x i64]*, [3 x i64]** %5
%15 = bitcast [3 x i64]* %14 to i64**
%16 = load i64, i64* %6
%17 = load i64, i64* %7
%18 = load i64, i64* %8
%19 = call i64 @partition(i64** %15, i64 %16, i64 %17, i64 %18)
store i64 %19, i64* %9
%20 = load [3 x i64]*, [3 x i64]** %5
%21 = load i64, i64* %6
%22 = load i64, i64* %9
%23 = sub nsw i64 %22, 1
%24 = load i64, i64* %8
%25 = load [3 x i64]*, [3 x i64]** %5
%26 = load i64, i64* %9
%27 = add nsw i64 %26, 1
%28 = load i64, i64* %7
%29 = load i64, i64* %8
br label %30
30: ; preds = %13, %4
ret void
}

LLVM IR (-O2):
define void @quickSort([3 x i64]* %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp slt i64 %1, %2
br i1 %5, label %6, label %14
6: ; preds = %4
%7 = bitcast [3 x i64]* %0 to i64**
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ %1, %6 ], [ %12, %8 ]
%10 = tail call i64 @partition(i64** %7, i64 %9, i64 %2, i64 %3)
%11 = add nsw i64 %10, -1
tail call void @quickSort([3 x i64]* %0, i64 %9, i64 %11, i64 %3)
%12 = add nsw i64 %10, 1
%13 = icmp slt i64 %12, %2
br i1 %13, label %8, label %14
14: ; preds = %8, %4
ret void
}