// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/zlib-1.3.0.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
pushq $0x2
popq %r15
movl $0xffff, %r13d          # imm = 0xFFFF
cmpl $0x105, 0xb4(%rbx)      # imm = 0x105
ja 0x7e353
testl %r12d, %r12d
sete %r14b
movq %rbx, %rdi
callq 0x7c100
movl 0xb4(%rbx), %eax
cmpl $0x106, %eax            # imm = 0x106
setb %cl
testb %cl, %r14b
jne 0x7e70b
testl %eax, %eax
je 0x7e713
xorl %esi, %esi
cmpl $0x3, %eax
jb 0x7e39c
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), %ecx
movl 0xb0(%rbx), %eax
movl %ecx, 0xb8(%rbx)
movl %eax, 0xa4(%rbx)
movl $0x2, 0xa0(%rbx)
movl %r15d, %eax
testl %esi, %esi
je 0x7e433
cmpl 0xc0(%rbx), %ecx
jae 0x7e42d
movl 0xac(%rbx), %ecx
subl %esi, %ecx
movl 0x50(%rbx), %edx
movl $0xfffffefa, %eax       # imm = 0xFFFFFEFA
addl %eax, %edx
movl %r15d, %eax
cmpl %edx, %ecx
ja 0x7e42d
movq %rbx, %rdi
callq 0x7e852
movl %eax, 0xa0(%rbx)
cmpl $0x5, %eax
ja 0x7e42d
cmpl $0x1, 0xc8(%rbx)
jne 0x7e411
movl $0x2, 0xa0(%rbx)
movl %r15d, %eax
jmp 0x7e42d
cmpl $0x3, %eax
jne 0x7e42d
movl 0xac(%rbx), %ecx
subl 0xb0(%rbx), %ecx
pushq $0x3
popq %rax
cmpl $0x1001, %ecx           # imm = 0x1001
jae 0x7e402
movl 0xb8(%rbx), %ecx
cmpl $0x3, %ecx
jb 0x7e5d8
cmpl %ecx, %eax
ja 0x7e5d8
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 0x62fc6(%rip), %rdx     # 0xe1490
movzbl (%rcx,%rdx), %ecx
incw 0x4d8(%rbx,%rcx,4)
movl %edi, %ecx
andl %r13d, %ecx
shrl $0x7, %ecx
addl $0x100, %ecx            # imm = 0x100
cmpw $0x100, %di             # imm = 0x100
cmovbl %edi, %ecx
andl %r13d, %ecx
leaq 0x62d9a(%rip), %rdx     # 0xe1290
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 0x7e58f
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 0x7e53c
andl $0x0, 0xa8(%rbx)
movl $0x2, 0xa0(%rbx)
movl %edx, 0xac(%rbx)
cmpl %edi, %esi
jne 0x7e312
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x7e68d
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x7e68f
cmpl $0x0, 0xa8(%rbx)
je 0x7e672
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 %edi, %edi
movb %dil, (%rcx,%rdx)
movq 0x1700(%rbx), %rcx
movl 0x170c(%rbx), %edx
leal 0x1(%rdx), %esi
movl %esi, 0x170c(%rbx)
movb %dil, (%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 0x7e6f2
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x7e6c8
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x7e6ca
movl $0x1, 0xa8(%rbx)
incl 0xac(%rbx)
decl 0xb4(%rbx)
jmp 0x7e312
xorl %esi, %esi
movl %edx, %edx
subq %rax, %rdx
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x7ede8
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x7d7cf
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x7e312
jmp 0x7e840
xorl %esi, %esi
movl 0xac(%rbx), %edx
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x7ede8
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x7d7cf
incl 0xac(%rbx)
decl 0xb4(%rbx)
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
jne 0x7e312
xorl %r14d, %r14d
jmp 0x7e840
cmpl $0x0, 0xa8(%rbx)
je 0x7e78a
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)
andl $0x0, 0xa8(%rbx)
movl 0xac(%rbx), %edx
cmpl $0x2, %edx
pushq $0x2
popq %rax
cmovbl %edx, %eax
movl %eax, 0x172c(%rbx)
cmpl $0x4, %r12d
jne 0x7e7b9
movq 0x98(%rbx), %rax
testq %rax, %rax
js 0x7e7d9
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x7e7db
cmpl $0x0, 0x170c(%rbx)
je 0x7e83c
movq 0x98(%rbx), %rax
xorl %r14d, %r14d
testq %rax, %rax
js 0x7e80f
movl %eax, %esi
addq 0x60(%rbx), %rsi
jmp 0x7e811
xorl %esi, %esi
subq %rax, %rdx
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0x7ede8
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x7d7cf
movq (%rbx), %rax
cmpl $0x1, 0x20(%rax)
pushq $0x3
popq %r14
sbbl $0x0, %r14d
jmp 0x7e840
xorl %esi, %esi
subq %rax, %rdx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x7ede8
movl 0xac(%rbx), %eax
movq %rax, 0x98(%rbx)
movq (%rbx), %rdi
callq 0x7d7cf
movq (%rbx), %rax
cmpl $0x0, 0x20(%rax)
je 0x7e840
pushq $0x1
popq %r14
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq