// File: /workspace/github_cpp_makefile_star2_O3/sisong[P]ApkDiffPatch/zlib1.3.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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
xorl %r15d, %r15d
leaq 0x1a442(%rip), %r12     # 0x662e0
leaq 0x1a23b(%rip), %r13     # 0x660e0
movl 0xb4(%rbx), %ecx
cmpl $0x103, %ecx            # imm = 0x103
jae 0x4befb
testl %ebp, %ebp
sete %r14b
movq %rbx, %rdi
callq 0x4a532
movl 0xb4(%rbx), %ecx
cmpl $0x103, %ecx            # imm = 0x103
setb %al
testb %al, %r14b
jne 0x4c192
testl %ecx, %ecx
je 0x4c19a
movl $0x0, 0xa0(%rbx)
movl 0xac(%rbx), %eax
cmpl $0x3, %ecx
jae 0x4bf0b
jmp 0x4bfb9
movl $0x0, 0xa0(%rbx)
movl 0xac(%rbx), %eax
testl %eax, %eax
je 0x4bfb9
movq 0x60(%rbx), %rsi
movl %eax, %edx
movb -0x1(%rsi,%rdx), %dil
cmpb (%rsi,%rdx), %dil
jne 0x4bfb9
addq %rdx, %rsi
cmpb 0x1(%rsi), %dil
jne 0x4bfb9
cmpb 0x2(%rsi), %dil
jne 0x4bfb9
leaq 0x102(%rsi), %rdx
xorl %r8d, %r8d
cmpb 0x3(%rsi,%r8), %dil
jne 0x4c08f
cmpb 0x4(%rsi,%r8), %dil
jne 0x4c098
cmpb 0x5(%rsi,%r8), %dil
jne 0x4c0a1
cmpb 0x6(%rsi,%r8), %dil
jne 0x4c0aa
cmpb 0x7(%rsi,%r8), %dil
jne 0x4c0b3
cmpb 0x8(%rsi,%r8), %dil
jne 0x4c0bc
cmpb 0x9(%rsi,%r8), %dil
jne 0x4c0c5
leaq 0x2(%r8), %r10
leaq 0x8(%r8), %r9
cmpq $0xf9, %r10
ja 0x4bfad
cmpb 0xa(%rsi,%r8), %dil
movq %r9, %r8
je 0x4bf45
addq %r9, %rsi
addq $0x2, %rsi
jmp 0x4c0cc
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 0x4bea5
movq 0x98(%rbx), %rcx
testq %rcx, %rcx
js 0x4c054
movl %ecx, %esi
addq 0x60(%rbx), %rsi
jmp 0x4c056
xorl %esi, %esi
movl %eax, %edx
subq %rcx, %rdx
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x51617
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4b800
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x4bea5
jmp 0x4c25a
addq %r8, %rsi
addq $0x3, %rsi
jmp 0x4c0cc
addq %r8, %rsi
addq $0x4, %rsi
jmp 0x4c0cc
addq %r8, %rsi
addq $0x5, %rsi
jmp 0x4c0cc
addq %r8, %rsi
addq $0x6, %rsi
jmp 0x4c0cc
addq %r8, %rsi
addq $0x7, %rsi
jmp 0x4c0cc
addq %r8, %rsi
addq $0x8, %rsi
jmp 0x4c0cc
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 0x4bfbf
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 (%r12,%rax), %eax
incw 0x4d8(%rbx,%rax,4)
movzbl (%r13), %eax
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 0x4bea5
jmp 0x4c040
xorl %r14d, %r14d
jmp 0x4c25a
movl $0x0, 0x172c(%rbx)
cmpl $0x4, %ebp
jne 0x4c1bd
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x4c1e1
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x4c1e3
cmpl $0x0, 0x170c(%rbx)
je 0x4c254
movq 0x98(%rbx), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x4c221
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x4c223
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x51617
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4b800
movq (%rbx), %rax
cmpl $0x1, 0x20(%rax)
movl $0x3, %r14d
sbbl $0x0, %r14d
jmp 0x4c25a
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x51617
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4b800
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x4c25a
movl $0x1, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq