// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzWriteClose64
void BZ_API(BZ2_bzWriteClose64)
                  ( int*          bzerror, 
                    BZFILE*       b, 
                    int           abandon,
                    unsigned int* nbytes_in_lo32,
                    unsigned int* nbytes_in_hi32,
                    unsigned int* nbytes_out_lo32,
                    unsigned int* nbytes_out_hi32 )
{
   Int32   n, n2, ret;
   bzFile* bzf = (bzFile*)b;

   if (bzf == NULL)
      { BZ_SETERR(BZ_OK); return; };
   if (!(bzf->writing))
      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
   if (ferror(bzf->handle))
      { BZ_SETERR(BZ_IO_ERROR); return; };

   if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
   if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
   if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
   if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;

   if ((!abandon) && bzf->lastErr == BZ_OK) {
      while (True) {
         bzf->strm.avail_out = BZ_MAX_UNUSED;
         bzf->strm.next_out = bzf->buf;
         ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
         if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
            { BZ_SETERR(ret); return; };

         if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
            n = BZ_MAX_UNUSED - bzf->strm.avail_out;
            n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), 
                          n, bzf->handle );
            if (n != n2 || ferror(bzf->handle))
               { BZ_SETERR(BZ_IO_ERROR); return; };
         }

         if (ret == BZ_STREAM_END) break;
      }
   }

   if ( !abandon && !ferror ( bzf->handle ) ) {
      fflush ( bzf->handle );
      if (ferror(bzf->handle))
         { BZ_SETERR(BZ_IO_ERROR); return; };
   }

   if (nbytes_in_lo32 != NULL)
      *nbytes_in_lo32 = bzf->strm.total_in_lo32;
   if (nbytes_in_hi32 != NULL)
      *nbytes_in_hi32 = bzf->strm.total_in_hi32;
   if (nbytes_out_lo32 != NULL)
      *nbytes_out_lo32 = bzf->strm.total_out_lo32;
   if (nbytes_out_hi32 != NULL)
      *nbytes_out_hi32 = bzf->strm.total_out_hi32;

   BZ_SETERR(BZ_OK);
   BZ2_bzCompressEnd ( &(bzf->strm) );
   free ( bzf );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
testq %rsi, %rsi
je 0x98c72
movq %rsi, %rbx
cmpb $0x0, 0x1394(%rsi)
je 0x98c80
movl %edx, %r15d
movq %rcx, 0x10(%rsp)
movq %r8, %r13
movq %r9, 0x18(%rsp)
movq 0x60(%rsp), %r12
movq (%rbx), %rbp
movq %rbp, %rdi
callq 0xbc30
testl %eax, %eax
je 0x98ca5
testq %r14, %r14
je 0x98c66
movl $0xfffffffa, (%r14)     # imm = 0xFFFFFFFA
movl $0xfffffffa, 0x13e8(%rbx) # imm = 0xFFFFFFFA
jmp 0x98c96
testq %r14, %r14
je 0x98c96
movl $0x0, (%r14)
jmp 0x98c96
testq %r14, %r14
je 0x98c8c
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
movl $0xffffffff, 0x13e8(%rbx) # imm = 0xFFFFFFFF
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x8(%rsp)
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
movq 0x18(%rsp), %rcx
je 0x98cbf
movl $0x0, (%rsi)
movq %r13, %r12
testq %r13, %r13
movq 0x8(%rsp), %rdx
je 0x98cd4
movl $0x0, (%r12)
testq %rcx, %rcx
je 0x98cdf
movl $0x0, (%rcx)
testq %rdx, %rdx
je 0x98cea
movl $0x0, (%rdx)
testl %r15d, %r15d
jne 0x98d1b
cmpl $0x0, 0x13e8(%rbx)
je 0x98d89
movq %rbp, %rdi
callq 0xbc30
testl %eax, %eax
movq 0x18(%rsp), %rcx
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
je 0x98e18
testq %rsi, %rsi
je 0x98d28
movl 0x13a4(%rbx), %eax
movl %eax, (%rsi)
testq %r12, %r12
je 0x98d37
movl 0x13a8(%rbx), %eax
movl %eax, (%r12)
testq %rcx, %rcx
je 0x98d44
movl 0x13bc(%rbx), %eax
movl %eax, (%rcx)
testq %rdx, %rdx
je 0x98d51
movl 0x13c0(%rbx), %eax
movl %eax, (%rdx)
testq %r14, %r14
je 0x98d5d
movl $0x0, (%r14)
movl $0x0, 0x13e8(%rbx)
leaq 0x1398(%rbx), %rdi
callq 0x9789a
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb790
leaq 0x1398(%rbx), %r13
leaq 0x8(%rbx), %rax
movq %rax, 0x20(%rsp)
movl $0x1388, 0x13b8(%rbx)   # imm = 0x1388
movq 0x20(%rsp), %rax
movq %rax, 0x13b0(%rbx)
movq %r13, %rdi
movl $0x2, %esi
callq 0x973d6
movl %eax, %ebp
leal -0x5(%rbp), %eax
cmpl $-0x3, %eax
jbe 0x98e44
movl 0x13b8(%rbx), %eax
cmpq $0x1387, %rax           # imm = 0x1387
ja 0x98e0b
movl $0x1388, %r15d          # imm = 0x1388
subq %rax, %r15
movq (%rbx), %rcx
movl $0x1, %esi
movq 0x20(%rsp), %rdi
movq %r15, %rdx
callq 0xbcb0
cmpl %eax, %r15d
jne 0x98c5a
movq (%rbx), %rdi
callq 0xbc30
testl %eax, %eax
jne 0x98c5a
cmpl $0x4, %ebp
jne 0x98d99
movq (%rbx), %rbp
jmp 0x98cfc
movq %rbp, %rdi
callq 0xb760
movq (%rbx), %rdi
callq 0xbc30
movq 0x10(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rcx
testl %eax, %eax
jne 0x98c5a
jmp 0x98d1b
testq %r14, %r14
je 0x98e4c
movl %ebp, (%r14)
movl %ebp, 0x13e8(%rbx)
jmp 0x98c96