// File: /workspace/github_c_makefile_star2_O1/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 0x996d9
movq %rsi, %rbx
cmpb $0x0, 0x1394(%rsi)
je 0x996e7
movq %r9, %r15
movl %edx, %ebp
movq %rcx, 0x10(%rsp)
movq %r8, %r13
movq 0x60(%rsp), %r12
movq (%rbx), %rdi
callq 0xbc30
testl %eax, %eax
je 0x9970c
testq %r14, %r14
je 0x996cd
movl $0xfffffffa, (%r14)     # imm = 0xFFFFFFFA
movl $0xfffffffa, 0x13e8(%rbx) # imm = 0xFFFFFFFA
jmp 0x996fd
testq %r14, %r14
je 0x996fd
movl $0x0, (%r14)
jmp 0x996fd
testq %r14, %r14
je 0x996f3
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), %rdx
testq %rdx, %rdx
je 0x99721
movl $0x0, (%rdx)
movq %r13, %r12
testq %r13, %r13
movq 0x8(%rsp), %rcx
je 0x99736
movl $0x0, (%r12)
testq %r15, %r15
je 0x99742
movl $0x0, (%r15)
testq %rcx, %rcx
je 0x9974d
movl $0x0, (%rcx)
testl %ebp, %ebp
jne 0x9977b
cmpl $0x0, 0x13e8(%rbx)
je 0x997ea
movq (%rbx), %rbp
movq %rbp, %rdi
callq 0xbc30
testl %eax, %eax
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rdx
je 0x99880
testq %rdx, %rdx
je 0x99788
movl 0x13a4(%rbx), %eax
movl %eax, (%rdx)
testq %r12, %r12
je 0x99797
movl 0x13a8(%rbx), %eax
movl %eax, (%r12)
testq %r15, %r15
je 0x997a5
movl 0x13bc(%rbx), %eax
movl %eax, (%r15)
testq %rcx, %rcx
je 0x997b2
movl 0x13c0(%rbx), %eax
movl %eax, (%rcx)
testq %r14, %r14
je 0x997be
movl $0x0, (%r14)
movl $0x0, 0x13e8(%rbx)
leaq 0x1398(%rbx), %rdi
callq 0x9832e
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, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movl $0x1388, 0x13b8(%rbx)   # imm = 0x1388
movq 0x18(%rsp), %rax
movq %rax, 0x13b0(%rbx)
movq %r13, %rdi
movl $0x2, %esi
callq 0x97ea9
movl %eax, %ebp
leal -0x5(%rbp), %eax
cmpl $-0x3, %eax
jbe 0x998a7
movl 0x13b8(%rbx), %eax
cmpq $0x1387, %rax           # imm = 0x1387
ja 0x99876
movl $0x1388, %r15d          # imm = 0x1388
subq %rax, %r15
movq (%rbx), %rcx
movl $0x1, %esi
movq 0x18(%rsp), %rdi
movq %r15, %rdx
callq 0xbcb0
cmpl %eax, %r15d
movq 0x20(%rsp), %r15
jne 0x996c1
movq (%rbx), %rdi
callq 0xbc30
testl %eax, %eax
jne 0x996c1
cmpl $0x4, %ebp
jne 0x997ff
jmp 0x9975e
movq %rbp, %rdi
callq 0xb760
movq (%rbx), %rdi
callq 0xbc30
movq 0x10(%rsp), %rdx
movq 0x8(%rsp), %rcx
testl %eax, %eax
jne 0x996c1
jmp 0x9977b
testq %r14, %r14
je 0x998af
movl %ebp, (%r14)
movl %ebp, 0x13e8(%rbx)
jmp 0x996fd