// File: tomfunkhouser[P]gaps/pkgs/png/deflate.c
// Function: deflate_huff
local block_state deflate_huff(s, flush)
    deflate_state *s;
    int flush;
{
    int bflush;             /* set if current block must be flushed */

    for (;;) {
        /* Make sure that we have a literal to write. */
        if (s->lookahead == 0) {
            fill_window(s);
            if (s->lookahead == 0) {
                if (flush == Z_NO_FLUSH)
                    return need_more;
                break;      /* flush the current block */
            }
        }

        /* Output a literal byte */
        s->match_length = 0;
        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:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movl %esi, 0x34(%rsp)
movq 0x38(%rsp), %rax
cmpl $0x0, 0xa4(%rax)
jne 0x1172de
movq 0x38(%rsp), %rdi
callq 0x1193a0
movq 0x38(%rsp), %rax
cmpl $0x0, 0xa4(%rax)
jne 0x1172dc
cmpl $0x0, 0x34(%rsp)
jne 0x1172d7
movl $0x0, 0x44(%rsp)
jmp 0x117558
jmp 0x11747d
jmp 0x1172de
movq 0x38(%rsp), %rax
movl $0x0, 0x90(%rax)
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x38(%rsp), %rcx
movl 0x9c(%rcx), %ecx
movb (%rax,%rcx), %al
movb %al, 0x2f(%rsp)
movq 0x38(%rsp), %rax
movq 0x1700(%rax), %rax
movq 0x38(%rsp), %rcx
movl 0x16fc(%rcx), %ecx
movw $0x0, (%rax,%rcx,2)
movb 0x2f(%rsp), %dl
movq 0x38(%rsp), %rax
movq 0x16f0(%rax), %rax
movq 0x38(%rsp), %rsi
movl 0x16fc(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x16fc(%rsi)
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
movq 0x38(%rsp), %rax
movzbl 0x2f(%rsp), %ecx
movw 0xc4(%rax,%rcx,4), %dx
addw $0x1, %dx
movw %dx, 0xc4(%rax,%rcx,4)
movq 0x38(%rsp), %rax
movl 0x16fc(%rax), %eax
movq 0x38(%rsp), %rcx
movl 0x16f8(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x30(%rsp)
movq 0x38(%rsp), %rax
movl 0xa4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xa4(%rax)
movq 0x38(%rsp), %rax
movl 0x9c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x9c(%rax)
cmpl $0x0, 0x30(%rsp)
je 0x117478
movq 0x38(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, 0x88(%rax)
jl 0x117402
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x88(%rcx), %rcx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
jmp 0x11740b
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x11740b
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rax
movl 0x9c(%rax), %eax
movl %eax, %edx
movq 0x38(%rsp), %rax
subq 0x88(%rax), %rdx
xorl %ecx, %ecx
callq 0x11f710
movq 0x38(%rsp), %rax
movl 0x9c(%rax), %eax
movl %eax, %ecx
movq 0x38(%rsp), %rax
movq %rcx, 0x88(%rax)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x117190
movq 0x38(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, 0x20(%rax)
jne 0x117476
movl $0x0, 0x44(%rsp)
jmp 0x117558
jmp 0x117478
jmp 0x11729d
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, 0x88(%rax)
jl 0x1174b7
movq 0x38(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x38(%rsp), %rcx
movq 0x88(%rcx), %rcx
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x8(%rsp)
jmp 0x1174c0
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x1174c0
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x38(%rsp), %rax
movl 0x9c(%rax), %eax
movl %eax, %edx
movq 0x38(%rsp), %rax
subq 0x88(%rax), %rdx
cmpl $0x4, 0x34(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x11f710
movq 0x38(%rsp), %rax
movl 0x9c(%rax), %eax
movl %eax, %ecx
movq 0x38(%rsp), %rax
movq %rcx, 0x88(%rax)
movq 0x38(%rsp), %rax
movq (%rax), %rdi
callq 0x117190
movq 0x38(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, 0x20(%rax)
jne 0x117540
movl 0x34(%rsp), %edx
xorl %eax, %eax
movl $0x2, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, 0x44(%rsp)
jmp 0x117558
movl 0x34(%rsp), %edx
movl $0x1, %eax
movl $0x3, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)