// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq 0x50(%rsp), %rax
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movl %edx, 0x34(%rsp)
movq %rcx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
movq 0x38(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, (%rsp)
jne 0xcab93
cmpq $0x0, 0x40(%rsp)
je 0xcab79
movq 0x40(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, (%rsp)
je 0xcab8e
movq (%rsp), %rax
movl $0x0, 0x13e8(%rax)
jmp 0xcae92
movq (%rsp), %rax
cmpb $0x0, 0x1394(%rax)
jne 0xcabcd
cmpq $0x0, 0x40(%rsp)
je 0xcabb3
movq 0x40(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, (%rsp)
je 0xcabc8
movq (%rsp), %rax
movl $0xffffffff, 0x13e8(%rax) # imm = 0xFFFFFFFF
jmp 0xcae92
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xcac0b
cmpq $0x0, 0x40(%rsp)
je 0xcabf1
movq 0x40(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, (%rsp)
je 0xcac06
movq (%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
jmp 0xcae92
cmpq $0x0, 0x28(%rsp)
je 0xcac1e
movq 0x28(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x20(%rsp)
je 0xcac31
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x18(%rsp)
je 0xcac44
movq 0x18(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x50(%rsp)
je 0xcac57
movq 0x50(%rsp), %rax
movl $0x0, (%rax)
cmpl $0x0, 0x34(%rsp)
jne 0xcad89
movq (%rsp), %rax
cmpl $0x0, 0x13e8(%rax)
jne 0xcad89
jmp 0xcac75
movq (%rsp), %rax
movl $0x1388, 0x13b8(%rax)   # imm = 0x1388
movq (%rsp), %rcx
addq $0x8, %rcx
movq (%rsp), %rax
movq %rcx, 0x13b0(%rax)
movq (%rsp), %rdi
addq $0x1398, %rdi           # imm = 0x1398
movl $0x2, %esi
callq 0xc8040
movl %eax, 0xc(%rsp)
cmpl $0x3, 0xc(%rsp)
je 0xcacea
cmpl $0x4, 0xc(%rsp)
je 0xcacea
cmpq $0x0, 0x40(%rsp)
je 0xcacd0
movl 0xc(%rsp), %ecx
movq 0x40(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, (%rsp)
je 0xcace5
movl 0xc(%rsp), %ecx
movq (%rsp), %rax
movl %ecx, 0x13e8(%rax)
jmp 0xcae92
movq (%rsp), %rax
cmpl $0x1388, 0x13b8(%rax)   # imm = 0x1388
jae 0xcad79
movq (%rsp), %rcx
movl $0x1388, %eax           # imm = 0x1388
subl 0x13b8(%rcx), %eax
movl %eax, 0x14(%rsp)
movq (%rsp), %rdi
addq $0x8, %rdi
movslq 0x14(%rsp), %rdx
movq (%rsp), %rax
movq (%rax), %rcx
movl $0x1, %esi
callq 0xbc70
movl %eax, 0x10(%rsp)
movl 0x14(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0xcad4a
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xcad77
cmpq $0x0, 0x40(%rsp)
je 0xcad5d
movq 0x40(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, (%rsp)
je 0xcad72
movq (%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
jmp 0xcae92
jmp 0xcad79
cmpl $0x4, 0xc(%rsp)
jne 0xcad82
jmp 0xcad87
jmp 0xcac75
jmp 0xcad89
cmpl $0x0, 0x34(%rsp)
jne 0xcaded
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
jne 0xcaded
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xb730
movq (%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xcadeb
cmpq $0x0, 0x40(%rsp)
je 0xcadd1
movq 0x40(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, (%rsp)
je 0xcade6
movq (%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
jmp 0xcae92
jmp 0xcaded
cmpq $0x0, 0x28(%rsp)
je 0xcae06
movq (%rsp), %rax
movl 0x13a4(%rax), %ecx
movq 0x28(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x20(%rsp)
je 0xcae1f
movq (%rsp), %rax
movl 0x13a8(%rax), %ecx
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x18(%rsp)
je 0xcae38
movq (%rsp), %rax
movl 0x13bc(%rax), %ecx
movq 0x18(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x50(%rsp)
je 0xcae51
movq (%rsp), %rax
movl 0x13c0(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x40(%rsp)
je 0xcae64
movq 0x40(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, (%rsp)
je 0xcae79
movq (%rsp), %rax
movl $0x0, 0x13e8(%rax)
movq (%rsp), %rdi
addq $0x1398, %rdi           # imm = 0x1398
callq 0xc84a0
movq (%rsp), %rdi
callq 0xb760
addq $0x48, %rsp
retq
nopw (%rax,%rax)