// File: /workspace/github_c_makefile_star2_O1/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 0x97e7e
movq %rdi, %rbx
testl %ecx, %ecx
movl $0x1e, %ebp
cmovnel %ecx, %ebp
cmpq $0x0, 0x38(%rdi)
jne 0x97cf7
leaq 0x19d(%rip), %rax       # 0x97e90
movq %rax, 0x38(%rbx)
cmpq $0x0, 0x40(%rbx)
jne 0x97d09
leaq 0x196(%rip), %rax       # 0x97e9b
movq %rax, 0x40(%rbx)
movq 0x48(%rbx), %rdi
movl $0xd9d8, %esi           # imm = 0xD9D8
movl $0x1, %edx
callq *0x38(%rbx)
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
testq %rax, %rax
je 0x97e7e
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 0x97db7
movq 0x20(%r15), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0x97de6
testq %rsi, %rsi
je 0x97db7
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x20(%r15), %rsi
testq %rsi, %rsi
je 0x97dc7
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x28(%r15), %rsi
testq %rsi, %rsi
je 0x97dd7
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x48(%rbx), %rdi
movq %r15, %rsi
callq *0x40(%rbx)
jmp 0x97e7e
imull $0x186a0, %r12d, %eax   # imm = 0x186A0
xorl %r14d, %r14d
movl %r14d, 0x294(%r15)
movabsq $0x200000002, %rdx      # imm = 0x200000002
movq %rdx, 0x8(%r15)
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