// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzCompressInit
int BZ_API(BZ2_bzCompressInit) 
                    ( bz_stream* strm, 
                     int        blockSize100k,
                     int        verbosity,
                     int        workFactor )
{
   Int32   n;
   EState* s;

   if (!bz_config_ok()) return BZ_CONFIG_ERROR;

   if (strm == NULL || 
       blockSize100k < 1 || blockSize100k > 9 ||
       workFactor < 0 || workFactor > 250)
     return BZ_PARAM_ERROR;

   if (workFactor == 0) workFactor = 30;
   if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
   if (strm->bzfree == NULL) strm->bzfree = default_bzfree;

   s = BZALLOC( sizeof(EState) );
   if (s == NULL) return BZ_MEM_ERROR;
   s->strm = strm;

   s->arr1 = NULL;
   s->arr2 = NULL;
   s->ftab = NULL;

   n       = 100000 * blockSize100k;
   s->arr1 = BZALLOC( n                  * sizeof(UInt32) );
   s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
   s->ftab = BZALLOC( 65537              * sizeof(UInt32) );

   if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
      if (s->arr1 != NULL) BZFREE(s->arr1);
      if (s->arr2 != NULL) BZFREE(s->arr2);
      if (s->ftab != NULL) BZFREE(s->ftab);
      if (s       != NULL) BZFREE(s);
      return BZ_MEM_ERROR;
   }

   s->blockNo           = 0;
   s->state             = BZ_S_INPUT;
   s->mode              = BZ_M_RUNNING;
   s->combinedCRC       = 0;
   s->blockSize100k     = blockSize100k;
   s->nblockMAX         = 100000 * blockSize100k - 19;
   s->verbosity         = verbosity;
   s->workFactor        = workFactor;

   s->block             = (UChar*)s->arr2;
   s->mtfv              = (UInt16*)s->arr1;
   s->zbits             = NULL;
   s->ptr               = (UInt32*)s->arr1;

   strm->state          = s;
   strm->total_in_lo32  = 0;
   strm->total_in_hi32  = 0;
   strm->total_out_lo32 = 0;
   strm->total_out_hi32 = 0;
   init_RL ( s );
   prepare_new_block ( s );
   return BZ_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r13d
movl %esi, %r12d
testq %rdi, %rdi
sete %al
leal -0xa(%r12), %edx
cmpl $-0x9, %edx
setb %dl
cmpl $0xfb, %ecx
setae %sil
orb %al, %sil
orb %dl, %sil
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
jne 0x973ab
movq %rdi, %rbx
testl %ecx, %ecx
movl $0x1e, %ebp
cmovnel %ecx, %ebp
movq 0x38(%rdi), %rax
testq %rax, %rax
jne 0x97231
leaq 0x190(%rip), %rax       # 0x973bd
movq %rax, 0x38(%rbx)
cmpq $0x0, 0x40(%rbx)
jne 0x97243
leaq 0x189(%rip), %rcx       # 0x973c8
movq %rcx, 0x40(%rbx)
movq 0x48(%rbx), %rdi
movl $0xd9d8, %esi           # imm = 0xD9D8
movl $0x1, %edx
callq *%rax
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
testq %rax, %rax
je 0x973ab
movq %rax, %r15
movl %r13d, 0x4(%rsp)
movq %rbx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq 0x48(%rbx), %rdi
imull $0x61a80, %r12d, %r13d  # imm = 0x61A80
movl %r13d, %esi
movl $0x1, %edx
callq *0x38(%rbx)
movq %rax, 0x18(%r15)
movq 0x48(%rbx), %rdi
addl $0x88, %r13d
movl %r13d, %esi
movl $0x1, %edx
callq *0x38(%rbx)
movq %rax, 0x20(%r15)
movq 0x48(%rbx), %rdi
movl $0x40004, %esi          # imm = 0x40004
movl $0x1, %edx
callq *0x38(%rbx)
movq %rax, 0x28(%r15)
movq 0x18(%r15), %rsi
testq %rsi, %rsi
je 0x972eb
movq 0x20(%r15), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0x9731a
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x20(%r15), %rsi
testq %rsi, %rsi
je 0x972fb
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x28(%r15), %rsi
testq %rsi, %rsi
je 0x9730b
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x48(%rbx), %rdi
movq %r15, %rsi
callq *0x40(%rbx)
jmp 0x973ab
imull $0x186a0, %r12d, %eax   # imm = 0x186A0
movabsq $0x200000002, %rdx      # imm = 0x200000002
movq %rdx, 0x8(%r15)
xorl %r14d, %r14d
movl %r14d, 0x28c(%r15)
movl %r12d, 0x298(%r15)
addl $-0x13, %eax
movl %eax, 0x70(%r15)
movl 0x4(%rsp), %eax
movl %eax, 0x290(%r15)
movl %ebp, 0x58(%r15)
movq %rcx, 0x40(%r15)
movq %rsi, 0x48(%r15)
movq %r14, 0x50(%r15)
movq %rsi, 0x38(%r15)
movq %r15, 0x30(%rbx)
movq %r14, 0xc(%rbx)
movq %r14, 0x24(%rbx)
movq $0x100, 0x5c(%r15)      # imm = 0x100
movl %r14d, 0x6c(%r15)
movq %r14, 0x74(%r15)
movl $0xffffffff, 0x288(%r15) # imm = 0xFFFFFFFF
movq %r15, %rdi
subq $-0x80, %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0xb2f0
movl $0x1, 0x294(%r15)
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq