// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/bzip2-1.0.6/blocksort.c
// Function: fallbackQSort3
static
void fallbackQSort3 ( UInt32* fmap, 
                      UInt32* eclass,
                      Int32   loSt, 
                      Int32   hiSt )
{
   Int32 unLo, unHi, ltLo, gtHi, n, m;
   Int32 sp, lo, hi;
   UInt32 med, r, r3;
   Int32 stackLo[FALLBACK_QSORT_STACK_SIZE];
   Int32 stackHi[FALLBACK_QSORT_STACK_SIZE];

   r = 0;

   sp = 0;
   fpush ( loSt, hiSt );

   while (sp > 0) {

      AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 );

      fpop ( lo, hi );
      if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
         fallbackSimpleSort ( fmap, eclass, lo, hi );
         continue;
      }

      /* Random partitioning.  Median of 3 sometimes fails to
         avoid bad cases.  Median of 9 seems to help but 
         looks rather expensive.  This too seems to work but
         is cheaper.  Guidance for the magic constants 
         7621 and 32768 is taken from Sedgewick's algorithms
         book, chapter 35.
      */
      r = ((r * 7621) + 1) % 32768;
      r3 = r % 3;
      if (r3 == 0) med = eclass[fmap[lo]]; else
      if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else
                   med = eclass[fmap[hi]];

      unLo = ltLo = lo;
      unHi = gtHi = hi;

      while (1) {
         while (1) {
            if (unLo > unHi) break;
            n = (Int32)eclass[fmap[unLo]] - (Int32)med;
            if (n == 0) { 
               fswap(fmap[unLo], fmap[ltLo]); 
               ltLo++; unLo++; 
               continue; 
            };
            if (n > 0) break;
            unLo++;
         }
         while (1) {
            if (unLo > unHi) break;
            n = (Int32)eclass[fmap[unHi]] - (Int32)med;
            if (n == 0) { 
               fswap(fmap[unHi], fmap[gtHi]); 
               gtHi--; unHi--; 
               continue; 
            };
            if (n < 0) break;
            unHi--;
         }
         if (unLo > unHi) break;
         fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--;
      }

      AssertD ( unHi == unLo-1, "fallbackQSort3(2)" );

      if (gtHi < ltLo) continue;

      n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n);
      m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m);

      n = lo + unLo - ltLo - 1;
      m = hi - (gtHi - unHi) + 1;

      if (n - lo > hi - m) {
         fpush ( lo, n );
         fpush ( m, hi );
      } else {
         fpush ( m, hi );
         fpush ( lo, n );
      }
   }
}

// Assembly:
subq $0x3a8, %rsp            # imm = 0x3A8
movq %rdi, 0x3a0(%rsp)
movq %rsi, 0x398(%rsp)
movl %edx, 0x394(%rsp)
movl %ecx, 0x390(%rsp)
movl $0x0, 0x364(%rsp)
movl $0x0, 0x374(%rsp)
movl 0x394(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x1d0(%rsp,%rax,4)
movl 0x390(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x40(%rsp,%rax,4)
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
cmpl $0x0, 0x374(%rsp)
jle 0x1547d9
cmpl $0x63, 0x374(%rsp)
jl 0x1540d7
movl $0x3ec, %edi            # imm = 0x3EC
callq 0xc7b30
movl 0x374(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x374(%rsp)
movslq 0x374(%rsp), %rax
movl 0x1d0(%rsp,%rax,4), %eax
movl %eax, 0x370(%rsp)
movslq 0x374(%rsp), %rax
movl 0x40(%rsp,%rax,4), %eax
movl %eax, 0x36c(%rsp)
movl 0x36c(%rsp), %eax
subl 0x370(%rsp), %eax
cmpl $0xa, %eax
jge 0x15414c
movq 0x3a0(%rsp), %rdi
movq 0x398(%rsp), %rsi
movl 0x370(%rsp), %edx
movl 0x36c(%rsp), %ecx
callq 0x1547f0
jmp 0x1540b5
imull $0x1dc5, 0x364(%rsp), %eax # imm = 0x1DC5
addl $0x1, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x364(%rsp)
movl 0x364(%rsp), %eax
movl $0x3, %ecx
xorl %edx, %edx
divl %ecx
movl %edx, 0x360(%rsp)
cmpl $0x0, 0x360(%rsp)
jne 0x1541ae
movq 0x398(%rsp), %rax
movq 0x3a0(%rsp), %rcx
movslq 0x370(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x368(%rsp)
jmp 0x154211
cmpl $0x1, 0x360(%rsp)
jne 0x1541ea
movq 0x398(%rsp), %rax
movq 0x3a0(%rsp), %rcx
movl 0x370(%rsp), %edx
addl 0x36c(%rsp), %edx
sarl %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x368(%rsp)
jmp 0x15420f
movq 0x398(%rsp), %rax
movq 0x3a0(%rsp), %rcx
movslq 0x36c(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, 0x368(%rsp)
jmp 0x154211
movl 0x370(%rsp), %eax
movl %eax, 0x384(%rsp)
movl %eax, 0x38c(%rsp)
movl 0x36c(%rsp), %eax
movl %eax, 0x380(%rsp)
movl %eax, 0x388(%rsp)
jmp 0x15423d
movl 0x38c(%rsp), %eax
cmpl 0x388(%rsp), %eax
jle 0x154252
jmp 0x154325
movq 0x398(%rsp), %rax
movq 0x3a0(%rsp), %rcx
movslq 0x38c(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
subl 0x368(%rsp), %eax
movl %eax, 0x37c(%rsp)
cmpl $0x0, 0x37c(%rsp)
jne 0x154303
movq 0x3a0(%rsp), %rax
movslq 0x38c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x3c(%rsp)
movq 0x3a0(%rsp), %rax
movslq 0x384(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x3a0(%rsp), %rax
movslq 0x38c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x3c(%rsp), %edx
movq 0x3a0(%rsp), %rax
movslq 0x384(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x384(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x384(%rsp)
movl 0x38c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38c(%rsp)
jmp 0x15423d
cmpl $0x0, 0x37c(%rsp)
jle 0x15430f
jmp 0x154325
movl 0x38c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38c(%rsp)
jmp 0x15423d
jmp 0x154327
movl 0x38c(%rsp), %eax
cmpl 0x388(%rsp), %eax
jle 0x15433c
jmp 0x15440f
movq 0x398(%rsp), %rax
movq 0x3a0(%rsp), %rcx
movslq 0x388(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
subl 0x368(%rsp), %eax
movl %eax, 0x37c(%rsp)
cmpl $0x0, 0x37c(%rsp)
jne 0x1543ed
movq 0x3a0(%rsp), %rax
movslq 0x388(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x38(%rsp)
movq 0x3a0(%rsp), %rax
movslq 0x380(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x3a0(%rsp), %rax
movslq 0x388(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x38(%rsp), %edx
movq 0x3a0(%rsp), %rax
movslq 0x380(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x380(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x380(%rsp)
movl 0x388(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x388(%rsp)
jmp 0x154327
cmpl $0x0, 0x37c(%rsp)
jge 0x1543f9
jmp 0x15440f
movl 0x388(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x388(%rsp)
jmp 0x154327
movl 0x38c(%rsp), %eax
cmpl 0x388(%rsp), %eax
jle 0x154421
jmp 0x15449c
movq 0x3a0(%rsp), %rax
movslq 0x38c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x34(%rsp)
movq 0x3a0(%rsp), %rax
movslq 0x388(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x3a0(%rsp), %rax
movslq 0x38c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x34(%rsp), %edx
movq 0x3a0(%rsp), %rax
movslq 0x388(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x38c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38c(%rsp)
movl 0x388(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x388(%rsp)
jmp 0x15423b
movl 0x380(%rsp), %eax
cmpl 0x384(%rsp), %eax
jge 0x1544b1
jmp 0x1540b5
movl 0x384(%rsp), %eax
subl 0x370(%rsp), %eax
movl 0x38c(%rsp), %ecx
subl 0x384(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1544e5
movl 0x384(%rsp), %eax
subl 0x370(%rsp), %eax
movl %eax, 0x10(%rsp)
jmp 0x1544f7
movl 0x38c(%rsp), %eax
subl 0x384(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x37c(%rsp)
movl 0x370(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x38c(%rsp), %eax
subl 0x37c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x37c(%rsp), %eax
movl %eax, 0x28(%rsp)
cmpl $0x0, 0x28(%rsp)
jle 0x15459c
movq 0x3a0(%rsp), %rax
movslq 0x30(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x24(%rsp)
movq 0x3a0(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x3a0(%rsp), %rax
movslq 0x30(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x24(%rsp), %edx
movq 0x3a0(%rsp), %rax
movslq 0x2c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x30(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x30(%rsp)
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
movl 0x28(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x28(%rsp)
jmp 0x15452a
movl 0x36c(%rsp), %eax
subl 0x380(%rsp), %eax
movl 0x380(%rsp), %ecx
subl 0x388(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1545d0
movl 0x36c(%rsp), %eax
subl 0x380(%rsp), %eax
movl %eax, 0xc(%rsp)
jmp 0x1545e2
movl 0x380(%rsp), %eax
subl 0x388(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x378(%rsp)
movl 0x38c(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x36c(%rsp), %eax
subl 0x378(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl 0x378(%rsp), %eax
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x18(%rsp)
jle 0x15468a
movq 0x3a0(%rsp), %rax
movslq 0x20(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x14(%rsp)
movq 0x3a0(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x3a0(%rsp), %rax
movslq 0x20(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x14(%rsp), %edx
movq 0x3a0(%rsp), %rax
movslq 0x1c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
movl 0x1c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c(%rsp)
movl 0x18(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x154618
movl 0x370(%rsp), %eax
addl 0x38c(%rsp), %eax
subl 0x384(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x37c(%rsp)
movl 0x36c(%rsp), %eax
movl 0x380(%rsp), %ecx
subl 0x388(%rsp), %ecx
subl %ecx, %eax
addl $0x1, %eax
movl %eax, 0x378(%rsp)
movl 0x37c(%rsp), %eax
subl 0x370(%rsp), %eax
movl 0x36c(%rsp), %ecx
subl 0x378(%rsp), %ecx
cmpl %ecx, %eax
jle 0x154760
movl 0x370(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x1d0(%rsp,%rax,4)
movl 0x37c(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x40(%rsp,%rax,4)
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
movl 0x378(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x1d0(%rsp,%rax,4)
movl 0x36c(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x40(%rsp,%rax,4)
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
jmp 0x1547d4
movl 0x378(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x1d0(%rsp,%rax,4)
movl 0x36c(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x40(%rsp,%rax,4)
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
movl 0x370(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x1d0(%rsp,%rax,4)
movl 0x37c(%rsp), %ecx
movslq 0x374(%rsp), %rax
movl %ecx, 0x40(%rsp,%rax,4)
movl 0x374(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x374(%rsp)
jmp 0x1540b5
addq $0x3a8, %rsp            # imm = 0x3A8
retq
nopw %cs:(%rax,%rax)