// File: /workspace/github_c_makefile_star2_O1/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:
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
testq %rdi, %rdi
je 0x97fdc
pushq %rbx
movq 0x30(%rdi), %rbx
testq %rbx, %rbx
je 0x97fdb
movq (%rbx), %rcx
cmpq %rdi, %rcx
jne 0x97fdb
movl 0x8(%rbx), %edx
cmpl $0x2, %edx
jne 0x97eff
cmpl $0x1, %esi
je 0x97eed
movl $0x4, %edx
cmpl $0x2, %esi
je 0x97ef2
jmp 0x97fc5
movl $0x3, %edx
movl 0x8(%rdi), %r8d
movl %r8d, 0x10(%rbx)
movl %edx, 0x8(%rbx)
jmp 0x97ed4
cmpl $0x1, %edx
je 0x97fba
cmpl $0x3, %edx
je 0x97f73
cmpl $0x4, %edx
jne 0x97fc1
cmpl $0x2, %esi
jne 0x97fba
movl 0x10(%rbx), %eax
cmpl 0x8(%rcx), %eax
jne 0x97fba
callq 0x97fdd
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %cl, %cl
je 0x97fdb
movl $0x3, %eax
cmpl $0x0, 0x10(%rbx)
jne 0x97fdb
cmpl $0xff, 0x5c(%rbx)
ja 0x97f5d
cmpl $0x0, 0x60(%rbx)
jg 0x97fdb
movl 0x78(%rbx), %ecx
cmpl 0x74(%rbx), %ecx
jl 0x97fdb
movl $0x1, 0x8(%rbx)
movl $0x4, %eax
jmp 0x97fdb
cmpl $0x1, %esi
jne 0x97fba
movl 0x10(%rbx), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl 0x8(%rcx), %edx
jne 0x97fdb
callq 0x97fdd
movl $0x2, %eax
cmpl $0x0, 0x10(%rbx)
jne 0x97fdb
cmpl $0xff, 0x5c(%rbx)
ja 0x97fa4
cmpl $0x0, 0x60(%rbx)
jg 0x97fdb
movl 0x78(%rbx), %ecx
cmpl 0x74(%rbx), %ecx
jl 0x97fdb
movl $0x2, 0x8(%rbx)
movl $0x1, %eax
jmp 0x97fdb
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x97fdb
xorl %eax, %eax
jmp 0x97fdb
testl %esi, %esi
jne 0x97fdb
callq 0x97fdd
xorl %ecx, %ecx
testb %al, %al
setne %cl
leal (%rcx,%rcx,2), %eax
addl $-0x2, %eax
popq %rbx
retq