// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/bzip2-1.0.6/blocksort.c
// Function: mainQSort3
static
void mainQSort3 ( UInt32* ptr,
                  UChar*  block,
                  UInt16* quadrant,
                  Int32   nblock,
                  Int32   loSt, 
                  Int32   hiSt, 
                  Int32   dSt,
                  Int32*  budget )
{
   Int32 unLo, unHi, ltLo, gtHi, n, m, med;
   Int32 sp, lo, hi, d;

   Int32 stackLo[MAIN_QSORT_STACK_SIZE];
   Int32 stackHi[MAIN_QSORT_STACK_SIZE];
   Int32 stackD [MAIN_QSORT_STACK_SIZE];

   Int32 nextLo[3];
   Int32 nextHi[3];
   Int32 nextD [3];

   sp = 0;
   mpush ( loSt, hiSt, dSt );

   while (sp > 0) {

      AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 );

      mpop ( lo, hi, d );
      if (hi - lo < MAIN_QSORT_SMALL_THRESH || 
          d > MAIN_QSORT_DEPTH_THRESH) {
         mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
         if (*budget < 0) return;
         continue;
      }

      med = (Int32) 
            mmed3 ( block[ptr[ lo         ]+d],
                    block[ptr[ hi         ]+d],
                    block[ptr[ (lo+hi)>>1 ]+d] );

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

      while (True) {
         while (True) {
            if (unLo > unHi) break;
            n = ((Int32)block[ptr[unLo]+d]) - med;
            if (n == 0) { 
               mswap(ptr[unLo], ptr[ltLo]); 
               ltLo++; unLo++; continue; 
            };
            if (n >  0) break;
            unLo++;
         }
         while (True) {
            if (unLo > unHi) break;
            n = ((Int32)block[ptr[unHi]+d]) - med;
            if (n == 0) { 
               mswap(ptr[unHi], ptr[gtHi]); 
               gtHi--; unHi--; continue; 
            };
            if (n <  0) break;
            unHi--;
         }
         if (unLo > unHi) break;
         mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--;
      }

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

      if (gtHi < ltLo) {
         mpush(lo, hi, d+1 );
         continue;
      }

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

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

      nextLo[0] = lo;  nextHi[0] = n;   nextD[0] = d;
      nextLo[1] = m;   nextHi[1] = hi;  nextD[1] = d;
      nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1;

      if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
      if (mnextsize(1) < mnextsize(2)) mnextswap(1,2);
      if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);

      AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" );
      AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" );

      mpush (nextLo[0], nextHi[0], nextD[0]);
      mpush (nextLo[1], nextHi[1], nextD[1]);
      mpush (nextLo[2], nextHi[2], nextD[2]);
   }
}

// Assembly:
subq $0x588, %rsp            # imm = 0x588
movq 0x598(%rsp), %rax
movl 0x590(%rsp), %eax
movq %rdi, 0x580(%rsp)
movq %rsi, 0x578(%rsp)
movq %rdx, 0x570(%rsp)
movl %ecx, 0x56c(%rsp)
movl %r8d, 0x568(%rsp)
movl %r9d, 0x564(%rsp)
movl $0x0, 0x544(%rsp)
movl 0x568(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x3a0(%rsp,%rax,4)
movl 0x564(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x210(%rsp,%rax,4)
movl 0x590(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x80(%rsp,%rax,4)
movl 0x544(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x544(%rsp)
cmpl $0x0, 0x544(%rsp)
jle 0x155387
cmpl $0x62, 0x544(%rsp)
jl 0x154a95
movl $0x3e9, %edi            # imm = 0x3E9
callq 0xc7b30
movl 0x544(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x544(%rsp)
movslq 0x544(%rsp), %rax
movl 0x3a0(%rsp,%rax,4), %eax
movl %eax, 0x540(%rsp)
movslq 0x544(%rsp), %rax
movl 0x210(%rsp,%rax,4), %eax
movl %eax, 0x53c(%rsp)
movslq 0x544(%rsp), %rax
movl 0x80(%rsp,%rax,4), %eax
movl %eax, 0x538(%rsp)
movl 0x53c(%rsp), %eax
subl 0x540(%rsp), %eax
cmpl $0x14, %eax
jl 0x154b05
cmpl $0xe, 0x538(%rsp)
jle 0x154b69
movq 0x580(%rsp), %rdi
movq 0x578(%rsp), %rsi
movq 0x570(%rsp), %rdx
movl 0x56c(%rsp), %ecx
movl 0x540(%rsp), %r8d
movl 0x53c(%rsp), %r9d
movl 0x538(%rsp), %r10d
movq 0x598(%rsp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x155390
movq 0x598(%rsp), %rax
cmpl $0x0, (%rax)
jge 0x154b64
jmp 0x155387
jmp 0x154a73
movq 0x578(%rsp), %rax
movq 0x580(%rsp), %rcx
movslq 0x540(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
addl 0x538(%rsp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %sil
movq 0x578(%rsp), %rax
movq 0x580(%rsp), %rcx
movslq 0x53c(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
addl 0x538(%rsp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq 0x578(%rsp), %rax
movq 0x580(%rsp), %rcx
movl 0x540(%rsp), %edi
addl 0x53c(%rsp), %edi
sarl %edi
movslq %edi, %rdi
movl (%rcx,%rdi,4), %ecx
addl 0x538(%rsp), %ecx
movl %ecx, %ecx
movzbl %sil, %edi
movzbl %dl, %esi
movzbl (%rax,%rcx), %edx
callq 0x1556b0
movzbl %al, %eax
movl %eax, 0x548(%rsp)
movl 0x540(%rsp), %eax
movl %eax, 0x558(%rsp)
movl %eax, 0x560(%rsp)
movl 0x53c(%rsp), %eax
movl %eax, 0x554(%rsp)
movl %eax, 0x55c(%rsp)
jmp 0x154c2d
movl 0x560(%rsp), %eax
cmpl 0x55c(%rsp), %eax
jle 0x154c42
jmp 0x154d1f
movq 0x578(%rsp), %rax
movq 0x580(%rsp), %rcx
movslq 0x560(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
addl 0x538(%rsp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
subl 0x548(%rsp), %eax
movl %eax, 0x550(%rsp)
cmpl $0x0, 0x550(%rsp)
jne 0x154cfd
movq 0x580(%rsp), %rax
movslq 0x560(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x58(%rsp)
movq 0x580(%rsp), %rax
movslq 0x558(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x580(%rsp), %rax
movslq 0x560(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x58(%rsp), %edx
movq 0x580(%rsp), %rax
movslq 0x558(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x558(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x558(%rsp)
movl 0x560(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x560(%rsp)
jmp 0x154c2d
cmpl $0x0, 0x550(%rsp)
jle 0x154d09
jmp 0x154d1f
movl 0x560(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x560(%rsp)
jmp 0x154c2d
jmp 0x154d21
movl 0x560(%rsp), %eax
cmpl 0x55c(%rsp), %eax
jle 0x154d36
jmp 0x154e13
movq 0x578(%rsp), %rax
movq 0x580(%rsp), %rcx
movslq 0x55c(%rsp), %rdx
movl (%rcx,%rdx,4), %ecx
addl 0x538(%rsp), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
subl 0x548(%rsp), %eax
movl %eax, 0x550(%rsp)
cmpl $0x0, 0x550(%rsp)
jne 0x154df1
movq 0x580(%rsp), %rax
movslq 0x55c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x54(%rsp)
movq 0x580(%rsp), %rax
movslq 0x554(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x580(%rsp), %rax
movslq 0x55c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x54(%rsp), %edx
movq 0x580(%rsp), %rax
movslq 0x554(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x554(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x554(%rsp)
movl 0x55c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x55c(%rsp)
jmp 0x154d21
cmpl $0x0, 0x550(%rsp)
jge 0x154dfd
jmp 0x154e13
movl 0x55c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x55c(%rsp)
jmp 0x154d21
movl 0x560(%rsp), %eax
cmpl 0x55c(%rsp), %eax
jle 0x154e25
jmp 0x154ea0
movq 0x580(%rsp), %rax
movslq 0x560(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x50(%rsp)
movq 0x580(%rsp), %rax
movslq 0x55c(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x580(%rsp), %rax
movslq 0x560(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x50(%rsp), %edx
movq 0x580(%rsp), %rax
movslq 0x55c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x560(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x560(%rsp)
movl 0x55c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x55c(%rsp)
jmp 0x154c2b
movl 0x554(%rsp), %eax
cmpl 0x558(%rsp), %eax
jge 0x154f0b
movl 0x540(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x3a0(%rsp,%rax,4)
movl 0x53c(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x210(%rsp,%rax,4)
movl 0x538(%rsp), %ecx
addl $0x1, %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x80(%rsp,%rax,4)
movl 0x544(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x544(%rsp)
jmp 0x154a73
movl 0x558(%rsp), %eax
subl 0x540(%rsp), %eax
movl 0x560(%rsp), %ecx
subl 0x558(%rsp), %ecx
cmpl %ecx, %eax
jge 0x154f3f
movl 0x558(%rsp), %eax
subl 0x540(%rsp), %eax
movl %eax, 0x20(%rsp)
jmp 0x154f51
movl 0x560(%rsp), %eax
subl 0x558(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x20(%rsp), %eax
movl %eax, 0x550(%rsp)
movl 0x540(%rsp), %eax
movl %eax, 0x4c(%rsp)
movl 0x560(%rsp), %eax
subl 0x550(%rsp), %eax
movl %eax, 0x48(%rsp)
movl 0x550(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
jle 0x154ff6
movq 0x580(%rsp), %rax
movslq 0x4c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x40(%rsp)
movq 0x580(%rsp), %rax
movslq 0x48(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x580(%rsp), %rax
movslq 0x4c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x40(%rsp), %edx
movq 0x580(%rsp), %rax
movslq 0x48(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
movl 0x44(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x154f84
movl 0x53c(%rsp), %eax
subl 0x554(%rsp), %eax
movl 0x554(%rsp), %ecx
subl 0x55c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x15502a
movl 0x53c(%rsp), %eax
subl 0x554(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x15503c
movl 0x554(%rsp), %eax
subl 0x55c(%rsp), %eax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x54c(%rsp)
movl 0x560(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x53c(%rsp), %eax
subl 0x54c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
movl 0x54c(%rsp), %eax
movl %eax, 0x34(%rsp)
cmpl $0x0, 0x34(%rsp)
jle 0x1550e4
movq 0x580(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x30(%rsp)
movq 0x580(%rsp), %rax
movslq 0x38(%rsp), %rcx
movl (%rax,%rcx,4), %edx
movq 0x580(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x30(%rsp), %edx
movq 0x580(%rsp), %rax
movslq 0x38(%rsp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
movl 0x34(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x155072
movl 0x540(%rsp), %eax
addl 0x560(%rsp), %eax
subl 0x558(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x550(%rsp)
movl 0x53c(%rsp), %eax
movl 0x554(%rsp), %ecx
subl 0x55c(%rsp), %ecx
subl %ecx, %eax
addl $0x1, %eax
movl %eax, 0x54c(%rsp)
movl 0x540(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x550(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0x538(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x54c(%rsp), %eax
movl %eax, 0x78(%rsp)
movl 0x53c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x538(%rsp), %eax
movl %eax, 0x60(%rsp)
movl 0x550(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
movl 0x54c(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x70(%rsp)
movl 0x538(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
movl 0x68(%rsp), %eax
subl 0x74(%rsp), %eax
movl 0x6c(%rsp), %ecx
subl 0x78(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1551ec
movl 0x74(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x78(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0x60(%rsp)
movl 0x6c(%rsp), %eax
subl 0x78(%rsp), %eax
movl 0x70(%rsp), %ecx
subl 0x7c(%rsp), %ecx
cmpl %ecx, %eax
jge 0x155248
movl 0x78(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0x78(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x7c(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x70(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x64(%rsp), %eax
movl %eax, 0x60(%rsp)
movl 0x28(%rsp), %eax
movl %eax, 0x64(%rsp)
movl 0x68(%rsp), %eax
subl 0x74(%rsp), %eax
movl 0x6c(%rsp), %ecx
subl 0x78(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1552a4
movl 0x74(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x78(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x78(%rsp)
movl 0x68(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl 0x24(%rsp), %eax
movl %eax, 0x60(%rsp)
movl 0x74(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x3a0(%rsp,%rax,4)
movl 0x68(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x210(%rsp,%rax,4)
movl 0x5c(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x80(%rsp,%rax,4)
movl 0x544(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x544(%rsp)
movl 0x78(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x3a0(%rsp,%rax,4)
movl 0x6c(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x210(%rsp,%rax,4)
movl 0x60(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x80(%rsp,%rax,4)
movl 0x544(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x544(%rsp)
movl 0x7c(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x3a0(%rsp,%rax,4)
movl 0x70(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x210(%rsp,%rax,4)
movl 0x64(%rsp), %ecx
movslq 0x544(%rsp), %rax
movl %ecx, 0x80(%rsp,%rax,4)
movl 0x544(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x544(%rsp)
jmp 0x154a73
addq $0x588, %rsp            # imm = 0x588
retq
nop