// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/png/deflate.c
// Function: deflate_rle
local block_state deflate_rle(s, flush)
    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 encodable run.
         */
        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 - (int)(strend - scan);
                if (s->match_length > s->lookahead)
                    s->match_length = s->lookahead;
            }
        }

        /* 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);
    }
    FLUSH_BLOCK(s, flush == Z_FINISH);
    return flush == Z_FINISH ? finish_done : block_done;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
leaq 0x1d614(%rip), %r15     # 0xb1e80
leaq 0x1d40d(%rip), %r12     # 0xb1c80
cmpl $0x101, 0xa4(%r14) # imm = 0x101
ja 0x948ae
testl %ebx, %ebx
sete %bpl
movq %r14, %rdi
callq 0x9574c
movl 0xa4(%r14), %eax
cmpl $0x102, %eax            # imm = 0x102
setb %cl
testb %cl, %bpl
jne 0x94af6
testl %eax, %eax
je 0x94afa
movl $0x0, 0x90(%r14)
movl 0xa4(%r14), %eax
cmpl $0x3, %eax
jb 0x949b2
movl 0x9c(%r14), %ecx
testq %rcx, %rcx
je 0x949b2
movq 0x50(%r14), %rdx
movb -0x1(%rdx,%rcx), %sil
cmpb (%rdx,%rcx), %sil
jne 0x949b2
addq %rcx, %rdx
cmpb 0x1(%rdx), %sil
jne 0x949b2
cmpb 0x2(%rdx), %sil
jne 0x949b2
leaq 0x102(%rdx), %rcx
xorl %edi, %edi
cmpb 0x3(%rdx,%rdi), %sil
jne 0x94961
cmpb 0x4(%rdx,%rdi), %sil
jne 0x9496a
cmpb 0x5(%rdx,%rdi), %sil
jne 0x94973
cmpb 0x6(%rdx,%rdi), %sil
jne 0x9497c
cmpb 0x7(%rdx,%rdi), %sil
jne 0x94985
cmpb 0x8(%rdx,%rdi), %sil
jne 0x9498e
cmpb 0x9(%rdx,%rdi), %sil
jne 0x94997
leaq 0x2(%rdi), %r9
leaq 0x8(%rdi), %r8
cmpq $0xf9, %r9
ja 0x94958
cmpb 0xa(%rdx,%rdi), %sil
movq %r8, %rdi
je 0x9490c
addq %r8, %rdx
addq $0x2, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x3, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x4, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x5, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x6, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x7, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x8, %rdx
jmp 0x9499e
addq %rdi, %rdx
addq $0x9, %rdx
subl %ecx, %edx
addl $0x102, %edx            # imm = 0x102
cmpl %eax, %edx
cmovael %eax, %edx
movl %edx, 0x90(%r14)
movl 0x90(%r14), %eax
cmpl $0x3, %eax
jb 0x94a3c
addb $-0x3, %al
movq 0x1700(%r14), %rcx
movl 0x16fc(%r14), %edx
movw $0x1, (%rcx,%rdx,2)
movq 0x16f0(%r14), %rcx
leal 0x1(%rdx), %esi
movl %esi, 0x16fc(%r14)
movb %al, (%rcx,%rdx)
movzbl %al, %eax
movzbl (%r15,%rax), %eax
incw 0x4c8(%r14,%rax,4)
movzbl (%r12), %eax
incw 0x9b8(%r14,%rax,4)
movl 0x16f8(%r14), %eax
decl %eax
cmpl %eax, 0x16fc(%r14)
sete %al
movl 0x90(%r14), %ecx
subl %ecx, 0xa4(%r14)
addl %ecx, 0x9c(%r14)
movl $0x0, 0x90(%r14)
jmp 0x94a9d
movq 0x50(%r14), %rax
movl 0x9c(%r14), %ecx
movzbl (%rax,%rcx), %eax
movq 0x1700(%r14), %rcx
movl 0x16fc(%r14), %edx
movw $0x0, (%rcx,%rdx,2)
movq 0x16f0(%r14), %rcx
leal 0x1(%rdx), %esi
movl %esi, 0x16fc(%r14)
movb %al, (%rcx,%rdx)
incw 0xc4(%r14,%rax,4)
movl 0x16f8(%r14), %eax
decl %eax
cmpl %eax, 0x16fc(%r14)
sete %al
decl 0xa4(%r14)
incl 0x9c(%r14)
testb %al, %al
je 0x94873
movq 0x88(%r14), %rax
testq %rax, %rax
js 0x94ab9
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x94abb
xorl %esi, %esi
movl 0x9c(%r14), %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x988ce
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9469d
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
jne 0x94873
jmp 0x94b65
xorl %ebp, %ebp
jmp 0x94b65
movq 0x88(%r14), %rax
testq %rax, %rax
js 0x94b0e
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x94b10
xorl %esi, %esi
movl 0x9c(%r14), %edx
subq %rax, %rdx
xorl %ecx, %ecx
cmpl $0x4, %ebx
sete %cl
movq %r14, %rdi
callq 0x988ce
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9469d
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x94b5a
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x94b65
xorl %ebp, %ebp
cmpl $0x4, %ebx
sete %bpl
addl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq