// File: /workspace/github_c_makefile_star2_O3/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 0x5acd1(%rip), %r12     # 0xf8180
movl 0xb4(%rbx), %ecx
cmpl $0x103, %ecx            # imm = 0x103
jae 0x9d505
testl %ebp, %ebp
sete %r14b
movq %rbx, %rdi
callq 0x9bb46
movl 0xb4(%rbx), %ecx
cmpl $0x103, %ecx            # imm = 0x103
setb %al
testb %al, %r14b
jne 0x9d79e
testl %ecx, %ecx
je 0x9d7a6
movl $0x0, 0xa0(%rbx)
movl 0xac(%rbx), %eax
cmpl $0x3, %ecx
jae 0x9d515
jmp 0x9d5c3
movl $0x0, 0xa0(%rbx)
movl 0xac(%rbx), %eax
testl %eax, %eax
je 0x9d5c3
movq 0x60(%rbx), %rsi
movl %eax, %edx
movb -0x1(%rsi,%rdx), %dil
cmpb (%rsi,%rdx), %dil
jne 0x9d5c3
addq %rdx, %rsi
cmpb 0x1(%rsi), %dil
jne 0x9d5c3
cmpb 0x2(%rsi), %dil
jne 0x9d5c3
leaq 0x102(%rsi), %rdx
xorl %r8d, %r8d
cmpb 0x3(%rsi,%r8), %dil
jne 0x9d699
cmpb 0x4(%rsi,%r8), %dil
jne 0x9d6a2
cmpb 0x5(%rsi,%r8), %dil
jne 0x9d6ab
cmpb 0x6(%rsi,%r8), %dil
jne 0x9d6b4
cmpb 0x7(%rsi,%r8), %dil
jne 0x9d6bd
cmpb 0x8(%rsi,%r8), %dil
jne 0x9d6c6
cmpb 0x9(%rsi,%r8), %dil
jne 0x9d6cf
leaq 0x2(%r8), %r10
leaq 0x8(%r8), %r9
cmpq $0xf9, %r10
ja 0x9d5b7
cmpb 0xa(%rsi,%r8), %dil
movq %r9, %r8
je 0x9d54f
addq %r9, %rsi
addq $0x2, %rsi
jmp 0x9d6d6
movl 0x170c(%rbx), %ecx
movq 0x60(%rbx), %rdx
movl %eax, %eax
movzbl (%rdx,%rax), %eax
movq 0x1700(%rbx), %rdx
leal 0x1(%rcx), %esi
movl %esi, 0x170c(%rbx)
movl %ecx, %ecx
movb %r15b, (%rdx,%rcx)
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), %ecx
decl 0xb4(%rbx)
movl 0xac(%rbx), %eax
incl %eax
cmpl 0x1710(%rbx), %ecx
movl %eax, 0xac(%rbx)
jne 0x9d4af
movq 0x98(%rbx), %rcx
testq %rcx, %rcx
js 0x9d65e
movl %ecx, %esi
addq 0x60(%rbx), %rsi
jmp 0x9d660
xorl %esi, %esi
movl %eax, %edx
subq %rcx, %rdx
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9ee9f
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x9ce14
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x9d4af
jmp 0x9d866
addq %r8, %rsi
addq $0x3, %rsi
jmp 0x9d6d6
addq %r8, %rsi
addq $0x4, %rsi
jmp 0x9d6d6
addq %r8, %rsi
addq $0x5, %rsi
jmp 0x9d6d6
addq %r8, %rsi
addq $0x6, %rsi
jmp 0x9d6d6
addq %r8, %rsi
addq $0x7, %rsi
jmp 0x9d6d6
addq %r8, %rsi
addq $0x8, %rsi
jmp 0x9d6d6
addq %r8, %rsi
addq $0x9, %rsi
subl %edx, %esi
addl $0x102, %esi            # imm = 0x102
cmpl %ecx, %esi
cmovael %ecx, %esi
movl %esi, 0xa0(%rbx)
movl 0x170c(%rbx), %ecx
cmpl $0x3, %esi
jb 0x9d5c9
addb $-0x3, %sil
movq 0x1700(%rbx), %rax
movl %ecx, %edx
incl %edx
movl %edx, 0x170c(%rbx)
movb $0x1, (%rax,%rcx)
movq 0x1700(%rbx), %rax
movl 0x170c(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x170c(%rbx)
movb $0x0, (%rax,%rcx)
movq 0x1700(%rbx), %rax
movl 0x170c(%rbx), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x170c(%rbx)
movb %sil, (%rax,%rcx)
movzbl %sil, %eax
movzbl (%rax,%r12), %eax
incw 0x4d8(%rbx,%rax,4)
movzbl 0x5a823(%rip), %eax     # 0xf7f80
incw 0x9c8(%rbx,%rax,4)
movl 0x170c(%rbx), %ecx
movl 0xa0(%rbx), %eax
subl %eax, 0xb4(%rbx)
addl 0xac(%rbx), %eax
cmpl 0x1710(%rbx), %ecx
movl %eax, 0xac(%rbx)
movl $0x0, 0xa0(%rbx)
jne 0x9d4af
jmp 0x9d64a
xorl %r14d, %r14d
jmp 0x9d866
movl $0x0, 0x172c(%rbx)
cmpl $0x4, %ebp
jne 0x9d7c9
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x9d7ed
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x9d7ef
cmpl $0x0, 0x170c(%rbx)
je 0x9d860
movq 0x98(%rbx), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x9d82d
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x9d82f
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x9ee9f
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x9ce14
movq (%rbx), %rax
cmpl $0x1, 0x20(%rax)
movl $0x3, %r14d
sbbl $0x0, %r14d
jmp 0x9d866
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x9ee9f
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x9ce14
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x9d866
movl $0x1, %r14d
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq