// File: /workspace/github_c_makefile_star2_O2/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
pushq $-0x2
popq %rbx
testq %rdi, %rdi
je 0x77e45
movq 0x30(%rdi), %r14
testq %r14, %r14
je 0x77e45
movq (%r14), %rax
cmpq %rdi, %rax
je 0x77e4f
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl 0x8(%r14), %r9d
leaq 0x68b52(%rip), %rcx     # 0xe09ac
pushq $0x3
popq %rdx
pushq $0x4
popq %r8
decl %r9d
cmpl $0x3, %r9d
ja 0x77f50
movslq (%rcx,%r9,4), %r9
addq %rcx, %r9
jmpq *%r9
movl %edx, %r9d
cmpl $0x1, %esi
je 0x77e8c
cmpl $0x2, %esi
jne 0x77f57
movl %r8d, %r9d
movl 0x8(%rdi), %r10d
movl %r10d, 0x10(%r14)
movl %r9d, 0x8(%r14)
jmp 0x77e61
pushq $-0x1
popq %rbx
cmpl $0x2, %esi
jne 0x77e45
movl 0x10(%r14), %ecx
cmpl 0x8(%rax), %ecx
jne 0x77e45
callq 0x77f76
testb %al, %al
je 0x77e45
pushq $0x3
popq %rbx
cmpl $0x0, 0x10(%r14)
jne 0x77e45
cmpl $0xff, 0x5c(%r14)
ja 0x77ed3
cmpl $0x0, 0x60(%r14)
jg 0x77e45
movl 0x78(%r14), %eax
cmpl 0x74(%r14), %eax
jl 0x77e45
movl $0x1, 0x8(%r14)
pushq $0x4
jmp 0x77eef
pushq $-0x1
popq %rbx
jmp 0x77e45
pushq $-0x1
popq %rbx
cmpl $0x1, %esi
jne 0x77e45
movl 0x10(%r14), %ecx
cmpl 0x8(%rax), %ecx
jne 0x77e45
callq 0x77f76
pushq $0x2
popq %rbx
cmpl $0x0, 0x10(%r14)
jne 0x77e45
cmpl $0xff, 0x5c(%r14)
ja 0x77f36
cmpl $0x0, 0x60(%r14)
jg 0x77e45
movl 0x78(%r14), %eax
cmpl 0x74(%r14), %eax
jl 0x77e45
movl $0x2, 0x8(%r14)
pushq $0x1
jmp 0x77eef
xorl %ebx, %ebx
jmp 0x77e45
testl %esi, %esi
jne 0x77e45
callq 0x77f76
xorl %ecx, %ecx
testb %al, %al
setne %cl
leal (%rcx,%rcx,2), %ebx
addl $-0x2, %ebx
jmp 0x77e45