// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/zlib-1.3.0.1/deflate.c
// Function: deflate_rle
local block_state deflate_rle(deflate_state *s, int flush) {
    int bflush;             /* set if current block must be flushed */
    uInt prev;              /* byte at distance one to match */
    Bytef *scan, *strend;   /* scan goes up to strend for length of run */

    for (;;) {
        /* Make sure that we always have enough lookahead, except
         * at the end of the input file. We need MAX_MATCH bytes
         * for the longest run, plus one for the unrolled loop.
         */
        if (s->lookahead <= MAX_MATCH) {
            fill_window(s);
            if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
                return need_more;
            }
            if (s->lookahead == 0) break; /* flush the current block */
        }

        /* See how many times the previous byte repeats */
        s->match_length = 0;
        if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
            scan = s->window + s->strstart - 1;
            prev = *scan;
            if (prev == *++scan && prev == *++scan && prev == *++scan) {
                strend = s->window + s->strstart + MAX_MATCH;
                do {
                } while (prev == *++scan && prev == *++scan &&
                         prev == *++scan && prev == *++scan &&
                         prev == *++scan && prev == *++scan &&
                         prev == *++scan && prev == *++scan &&
                         scan < strend);
                s->match_length = MAX_MATCH - (uInt)(strend - scan);
                if (s->match_length > s->lookahead)
                    s->match_length = s->lookahead;
            }
            Assert(scan <= s->window + (uInt)(s->window_size - 1),
                   "wild scan");
        }

        /* Emit match if have run of MIN_MATCH or longer, else emit literal */
        if (s->match_length >= MIN_MATCH) {
            check_match(s, s->strstart, s->strstart - 1, s->match_length);

            _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);

            s->lookahead -= s->match_length;
            s->strstart += s->match_length;
            s->match_length = 0;
        } else {
            /* No match, output a literal byte */
            Tracevv((stderr,"%c", s->window[s->strstart]));
            _tr_tally_lit(s, s->window[s->strstart], bflush);
            s->lookahead--;
            s->strstart++;
        }
        if (bflush) FLUSH_BLOCK(s, 0);
    }
    s->insert = 0;
    if (flush == Z_FINISH) {
        FLUSH_BLOCK(s, 1);
        return finish_done;
    }
    if (s->sym_next)
        FLUSH_BLOCK(s, 0);
    return block_done;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x5a363(%rip), %r12     # 0xf8210
cmpl $0x102, 0xb4(%rbx)      # imm = 0x102
ja 0x9dee6
testl %ebp, %ebp
sete %r14b
movq %rbx, %rdi
callq 0x9c512
movl 0xb4(%rbx), %eax
cmpl $0x103, %eax            # imm = 0x103
setb %cl
testb %cl, %r14b
jne 0x9e169
testl %eax, %eax
je 0x9e171
movl $0x0, 0xa0(%rbx)
movl 0xb4(%rbx), %eax
cmpl $0x3, %eax
jb 0x9dfe6
movl 0xac(%rbx), %ecx
testq %rcx, %rcx
je 0x9dfe6
movq 0x60(%rbx), %rdx
movb -0x1(%rdx,%rcx), %sil
cmpb (%rdx,%rcx), %sil
jne 0x9dfe6
addq %rcx, %rdx
cmpb 0x1(%rdx), %sil
jne 0x9dfe6
cmpb 0x2(%rdx), %sil
jne 0x9dfe6
leaq 0x102(%rdx), %rcx
xorl %edi, %edi
cmpb 0x3(%rdx,%rdi), %sil
jne 0x9df96
cmpb 0x4(%rdx,%rdi), %sil
jne 0x9df9f
cmpb 0x5(%rdx,%rdi), %sil
jne 0x9dfa8
cmpb 0x6(%rdx,%rdi), %sil
jne 0x9dfb1
cmpb 0x7(%rdx,%rdi), %sil
jne 0x9dfba
cmpb 0x8(%rdx,%rdi), %sil
jne 0x9dfc3
cmpb 0x9(%rdx,%rdi), %sil
jne 0x9dfcc
leaq 0x2(%rdi), %r9
leaq 0x8(%rdi), %r8
cmpq $0xf9, %r9
ja 0x9df8d
cmpb 0xa(%rdx,%rdi), %sil
movq %r8, %rdi
je 0x9df41
addq %r8, %rdx
addq $0x2, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x3, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x4, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x5, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x6, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x7, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x8, %rdx
jmp 0x9dfd3
addq %rdi, %rdx
addq $0x9, %rdx
subl %ecx, %edx
addl $0x102, %edx            # imm = 0x102
cmpl %eax, %edx
cmovael %eax, %edx
movl %edx, 0xa0(%rbx)
movl 0xa0(%rbx), %eax
cmpl $0x3, %eax
jb 0x9e090
addb $-0x3, %al
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb $0x1, (%rcx,%rdx)
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb $0x0, (%rcx,%rdx)
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb %al, (%rcx,%rdx)
movzbl %al, %eax
movzbl (%rax,%r12), %eax
incw 0x4d8(%rbx,%rax,4)
movzbl 0x59fb5(%rip), %eax     # 0xf8010
incw 0x9c8(%rbx,%rax,4)
movl 0x170c(%rbx), %eax
cmpl 0x1710(%rbx), %eax
sete %al
movl 0xa0(%rbx), %ecx
subl %ecx, 0xb4(%rbx)
addl %ecx, 0xac(%rbx)
movl $0x0, 0xa0(%rbx)
jmp 0x9e10e
movq 0x60(%rbx), %rax
movl 0xac(%rbx), %ecx
movzbl (%rax,%rcx), %eax
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb %r15b, (%rcx,%rdx)
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb %r15b, (%rcx,%rdx)
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb %al, (%rcx,%rdx)
incw 0xd4(%rbx,%rax,4)
movl 0x170c(%rbx), %eax
cmpl 0x1710(%rbx), %eax
sete %al
decl 0xb4(%rbx)
incl 0xac(%rbx)
testb %al, %al
je 0x9dead
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x9e12a
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x9e12c
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9f838
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x9d803
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x9dead
jmp 0x9e231
xorl %r14d, %r14d
jmp 0x9e231
movl $0x0, 0x172c(%rbx)
cmpl $0x4, %ebp
jne 0x9e194
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x9e1b8
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x9e1ba
cmpl $0x0, 0x170c(%rbx)
je 0x9e22b
movq 0x98(%rbx), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x9e1f8
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x9e1fa
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x9f838
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x9d803
movq (%rbx), %rax
cmpl $0x1, 0x20(%rax)
movl $0x3, %r14d
sbbl $0x0, %r14d
jmp 0x9e231
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9f838
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x9d803
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x9e231
movl $0x1, %r14d
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq