// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/bzip2-1.0.6/blocksort.c
// Function: fallbackSort
static
void fallbackSort ( UInt32* fmap, 
                    UInt32* eclass, 
                    UInt32* bhtab,
                    Int32   nblock,
                    Int32   verb )
{
   Int32 ftab[257];
   Int32 ftabCopy[256];
   Int32 H, i, j, k, l, r, cc, cc1;
   Int32 nNotDone;
   Int32 nBhtab;
   UChar* eclass8 = (UChar*)eclass;

   /*--
      Initial 1-char radix sort to generate
      initial fmap and initial BH bits.
   --*/
   if (verb >= 4)
      VPrintf0 ( "        bucket sorting ...\n" );
   for (i = 0; i < 257;    i++) ftab[i] = 0;
   for (i = 0; i < nblock; i++) ftab[eclass8[i]]++;
   for (i = 0; i < 256;    i++) ftabCopy[i] = ftab[i];
   for (i = 1; i < 257;    i++) ftab[i] += ftab[i-1];

   for (i = 0; i < nblock; i++) {
      j = eclass8[i];
      k = ftab[j] - 1;
      ftab[j] = k;
      fmap[k] = i;
   }

   nBhtab = 2 + (nblock / 32);
   for (i = 0; i < nBhtab; i++) bhtab[i] = 0;
   for (i = 0; i < 256; i++) SET_BH(ftab[i]);

   /*--
      Inductively refine the buckets.  Kind-of an
      "exponential radix sort" (!), inspired by the
      Manber-Myers suffix array construction algorithm.
   --*/

   /*-- set sentinel bits for block-end detection --*/
   for (i = 0; i < 32; i++) { 
      SET_BH(nblock + 2*i);
      CLEAR_BH(nblock + 2*i + 1);
   }

   /*-- the log(N) loop --*/
   H = 1;
   while (1) {

      if (verb >= 4) 
         VPrintf1 ( "        depth %6d has ", H );

      j = 0;
      for (i = 0; i < nblock; i++) {
         if (ISSET_BH(i)) j = i;
         k = fmap[i] - H; if (k < 0) k += nblock;
         eclass[k] = j;
      }

      nNotDone = 0;
      r = -1;
      while (1) {

	 /*-- find the next non-singleton bucket --*/
         k = r + 1;
         while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
         if (ISSET_BH(k)) {
            while (WORD_BH(k) == 0xffffffff) k += 32;
            while (ISSET_BH(k)) k++;
         }
         l = k - 1;
         if (l >= nblock) break;
         while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++;
         if (!ISSET_BH(k)) {
            while (WORD_BH(k) == 0x00000000) k += 32;
            while (!ISSET_BH(k)) k++;
         }
         r = k - 1;
         if (r >= nblock) break;

         /*-- now [l, r] bracket current bucket --*/
         if (r > l) {
            nNotDone += (r - l + 1);
            fallbackQSort3 ( fmap, eclass, l, r );

            /*-- scan bucket and generate header bits-- */
            cc = -1;
            for (i = l; i <= r; i++) {
               cc1 = eclass[fmap[i]];
               if (cc != cc1) { SET_BH(i); cc = cc1; };
            }
         }
      }

      if (verb >= 4) 
         VPrintf1 ( "%6d unresolved strings\n", nNotDone );

      H *= 2;
      if (H > nblock || nNotDone == 0) break;
   }

   /*-- 
      Reconstruct the original block in
      eclass8 [0 .. nblock-1], since the
      previous phase destroyed it.
   --*/
   if (verb >= 4)
      VPrintf0 ( "        reconstructing block ...\n" );
   j = 0;
   for (i = 0; i < nblock; i++) {
      while (ftabCopy[j] == 0) j++;
      ftabCopy[j]--;
      eclass8[fmap[i]] = (UChar)j;
   }
   AssertH ( j < 256, 1005 );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xba8, %rsp            # imm = 0xBA8
movl %ecx, %r10d
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x4, %r8d
movl %r8d, 0x8(%rsp)
movq %r10, 0x38(%rsp)
jge 0xc6450
xorl %eax, %eax
cmpq $0x101, %rax            # imm = 0x101
je 0xc5c8e
andl $0x0, 0x390(%rsp,%rax,4)
incq %rax
jmp 0xc5c79
xorl %eax, %eax
testl %r10d, %r10d
movl $0x0, %r9d
cmovgl %r10d, %r9d
cmpq %rax, %r9
je 0xc5cb2
movzbl (%rbx,%rax), %ecx
incl 0x390(%rsp,%rcx,4)
incq %rax
jmp 0xc5c9d
xorl %eax, %eax
cmpq $0x100, %rax            # imm = 0x100
je 0xc5ccf
movl 0x390(%rsp,%rax,4), %ecx
movl %ecx, 0x7a0(%rsp,%rax,4)
incq %rax
jmp 0xc5cb4
pushq $0x1
popq %rax
cmpq $0x101, %rax            # imm = 0x101
je 0xc5ced
movl 0x38c(%rsp,%rax,4), %ecx
addl %ecx, 0x390(%rsp,%rax,4)
incq %rax
jmp 0xc5cd2
xorl %eax, %eax
cmpq %rax, %r9
je 0xc5d15
movzbl (%rbx,%rax), %ecx
movslq 0x390(%rsp,%rcx,4), %rdx
leaq -0x1(%rdx), %rsi
movl %esi, 0x390(%rsp,%rcx,4)
movl %eax, -0x4(%r14,%rdx,4)
incq %rax
jmp 0xc5cef
pushq $0x20
popq %rcx
movl %r10d, %eax
cltd
idivl %ecx
cmpl $-0x1, %eax
pushq $-0x2
popq %rdx
cmovll %edx, %eax
addl $0x2, %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xc5d3b
andl $0x0, (%r12,%rcx,4)
incq %rcx
jmp 0xc5d2c
xorl %eax, %eax
pushq $0x1
popq %r11
cmpq $0x100, %rax            # imm = 0x100
je 0xc5d64
movl 0x390(%rsp,%rax,4), %ecx
movl %r11d, %esi
shll %cl, %esi
sarl $0x5, %ecx
movslq %ecx, %rcx
orl %esi, (%r12,%rcx,4)
incq %rax
jmp 0xc5d41
leal 0x1(%r10), %eax
xorl %esi, %esi
cmpl $0x40, %esi
je 0xc5d98
leal (%r10,%rsi), %ecx
movl %r11d, %edi
shll %cl, %edi
sarl $0x5, %ecx
movslq %ecx, %rcx
orl %edi, (%r12,%rcx,4)
leal (%rax,%rsi), %ecx
movl %edx, %edi
roll %cl, %edi
sarl $0x5, %ecx
movslq %ecx, %rcx
andl %edi, (%r12,%rcx,4)
addl $0x2, %esi
jmp 0xc5d6a
movabsq $0x100000000, %rbp      # imm = 0x100000000
movl %r11d, %r15d
movq %r9, 0x40(%rsp)
cmpl $0x4, %r8d
jge 0xc6378
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %rax, %r9
je 0xc5de8
movl %eax, %edx
shrl $0x5, %edx
movl (%r12,%rdx,4), %edx
btl %eax, %edx
cmovbl %eax, %ecx
movl (%r14,%rax,4), %edx
subl %r15d, %edx
movl %edx, %esi
sarl $0x1f, %esi
andl %r10d, %esi
addl %edx, %esi
movslq %esi, %rdx
movl %ecx, (%rbx,%rdx,4)
incq %rax
jmp 0xc5db8
movl %r15d, 0x64(%rsp)
movl $0x0, 0xc(%rsp)
xorl %r13d, %r13d
leal -0x20(%r13), %ecx
leal -0x1(%r13), %edi
movl %ecx, %eax
movl %edi, %edx
movl %r13d, %ecx
sarl $0x5, %ecx
movslq %ecx, %rdi
movl %r13d, %ecx
andl $0x1f, %ecx
movl %r11d, %esi
shll %cl, %esi
andl (%r12,%rdi,4), %esi
incl %r13d
testl %ecx, %ecx
je 0xc5e2d
leal 0x1(%rax), %ecx
leal 0x1(%rdx), %edi
testl %esi, %esi
jne 0xc5e00
testl %esi, %esi
je 0xc5e61
movl %edx, %r15d
addl $0x20, %eax
movl %eax, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
leal 0x20(%r15), %edx
cmpl $-0x1, (%r12,%rcx,4)
je 0xc5e31
incl %r15d
movl %r15d, %eax
sarl $0x5, %eax
cltq
movl (%r12,%rax,4), %eax
btl %r15d, %eax
jb 0xc5e4a
jmp 0xc5e67
decl %r13d
movl %r13d, %r15d
cmpl %r10d, %r15d
jg 0xc6355
leal -0x20(%r15), %ecx
leal -0x1(%r15), %edi
movl %r15d, %r13d
movl %ecx, %eax
movl %edi, %edx
movl %r13d, %ecx
sarl $0x5, %ecx
movslq %ecx, %rdi
movl %r13d, %ecx
andl $0x1f, %ecx
movl %r11d, %esi
shll %cl, %esi
andl (%r12,%rdi,4), %esi
incl %r13d
testl %ecx, %ecx
je 0xc5ea8
leal 0x1(%rax), %ecx
leal 0x1(%rdx), %edi
testl %esi, %esi
je 0xc5e7b
testl %esi, %esi
je 0xc5eb1
decl %r13d
jmp 0xc5edf
movl %edx, %r13d
addl $0x20, %eax
movl %eax, %ecx
sarl $0x5, %ecx
movslq %ecx, %rcx
leal 0x20(%r13), %edx
cmpl $0x0, (%r12,%rcx,4)
je 0xc5eb1
incl %r13d
movl %r13d, %eax
sarl $0x5, %eax
cltq
movl (%r12,%rax,4), %eax
btl %r13d, %eax
jae 0xc5eca
cmpl %r10d, %r13d
jg 0xc6355
cmpl %r15d, %r13d
jle 0xc5df8
leal -0x1(%r13), %eax
movl 0xc(%rsp), %ecx
subl %r15d, %ecx
decl %r15d
incl %ecx
movl %ecx, 0xc(%rsp)
movl %r15d, 0x200(%rsp)
movl %eax, 0x70(%rsp)
movl $0x0, 0x28(%rsp)
pushq $0x1
popq %rcx
movl %ecx, %r8d
testl %r8d, %r8d
jle 0xc630b
cmpq $0x63, %r8
jb 0xc5f46
movl $0x3ec, %edi            # imm = 0x3EC
movq %r8, 0x10(%rsp)
callq 0x77bd0
movq 0x10(%rsp), %r8
pushq $0x1
popq %r11
leaq -0x1(%r8), %rcx
movl %ecx, %r9d
movl 0x200(%rsp,%r9,4), %esi
movslq %esi, %rax
movq %rax, 0x58(%rsp)
movl 0x70(%rsp,%r9,4), %edi
movl %edi, %edx
subl %eax, %edx
cmpl $0x9, %edx
jg 0xc6059
movq %rcx, %r8
cmpl %esi, %edi
je 0xc5f1f
movq %rcx, 0x10(%rsp)
movslq %edi, %rax
cmpl $0x3, %edx
jle 0xc5ff1
addl $-0x4, %edi
movslq %edi, %rdx
movq %rdx, %rdi
shlq $0x20, %rdi
leaq 0x4(%rdx), %rsi
cmpq 0x58(%rsp), %rdx
jl 0xc5ff1
movslq (%r14,%rdx,4), %r9
movl (%rbx,%r9,4), %r11d
movq %rsi, %r8
movq %rdi, %r10
cmpq %rax, %r8
jg 0xc5fd0
movl (%r14,%r8,4), %ecx
cmpl (%rbx,%rcx,4), %r11d
jbe 0xc5fd0
movl %ecx, -0x10(%r14,%r8,4)
movabsq $0x400000000, %rcx      # imm = 0x400000000
addq %rcx, %r10
addq $0x4, %r8
jmp 0xc5fa9
sarq $0x1e, %r10
movl %r9d, (%r14,%r10)
decq %rdx
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rcx, %rdi
decq %rsi
pushq $0x1
popq %r11
jmp 0xc5f94
movq %rax, %rdx
shlq $0x20, %rdx
movq %rax, %r8
movq 0x58(%rsp), %rsi
leaq -0x1(%r8), %rdi
cmpq %rsi, %r8
jle 0xc604f
movslq (%r14,%rdi,4), %r9
movl (%rbx,%r9,4), %r11d
movq %rdx, %r10
cmpq %rax, %r8
jg 0xc6030
movl (%r14,%r8,4), %ecx
cmpl (%rbx,%rcx,4), %r11d
jbe 0xc6030
movl %ecx, -0x4(%r14,%r8,4)
incq %r8
addq %rbp, %r10
jmp 0xc6014
sarq $0x1e, %r10
movl %r9d, -0x4(%r14,%r10)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
addq %rcx, %rdx
movq %rdi, %r8
pushq $0x1
popq %r11
jmp 0xc6000
movq 0x10(%rsp), %r8
jmp 0xc5f1f
movq %r9, 0x68(%rsp)
movq %rcx, 0x10(%rsp)
movl 0x28(%rsp), %eax
imull $0x1dc5, %eax, %eax     # imm = 0x1DC5
incl %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x28(%rsp)
xorl %edx, %edx
movw $0x3, %cx
divw %cx
movl %esi, %eax
testw %dx, %dx
je 0xc6099
movzwl %dx, %eax
cmpl $0x1, %eax
jne 0xc6097
leal (%rdi,%rsi), %eax
sarl %eax
jmp 0xc6099
movl %edi, %eax
cltq
movl (%r14,%rax,4), %eax
movl (%rbx,%rax,4), %r9d
movl %edi, %eax
movl %edi, 0x18(%rsp)
movl %esi, %ecx
movl %esi, %r10d
movq %rsi, 0x50(%rsp)
movl %eax, 0x20(%rsp)
cltq
leaq 0x1(%rax), %rdx
movq %rdx, (%rsp)
movslq %ecx, %rcx
movl %ecx, %edx
subl %esi, %edx
movl %edx, 0x30(%rsp)
movl %ecx, %edx
negl %edx
movl %edx, 0x34(%rsp)
movslq %r10d, %r11
leal 0x1(%r11), %r10d
movq %r11, %rdx
cmpq %rax, %rdx
jg 0xc611c
movl (%r14,%rdx,4), %esi
cmpl %r9d, (%rbx,%rsi,4)
je 0xc60f7
jg 0xc6131
incq %rdx
incl %r10d
jmp 0xc60de
movq %r10, %r11
movq %rcx, %r10
movl (%r14,%rcx,4), %ecx
movl %ecx, (%r14,%rdx,4)
movq %r10, %rcx
movq %r11, %r10
movl %esi, (%r14,%rcx,4)
incq %rcx
incl 0x30(%rsp)
decl 0x34(%rsp)
jmp 0xc60d4
movq %rcx, 0x48(%rsp)
movq (%rsp), %rax
cmpq %r11, %rax
cmovgq %rax, %r11
movq %r11, %rdx
jmp 0xc6136
movq %rcx, 0x48(%rsp)
movslq %edx, %r10
movl 0x18(%rsp), %esi
movslq %esi, %rax
movl %edi, %ecx
movq %rax, (%rsp)
subl %eax, %ecx
movl %ecx, 0x2c(%rsp)
movl 0x20(%rsp), %ecx
movslq %ecx, %r11
movl %esi, 0x18(%rsp)
movl %esi, %eax
subl %r11d, %eax
movl %r11d, %ecx
negl %ecx
movq %r11, 0x20(%rsp)
cmpq %r10, %r11
jl 0xc61d9
movl (%r14,%r11,4), %esi
cmpl %r9d, (%rbx,%rsi,4)
je 0xc6180
jl 0xc61af
decq %r11
incl %ecx
incl %eax
jmp 0xc6166
movl %r9d, 0x20(%rsp)
movq (%rsp), %r9
movl (%r14,%r9,4), %eax
movl %eax, (%r14,%r11,4)
movl %esi, (%r14,%r9,4)
decq %r9
movq %r9, (%rsp)
movl 0x20(%rsp), %r9d
notl %ecx
incl 0x2c(%rsp)
movl 0x18(%rsp), %esi
decl %esi
jmp 0xc6150
notl %ecx
movl (%r14,%r10,4), %eax
movl %esi, (%r14,%r10,4)
movl %eax, (%r14,%r11,4)
incl %r10d
movq (%rsp), %rax
movl %eax, 0x18(%rsp)
movl %ecx, %eax
movq 0x50(%rsp), %rsi
movq 0x48(%rsp), %rcx
jmp 0xc60b3
decq %r10
movq 0x20(%rsp), %rcx
cmpq %rcx, %r10
cmovgeq %rcx, %r10
movq %r10, 0x18(%rsp)
movq 0x48(%rsp), %r10
cmpq %r10, (%rsp)
pushq $0x1
popq %r11
movq 0x10(%rsp), %rcx
jl 0xc5f1c
movq %r8, 0x10(%rsp)
movl %r10d, %ecx
subl 0x50(%rsp), %ecx
movl %edx, %esi
subl %r10d, %esi
cmpl %esi, %ecx
cmovll %ecx, %esi
movl 0x34(%rsp), %r8d
addl %edx, %r8d
movl 0x30(%rsp), %ecx
cmpl %r8d, %ecx
cmovll %ecx, %r8d
movl %edx, %ecx
subl %r8d, %ecx
movslq %ecx, %r11
movq %r14, %r9
testl %esi, %esi
jle 0xc625a
movq 0x58(%rsp), %r10
movl (%r9,%r10,4), %ecx
movl (%r9,%r11,4), %r8d
movl %r8d, (%r9,%r10,4)
movl %ecx, (%r9,%r11,4)
decl %esi
addq $0x4, %r9
jmp 0xc6239
movl %edi, %ecx
movq (%rsp), %rsi
subl %esi, %ecx
subl 0x18(%rsp), %esi
cmpl %esi, %ecx
movq %rsi, (%rsp)
cmovgel %esi, %ecx
movl 0x2c(%rsp), %esi
cmpl %eax, %esi
cmovll %esi, %eax
movl %edi, %esi
subl %eax, %esi
movslq %esi, %rax
movslq %edx, %rsi
movq %r14, %r9
pushq $0x1
popq %r11
testl %ecx, %ecx
jle 0xc62a7
movl (%r9,%rsi,4), %r8d
movl 0x4(%r9,%rax,4), %r10d
movl %r10d, (%r9,%rsi,4)
movl %r8d, 0x4(%r9,%rax,4)
decl %ecx
addq $0x4, %r9
jmp 0xc6289
movq 0x48(%rsp), %r8
notl %r8d
movq 0x50(%rsp), %rsi
leal (%rsi,%r8), %ecx
addl %edx, %ecx
movl %edi, %eax
subl (%rsp), %eax
incl %eax
addl %edx, %r8d
movl %edi, %edx
subl %eax, %edx
cmpl %edx, %r8d
jle 0xc62d8
movq 0x68(%rsp), %rdx
movl %ecx, 0x70(%rsp,%rdx,4)
jmp 0xc62e8
movq 0x68(%rsp), %rdx
movl %eax, 0x200(%rsp,%rdx,4)
movl %esi, %eax
movl %ecx, %edi
movq 0x10(%rsp), %rdx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %eax, 0x200(%rsp,%rcx,4)
movl %edi, 0x70(%rsp,%rcx,4)
incq %rdx
movq %rdx, %rcx
jmp 0xc5f1c
movslq %r15d, %rcx
movslq %r13d, %rax
pushq $-0x1
popq %rdx
movq 0x40(%rsp), %r9
movl 0x8(%rsp), %r8d
movq 0x38(%rsp), %r10
cmpq %rax, %rcx
jge 0xc634b
movl (%r14,%rcx,4), %esi
movl (%rbx,%rsi,4), %esi
cmpl %esi, %edx
je 0xc6346
movl %r11d, %edx
shll %cl, %edx
movl %ecx, %edi
sarl $0x5, %edi
movslq %edi, %rdi
orl %edx, (%r12,%rdi,4)
movl %esi, %edx
incq %rcx
jmp 0xc6323
addl %r13d, 0xc(%rsp)
jmp 0xc5df8
cmpl $0x4, %r8d
movl 0xc(%rsp), %r13d
jge 0xc63ab
movl 0x64(%rsp), %r15d
addl %r15d, %r15d
cmpl %r10d, %r15d
jg 0xc63db
testl %r13d, %r13d
jne 0xc5daa
jmp 0xc63db
movq 0x67c39(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x2ee08(%rip), %rsi     # 0xf5191
movl %r15d, %edx
xorl %eax, %eax
callq 0xb8c0
pushq $0x1
popq %r11
movq 0x38(%rsp), %r10
movl 0x8(%rsp), %r8d
movq 0x40(%rsp), %r9
jmp 0xc5db4
movq 0x67c06(%rip), %rax     # 0x12dfb8
movq (%rax), %rdi
leaq 0x2edec(%rip), %rsi     # 0xf51a8
movl %r13d, %edx
xorl %eax, %eax
callq 0xb8c0
pushq $0x1
popq %r11
movq 0x38(%rsp), %r10
movl 0x8(%rsp), %r8d
movq 0x40(%rsp), %r9
jmp 0xc6360
cmpl $0x4, %r8d
jge 0xc647b
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %r9, %rax
je 0xc641b
movslq %ecx, %rcx
leaq (%rsp,%rcx,4), %rdx
addq $0x7a0, %rdx            # imm = 0x7A0
decl %ecx
movl (%rdx), %esi
addq $0x4, %rdx
incl %ecx
testl %esi, %esi
je 0xc63fe
decl %esi
movl %esi, -0x4(%rdx)
movl (%r14,%rax,4), %edx
movb %cl, (%rbx,%rdx)
incq %rax
jmp 0xc63e9
cmpl $0x100, %ecx            # imm = 0x100
jge 0xc6435
addq $0xba8, %rsp            # imm = 0xBA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3ed, %edi            # imm = 0x3ED
addq $0xba8, %rsp            # imm = 0xBA8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x77bd0
movq 0x67b61(%rip), %rax     # 0x12dfb8
movq (%rax), %rcx
leaq 0x2ed14(%rip), %rdi     # 0xf5175
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0xbca0
movq 0x38(%rsp), %r10
movl 0x8(%rsp), %r8d
jmp 0xc5c77
movq 0x67b36(%rip), %rax     # 0x12dfb8
movq (%rax), %rcx
leaq 0x2ed34(%rip), %rdi     # 0xf51c0
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
callq 0xbca0
movq 0x40(%rsp), %r9
jmp 0xc63e5