// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzRead
int BZ_API(BZ2_bzRead) 
           ( int*    bzerror, 
             BZFILE* b, 
             void*   buf, 
             int     len )
{
   Int32   n, ret;
   bzFile* bzf = (bzFile*)b;

   BZ_SETERR(BZ_OK);

   if (bzf == NULL || buf == NULL || len < 0)
      { BZ_SETERR(BZ_PARAM_ERROR); return 0; };

   if (bzf->writing)
      { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };

   if (len == 0)
      { BZ_SETERR(BZ_OK); return 0; };

   bzf->strm.avail_out = len;
   bzf->strm.next_out = buf;

   while (True) {

      if (ferror(bzf->handle)) 
         { BZ_SETERR(BZ_IO_ERROR); return 0; };

      if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
         n = fread ( bzf->buf, sizeof(UChar), 
                     BZ_MAX_UNUSED, bzf->handle );
         if (ferror(bzf->handle))
            { BZ_SETERR(BZ_IO_ERROR); return 0; };
         bzf->bufN = n;
         bzf->strm.avail_in = bzf->bufN;
         bzf->strm.next_in = bzf->buf;
      }

      ret = BZ2_bzDecompress ( &(bzf->strm) );

      if (ret != BZ_OK && ret != BZ_STREAM_END)
         { BZ_SETERR(ret); return 0; };

      if (ret == BZ_OK && myfeof(bzf->handle) && 
          bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
         { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };

      if (ret == BZ_STREAM_END)
         { BZ_SETERR(BZ_STREAM_END);
           return len - bzf->strm.avail_out; };
      if (bzf->strm.avail_out == 0)
         { BZ_SETERR(BZ_OK); return len; };
      
   }

   return 0; /*not reached*/
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x28(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, 0x28(%rsp)
je 0xcb2b3
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, (%rsp)
je 0xcb2c8
movq (%rsp), %rax
movl $0x0, 0x13e8(%rax)
cmpq $0x0, (%rsp)
je 0xcb2de
cmpq $0x0, 0x18(%rsp)
je 0xcb2de
cmpl $0x0, 0x14(%rsp)
jge 0xcb313
cmpq $0x0, 0x28(%rsp)
je 0xcb2f1
movq 0x28(%rsp), %rax
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
cmpq $0x0, (%rsp)
je 0xcb306
movq (%rsp), %rax
movl $0xfffffffe, 0x13e8(%rax) # imm = 0xFFFFFFFE
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
movq (%rsp), %rax
cmpb $0x0, 0x1394(%rax)
je 0xcb355
cmpq $0x0, 0x28(%rsp)
je 0xcb333
movq 0x28(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, (%rsp)
je 0xcb348
movq (%rsp), %rax
movl $0xffffffff, 0x13e8(%rax) # imm = 0xFFFFFFFF
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
cmpl $0x0, 0x14(%rsp)
jne 0xcb391
cmpq $0x0, 0x28(%rsp)
je 0xcb36f
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, (%rsp)
je 0xcb384
movq (%rsp), %rax
movl $0x0, 0x13e8(%rax)
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
movl 0x14(%rsp), %ecx
movq (%rsp), %rax
movl %ecx, 0x13b8(%rax)
movq 0x18(%rsp), %rcx
movq (%rsp), %rax
movq %rcx, 0x13b0(%rax)
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xcb3f5
cmpq $0x0, 0x28(%rsp)
je 0xcb3d3
movq 0x28(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, (%rsp)
je 0xcb3e8
movq (%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
movq (%rsp), %rax
cmpl $0x0, 0x13a0(%rax)
jne 0xcb4b7
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xcb610
cmpb $0x0, %al
jne 0xcb4b7
movq (%rsp), %rdi
addq $0x8, %rdi
movq (%rsp), %rax
movq (%rax), %rcx
movl $0x1, %esi
movl $0x1388, %edx           # imm = 0x1388
callq 0xb900
movl %eax, 0x10(%rsp)
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xcb482
cmpq $0x0, 0x28(%rsp)
je 0xcb460
movq 0x28(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, (%rsp)
je 0xcb475
movq (%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
movl 0x10(%rsp), %ecx
movq (%rsp), %rax
movl %ecx, 0x1390(%rax)
movq (%rsp), %rax
movl 0x1390(%rax), %ecx
movq (%rsp), %rax
movl %ecx, 0x13a0(%rax)
movq (%rsp), %rcx
addq $0x8, %rcx
movq (%rsp), %rax
movq %rcx, 0x1398(%rax)
movq (%rsp), %rdi
addq $0x1398, %rdi           # imm = 0x1398
callq 0xc87e0
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0xcb50e
cmpl $0x4, 0xc(%rsp)
je 0xcb50e
cmpq $0x0, 0x28(%rsp)
je 0xcb4ec
movl 0xc(%rsp), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, (%rsp)
je 0xcb501
movl 0xc(%rsp), %ecx
movq (%rsp), %rax
movl %ecx, 0x13e8(%rax)
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
cmpl $0x0, 0xc(%rsp)
jne 0xcb578
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xcb610
movzbl %al, %eax
cmpl $0x0, %eax
je 0xcb578
movq (%rsp), %rax
cmpl $0x0, 0x13a0(%rax)
jne 0xcb578
movq (%rsp), %rax
cmpl $0x0, 0x13b8(%rax)
jbe 0xcb578
cmpq $0x0, 0x28(%rsp)
je 0xcb556
movq 0x28(%rsp), %rax
movl $0xfffffff9, (%rax)     # imm = 0xFFFFFFF9
cmpq $0x0, (%rsp)
je 0xcb56b
movq (%rsp), %rax
movl $0xfffffff9, 0x13e8(%rax) # imm = 0xFFFFFFF9
movl $0x0, 0x34(%rsp)
jmp 0xcb5ff
cmpl $0x4, 0xc(%rsp)
jne 0xcb5bb
cmpq $0x0, 0x28(%rsp)
je 0xcb592
movq 0x28(%rsp), %rax
movl $0x4, (%rax)
cmpq $0x0, (%rsp)
je 0xcb5a7
movq (%rsp), %rax
movl $0x4, 0x13e8(%rax)
movl 0x14(%rsp), %eax
movq (%rsp), %rcx
subl 0x13b8(%rcx), %eax
movl %eax, 0x34(%rsp)
jmp 0xcb5ff
movq (%rsp), %rax
cmpl $0x0, 0x13b8(%rax)
jne 0xcb5fa
cmpq $0x0, 0x28(%rsp)
je 0xcb5db
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, (%rsp)
je 0xcb5f0
movq (%rsp), %rax
movl $0x0, 0x13e8(%rax)
movl 0x14(%rsp), %eax
movl %eax, 0x34(%rsp)
jmp 0xcb5ff
jmp 0xcb3af
movl 0x34(%rsp), %eax
addq $0x38, %rsp
retq
nopl (%rax,%rax)