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

   BZ_SETERR(BZ_OK);
   if (bzf == NULL || buf == NULL || len < 0)
      { BZ_SETERR(BZ_PARAM_ERROR); return; };
   if (!(bzf->writing))
      { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
   if (ferror(bzf->handle))
      { BZ_SETERR(BZ_IO_ERROR); return; };

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

   bzf->strm.avail_in = len;
   bzf->strm.next_in  = buf;

   while (True) {
      bzf->strm.avail_out = BZ_MAX_UNUSED;
      bzf->strm.next_out = bzf->buf;
      ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
      if (ret != BZ_RUN_OK)
         { 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 (bzf->strm.avail_in == 0)
         { BZ_SETERR(BZ_OK); return; };
   }
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movl %ecx, 0x1c(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x30(%rsp)
je 0xca854
movq 0x30(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca86b
movq 0x8(%rsp), %rax
movl $0x0, 0x13e8(%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca882
cmpq $0x0, 0x20(%rsp)
je 0xca882
cmpl $0x0, 0x1c(%rsp)
jge 0xca8b1
cmpq $0x0, 0x30(%rsp)
je 0xca895
movq 0x30(%rsp), %rax
movl $0xfffffffe, (%rax)     # imm = 0xFFFFFFFE
cmpq $0x0, 0x8(%rsp)
je 0xca8ac
movq 0x8(%rsp), %rax
movl $0xfffffffe, 0x13e8(%rax) # imm = 0xFFFFFFFE
jmp 0xcaacc
movq 0x8(%rsp), %rax
cmpb $0x0, 0x1394(%rax)
jne 0xca8ee
cmpq $0x0, 0x30(%rsp)
je 0xca8d2
movq 0x30(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
cmpq $0x0, 0x8(%rsp)
je 0xca8e9
movq 0x8(%rsp), %rax
movl $0xffffffff, 0x13e8(%rax) # imm = 0xFFFFFFFF
jmp 0xcaacc
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xca92f
cmpq $0x0, 0x30(%rsp)
je 0xca913
movq 0x30(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, 0x8(%rsp)
je 0xca92a
movq 0x8(%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
jmp 0xcaacc
cmpl $0x0, 0x1c(%rsp)
jne 0xca965
cmpq $0x0, 0x30(%rsp)
je 0xca949
movq 0x30(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca960
movq 0x8(%rsp), %rax
movl $0x0, 0x13e8(%rax)
jmp 0xcaacc
movl 0x1c(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x13a0(%rax)
movq 0x20(%rsp), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x1398(%rax)
movq 0x8(%rsp), %rax
movl $0x1388, 0x13b8(%rax)   # imm = 0x1388
movq 0x8(%rsp), %rcx
addq $0x8, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x13b0(%rax)
movq 0x8(%rsp), %rdi
addq $0x1398, %rdi           # imm = 0x1398
xorl %esi, %esi
callq 0xc8040
movl %eax, 0x10(%rsp)
cmpl $0x1, 0x10(%rsp)
je 0xca9f6
cmpq $0x0, 0x30(%rsp)
je 0xca9da
movl 0x10(%rsp), %ecx
movq 0x30(%rsp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xca9f1
movl 0x10(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x13e8(%rax)
jmp 0xcaacc
movq 0x8(%rsp), %rax
cmpl $0x1388, 0x13b8(%rax)   # imm = 0x1388
jae 0xcaa8d
movq 0x8(%rsp), %rcx
movl $0x1388, %eax           # imm = 0x1388
subl 0x13b8(%rcx), %eax
movl %eax, 0x18(%rsp)
movq 0x8(%rsp), %rdi
addq $0x8, %rdi
movslq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rax
movq (%rax), %rcx
movl $0x1, %esi
callq 0xbc70
movl %eax, 0x14(%rsp)
movl 0x18(%rsp), %eax
cmpl 0x14(%rsp), %eax
jne 0xcaa5f
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0xbbf0
cmpl $0x0, %eax
je 0xcaa8b
cmpq $0x0, 0x30(%rsp)
je 0xcaa72
movq 0x30(%rsp), %rax
movl $0xfffffffa, (%rax)     # imm = 0xFFFFFFFA
cmpq $0x0, 0x8(%rsp)
je 0xcaa89
movq 0x8(%rsp), %rax
movl $0xfffffffa, 0x13e8(%rax) # imm = 0xFFFFFFFA
jmp 0xcaacc
jmp 0xcaa8d
movq 0x8(%rsp), %rax
cmpl $0x0, 0x13a0(%rax)
jne 0xcaac7
cmpq $0x0, 0x30(%rsp)
je 0xcaaae
movq 0x30(%rsp), %rax
movl $0x0, (%rax)
cmpq $0x0, 0x8(%rsp)
je 0xcaac5
movq 0x8(%rsp), %rax
movl $0x0, 0x13e8(%rax)
jmp 0xcaacc
jmp 0xca985
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)