// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/deflate.c
// Function: deflate_fast
local block_state deflate_fast(s, flush)
    deflate_state *s;
    int flush;
{
    IPos hash_head;       /* head of the hash chain */
    int bflush;           /* set if current block must be flushed */

    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.
         * At this point we have always match_length < MIN_MATCH
         */
        if (hash_head != NIL && 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 >= MIN_MATCH) {
            check_match(s, s->strstart, s->match_start, s->match_length);

            _tr_tally_dist(s, s->strstart - s->match_start,
                           s->match_length - MIN_MATCH, bflush);

            s->lookahead -= s->match_length;

            /* Insert new strings in the hash table only if the match length
             * is not too large. This saves time but degrades compression.
             */
#ifndef FASTEST
            if (s->match_length <= s->max_insert_length &&
                s->lookahead >= MIN_MATCH) {
                s->match_length--; /* string at strstart already in table */
                do {
                    s->strstart++;
                    INSERT_STRING(s, s->strstart, hash_head);
                    /* strstart never exceeds WSIZE-MAX_MATCH, so there are
                     * always MIN_MATCH bytes ahead.
                     */
                } while (--s->match_length != 0);
                s->strstart++;
            } else
#endif
            {
                s->strstart += s->match_length;
                s->match_length = 0;
                s->ins_h = s->window[s->strstart];
                UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
#if MIN_MATCH != 3
                Call UPDATE_HASH() MIN_MATCH-3 more times
#endif
                /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
                 * matter since it will be recomputed at next deflate call.
                 */
            }
        } 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 %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl $0xfffffefa, %r15d      # imm = 0xFFFFFEFA
leaq 0x1dcab(%rip), %r12     # 0xb1ed0
movl $0xffff, %r13d          # imm = 0xFFFF
cmpl $0x105, 0xa4(%r14) # imm = 0x105
ja 0x9426b
testl %ebx, %ebx
sete %bpl
movq %r14, %rdi
callq 0x94ab7
movl 0xa4(%r14), %eax
cmpl $0x106, %eax            # imm = 0x106
setb %cl
testb %cl, %bpl
jne 0x9454c
testl %eax, %eax
je 0x94550
cmpl $0x3, %eax
jb 0x942c1
movl 0x70(%r14), %edx
movb 0x80(%r14), %cl
shll %cl, %edx
movl 0x9c(%r14), %eax
leal 0x2(%rax), %ecx
movq 0x50(%r14), %rsi
movq 0x60(%r14), %rdi
movzbl (%rsi,%rcx), %ecx
xorl %edx, %ecx
andl 0x7c(%r14), %ecx
movl %ecx, 0x70(%r14)
movq 0x68(%r14), %rdx
movzwl (%rdx,%rcx,2), %esi
movl 0x4c(%r14), %r8d
andl %eax, %r8d
movw %si, (%rdi,%r8,2)
movw %ax, (%rdx,%rcx,2)
testl %esi, %esi
je 0x942c1
subl %esi, %eax
movl 0x44(%r14), %ecx
addl %r15d, %ecx
cmpl %ecx, %eax
jbe 0x942ca
movl 0x90(%r14), %eax
jmp 0x942d9
movq %r14, %rdi
callq 0x94d15
movl %eax, 0x90(%r14)
cmpl $0x3, %eax
jb 0x9443d
addb $-0x3, %al
movl 0x9c(%r14), %ecx
subl 0xa0(%r14), %ecx
movq 0x1700(%r14), %rdx
movl 0x16fc(%r14), %esi
movw %cx, (%rdx,%rsi,2)
movq 0x16f0(%r14), %rdx
leal 0x1(%rsi), %edi
movl %edi, 0x16fc(%r14)
movb %al, (%rdx,%rsi)
decl %ecx
movzbl %al, %eax
movzbl (%r12,%rax), %eax
incw 0x4c8(%r14,%rax,4)
movl %ecx, %eax
andl %r13d, %eax
movl %eax, %edx
shrl $0x7, %edx
movl $0x100, %esi            # imm = 0x100
addl %esi, %edx
cmpl %esi, %eax
cmovbl %ecx, %edx
andl %r13d, %edx
leaq 0x1d985(%rip), %rax     # 0xb1cd0
movzbl (%rax,%rdx), %eax
incw 0x9b8(%r14,%rax,4)
movl 0x16fc(%r14), %edx
movl 0x16f8(%r14), %esi
decl %esi
movl 0x90(%r14), %edi
movl 0xa4(%r14), %eax
subl %edi, %eax
movl %eax, 0xa4(%r14)
cmpl 0xb0(%r14), %edi
setbe %cl
cmpl $0x3, %eax
setae %al
andb %cl, %al
cmpb $0x1, %al
jne 0x944ae
movl %ebx, %r15d
leal -0x1(%rdi), %eax
movl %eax, 0x90(%r14)
movl 0x80(%r14), %ecx
movq 0x50(%r14), %r8
movl 0x7c(%r14), %r9d
movq 0x68(%r14), %r10
movq 0x60(%r14), %r11
movl 0x4c(%r14), %ebp
movl 0x9c(%r14), %eax
movl 0x70(%r14), %r12d
addl $-0x2, %edi
incl %eax
shll %cl, %r12d
movl %eax, 0x9c(%r14)
leal 0x2(%rax), %ebx
movzbl (%r8,%rbx), %ebx
xorl %r12d, %ebx
andl %r9d, %ebx
movl %ebx, 0x70(%r14)
movzwl (%r10,%rbx,2), %r12d
movl %ebp, %r13d
andl %eax, %r13d
movw %r12w, (%r11,%r13,2)
movw %ax, (%r10,%rbx,2)
movl %edi, 0x90(%r14)
incl %eax
movl %ebx, %r12d
addl $-0x1, %edi
jb 0x943d1
movl %eax, 0x9c(%r14)
cmpl %esi, %edx
movl %r15d, %ebx
movl $0xfffffefa, %r15d      # imm = 0xFFFFFEFA
leaq 0x1daa4(%rip), %r12     # 0xb1ed0
movl $0xffff, %r13d          # imm = 0xFFFF
jne 0x9422b
jmp 0x94500
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 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 0x9422b
jmp 0x94500
movl 0x9c(%r14), %r8d
leal (%r8,%rdi), %eax
movl %eax, 0x9c(%r14)
movl $0x0, 0x90(%r14)
movq 0x50(%r14), %r9
movzbl (%r9,%rax), %r10d
movl %r10d, 0x70(%r14)
movb 0x80(%r14), %cl
shll %cl, %r10d
leal (%r8,%rdi), %ecx
incl %ecx
movzbl (%r9,%rcx), %ecx
xorl %r10d, %ecx
andl 0x7c(%r14), %ecx
movl %ecx, 0x70(%r14)
cmpl %esi, %edx
jne 0x9422b
movq 0x88(%r14), %rcx
testq %rcx, %rcx
js 0x94514
movl %ecx, %esi
addq 0x50(%r14), %rsi
jmp 0x94516
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 0x9422b
jmp 0x945bb
xorl %ebp, %ebp
jmp 0x945bb
movq 0x88(%r14), %rax
testq %rax, %rax
js 0x94564
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x94566
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 0x945b0
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x945bb
xorl %ebp, %ebp
cmpl $0x4, %ebx
sete %bpl
addl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq