#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*/ set_imatrix_j(int **, long, long, long, long);
int /*<<< orphan*/ sort_index_ivector_selection_kmin(int *, long, long, int *,
                                                     int);
void sort_index_imatrix_selection_kmin(int **key, long nrl, long nrh, long ncl,
                                       long nch, int **index, int k) {
  int i;
  set_imatrix_j(index, nrl, nrh, ncl, nch);
  for (i = nrl; i <= nrh; i++) {
    sort_index_ivector_selection_kmin(key[i], ncl, nch, index[i], k);
  }
}


x86 assembly (clang, -O0):
<sort_index_imatrix_selection_kmin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <set_imatrix_j@plt>
mov    -0x10(%rbp),%rax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11a8 <sort_index_imatrix_selection_kmin+0x88>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    0x10(%rbp),%r8d
call   1040 <sort_index_ivector_selection_kmin@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1163 <sort_index_imatrix_selection_kmin+0x43>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_index_imatrix_selection_kmin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r13
mov    %r9,%rdi
call   1030 <set_imatrix_j@plt>
movslq %ebp,%rbp
cmp    %rbx,%rbp
jg     1172 <sort_index_imatrix_selection_kmin+0x52>
nopl   (%rax)
mov    0x0(%r13,%rbp,8),%rdi
mov    (%r14,%rbp,8),%rcx
mov    %r12,%rsi
mov    %r15,%rdx
mov    0x40(%rsp),%r8d
call   1040 <sort_index_ivector_selection_kmin@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
jle    1150 <sort_index_imatrix_selection_kmin+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @sort_index_imatrix_selection_kmin(i32** nocapture %0, i64 %1, i64 %2, i64 %3, i64 %4, i32** %5, i32 %6) {
%8 = tail call i32 @set_imatrix_j(i32** %5, i64 %1, i64 %2, i64 %3, i64 %4)
%9 = shl i64 %1, 32
%10 = ashr exact i64 %9, 32
%11 = icmp sgt i64 %10, %2
br i1 %11, label %21, label %12
12: ; preds = %7, %12
%13 = phi i64 [ %19, %12 ], [ %10, %7 ]
%14 = getelementptr inbounds i32*, i32** %0, i64 %13
%15 = load i32*, i32** %14
%16 = getelementptr inbounds i32*, i32** %5, i64 %13
%17 = load i32*, i32** %16
%18 = tail call i32 @sort_index_ivector_selection_kmin(i32* %15, i64 %3, i64 %4, i32* %17, i32 %6)
%19 = add i64 %13, 1
%20 = icmp sgt i64 %19, %2
br i1 %20, label %21, label %12
21: ; preds = %12, %7
ret void
}