// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movl %esi, %ebp
movq %rdi, %rbx
movl %r15d, %r14d
subl %ebp, %r14d
jle 0x18056
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
callq 0x8145
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18065
movq %rbx, %rdi
testl %eax, %eax
je 0x17d45
movl $0x1, %esi
movl %ebp, %edx
callq 0x840d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x840d
jmp 0x17d4f
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x7697
cmpl $0x1, %r14d
je 0x17e1e
leal (%r15,%rbp), %eax
movl %eax, %r13d
shrl $0x1f, %r13d
addl %eax, %r13d
sarl %r13d
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x18065
testl %eax, %eax
je 0x17dbe
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %r12d
movl %r13d, %edx
callq 0x840d
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
jmp 0x17e13
movl %r13d, %r12d
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7697
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18065
movq %rbx, %rdi
testl %eax, %eax
je 0x18047
movl $0x1, %esi
movl %r12d, %edx
callq 0x840d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x840d
cmpl $0x2, %r14d
jne 0x17e25
xorl %eax, %eax
jmp 0x1803d
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x7869
leal -0x1(%r15), %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
callq 0x8145
movl %r12d, %edx
movl %r14d, 0xc(%rsp)
movl %r14d, %r13d
movl %ebp, %r12d
movq %r15, 0x10(%rsp)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x840d
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x840d
leal 0x1(%r12), %edx
movq %rbx, %rdi
movl $0x1, %esi
movl %edx, 0x8(%rsp)
callq 0x8145
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18065
movl %r12d, %r14d
testl %eax, %eax
je 0x17f12
leal 0x1(%r12), %r14d
cmpl %r15d, %r14d
jl 0x17ed0
movq %rbx, %rdi
leaq 0x9d43(%rip), %rsi      # 0x21c0c
xorl %eax, %eax
callq 0x9024
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7697
addl $0x2, %r12d
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x18065
movl %r14d, %r12d
testl %eax, %eax
jne 0x17eb5
leal 0x1(%r14), %eax
movl %eax, 0x8(%rsp)
leal -0x1(%r13), %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl %r15d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x18065
testl %eax, %eax
je 0x17f98
leal -0x1(%r13), %r12d
cmpl %ebp, %r12d
jg 0x17f56
movq %rbx, %rdi
leaq 0x9cbd(%rip), %rsi      # 0x21c0c
xorl %eax, %eax
callq 0x9024
movq %rbx, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x7697
addl $-0x2, %r13d
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x18065
movl %r12d, %r13d
testl %eax, %eax
jne 0x17f3c
leal -0x1(%r12), %r15d
movl %r12d, %r13d
movl 0x8(%rsp), %edx
movl %edx, %r12d
cmpl %edx, %r13d
movl %r15d, %r13d
movq 0x10(%rsp), %r15
jg 0x17e69
movq %rbx, %rdi
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
movl %edx, %r12d
callq 0x7697
movq %rbx, %rdi
movl $0x1, %esi
movl 0xc(%rsp), %r13d
movl %r13d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x8145
movq %rbx, %rdi
movl $0x1, %esi
movl %r13d, %edx
callq 0x840d
movq %rbx, %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x840d
movl %r15d, %eax
subl %r12d, %eax
subl %ebp, %r12d
leal 0x2(%r14), %esi
cmpl %eax, %r12d
movq %r15, %rdx
movl %ebp, %r15d
cmovll %esi, %r15d
movl %r14d, %r12d
cmovll %edx, %r12d
cmovll %r14d, %edx
cmovll %ebp, %esi
movq %rbx, %rdi
callq 0x17ccd
movb $0x1, %al
movl %r15d, %ebp
movl %r12d, %r15d
testb %al, %al
jne 0x17ce3
jmp 0x18056
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x7697
jmp 0x17e18
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq