// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rbx
leaq 0x80(%rdi), %rax
movq %rax, (%rsp)
xorl %r12d, %r12d
leaq 0xba5f6(%rip), %r15     # 0x151b50
xorl %ebp, %ebp
movl 0xc(%rbx), %eax
cmpl $0x2, %eax
je 0x975ce
cmpl $0x1, %eax
jne 0x9755f
movq (%rbx), %rdx
cmpl $0x0, 0x20(%rdx)
setne %sil
movl 0x78(%rbx), %eax
movl 0x74(%rbx), %ecx
cmpl %ecx, %eax
setl %dil
andb %sil, %dil
cmpb $0x1, %dil
jne 0x975d6
movq 0x18(%rdx), %rdx
movq 0x50(%rbx), %rcx
cltq
movb (%rcx,%rax), %al
movb %al, (%rdx)
movl 0x78(%rbx), %eax
incl %eax
movl %eax, 0x78(%rbx)
movq (%rbx), %rcx
movl 0x20(%rcx), %esi
decl %esi
movl %esi, 0x20(%rcx)
movq 0x18(%rcx), %rdx
incq %rdx
movq %rdx, 0x18(%rcx)
incl 0x24(%rcx)
jne 0x975be
incl 0x28(%rcx)
movl 0x74(%rbx), %ecx
movb $0x1, %r13b
testl %esi, %esi
je 0x975d9
cmpl %ecx, %eax
jl 0x9758d
jmp 0x975d9
movl %r12d, %r13d
jmp 0x97664
xorl %r13d, %r13d
orb %r12b, %r13b
cmpl %ecx, %eax
jl 0x97882
movl 0x8(%rbx), %r14d
cmpl $0x4, %r14d
jne 0x9760b
cmpl $0x0, 0x10(%rbx)
jne 0x9760b
cmpl $0xff, 0x5c(%rbx)
ja 0x97882
cmpl $0x0, 0x60(%rbx)
jle 0x97882
movl $0x0, 0x6c(%rbx)
movq $0x0, 0x74(%rbx)
movl $0xffffffff, 0x288(%rbx) # imm = 0xFFFFFFFF
movl $0x100, %edx            # imm = 0x100
movq (%rsp), %rdi
xorl %esi, %esi
callq 0xb2f0
incl 0x294(%rbx)
movl $0x2, 0xc(%rbx)
cmpl $0x3, %r14d
jne 0x97668
cmpl $0x0, 0x10(%rbx)
jne 0x97664
cmpl $0xff, 0x5c(%rbx)
ja 0x97882
cmpl $0x0, 0x60(%rbx)
jle 0x97882
movl 0x8(%rbx), %r14d
movl %r13d, %r12d
movl 0x6c(%rbx), %eax
movl 0x70(%rbx), %ecx
cmpl $0x2, %r14d
jne 0x9774c
cmpl %ecx, %eax
jge 0x9781f
movq (%rbx), %rdx
cmpl $0x0, 0x8(%rdx)
je 0x9781f
movq (%rdx), %rdi
movl 0x5c(%rbx), %esi
movzbl (%rdi), %r13d
movl 0x60(%rbx), %ecx
cmpl %r13d, %esi
jne 0x976b1
cmpl $0xff, %ecx
je 0x976f9
incl %ecx
movl %ecx, 0x60(%rbx)
jmp 0x9770c
cmpl $0x1, %ecx
jne 0x976f1
movl 0x288(%rbx), %ecx
movl %ecx, %edx
shll $0x8, %edx
shrl $0x18, %ecx
movzbl %sil, %edi
xorl %edi, %ecx
xorl (%r15,%rcx,4), %edx
movl %edx, 0x288(%rbx)
movl %esi, %ecx
movb $0x1, 0x80(%rbx,%rcx)
movq 0x40(%rbx), %rcx
cltq
movb %dil, (%rcx,%rax)
incl 0x6c(%rbx)
movl %r13d, 0x5c(%rbx)
jmp 0x9770c
cmpl $0xff, %esi
ja 0x97701
movq %rbx, %rdi
callq 0x9977c
movl %r13d, 0x5c(%rbx)
movl $0x1, 0x60(%rbx)
movq (%rbx), %rax
movq (%rax), %rdi
incq %rdi
movq %rdi, (%rax)
movl 0x8(%rax), %r8d
decl %r8d
movl %r8d, 0x8(%rax)
incl 0xc(%rax)
jne 0x9772b
incl 0x10(%rax)
movl 0x6c(%rbx), %eax
movl 0x70(%rbx), %ecx
movb $0x1, %dl
cmpl %ecx, %eax
jge 0x97821
movl %r13d, %esi
testl %r8d, %r8d
jne 0x97696
jmp 0x97821
cmpl %ecx, %eax
jge 0x9781f
movq (%rbx), %rsi
cmpl $0x0, 0x8(%rsi)
je 0x9781f
cmpl $0x0, 0x10(%rbx)
je 0x9781f
movq (%rsi), %rcx
movzbl (%rcx), %r13d
movl 0x5c(%rbx), %ecx
movl 0x60(%rbx), %edx
cmpl %r13d, %ecx
jne 0x9778c
cmpl $0xff, %edx
je 0x977d0
incl %edx
movl %edx, 0x60(%rbx)
jmp 0x977e3
cmpl $0x1, %edx
jne 0x977c8
movl 0x288(%rbx), %edx
movl %edx, %esi
shll $0x8, %esi
shrl $0x18, %edx
movzbl %cl, %edi
xorl %edx, %edi
xorl (%r15,%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 0x977e3
cmpl $0xff, %ecx
ja 0x977d8
movq %rbx, %rdi
callq 0x9977c
movl %r13d, 0x5c(%rbx)
movl $0x1, 0x60(%rbx)
movq (%rbx), %rsi
incq (%rsi)
movl 0x8(%rsi), %edi
decl %edi
movl %edi, 0x8(%rsi)
incl 0xc(%rsi)
jne 0x977f9
incl 0x10(%rsi)
movl 0x10(%rbx), %r8d
movl 0x6c(%rbx), %eax
decl %r8d
movl %r8d, 0x10(%rbx)
movl 0x70(%rbx), %ecx
movb $0x1, %dl
cmpl %ecx, %eax
jge 0x97821
testl %edi, %edi
je 0x97821
testl %r8d, %r8d
jne 0x9776b
jmp 0x97821
xorl %edx, %edx
orb %dl, %bpl
movl 0x8(%rbx), %edx
cmpl $0x2, %edx
je 0x97832
cmpl $0x0, 0x10(%rbx)
je 0x97849
cmpl %ecx, %eax
jge 0x97845
movq (%rbx), %rax
cmpl $0x0, 0x8(%rax)
jne 0x9755c
jmp 0x97885
xorl %eax, %eax
jmp 0x9786b
cmpl $0xff, 0x5c(%rbx)
ja 0x9785d
movq %rbx, %rdi
callq 0x9977c
movl 0x8(%rbx), %edx
movq $0x100, 0x5c(%rbx)      # imm = 0x100
cmpl $0x4, %edx
sete %al
movzbl %al, %esi
movq %rbx, %rdi
callq 0xb1e04
movl $0x1, 0xc(%rbx)
jmp 0x9755c
movl %r13d, %r12d
orb %bpl, %r12b
setne %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq