#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*/ hypre_swap3i(int *, int *, int *, int, int);
void hypre_qsort3i(int *v, int *w, int *z, int left, int right) {
  int i, last;
  if (left >= right) {
    return;
  }
  hypre_swap3i(v, w, z, left, (left + right) / 2);
  last = left;
  for (i = left + 1; i <= right; i++) {
    if (v[i] < v[left]) {
      hypre_swap3i(v, w, z, ++last, i);
    }
  }
  hypre_swap3i(v, w, z, left, last);
  hypre_qsort3i(v, w, z, left, last - 1);
  hypre_qsort3i(v, w, z, last + 1, right);
}


x86 assembly (clang, -O0):
<hypre_qsort3i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     114c <hypre_qsort3i+0x2c>
jmp    1232 <hypre_qsort3i+0x112>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    $0x2,%r8d
cltd
idiv   %r8d
mov    -0x30(%rbp),%rdx
mov    %eax,%r8d
call   1030 <hypre_swap3i@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     11e3 <hypre_qsort3i+0xc3>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11d0 <hypre_qsort3i+0xb0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
mov    -0x24(%rbp),%r8d
call   1030 <hypre_swap3i@plt>
jmp    11d5 <hypre_qsort3i+0xb5>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118a <hypre_qsort3i+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1030 <hypre_swap3i@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%r8d
sub    $0x1,%r8d
call   1040 <hypre_qsort3i@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%r8d
call   1040 <hypre_qsort3i@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hypre_qsort3i>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    %r8d,%ecx
jge    1228 <hypre_qsort3i+0x108>
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
movslq %r8d,%r15
mov    %r14,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
jmp    11aa <hypre_qsort3i+0x8a>
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    0x10(%rsp),%r13
mov    %r13,%rsi
mov    0x18(%rsp),%r12
mov    %r12,%rdx
mov    0x8(%rsp),%r14
mov    %r14d,%ecx
mov    %ebp,%r8d
call   1030 <hypre_swap3i@plt>
lea    -0x1(%rbp),%r8d
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r14d,%ecx
call   1040 <hypre_qsort3i@plt>
add    $0x1,%ebp
mov    %ebp,%eax
mov    0x20(%rsp),%r14
cmp    %r14d,%ebp
mov    %rax,%rbp
jge    1228 <hypre_qsort3i+0x108>
lea    (%r14,%rbp,1),%eax
mov    %eax,%r8d
shr    $0x1f,%r8d
add    %eax,%r8d
sar    %r8d
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
call   1030 <hypre_swap3i@plt>
mov    %rbp,%rax
mov    %rbp,0x8(%rsp)
cmp    %r14d,%eax
jge    1160 <hypre_qsort3i+0x40>
mov    0x8(%rsp),%rbp
movslq %ebp,%r12
lea    0x1(%rbp),%r14d
mov    %r12,%r13
jmp    11fd <hypre_qsort3i+0xdd>
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    %r13,%r15
je     1160 <hypre_qsort3i+0x40>
mov    0x4(%rbx,%r13,4),%eax
add    $0x1,%r13
cmp    (%rbx,%r12,4),%eax
jge    11f0 <hypre_qsort3i+0xd0>
add    $0x1,%ebp
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
mov    0x18(%rsp),%rdx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1030 <hypre_swap3i@plt>
jmp    11f0 <hypre_qsort3i+0xd0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hypre_qsort3i(i32* %0, i32* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %9
%14 = load i32, i32* %10
%15 = icmp sge i32 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %5
br label %77
17: ; preds = %5
%18 = load i32*, i32** %6
%19 = load i32*, i32** %7
%20 = load i32*, i32** %8
%21 = load i32, i32* %9
%22 = load i32, i32* %9
%23 = load i32, i32* %10
%24 = add nsw i32 %22, %23
%25 = sdiv i32 %24, 2
%26 = call i32 @hypre_swap3i(i32* %18, i32* %19, i32* %20, i32 %21, i32 %25)
%27 = load i32, i32* %9
store i32 %27, i32* %12
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
br label %30
30: ; preds = %55, %17
%31 = load i32, i32* %11
%32 = load i32, i32* %10
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %58
34: ; preds = %30
%35 = load i32*, i32** %6
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = load i32*, i32** %6
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = icmp slt i32 %39, %44
br i1 %45, label %46, label %54
46: ; preds = %34
%47 = load i32*, i32** %6
%48 = load i32*, i32** %7
%49 = load i32*, i32** %8
%50 = load i32, i32* %12
%51 = add nsw i32 %50, 1
store i32 %51, i32* %12
%52 = load i32, i32* %11
%53 = call i32 @hypre_swap3i(i32* %47, i32* %48, i32* %49, i32 %51, i32 %52)
br label %54
54: ; preds = %46, %34
br label %55
55: ; preds = %54
%56 = load i32, i32* %11
%57 = add nsw i32 %56, 1
store i32 %57, i32* %11
br label %30
58: ; preds = %30
%59 = load i32*, i32** %6
%60 = load i32*, i32** %7
%61 = load i32*, i32** %8
%62 = load i32, i32* %9
%63 = load i32, i32* %12
%64 = call i32 @hypre_swap3i(i32* %59, i32* %60, i32* %61, i32 %62, i32 %63)
%65 = load i32*, i32** %6
%66 = load i32*, i32** %7
%67 = load i32*, i32** %8
%68 = load i32, i32* %9
%69 = load i32, i32* %12
%70 = sub nsw i32 %69, 1
%71 = load i32*, i32** %6
%72 = load i32*, i32** %7
%73 = load i32*, i32** %8
%74 = load i32, i32* %12
%75 = add nsw i32 %74, 1
%76 = load i32, i32* %10
br label %77
77: ; preds = %58, %16
ret void
}

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