// File: /workspace/github_c_makefile_star2_O2/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, %ebp
movl %esi, %r15d
testq %rdi, %rdi
sete %al
leal -0xa(%r15), %edx
cmpl $-0x9, %edx
setb %dl
cmpl $0xfb, %ecx
setae %sil
orb %al, %sil
orb %dl, %sil
je 0x77c61
pushq $-0x2
popq %r12
jmp 0x77dd5
movq %rdi, %rbx
testl %ecx, %ecx
pushq $0x1e
popq %r13
cmovnel %ecx, %r13d
movq 0x38(%rdi), %rax
testq %rax, %rax
jne 0x77c82
leaq 0x169(%rip), %rax       # 0x77de7
movq %rax, 0x38(%rbx)
cmpq $0x0, 0x40(%rbx)
jne 0x77c94
leaq 0x162(%rip), %rcx       # 0x77df2
movq %rcx, 0x40(%rbx)
movq 0x48(%rbx), %rdi
pushq $0x1
popq %rdx
movl $0xd9d8, %esi           # imm = 0xD9D8
callq *%rax
pushq $-0x3
popq %r12
testq %rax, %rax
je 0x77dd5
movq %rax, %r14
movl %r13d, (%rsp)
movl %ebp, 0x4(%rsp)
movq %rbx, (%rax)
andq $0x0, 0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq 0x48(%rbx), %rdi
imull $0x61a80, %r15d, %r13d  # imm = 0x61A80
pushq $0x1
popq %rbp
movl %r13d, %esi
movl %ebp, %edx
callq *0x38(%rbx)
movq %rax, 0x18(%r14)
movq 0x48(%rbx), %rdi
addl $0x88, %r13d
movl %r13d, %esi
movl %ebp, %edx
callq *0x38(%rbx)
movq %rax, 0x20(%r14)
movq 0x48(%rbx), %rdi
movl $0x40004, %esi          # imm = 0x40004
movl %ebp, %edx
callq *0x38(%rbx)
movq %rax, 0x28(%r14)
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0x77d32
movq 0x20(%r14), %rcx
testq %rcx, %rcx
sete %dl
testq %rax, %rax
sete %al
orb %dl, %al
cmpb $0x1, %al
jne 0x77d5e
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x20(%r14), %rsi
testq %rsi, %rsi
je 0x77d42
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x28(%r14), %rsi
testq %rsi, %rsi
je 0x77d52
movq 0x48(%rbx), %rdi
callq *0x40(%rbx)
movq 0x48(%rbx), %rdi
movq %r14, %rsi
callq *0x40(%rbx)
jmp 0x77dd5
andl $0x0, 0x294(%r14)
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0x8(%r14)
andl $0x0, 0x28c(%r14)
imull $0x186a0, %r15d, %eax   # imm = 0x186A0
movl %r15d, 0x298(%r14)
addl $-0x13, %eax
movl %eax, 0x70(%r14)
movl 0x4(%rsp), %eax
movl %eax, 0x290(%r14)
movl (%rsp), %eax
movl %eax, 0x58(%r14)
movq %rcx, 0x40(%r14)
movq %rsi, 0x48(%r14)
andq $0x0, 0x50(%r14)
movq %rsi, 0x38(%r14)
movq %r14, 0x30(%rbx)
andq $0x0, 0xc(%rbx)
andq $0x0, 0x24(%rbx)
movq $0x100, 0x5c(%r14)      # imm = 0x100
movq %r14, %rdi
callq 0x77dfa
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq