// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzBuffToBuffCompress
int BZ_API(BZ2_bzBuffToBuffCompress) 
                         ( char*         dest, 
                           unsigned int* destLen,
                           char*         source, 
                           unsigned int  sourceLen,
                           int           blockSize100k, 
                           int           verbosity, 
                           int           workFactor )
{
   bz_stream strm;
   int ret;

   if (dest == NULL || destLen == NULL || 
       source == NULL ||
       blockSize100k < 1 || blockSize100k > 9 ||
       verbosity < 0 || verbosity > 4 ||
       workFactor < 0 || workFactor > 250) 
      return BZ_PARAM_ERROR;

   if (workFactor == 0) workFactor = 30;
   strm.bzalloc = NULL;
   strm.bzfree = NULL;
   strm.opaque = NULL;
   ret = BZ2_bzCompressInit ( &strm, blockSize100k, 
                              verbosity, workFactor );
   if (ret != BZ_OK) return ret;

   strm.next_in = source;
   strm.next_out = dest;
   strm.avail_in = sourceLen;
   strm.avail_out = *destLen;

   ret = BZ2_bzCompress ( &strm, BZ_FINISH );
   if (ret == BZ_FINISH_OK) goto output_overflow;
   if (ret != BZ_STREAM_END) goto errhandler;

   /* normal termination */
   *destLen -= strm.avail_out;   
   BZ2_bzCompressEnd ( &strm );
   return BZ_OK;

   output_overflow:
   BZ2_bzCompressEnd ( &strm );
   return BZ_OUTBUFF_FULL;

   errhandler:
   BZ2_bzCompressEnd ( &strm );
   return ret;
}

// Assembly:
subq $0x88, %rsp
movl 0x90(%rsp), %eax
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movl %ecx, 0x64(%rsp)
movl %r8d, 0x60(%rsp)
movl %r9d, 0x5c(%rsp)
cmpq $0x0, 0x78(%rsp)
je 0xcb7f6
cmpq $0x0, 0x70(%rsp)
je 0xcb7f6
cmpq $0x0, 0x68(%rsp)
je 0xcb7f6
cmpl $0x1, 0x60(%rsp)
jl 0xcb7f6
cmpl $0x9, 0x60(%rsp)
jg 0xcb7f6
cmpl $0x0, 0x5c(%rsp)
jl 0xcb7f6
cmpl $0x4, 0x5c(%rsp)
jg 0xcb7f6
cmpl $0x0, 0x90(%rsp)
jl 0xcb7f6
cmpl $0xfa, 0x90(%rsp)
jle 0xcb806
movl $0xfffffffe, 0x84(%rsp) # imm = 0xFFFFFFFE
jmp 0xcb908
cmpl $0x0, 0x90(%rsp)
jne 0xcb81b
movl $0x1e, 0x90(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x50(%rsp)
movl 0x60(%rsp), %esi
movl 0x5c(%rsp), %edx
movl 0x90(%rsp), %ecx
leaq 0x8(%rsp), %rdi
callq 0xc7bb0
movl %eax, 0x4(%rsp)
cmpl $0x0, 0x4(%rsp)
je 0xcb86a
movl 0x4(%rsp), %eax
movl %eax, 0x84(%rsp)
jmp 0xcb908
movq 0x68(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x64(%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x70(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x28(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x2, %esi
callq 0xc8040
movl %eax, 0x4(%rsp)
cmpl $0x3, 0x4(%rsp)
jne 0xcb8ad
jmp 0xcb8dc
cmpl $0x4, 0x4(%rsp)
je 0xcb8b6
jmp 0xcb8f3
movl 0x28(%rsp), %edx
movq 0x70(%rsp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
leaq 0x8(%rsp), %rdi
callq 0xc84a0
movl $0x0, 0x84(%rsp)
jmp 0xcb908
leaq 0x8(%rsp), %rdi
callq 0xc84a0
movl $0xfffffff8, 0x84(%rsp) # imm = 0xFFFFFFF8
jmp 0xcb908
leaq 0x8(%rsp), %rdi
callq 0xc84a0
movl 0x4(%rsp), %eax
movl %eax, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopw (%rax,%rax)