// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzReadOpen
BZFILE* BZ_API(BZ2_bzReadOpen) 
                   ( int*  bzerror, 
                     FILE* f, 
                     int   verbosity,
                     int   small,
                     void* unused,
                     int   nUnused )
{
   bzFile* bzf = NULL;
   int     ret;

   BZ_SETERR(BZ_OK);

   if (f == NULL || 
       (small != 0 && small != 1) ||
       (verbosity < 0 || verbosity > 4) ||
       (unused == NULL && nUnused != 0) ||
       (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
      { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };

   if (ferror(f))
      { BZ_SETERR(BZ_IO_ERROR); return NULL; };

   bzf = malloc ( sizeof(bzFile) );
   if (bzf == NULL) 
      { BZ_SETERR(BZ_MEM_ERROR); return NULL; };

   BZ_SETERR(BZ_OK);

   bzf->initialisedOk = False;
   bzf->handle        = f;
   bzf->bufN          = 0;
   bzf->writing       = False;
   bzf->strm.bzalloc  = NULL;
   bzf->strm.bzfree   = NULL;
   bzf->strm.opaque   = NULL;
   
   while (nUnused > 0) {
      bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
      unused = ((void*)( 1 + ((UChar*)(unused))  ));
      nUnused--;
   }

   ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
   if (ret != BZ_OK)
      { BZ_SETERR(ret); free(bzf); return NULL; };

   bzf->strm.avail_in = bzf->bufN;
   bzf->strm.next_in  = bzf->buf;

   bzf->initialisedOk = True;
   return bzf;   
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r9d, %r12d
movq %r8, %r13
movl %ecx, %r14d
movl %edx, %r15d
movq %rsi, %rbp
movq %rdi, %rbx
testq %rdi, %rdi
je 0x998e2
movl $0x0, (%rbx)
testq %rbp, %rbp
je 0x9991d
cmpl $0x2, %r14d
setae %al
cmpl $0x5, %r15d
setae %cl
orb %al, %cl
jne 0x9991d
testq %r13, %r13
sete %al
testl %r12d, %r12d
setne %cl
testb %cl, %al
jne 0x9991d
testq %r13, %r13
sete %al
cmpl $0x1389, %r12d          # imm = 0x1389
setb %cl
orb %al, %cl
jne 0x9993d
testq %rbx, %rbx
je 0x99928
movl $0xfffffffe, (%rbx)     # imm = 0xFFFFFFFE
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0xbc30
testl %eax, %eax
je 0x99956
testq %rbx, %rbx
je 0x99928
movl $0xfffffffa, (%rbx)     # imm = 0xFFFFFFFA
jmp 0x99928
movl %r14d, 0x4(%rsp)
movl $0x13f0, %edi           # imm = 0x13F0
callq 0xb810
testq %rax, %rax
je 0x99a10
movq %rax, %r14
testq %rbx, %rbx
je 0x9997c
movl $0x0, (%rbx)
xorl %eax, %eax
movl %eax, 0x13e8(%r14)
movb %al, 0x13ec(%r14)
movq %rbp, (%r14)
movl %eax, 0x1390(%r14)
movb %al, 0x1394(%r14)
leaq 0x1398(%r14), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x13d0(%r14)
movq $0x0, 0x13e0(%r14)
testl %r12d, %r12d
jle 0x999e5
incl %r12d
movb (%r13), %al
movslq 0x1390(%r14), %rcx
movb %al, 0x8(%r14,%rcx)
incl 0x1390(%r14)
incq %r13
decl %r12d
cmpl $0x1, %r12d
jg 0x999c2
movl %r15d, %esi
movl 0x4(%rsp), %edx
callq 0x9839a
testl %eax, %eax
je 0x99a24
testq %rbx, %rbx
je 0x999fc
movl %eax, (%rbx)
movl %eax, 0x13e8(%r14)
movq %r14, %rdi
callq 0xb790
jmp 0x99928
testq %rbx, %rbx
je 0x99928
movl $0xfffffffd, (%rbx)     # imm = 0xFFFFFFFD
jmp 0x99928
movl 0x1390(%r14), %eax
movl %eax, 0x13a0(%r14)
movq %r14, %rax
addq $0x8, %rax
movq %rax, 0x1398(%r14)
movb $0x1, 0x13ec(%r14)
jmp 0x9992b