// File: /workspace/github_c_makefile_star2_O3/bhk[P]tooltree/lua/../opensource/lua-5.2.3/src/ltablib.c
// Function: auxsort
static void auxsort (lua_State *L, int l, int u) {
  while (l < u) {  /* for tail recursion */
    int i, j;
    /* sort elements a[l], a[(l+u)/2] and a[u] */
    lua_rawgeti(L, 1, l);
    lua_rawgeti(L, 1, u);
    if (sort_comp(L, -1, -2))  /* a[u] < a[l]? */
      set2(L, l, u);  /* swap a[l] - a[u] */
    else
      lua_pop(L, 2);
    if (u-l == 1) break;  /* only 2 elements */
    i = (l+u)/2;
    lua_rawgeti(L, 1, i);
    lua_rawgeti(L, 1, l);
    if (sort_comp(L, -2, -1))  /* a[i]<a[l]? */
      set2(L, i, l);
    else {
      lua_pop(L, 1);  /* remove a[l] */
      lua_rawgeti(L, 1, u);
      if (sort_comp(L, -1, -2))  /* a[u]<a[i]? */
        set2(L, i, u);
      else
        lua_pop(L, 2);
    }
    if (u-l == 2) break;  /* only 3 elements */
    lua_rawgeti(L, 1, i);  /* Pivot */
    lua_pushvalue(L, -1);
    lua_rawgeti(L, 1, u-1);
    set2(L, i, u-1);
    /* a[l] <= P == a[u-1] <= a[u], only need to sort from l+1 to u-2 */
    i = l; j = u-1;
    for (;;) {  /* invariant: a[l..i] <= P <= a[j..u] */
      /* repeat ++i until a[i] >= P */
      while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
        if (i>=u) luaL_error(L, "invalid order function for sorting");
        lua_pop(L, 1);  /* remove a[i] */
      }
      /* repeat --j until a[j] <= P */
      while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
        if (j<=l) luaL_error(L, "invalid order function for sorting");
        lua_pop(L, 1);  /* remove a[j] */
      }
      if (j<i) {
        lua_pop(L, 3);  /* pop pivot, a[i], a[j] */
        break;
      }
      set2(L, i, j);
    }
    lua_rawgeti(L, 1, u-1);
    lua_rawgeti(L, 1, i);
    set2(L, u-1, i);  /* swap pivot (a[u-1]) with a[i] */
    /* a[l..i-1] <= a[i] == P <= a[i+1..u] */
    /* adjust so that smaller half is in [j..i] and larger one in [l..u] */
    if (i-l < u-i) {
      j=l; i=i-1; l=i+2;
    }
    else {
      j=i+1; i=u; u=j-2;
    }
    auxsort(L, j, i);  /* call recursively the smaller one */
  }  /* repeat the routine for the larger one */
}

// Assembly:
cmpl %edx, %esi
jge 0x18117
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r12d
movl %esi, %ebp
movq %rdi, %rbx
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
callq 0x8249
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18118
movq %rbx, %rdi
testl %eax, %eax
je 0x17df5
movl $0x1, %esi
movl %ebp, %edx
callq 0x8523
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8523
jmp 0x17dff
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x7688
movl %r12d, %r14d
subl %ebp, %r14d
cmpl $0x1, %r14d
je 0x18109
leal (%r12,%rbp), %eax
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
sarl %r13d
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x18118
testl %eax, %eax
je 0x17e74
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %r15d
movl %r13d, %edx
callq 0x8523
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
jmp 0x17ec9
movl %r13d, %r15d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7688
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18118
movq %rbx, %rdi
testl %eax, %eax
je 0x180fa
movl $0x1, %esi
movl %r15d, %edx
callq 0x8523
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8523
cmpl $0x2, %r14d
je 0x18109
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7972
leal -0x1(%r12), %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x8249
movl %r15d, %edx
movl %r14d, 0xc(%rsp)
movl %r14d, %r13d
movl %ebp, %r15d
movq %r12, 0x10(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x8523
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x8523
leal 0x1(%r15), %edx
movq %rbx, %rdi
movl $0x1, %esi
movl %edx, 0x8(%rsp)
callq 0x8249
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18118
movl %r15d, %r14d
testl %eax, %eax
je 0x17fc4
leal 0x1(%r15), %r14d
cmpl %r12d, %r14d
jl 0x17f82
movq %rbx, %rdi
leaq 0x9c89(%rip), %rsi      # 0x21c04
xorl %eax, %eax
callq 0x9144
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7688
addl $0x2, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18118
movl %r14d, %r15d
testl %eax, %eax
jne 0x17f68
leal 0x1(%r14), %eax
movl %eax, 0x8(%rsp)
leal -0x1(%r13), %r12d
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x18118
testl %eax, %eax
je 0x18049
leal -0x1(%r13), %r15d
cmpl %ebp, %r15d
jg 0x18008
movq %rbx, %rdi
leaq 0x9c03(%rip), %rsi      # 0x21c04
xorl %eax, %eax
callq 0x9144
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7688
addl $-0x2, %r13d
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x18118
movl %r15d, %r13d
testl %eax, %eax
jne 0x17fee
leal -0x1(%r15), %r12d
movl %r15d, %r13d
movl 0x8(%rsp), %edx
movl %edx, %r15d
cmpl %edx, %r13d
movl %r12d, %r13d
movq 0x10(%rsp), %r12
jg 0x17f1d
movq %rbx, %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
movl %edx, %r15d
callq 0x7688
movq %rbx, %rdi
movl $0x1, %esi
movl 0xc(%rsp), %r13d
movl %r13d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8249
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x8523
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8523
movl %r12d, %eax
subl %r15d, %eax
subl %ebp, %r15d
leal 0x2(%r14), %esi
cmpl %eax, %r15d
movl %ebp, %r15d
cmovll %esi, %r15d
movq %r12, %rdx
movl %r14d, %r12d
cmovll %edx, %r12d
cmovll %r14d, %edx
cmovll %ebp, %esi
movq %rbx, %rdi
callq 0x17d81
movl %r12d, %eax
movl %r15d, %ebp
cmpl %r12d, %r15d
movq %rax, %r12
jl 0x17d9f
jmp 0x18109
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x7688
jmp 0x17ece
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq