// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/bzip2-1.0.6/blocksort.c
// Function: BZ2_blockSort
void BZ2_blockSort ( EState* s )
{
   UInt32* ptr    = s->ptr; 
   UChar*  block  = s->block;
   UInt32* ftab   = s->ftab;
   Int32   nblock = s->nblock;
   Int32   verb   = s->verbosity;
   Int32   wfact  = s->workFactor;
   UInt16* quadrant;
   Int32   budget;
   Int32   budgetInit;
   Int32   i;

   if (nblock < 10000) {
      fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
   } else {
      /* Calculate the location for quadrant, remembering to get
         the alignment right.  Assumes that &(block[0]) is at least
         2-byte aligned -- this should be ok since block is really
         the first section of arr2.
      */
      i = nblock+BZ_N_OVERSHOOT;
      if (i & 1) i++;
      quadrant = (UInt16*)(&(block[i]));

      /* (wfact-1) / 3 puts the default-factor-30
         transition point at very roughly the same place as 
         with v0.1 and v0.9.0.  
         Not that it particularly matters any more, since the
         resulting compressed stream is now the same regardless
         of whether or not we use the main sort or fallback sort.
      */
      if (wfact < 1  ) wfact = 1;
      if (wfact > 100) wfact = 100;
      budgetInit = nblock * ((wfact-1) / 3);
      budget = budgetInit;

      mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
      if (verb >= 3) 
         VPrintf3 ( "      %d work, %d block, ratio %5.2f\n",
                    budgetInit - budget,
                    nblock, 
                    (float)(budgetInit - budget) /
                    (float)(nblock==0 ? 1 : nblock) ); 
      if (budget < 0) {
         if (verb >= 2) 
            VPrintf0 ( "    too repetitive; using fallback"
                       " sorting algorithm\n" );
         fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
      }
   }

   s->origPtr = -1;
   for (i = 0; i < s->nblock; i++)
      if (ptr[i] == 0)
         { s->origPtr = i; break; };

   AssertH( s->origPtr != -1, 1003 );
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq 0x40(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %rax
movl 0x6c(%rax), %eax
movl %eax, 0x54(%rsp)
movq 0x70(%rsp), %rax
movl 0x290(%rax), %eax
movl %eax, 0x50(%rsp)
movq 0x70(%rsp), %rax
movl 0x58(%rax), %eax
movl %eax, 0x4c(%rsp)
cmpl $0x2710, 0x54(%rsp)     # imm = 0x2710
jge 0x15276e
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x58(%rsp), %rdx
movl 0x54(%rsp), %ecx
movl 0x50(%rsp), %r8d
callq 0x152960
jmp 0x1528f0
movl 0x54(%rsp), %eax
addl $0x22, %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x152790
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
movq 0x60(%rsp), %rax
movslq 0x34(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
cmpl $0x1, 0x4c(%rsp)
jge 0x1527b1
movl $0x1, 0x4c(%rsp)
cmpl $0x64, 0x4c(%rsp)
jle 0x1527c0
movl $0x64, 0x4c(%rsp)
movl 0x54(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x4c(%rsp), %eax
subl $0x1, %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl 0x30(%rsp), %eax
imull %ecx, %eax
movl %eax, 0x38(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x58(%rsp), %rcx
movl 0x54(%rsp), %r8d
movl 0x50(%rsp), %r9d
leaq 0x3c(%rsp), %rax
movq %rax, (%rsp)
callq 0x153130
cmpl $0x3, 0x50(%rsp)
jl 0x1528a3
movq 0x617ae(%rip), %rax     # 0x1b3fd8
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movl 0x38(%rsp), %eax
subl 0x3c(%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x54(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x38(%rsp), %eax
subl 0x3c(%rsp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x2c(%rsp)
cmpl $0x0, 0x54(%rsp)
jne 0x15286a
movl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x152872
movl 0x54(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x28(%rsp), %ecx
movl 0x24(%rsp), %edx
movq 0x18(%rsp), %rdi
movss 0x2c(%rsp), %xmm0
movl 0x14(%rsp), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3c475(%rip), %rsi     # 0x18ed11
movb $0x1, %al
callq 0xb890
cmpl $0x0, 0x3c(%rsp)
jge 0x1528ee
cmpl $0x2, 0x50(%rsp)
jl 0x1528c9
movq 0x61720(%rip), %rax     # 0x1b3fd8
movq (%rax), %rdi
leaq 0x3c475(%rip), %rsi     # 0x18ed37
movb $0x0, %al
callq 0xb890
movq 0x70(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x70(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x58(%rsp), %rdx
movl 0x54(%rsp), %ecx
movl 0x50(%rsp), %r8d
callq 0x152960
jmp 0x1528f0
movq 0x70(%rsp), %rax
movl $0xffffffff, 0x30(%rax) # imm = 0xFFFFFFFF
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
movq 0x70(%rsp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x15293f
movq 0x68(%rsp), %rax
movslq 0x34(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x152930
movl 0x34(%rsp), %ecx
movq 0x70(%rsp), %rax
movl %ecx, 0x30(%rax)
jmp 0x15293f
jmp 0x152932
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x152904
movq 0x70(%rsp), %rax
cmpl $-0x1, 0x30(%rax)
jne 0x152954
movl $0x3eb, %edi            # imm = 0x3EB
callq 0xc7b30
addq $0x78, %rsp
retq
nopl (%rax)