// File: /workspace/github_c_makefile_star2_O0/tylerneylon[P]APIsWithLua/lua/ltablib.c
// Function: auxsort
static void auxsort (lua_State *L, IdxT lo, IdxT up,
                                   unsigned int rnd) {
  while (lo < up) {  /* loop for tail recursion */
    IdxT p;  /* Pivot index */
    IdxT n;  /* to be used later */
    /* sort elements 'lo', 'p', and 'up' */
    lua_geti(L, 1, lo);
    lua_geti(L, 1, up);
    if (sort_comp(L, -1, -2))  /* a[up] < a[lo]? */
      set2(L, lo, up);  /* swap a[lo] - a[up] */
    else
      lua_pop(L, 2);  /* remove both values */
    if (up - lo == 1)  /* only 2 elements? */
      return;  /* already sorted */
    if (up - lo < RANLIMIT || rnd == 0)  /* small interval or no randomize? */
      p = (lo + up)/2;  /* middle element is a good pivot */
    else  /* for larger intervals, it is worth a random pivot */
      p = choosePivot(lo, up, rnd);
    lua_geti(L, 1, p);
    lua_geti(L, 1, lo);
    if (sort_comp(L, -2, -1))  /* a[p] < a[lo]? */
      set2(L, p, lo);  /* swap a[p] - a[lo] */
    else {
      lua_pop(L, 1);  /* remove a[lo] */
      lua_geti(L, 1, up);
      if (sort_comp(L, -1, -2))  /* a[up] < a[p]? */
        set2(L, p, up);  /* swap a[up] - a[p] */
      else
        lua_pop(L, 2);
    }
    if (up - lo == 2)  /* only 3 elements? */
      return;  /* already sorted */
    lua_geti(L, 1, p);  /* get middle element (Pivot) */
    lua_pushvalue(L, -1);  /* push Pivot */
    lua_geti(L, 1, up - 1);  /* push a[up - 1] */
    set2(L, p, up - 1);  /* swap Pivot (a[p]) with a[up - 1] */
    p = partition(L, lo, up);
    /* a[lo .. p - 1] <= a[p] == P <= a[p + 1 .. up] */
    if (p - lo < up - p) {  /* lower interval is smaller? */
      auxsort(L, lo, p - 1, rnd);  /* call recursively for lower interval */
      n = p - lo;  /* size of smaller interval */
      lo = p + 1;  /* tail call for [p + 1 .. up] (upper interval) */
    }
    else {
      auxsort(L, p + 1, up, rnd);  /* call recursively for upper interval */
      n = up - p;  /* size of smaller interval */
      up = p - 1;  /* tail call for [lo .. p - 1]  (lower interval) */
    }
    if ((up - lo) / 128 > n) /* partition too imbalanced? */
      rnd = l_randomizePivot();  /* try a new randomization */
  }  /* tail call auxsort(L, lo, up, rnd) */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jae 0x312fe
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x31310
cmpl $0x0, %eax
je 0x31120
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x313d0
jmp 0x3112e
movq -0x8(%rbp), %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x5dc0
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
cmpl $0x1, %eax
jne 0x3113e
jmp 0x312fe
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
cmpl $0x64, %eax
jb 0x3114f
cmpl $0x0, -0x14(%rbp)
jne 0x3115c
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
shrl %eax
movl %eax, -0x18(%rbp)
jmp 0x3116d
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x31410
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x31310
cmpl $0x0, %eax
je 0x311bc
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0xc(%rbp), %edx
callq 0x313d0
jmp 0x31216
movq -0x8(%rbp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x5dc0
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq 0x31310
cmpl $0x0, %eax
je 0x31206
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x313d0
jmp 0x31214
movq -0x8(%rbp), %rdi
movl $0xfffffffd, %esi       # imm = 0xFFFFFFFD
callq 0x5dc0
jmp 0x31216
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
cmpl $0x2, %eax
jne 0x31226
jmp 0x312fe
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x6190
movq -0x8(%rbp), %rdi
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movl $0x1, %esi
callq 0x7330
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
movl -0x10(%rbp), %edx
subl $0x1, %edx
callq 0x313d0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x31450
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
subl -0xc(%rbp), %eax
movl -0x10(%rbp), %ecx
subl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jae 0x312bc
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x18(%rbp), %edx
subl $0x1, %edx
movl -0x14(%rbp), %ecx
callq 0x310b0
movl -0x18(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x312e3
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
addl $0x1, %esi
movl -0x10(%rbp), %edx
movl -0x14(%rbp), %ecx
callq 0x310b0
movl -0x10(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
shrl $0x7, %eax
cmpl -0x1c(%rbp), %eax
jbe 0x312f9
callq 0x31580
movl %eax, -0x14(%rbp)
jmp 0x310c5
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)