// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/bzip2-1.0.6/bzlib.c
// Function: handle_compress
static
Bool handle_compress ( bz_stream* strm )
{
   Bool progress_in  = False;
   Bool progress_out = False;
   EState* s = strm->state;
   
   while (True) {

      if (s->state == BZ_S_OUTPUT) {
         progress_out |= copy_output_until_stop ( s );
         if (s->state_out_pos < s->numZ) break;
         if (s->mode == BZ_M_FINISHING && 
             s->avail_in_expect == 0 &&
             isempty_RL(s)) break;
         prepare_new_block ( s );
         s->state = BZ_S_INPUT;
         if (s->mode == BZ_M_FLUSHING && 
             s->avail_in_expect == 0 &&
             isempty_RL(s)) break;
      }

      if (s->state == BZ_S_INPUT) {
         progress_in |= copy_input_until_stop ( s );
         if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
            flush_RL ( s );
            BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
            s->state = BZ_S_OUTPUT;
         }
         else
         if (s->nblock >= s->nblockMAX) {
            BZ2_compressBlock ( s, False );
            s->state = BZ_S_OUTPUT;
         }
         else
         if (s->strm->avail_in == 0) {
            break;
         }
      }

   }

   return progress_in || progress_out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x30(%rdi), %rbx
leaq 0x80(%rbx), %r14
xorl %ebp, %ebp
leaq 0xb9b54(%rip), %r12     # 0x151b50
xorl %r15d, %r15d
cmpl $0x1, 0xc(%rbx)
jne 0x980e4
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x98054
movl 0x78(%rbx), %edx
cmpl 0x74(%rbx), %edx
jge 0x98054
movq 0x50(%rbx), %rcx
movslq %edx, %rdx
movb (%rcx,%rdx), %cl
movq 0x18(%rax), %rax
movb %cl, (%rax)
incl 0x78(%rbx)
movq (%rbx), %rax
movl 0x20(%rax), %edx
decl %edx
movl %edx, 0x20(%rax)
incq 0x18(%rax)
incl 0x24(%rax)
jne 0x98044
incl 0x28(%rax)
movb $0x1, %cl
testl %edx, %edx
je 0x98056
movl 0x78(%rbx), %edx
cmpl 0x74(%rbx), %edx
jl 0x9801a
jmp 0x98056
xorl %ecx, %ecx
orb %cl, %bpl
movl 0x78(%rbx), %eax
cmpl 0x74(%rbx), %eax
jl 0x98319
movl 0x8(%rbx), %r13d
cmpl $0x4, %r13d
jne 0x9808c
cmpl $0x0, 0x10(%rbx)
jne 0x9808c
cmpl $0xff, 0x5c(%rbx)
ja 0x98319
cmpl $0x0, 0x60(%rbx)
jle 0x98319
movl $0x0, 0x6c(%rbx)
movq $0x0, 0x74(%rbx)
movl $0xffffffff, 0x288(%rbx) # imm = 0xFFFFFFFF
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0xb2f0
incl 0x294(%rbx)
movl $0x2, 0xc(%rbx)
cmpl $0x3, %r13d
jne 0x980e4
cmpl $0x0, 0x10(%rbx)
jne 0x980e4
cmpl $0xff, 0x5c(%rbx)
ja 0x98319
cmpl $0x0, 0x60(%rbx)
jle 0x98319
cmpl $0x2, 0xc(%rbx)
jne 0x97fff
cmpl $0x2, 0x8(%rbx)
jne 0x981d1
movl 0x6c(%rbx), %eax
cmpl 0x70(%rbx), %eax
jge 0x982b6
movq (%rbx), %rdx
cmpl $0x0, 0x8(%rdx)
je 0x982b6
movq (%rdx), %rcx
movzbl (%rcx), %r13d
movl 0x5c(%rbx), %ecx
movl 0x60(%rbx), %edx
cmpl %r13d, %ecx
jne 0x98132
cmpl $0xff, %edx
je 0x9816e
incl %edx
movl %edx, 0x60(%rbx)
jmp 0x98189
cmpl $0x1, %edx
jne 0x9816e
movl 0x288(%rbx), %edx
movl %edx, %esi
shll $0x8, %esi
shrl $0x18, %edx
movzbl %cl, %edi
xorl %edx, %edi
xorl (%r12,%rdi,4), %esi
movl %esi, 0x288(%rbx)
movb $0x1, 0x80(%rbx,%rcx)
movq 0x40(%rbx), %rdx
cltq
movb %cl, (%rdx,%rax)
incl 0x6c(%rbx)
movl %r13d, 0x5c(%rbx)
jmp 0x98189
cmpl $0xff, %ecx
ja 0x9817e
movq %rbx, %rdi
callq 0x9a1d6
movl %r13d, 0x5c(%rbx)
movl $0x1, 0x60(%rbx)
movq (%rbx), %rax
incq (%rax)
movq 0x8(%rax), %xmm0
paddd 0x5f544(%rip), %xmm0    # 0xf76e0
movq %xmm0, 0x8(%rax)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
testl %ecx, %ecx
jne 0x981b1
incl 0x10(%rax)
movl 0x6c(%rbx), %eax
movb $0x1, %cl
cmpl 0x70(%rbx), %eax
jge 0x982b8
movq (%rbx), %rdx
cmpl $0x0, 0x8(%rdx)
jne 0x98111
jmp 0x982b8
movl 0x6c(%rbx), %eax
cmpl 0x70(%rbx), %eax
jge 0x982b6
movq (%rbx), %rdx
cmpl $0x0, 0x8(%rdx)
je 0x982b6
cmpl $0x0, 0x10(%rbx)
je 0x982b6
movq (%rdx), %rcx
movzbl (%rcx), %r13d
movl 0x5c(%rbx), %ecx
movl 0x60(%rbx), %edx
cmpl %r13d, %ecx
jne 0x98215
cmpl $0xff, %edx
je 0x98251
incl %edx
movl %edx, 0x60(%rbx)
jmp 0x9826c
cmpl $0x1, %edx
jne 0x98251
movl 0x288(%rbx), %edx
movl %edx, %esi
shll $0x8, %esi
shrl $0x18, %edx
movzbl %cl, %edi
xorl %edx, %edi
xorl (%r12,%rdi,4), %esi
movl %esi, 0x288(%rbx)
movb $0x1, 0x80(%rbx,%rcx)
movq 0x40(%rbx), %rdx
cltq
movb %cl, (%rdx,%rax)
incl 0x6c(%rbx)
movl %r13d, 0x5c(%rbx)
jmp 0x9826c
cmpl $0xff, %ecx
ja 0x98261
movq %rbx, %rdi
callq 0x9a1d6
movl %r13d, 0x5c(%rbx)
movl $0x1, 0x60(%rbx)
movq (%rbx), %rax
incq (%rax)
movq 0x8(%rax), %xmm0
paddd 0x5f461(%rip), %xmm0    # 0xf76e0
movq %xmm0, 0x8(%rax)
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
testl %ecx, %ecx
jne 0x98294
incl 0x10(%rax)
decl 0x10(%rbx)
movl 0x6c(%rbx), %eax
movb $0x1, %cl
cmpl 0x70(%rbx), %eax
jge 0x982b8
movq (%rbx), %rdx
cmpl $0x0, 0x8(%rdx)
je 0x982b8
cmpl $0x0, 0x10(%rbx)
jne 0x981f4
jmp 0x982b8
xorl %ecx, %ecx
orb %cl, %r15b
cmpl $0x2, 0x8(%rbx)
je 0x982c7
cmpl $0x0, 0x10(%rbx)
je 0x982e2
movl 0x6c(%rbx), %eax
cmpl 0x70(%rbx), %eax
jge 0x982de
movq (%rbx), %rax
cmpl $0x0, 0x8(%rax)
jne 0x97fff
jmp 0x98319
xorl %eax, %eax
jmp 0x98302
cmpl $0xff, 0x5c(%rbx)
ja 0x982f3
movq %rbx, %rdi
callq 0x9a1d6
movq $0x100, 0x5c(%rbx)      # imm = 0x100
cmpl $0x4, 0x8(%rbx)
sete %al
movzbl %al, %esi
movq %rbx, %rdi
callq 0xb2958
movl $0x1, 0xc(%rbx)
jmp 0x97fff
orb %r15b, %bpl
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq