// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: BZ2_bzCompress
int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
{
   Bool progress;
   EState* s;
   if (strm == NULL) return BZ_PARAM_ERROR;
   s = strm->state;
   if (s == NULL) return BZ_PARAM_ERROR;
   if (s->strm != strm) return BZ_PARAM_ERROR;

   preswitch:
   switch (s->mode) {

      case BZ_M_IDLE:
         return BZ_SEQUENCE_ERROR;

      case BZ_M_RUNNING:
         if (action == BZ_RUN) {
            progress = handle_compress ( strm );
            return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
         } 
         else
	 if (action == BZ_FLUSH) {
            s->avail_in_expect = strm->avail_in;
            s->mode = BZ_M_FLUSHING;
            goto preswitch;
         }
         else
         if (action == BZ_FINISH) {
            s->avail_in_expect = strm->avail_in;
            s->mode = BZ_M_FINISHING;
            goto preswitch;
         }
         else 
            return BZ_PARAM_ERROR;

      case BZ_M_FLUSHING:
         if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
         if (s->avail_in_expect != s->strm->avail_in) 
            return BZ_SEQUENCE_ERROR;
         progress = handle_compress ( strm );
         if (s->avail_in_expect > 0 || !isempty_RL(s) ||
             s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
         s->mode = BZ_M_RUNNING;
         return BZ_RUN_OK;

      case BZ_M_FINISHING:
         if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
         if (s->avail_in_expect != s->strm->avail_in) 
            return BZ_SEQUENCE_ERROR;
         progress = handle_compress ( strm );
         if (!progress) return BZ_SEQUENCE_ERROR;
         if (s->avail_in_expect > 0 || !isempty_RL(s) ||
             s->state_out_pos < s->numZ) return BZ_FINISH_OK;
         s->mode = BZ_M_IDLE;
         return BZ_STREAM_END;
   }
   return BZ_OK; /*--not reached--*/
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x973f5
movq 0x30(%rdi), %r14
testq %r14, %r14
je 0x973f5
movq (%r14), %rax
cmpq %rdi, %rax
je 0x973ff
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl 0x8(%r14), %ecx
xorl %ebx, %ebx
cmpl $0x2, %ecx
jne 0x9742f
movl $0x3, %ecx
cmpl $0x1, %esi
je 0x97422
cmpl $0x2, %esi
jne 0x97510
movl $0x4, %ecx
movl 0x8(%rdi), %edx
movl %edx, 0x10(%r14)
movl %ecx, 0x8(%r14)
jmp 0x97405
cmpl $0x1, %ecx
je 0x9749e
cmpl $0x3, %ecx
je 0x974a8
cmpl $0x4, %ecx
jne 0x973f5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x2, %esi
jne 0x973f5
movl 0x10(%r14), %ecx
cmpl 0x8(%rax), %ecx
jne 0x973f5
movq %r14, %rdi
callq 0x97537
testb %al, %al
je 0x973f5
movl $0x3, %ebx
cmpl $0x0, 0x10(%r14)
jne 0x973f5
cmpl $0xff, 0x5c(%r14)
ja 0x9747e
cmpl $0x0, 0x60(%r14)
jg 0x973f5
movl 0x78(%r14), %eax
cmpl 0x74(%r14), %eax
jl 0x973f5
movl $0x1, 0x8(%r14)
movl $0x4, %ebx
jmp 0x973f5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x973f5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x1, %esi
jne 0x973f5
movl 0x10(%r14), %ecx
cmpl 0x8(%rax), %ecx
jne 0x973f5
movq %r14, %rdi
callq 0x97537
movl $0x2, %ebx
cmpl $0x0, 0x10(%r14)
jne 0x973f5
cmpl $0xff, 0x5c(%r14)
ja 0x974f0
cmpl $0x0, 0x60(%r14)
jg 0x973f5
movl 0x78(%r14), %eax
cmpl 0x74(%r14), %eax
jl 0x973f5
movl $0x2, 0x8(%r14)
movl $0x1, %ebx
jmp 0x973f5
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
testl %esi, %esi
jne 0x973f5
movq %r14, %rdi
callq 0x97537
xorl %ecx, %ecx
testb %al, %al
setne %cl
leal (%rcx,%rcx,2), %ebx
addl $-0x2, %ebx
jmp 0x973f5