#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_suffix_array_by_mate_2(int **, int **, int, int, int);
void quick_sort_suffixarray_by_mate_2(int **pSfa_s, int **pSfa_d, int left,
                                      int right) {
  int pivot_index, pivot_new_index, left1, right1, left2, right2;
  if (right > left) {
    pivot_index = left + (int)((right - left) / 2);
    pivot_new_index = partition_suffix_array_by_mate_2(pSfa_s, pSfa_d, left,
                                                       right, pivot_index);
    left1 = left;
    right1 = pivot_new_index - 1;
    left2 = pivot_new_index + 1;
    right2 = right;
    quick_sort_suffixarray_by_mate_2(pSfa_s, pSfa_d, left1, right1);
    quick_sort_suffixarray_by_mate_2(pSfa_s, pSfa_d, left2, right2);
  }
}


x86 assembly (clang, -O0):
<quick_sort_suffixarray_by_mate_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11be <quick_sort_suffixarray_by_mate_2+0x9e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1040 <partition_suffix_array_by_mate_2@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1030 <quick_sort_suffixarray_by_mate_2@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
call   1030 <quick_sort_suffixarray_by_mate_2@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quick_sort_suffixarray_by_mate_2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %edx,%ecx
jle    1181 <quick_sort_suffixarray_by_mate_2+0x61>
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
nopw   0x0(%rax,%rax,1)
mov    %r12d,%eax
sub    %ebp,%eax
mov    %eax,%r8d
shr    $0x1f,%r8d
add    %eax,%r8d
sar    %r8d
add    %ebp,%r8d
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1040 <partition_suffix_array_by_mate_2@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%ecx
add    $0x1,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <quick_sort_suffixarray_by_mate_2@plt>
mov    %ebx,%ebp
cmp    %r12d,%ebx
jl     1140 <quick_sort_suffixarray_by_mate_2+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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