// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x28, %rsp
movq %rdi, 0x18(%rsp)
movl %esi, 0x14(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0xc8062
movl $0xfffffffe, 0x24(%rsp) # imm = 0xFFFFFFFE
jmp 0xc82a7
movq 0x18(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
jne 0xc8085
movl $0xfffffffe, 0x24(%rsp) # imm = 0xFFFFFFFE
jmp 0xc82a7
movq 0x8(%rsp), %rax
movq (%rax), %rax
cmpq 0x18(%rsp), %rax
je 0xc80a1
movl $0xfffffffe, 0x24(%rsp) # imm = 0xFFFFFFFE
jmp 0xc82a7
jmp 0xc80a3
movq 0x8(%rsp), %rax
movl 0x8(%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, (%rsp)
subl $0x3, %eax
ja 0xc829f
movq (%rsp), %rax
leaq 0xad955(%rip), %rcx     # 0x175a1c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0xc82a7
cmpl $0x0, 0x14(%rsp)
jne 0xc8110
movq 0x18(%rsp), %rdi
callq 0xc82b0
movb %al, 0x13(%rsp)
movzbl 0x13(%rsp), %edx
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x24(%rsp)
jmp 0xc82a7
cmpl $0x1, 0x14(%rsp)
jne 0xc8138
movq 0x18(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x8(%rsp), %rax
movl $0x3, 0x8(%rax)
jmp 0xc80a3
cmpl $0x2, 0x14(%rsp)
jne 0xc8160
movq 0x18(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x10(%rax)
movq 0x8(%rsp), %rax
movl $0x4, 0x8(%rax)
jmp 0xc80a3
movl $0xfffffffe, 0x24(%rsp) # imm = 0xFFFFFFFE
jmp 0xc82a7
cmpl $0x1, 0x14(%rsp)
je 0xc8181
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0xc82a7
movq 0x8(%rsp), %rax
movl 0x10(%rax), %eax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
je 0xc81a3
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0xc82a7
movq 0x18(%rsp), %rdi
callq 0xc82b0
movb %al, 0x13(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, 0x10(%rax)
ja 0xc81dc
movq 0x8(%rsp), %rdi
callq 0xc8470
cmpb $0x0, %al
je 0xc81dc
movq 0x8(%rsp), %rax
movl 0x78(%rax), %eax
movq 0x8(%rsp), %rcx
cmpl 0x74(%rcx), %eax
jge 0xc81e9
movl $0x2, 0x24(%rsp)
jmp 0xc82a7
movq 0x8(%rsp), %rax
movl $0x2, 0x8(%rax)
movl $0x1, 0x24(%rsp)
jmp 0xc82a7
cmpl $0x2, 0x14(%rsp)
je 0xc8216
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0xc82a7
movq 0x8(%rsp), %rax
movl 0x10(%rax), %eax
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x8(%rcx), %eax
je 0xc8235
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0xc82a7
movq 0x18(%rsp), %rdi
callq 0xc82b0
movb %al, 0x13(%rsp)
cmpb $0x0, 0x13(%rsp)
jne 0xc8254
movl $0xffffffff, 0x24(%rsp) # imm = 0xFFFFFFFF
jmp 0xc82a7
movq 0x8(%rsp), %rax
cmpl $0x0, 0x10(%rax)
ja 0xc827f
movq 0x8(%rsp), %rdi
callq 0xc8470
cmpb $0x0, %al
je 0xc827f
movq 0x8(%rsp), %rax
movl 0x78(%rax), %eax
movq 0x8(%rsp), %rcx
cmpl 0x74(%rcx), %eax
jge 0xc8289
movl $0x3, 0x24(%rsp)
jmp 0xc82a7
movq 0x8(%rsp), %rax
movl $0x1, 0x8(%rax)
movl $0x4, 0x24(%rsp)
jmp 0xc82a7
movl $0x0, 0x24(%rsp)
movl 0x24(%rsp), %eax
addq $0x28, %rsp
retq