// File: /workspace/github_cpp_makefile_star2_O3/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 0x1e362(%rip), %r15     # 0xb1ed0
leaq 0x1e15b(%rip), %r12     # 0xb1cd0
movl 0xa4(%r14), %ecx
cmpl $0x102, %ecx            # imm = 0x102
jae 0x93bcf
testl %ebx, %ebx
sete %bpl
movq %r14, %rdi
callq 0x94ab7
movl 0xa4(%r14), %ecx
cmpl $0x102, %ecx            # imm = 0x102
setb %al
testb %al, %bpl
jne 0x93e2d
testl %ecx, %ecx
je 0x93e31
movl $0x0, 0x90(%r14)
movl 0x9c(%r14), %eax
cmpl $0x3, %ecx
jae 0x93be1
jmp 0x93c8f
movl $0x0, 0x90(%r14)
movl 0x9c(%r14), %eax
testl %eax, %eax
je 0x93c8f
movq 0x50(%r14), %rsi
movl %eax, %edx
movb -0x1(%rsi,%rdx), %dil
cmpb (%rsi,%rdx), %dil
jne 0x93c8f
addq %rdx, %rsi
cmpb 0x1(%rsi), %dil
jne 0x93c8f
cmpb 0x2(%rsi), %dil
jne 0x93c8f
leaq 0x102(%rsi), %rdx
xorl %r8d, %r8d
cmpb 0x3(%rsi,%r8), %dil
jne 0x93d49
cmpb 0x4(%rsi,%r8), %dil
jne 0x93d52
cmpb 0x5(%rsi,%r8), %dil
jne 0x93d5b
cmpb 0x6(%rsi,%r8), %dil
jne 0x93d64
cmpb 0x7(%rsi,%r8), %dil
jne 0x93d6d
cmpb 0x8(%rsi,%r8), %dil
jne 0x93d76
cmpb 0x9(%rsi,%r8), %dil
jne 0x93d7f
leaq 0x2(%r8), %r10
leaq 0x8(%r8), %r9
cmpq $0xf9, %r10
ja 0x93c83
cmpb 0xa(%rsi,%r8), %dil
movq %r9, %r8
je 0x93c1b
addq %r9, %rsi
addq $0x2, %rsi
jmp 0x93d86
movl 0x16fc(%r14), %ecx
movq 0x50(%r14), %rdx
movl %eax, %eax
movzbl (%rdx,%rax), %eax
movq 0x1700(%r14), %rdx
movl %ecx, %esi
movw $0x0, (%rdx,%rsi,2)
movq 0x16f0(%r14), %rdx
incl %ecx
movl %ecx, 0x16fc(%r14)
movb %al, (%rdx,%rsi)
incw 0xc4(%r14,%rax,4)
movl 0x16fc(%r14), %ecx
movl 0x16f8(%r14), %edx
decl %edx
decl 0xa4(%r14)
movl 0x9c(%r14), %eax
incl %eax
movl %eax, 0x9c(%r14)
cmpl %edx, %ecx
jne 0x93b75
movq 0x88(%r14), %rcx
testq %rcx, %rcx
js 0x93d0e
movl %ecx, %esi
addq 0x50(%r14), %rsi
jmp 0x93d10
xorl %esi, %esi
movl %eax, %edx
subq %rcx, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x97fbc
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9399f
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
jne 0x93b75
jmp 0x93e9c
addq %r8, %rsi
addq $0x3, %rsi
jmp 0x93d86
addq %r8, %rsi
addq $0x4, %rsi
jmp 0x93d86
addq %r8, %rsi
addq $0x5, %rsi
jmp 0x93d86
addq %r8, %rsi
addq $0x6, %rsi
jmp 0x93d86
addq %r8, %rsi
addq $0x7, %rsi
jmp 0x93d86
addq %r8, %rsi
addq $0x8, %rsi
jmp 0x93d86
addq %r8, %rsi
addq $0x9, %rsi
subl %edx, %esi
addl $0x102, %esi            # imm = 0x102
cmpl %ecx, %esi
cmovael %ecx, %esi
movl %esi, 0x90(%r14)
movl 0x16fc(%r14), %ecx
cmpl $0x3, %esi
jb 0x93c96
addb $-0x3, %sil
movq 0x1700(%r14), %rax
movw $0x1, (%rax,%rcx,2)
movq 0x16f0(%r14), %rax
movl %ecx, %edx
incl %edx
movl %edx, 0x16fc(%r14)
movb %sil, (%rax,%rcx)
movzbl %sil, %eax
movzbl (%r15,%rax), %eax
incw 0x4c8(%r14,%rax,4)
movzbl (%r12), %eax
incw 0x9b8(%r14,%rax,4)
movl 0x16fc(%r14), %ecx
movl 0x16f8(%r14), %edx
movl 0x90(%r14), %eax
subl %eax, 0xa4(%r14)
addl 0x9c(%r14), %eax
decl %edx
movl %eax, 0x9c(%r14)
movl $0x0, 0x90(%r14)
jmp 0x93cf2
xorl %ebp, %ebp
jmp 0x93e9c
movq 0x88(%r14), %rax
testq %rax, %rax
js 0x93e45
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x93e47
xorl %esi, %esi
movl 0x9c(%r14), %edx
subq %rax, %rdx
xorl %ecx, %ecx
cmpl $0x4, %ebx
sete %cl
movq %r14, %rdi
callq 0x97fbc
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9399f
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x93e91
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x93e9c
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