// File: /workspace/github_c_makefile_star2_O2/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 0x794d7
movq %rsi, %rbx
cmpb $0x0, 0x1394(%rsi)
je 0x794e2
movl %edx, %r15d
movq %rcx, 0x8(%rsp)
movq %r8, %r13
movq %r9, 0x10(%rsp)
movq 0x60(%rsp), %r12
movq (%rbx), %rbp
movq %rbp, %rdi
callq 0xbc20
testl %eax, %eax
je 0x79501
testq %r14, %r14
je 0x794cb
movl $0xfffffffa, (%r14)     # imm = 0xFFFFFFFA
movl $0xfffffffa, 0x13e8(%rbx) # imm = 0xFFFFFFFA
jmp 0x794f2
testq %r14, %r14
je 0x794f2
andl $0x0, (%r14)
jmp 0x794f2
testq %r14, %r14
je 0x794eb
orl $-0x1, (%r14)
orl $-0x1, 0x13e8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, (%rsp)
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
movq 0x10(%rsp), %rcx
je 0x79517
andl $0x0, (%rsi)
testq %r13, %r13
movq (%rsp), %rdx
je 0x79525
andl $0x0, (%r13)
testq %rcx, %rcx
je 0x7952d
andl $0x0, (%rcx)
testq %rdx, %rdx
je 0x79535
andl $0x0, (%rdx)
testl %r15d, %r15d
jne 0x79565
cmpl $0x0, 0x13e8(%rbx)
je 0x795cd
movq %rbp, %rdi
callq 0xbc20
testl %eax, %eax
movq 0x10(%rsp), %rcx
movq (%rsp), %rdx
movq 0x8(%rsp), %rsi
je 0x79670
testq %rsi, %rsi
je 0x79572
movl 0x13a4(%rbx), %eax
movl %eax, (%rsi)
testq %r13, %r13
je 0x79581
movl 0x13a8(%rbx), %eax
movl %eax, (%r13)
testq %rcx, %rcx
je 0x7958e
movl 0x13bc(%rbx), %eax
movl %eax, (%rcx)
testq %rdx, %rdx
je 0x7959b
movl 0x13c0(%rbx), %eax
movl %eax, (%rdx)
testq %r14, %r14
je 0x795a4
andl $0x0, (%r14)
andl $0x0, 0x13e8(%rbx)
leaq 0x1398(%rbx), %rdi
callq 0x78295
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb790
movq %r13, 0x20(%rsp)
leaq 0x1398(%rbx), %r12
leaq 0x8(%rbx), %rax
movq %rax, 0x18(%rsp)
pushq $0x2
popq %r15
movl $0x1388, 0x13b8(%rbx)   # imm = 0x1388
movq 0x18(%rsp), %rax
movq %rax, 0x13b0(%rbx)
movq %r12, %rdi
movl %r15d, %esi
callq 0x77e28
movl %eax, %ebp
leal -0x5(%rbp), %eax
cmpl $-0x3, %eax
jbe 0x7969b
movl 0x13b8(%rbx), %eax
cmpq $0x1387, %rax           # imm = 0x1387
ja 0x7965e
movl %r15d, %r13d
movl $0x1388, %r15d          # imm = 0x1388
subq %rax, %r15
movq (%rbx), %rcx
movq 0x18(%rsp), %rdi
pushq $0x1
popq %rsi
movq %r15, %rdx
callq 0xbca0
cmpl %eax, %r15d
jne 0x794bf
movl %r13d, %r15d
movq (%rbx), %rdi
callq 0xbc20
testl %eax, %eax
jne 0x794bf
cmpl $0x4, %ebp
jne 0x795e6
movq (%rbx), %rbp
movq 0x20(%rsp), %r13
jmp 0x79547
movq %rbp, %rdi
callq 0xb760
movq (%rbx), %rdi
callq 0xbc20
movq 0x8(%rsp), %rsi
movq (%rsp), %rdx
movq 0x10(%rsp), %rcx
testl %eax, %eax
jne 0x794bf
jmp 0x79565
testq %r14, %r14
je 0x796a3
movl %ebp, (%r14)
movl %ebp, 0x13e8(%rbx)
jmp 0x794f2