// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/zlib1.3.1/deflate.c
// Function: deflate_slow
local block_state deflate_slow(deflate_state *s, int flush) {
    IPos hash_head;          /* head of hash chain */
    int bflush;              /* set if current block must be flushed */

    /* Process the input block. */
    for (;;) {
        /* Make sure that we always have enough lookahead, except
         * at the end of the input file. We need MAX_MATCH bytes
         * for the next match, plus MIN_MATCH bytes to insert the
         * string following the next match.
         */
        if (s->lookahead < MIN_LOOKAHEAD) {
            fill_window(s);
            if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
                return need_more;
            }
            if (s->lookahead == 0) break; /* flush the current block */
        }

        /* Insert the string window[strstart .. strstart + 2] in the
         * dictionary, and set hash_head to the head of the hash chain:
         */
        hash_head = NIL;
        if (s->lookahead >= MIN_MATCH) {
            INSERT_STRING(s, s->strstart, hash_head);
        }

        /* Find the longest match, discarding those <= prev_length.
         */
        s->prev_length = s->match_length, s->prev_match = s->match_start;
        s->match_length = MIN_MATCH-1;

        if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
            s->strstart - hash_head <= MAX_DIST(s)) {
            /* To simplify the code, we prevent matches with the string
             * of window index 0 (in particular we have to avoid a match
             * of the string with itself at the start of the input file).
             */
            s->match_length = longest_match (s, hash_head);
            /* longest_match() sets match_start */

            if (s->match_length <= 5 && (s->strategy == Z_FILTERED
#if TOO_FAR <= 32767
                || (s->match_length == MIN_MATCH &&
                    s->strstart - s->match_start > TOO_FAR)
#endif
                )) {

                /* If prev_match is also MIN_MATCH, match_start is garbage
                 * but we will ignore the current match anyway.
                 */
                s->match_length = MIN_MATCH-1;
            }
        }
        /* If there was a match at the previous step and the current
         * match is not better, output the previous match:
         */
        if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
            uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
            /* Do not insert strings in hash table beyond this. */

            check_match(s, s->strstart - 1, s->prev_match, s->prev_length);

            _tr_tally_dist(s, s->strstart - 1 - s->prev_match,
                           s->prev_length - MIN_MATCH, bflush);

            /* Insert in hash table all strings up to the end of the match.
             * strstart - 1 and strstart are already inserted. If there is not
             * enough lookahead, the last two strings are not inserted in
             * the hash table.
             */
            s->lookahead -= s->prev_length - 1;
            s->prev_length -= 2;
            do {
                if (++s->strstart <= max_insert) {
                    INSERT_STRING(s, s->strstart, hash_head);
                }
            } while (--s->prev_length != 0);
            s->match_available = 0;
            s->match_length = MIN_MATCH-1;
            s->strstart++;

            if (bflush) FLUSH_BLOCK(s, 0);

        } else if (s->match_available) {
            /* If there was no match at the previous position, output a
             * single literal. If there was a match but the current match
             * is longer, truncate the previous match to a single literal.
             */
            Tracevv((stderr,"%c", s->window[s->strstart - 1]));
            _tr_tally_lit(s, s->window[s->strstart - 1], bflush);
            if (bflush) {
                FLUSH_BLOCK_ONLY(s, 0);
            }
            s->strstart++;
            s->lookahead--;
            if (s->strm->avail_out == 0) return need_more;
        } else {
            /* There is no previous match to compare with, wait for
             * the next step to decide.
             */
            s->match_available = 1;
            s->strstart++;
            s->lookahead--;
        }
    }
    Assert (flush != Z_NO_FLUSH, "no flush?");
    if (s->match_available) {
        Tracevv((stderr,"%c", s->window[s->strstart - 1]));
        _tr_tally_lit(s, s->window[s->strstart - 1], bflush);
        s->match_available = 0;
    }
    s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
    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, %r12d
movq %rdi, %rbx
movl $0x100, %r13d           # imm = 0x100
xorl %r15d, %r15d
cmpl $0x105, 0xb4(%rbx)      # imm = 0x105
ja 0x4d58e
testl %r12d, %r12d
sete %r14b
movq %rbx, %rdi
callq 0x4b18e
movl 0xb4(%rbx), %eax
cmpl $0x106, %eax            # imm = 0x106
setb %cl
testb %cl, %r14b
jne 0x4d947
testl %eax, %eax
je 0x4d94f
xorl %esi, %esi
cmpl $0x3, 0xb4(%rbx)
jb 0x4d5e2
movl 0x80(%rbx), %eax
movb 0x90(%rbx), %cl
shll %cl, %eax
movl 0xac(%rbx), %ecx
leal 0x2(%rcx), %edx
movq 0x60(%rbx), %rsi
movzbl (%rsi,%rdx), %edx
xorl %eax, %edx
andl 0x8c(%rbx), %edx
movq 0x70(%rbx), %rax
movl %edx, 0x80(%rbx)
movq 0x78(%rbx), %rdi
movzwl (%rdi,%rdx,2), %esi
movl 0x58(%rbx), %r8d
andl %ecx, %r8d
movw %si, (%rax,%r8,2)
movw %cx, (%rdi,%rdx,2)
movl 0xa0(%rbx), %eax
movl 0xb0(%rbx), %ecx
movl %eax, 0xb8(%rbx)
movl %ecx, 0xa4(%rbx)
movl $0x2, 0xa0(%rbx)
testl %esi, %esi
je 0x4d666
cmpl 0xc0(%rbx), %eax
jae 0x4d666
movl 0xac(%rbx), %eax
subl %esi, %eax
movl 0x50(%rbx), %ecx
movl $0xfffffefa, %edx       # imm = 0xFFFFFEFA
addl %edx, %ecx
cmpl %ecx, %eax
ja 0x4d666
movq %rbx, %rdi
callq 0x4da99
movl %eax, 0xa0(%rbx)
cmpl $0x5, %eax
ja 0x4d666
cmpl $0x1, 0xc8(%rbx)
jne 0x4d64e
movl $0x2, 0xa0(%rbx)
jmp 0x4d666
cmpl $0x3, %eax
jne 0x4d666
movl 0xac(%rbx), %eax
subl 0xb0(%rbx), %eax
cmpl $0x1001, %eax           # imm = 0x1001
jae 0x4d642
movl 0xb8(%rbx), %ecx
cmpl $0x3, %ecx
jb 0x4d67d
cmpl %ecx, 0xa0(%rbx)
jbe 0x4d737
cmpl $0x0, 0xa8(%rbx)
je 0x4d71c
movq 0x60(%rbx), %rax
movl 0xac(%rbx), %ecx
decl %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
jne 0x4d8f1
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x4d8c7
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x4d8c9
movl $0x1, 0xa8(%rbx)
incl 0xac(%rbx)
decl 0xb4(%rbx)
jmp 0x4d554
movl 0xa4(%rbx), %r8d
movl 0xac(%rbx), %esi
movl 0xb4(%rbx), %eax
addl %esi, %eax
addl $-0x3, %eax
addb $-0x3, %cl
notl %r8d
leal (%rsi,%r8), %edi
decl %edi
movl %esi, %edx
addl %r8d, %edx
movq 0x1700(%rbx), %rsi
movl 0x170c(%rbx), %r8d
leal 0x1(%r8), %r9d
movl %r9d, 0x170c(%rbx)
movb %dl, (%rsi,%r8)
movq 0x1700(%rbx), %rsi
movl 0x170c(%rbx), %ebp
leal 0x1(%rbp), %r8d
movl %r8d, 0x170c(%rbx)
movb %dh, (%rsi,%rbp)
movq 0x1700(%rbx), %rdx
movl 0x170c(%rbx), %esi
leal 0x1(%rsi), %r8d
movl %r8d, 0x170c(%rbx)
movb %cl, (%rdx,%rsi)
movzbl %cl, %ecx
leaq 0x18a73(%rip), %rdx     # 0x66230
movzbl (%rdx,%rcx), %ecx
incw 0x4d8(%rbx,%rcx,4)
movl %edi, %ecx
movl $0xffff, %esi           # imm = 0xFFFF
andl %esi, %ecx
movl %ecx, %edx
shrl $0x7, %edx
addl %r13d, %edx
cmpl %r13d, %ecx
cmovbl %edi, %edx
andl %esi, %edx
leaq 0x18847(%rip), %rcx     # 0x66030
movzbl (%rcx,%rdx), %ecx
incw 0x9c8(%rbx,%rcx,4)
movl 0x170c(%rbx), %esi
movl 0x1710(%rbx), %edi
movl 0xb8(%rbx), %r8d
movl 0xac(%rbx), %edx
movl 0xb4(%rbx), %ecx
subl %r8d, %ecx
incl %ecx
movl %ecx, 0xb4(%rbx)
leal -0x2(%r8), %ecx
movl %ecx, 0xb8(%rbx)
addl $-0x3, %r8d
incl %edx
movl %edx, 0xac(%rbx)
cmpl %eax, %edx
ja 0x4d882
movl 0x80(%rbx), %r9d
movb 0x90(%rbx), %cl
shll %cl, %r9d
leal 0x2(%rdx), %ecx
movq 0x60(%rbx), %r10
movzbl (%r10,%rcx), %ecx
xorl %r9d, %ecx
andl 0x8c(%rbx), %ecx
movq 0x70(%rbx), %r9
movl %ecx, 0x80(%rbx)
movq 0x78(%rbx), %r10
movzwl (%r10,%rcx,2), %r11d
movl 0x58(%rbx), %r14d
andl %edx, %r14d
movw %r11w, (%r9,%r14,2)
movw %dx, (%r10,%rcx,2)
movl %r8d, 0xb8(%rbx)
incl %edx
addl $-0x1, %r8d
jb 0x4d82f
movl $0x0, 0xa8(%rbx)
movl $0x2, 0xa0(%rbx)
movl %edx, 0xac(%rbx)
cmpl %edi, %esi
jne 0x4d554
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x4d90c
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x4d90e
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x51baa
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4c46a
incl 0xac(%rbx)
decl 0xb4(%rbx)
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x4d554
jmp 0x4d947
xorl %esi, %esi
movl %edx, %edx
subq %rax, %rdx
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x51baa
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4c46a
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x4d554
jmp 0x4da87
xorl %r14d, %r14d
jmp 0x4da87
cmpl $0x0, 0xa8(%rbx)
je 0x4d9c9
movq 0x60(%rbx), %rax
movl 0xac(%rbx), %ecx
decl %ecx
movzbl (%rax,%rcx), %eax
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
xorl %esi, %esi
movb %sil, (%rcx,%rdx)
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %edi
movl %edi, 0x170c(%rbx)
movb %sil, (%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 $0x0, 0xa8(%rbx)
movl 0xac(%rbx), %edx
cmpl $0x2, %edx
movl $0x2, %eax
cmovbl %edx, %eax
movl %eax, 0x172c(%rbx)
cmpl $0x4, %r12d
jne 0x4d9fa
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x4da1a
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x4da1c
cmpl $0x0, 0x170c(%rbx)
je 0x4da81
movq 0x98(%rbx), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x4da54
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x4da56
xorl %esi, %esi
subq %rax, %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0x51baa
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4c46a
movq (%rbx), %rax
cmpl $0x1, 0x20(%rax)
movl $0x3, %r14d
sbbl $0x0, %r14d
jmp 0x4da87
xorl %esi, %esi
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x51baa
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x4c46a
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x4da87
movl $0x1, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq