#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(double *, int, int);
int partition(double numerator[], double denominator[], int minIndex,
              int maxIndex) {
  double pivotElement = numerator[maxIndex] / denominator[maxIndex];
  int pivotIndex = minIndex;
  int i;
  for (i = minIndex; i <= maxIndex; i++) {
    if (numerator[i] / denominator[i] >= pivotElement) {
      swap(numerator, i, pivotIndex);
      swap(denominator, i, pivotIndex);
      pivotIndex++;
    }
  }
  return pivotIndex - 1;
}


x86 assembly (clang, -O0):
<partition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11bc <partition+0xac>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11a9 <partition+0x99>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <swap@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <swap@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ae <partition+0x9e>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1151 <partition+0x41>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<partition>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
cmp    %ecx,%edx
jle    1134 <partition+0x24>
add    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ecx,%r14d
mov    %rsi,%r15
mov    %rdi,%r12
movslq %ecx,%rax
movsd  (%rdi,%rax,8),%xmm1
divsd  (%rsi,%rax,8),%xmm1
movslq %ebx,%rbp
add    $0x1,%r14d
movsd  %xmm1,0x8(%rsp)
jmp    1169 <partition+0x59>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    %ebp,%r14d
je     1122 <partition+0x12>
movsd  (%r12,%rbp,8),%xmm0
divsd  (%r15,%rbp,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1160 <partition+0x50>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <swap@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <swap@plt>
movsd  0x8(%rsp),%xmm1
add    $0x1,%ebx
jmp    1160 <partition+0x50>

LLVM IR (-O0):
define i32 @partition(double* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load double*, double** %5
%13 = load i32, i32* %8
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = load double*, double** %6
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = fdiv double %16, %21
store double %22, double* %9
%23 = load i32, i32* %7
store i32 %23, i32* %10
%24 = load i32, i32* %7
store i32 %24, i32* %11
br label %25
25: ; preds = %55, %4
%26 = load i32, i32* %11
%27 = load i32, i32* %8
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %58
29: ; preds = %25
%30 = load double*, double** %5
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = load double*, double** %6
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fdiv double %34, %39
%41 = load double, double* %9
%42 = fcmp oge double %40, %41
br i1 %42, label %43, label %54
43: ; preds = %29
%44 = load double*, double** %5
%45 = load i32, i32* %11
%46 = load i32, i32* %10
%47 = call i32 @swap(double* %44, i32 %45, i32 %46)
%48 = load double*, double** %6
%49 = load i32, i32* %11
%50 = load i32, i32* %10
%51 = call i32 @swap(double* %48, i32 %49, i32 %50)
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %54
54: ; preds = %43, %29
br label %55
55: ; preds = %54
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
store i32 %57, i32* %11
br label %25
58: ; preds = %25
%59 = load i32, i32* %10
%60 = sub nsw i32 %59, 1
ret i32 %60
}

LLVM IR (-O2):
define i32 @partition(double* %0, double* %1, i32 %2, i32 %3) {
%5 = sext i32 %3 to i64
%6 = getelementptr inbounds double, double* %0, i64 %5
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %1, i64 %5
%9 = load double, double* %8
%10 = fdiv double %7, %9
%11 = icmp sgt i32 %2, %3
br i1 %11, label %34, label %12
12: ; preds = %4
%13 = sext i32 %2 to i64
%14 = add i32 %3, 1
br label %15
15: ; preds = %12, %29
%16 = phi i64 [ %13, %12 ], [ %31, %29 ]
%17 = phi i32 [ %2, %12 ], [ %30, %29 ]
%18 = getelementptr inbounds double, double* %0, i64 %16
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %1, i64 %16
%21 = load double, double* %20
%22 = fdiv double %19, %21
%23 = fcmp ult double %22, %10
br i1 %23, label %29, label %24
24: ; preds = %15
%25 = trunc i64 %16 to i32
%26 = tail call i32 @swap(double* %0, i32 %25, i32 %17)
%27 = tail call i32 @swap(double* %1, i32 %25, i32 %17)
%28 = add nsw i32 %17, 1
br label %29
29: ; preds = %15, %24
%30 = phi i32 [ %28, %24 ], [ %17, %15 ]
%31 = add nsw i64 %16, 1
%32 = trunc i64 %31 to i32
%33 = icmp eq i32 %14, %32
br i1 %33, label %34, label %15
34: ; preds = %29, %4
%35 = phi i32 [ %2, %4 ], [ %30, %29 ]
%36 = add nsw i32 %35, -1
ret i32 %36
}