#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(double *, int, int, int);
void quick_sort(double *srcdata, int p, int r, int partitionType) {
  int q = 0;
  if (p < r) {
    q = partition(srcdata, p, r, partitionType);
    quick_sort(srcdata, p, q - 1, 0);
    quick_sort(srcdata, q + 1, r, 0);
  }
}


x86 assembly (clang, -O0):
<quick_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1185 <quick_sort+0x65>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <partition@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
xor    %ecx,%ecx
call   1040 <quick_sort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
xor    %ecx,%ecx
call   1040 <quick_sort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quick_sort>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %edx,%esi
jge    118a <quick_sort+0x6a>
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
call   1030 <partition@plt>
mov    %eax,%ebp
lea    -0x1(%rbp),%edx
mov    %r14,%rdi
mov    %r15d,%esi
xor    %ecx,%ecx
call   1040 <quick_sort@plt>
add    $0x1,%ebp
cmp    %r12d,%ebp
jge    118a <quick_sort+0x6a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1030 <partition@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %ecx,%ecx
call   1040 <quick_sort@plt>
add    $0x1,%ebx
mov    %ebx,%ebp
cmp    %r12d,%ebx
jl     1160 <quick_sort+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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