// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/deflate.c
// Function: deflate_stored
local block_state deflate_stored(s, flush)
    deflate_state *s;
    int flush;
{
    /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
     * to pending_buf_size, and each stored block has a 5 byte header:
     */
    ulg max_block_size = 0xffff;
    ulg max_start;

    if (max_block_size > s->pending_buf_size - 5) {
        max_block_size = s->pending_buf_size - 5;
    }

    /* Copy as much as possible from input to output: */
    for (;;) {
        /* Fill the window as much as possible: */
        if (s->lookahead <= 1) {

            Assert(s->strstart < s->w_size+MAX_DIST(s) ||
                   s->block_start >= (long)s->w_size, "slide too late");

            fill_window(s);
            if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;

            if (s->lookahead == 0) break; /* flush the current block */
        }
        Assert(s->block_start >= 0L, "block gone");

        s->strstart += s->lookahead;
        s->lookahead = 0;

        /* Emit a stored block if pending_buf will be full: */
        max_start = s->block_start + max_block_size;
        if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
            /* strstart == 0 is possible when wraparound on 16-bit machine */
            s->lookahead = (uInt)(s->strstart - max_start);
            s->strstart = (uInt)max_start;
            FLUSH_BLOCK(s, 0);
        }
        /* Flush if we may have to slide, otherwise block_start may become
         * negative and the data will be gone:
         */
        if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
            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 %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq 0x18(%rdi), %r15
addq $-0x5, %r15
movl $0xffff, %eax           # imm = 0xFFFF
cmpq %rax, %r15
cmovaeq %rax, %r15
movl $0xfffffefa, %r12d      # imm = 0xFFFFFEFA
movl 0xa4(%r14), %ecx
cmpl $0x2, %ecx
jae 0x940af
movq %r14, %rdi
callq 0x94ab7
movl 0xa4(%r14), %ecx
movl %ecx, %eax
orl %ebx, %eax
je 0x94195
movq 0x88(%r14), %rax
testl %ecx, %ecx
jne 0x940b6
jmp 0x94199
movq 0x88(%r14), %rax
addl 0x9c(%r14), %ecx
movl %ecx, 0x9c(%r14)
movl $0x0, 0xa4(%r14)
leaq (%rax,%r15), %rdx
testl %ecx, %ecx
je 0x940dc
cmpq %rcx, %rdx
ja 0x9413d
subl %edx, %ecx
movl %ecx, 0xa4(%r14)
movl %edx, 0x9c(%r14)
testq %rax, %rax
js 0x940f9
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x940fb
xorl %esi, %esi
movl %edx, %edx
subq %rax, %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)
je 0x941fd
movl 0x9c(%r14), %ecx
movq 0x88(%r14), %rax
movl %ecx, %edx
subl %eax, %edx
movl 0x44(%r14), %esi
addl %r12d, %esi
cmpl %esi, %edx
jb 0x9407a
testq %rax, %rax
js 0x9415d
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x9415f
xorl %esi, %esi
movl %ecx, %edx
subq %rax, %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 0x9407a
jmp 0x941fd
xorl %ebp, %ebp
jmp 0x941fd
testq %rax, %rax
js 0x941a6
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x941a8
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 0x941f2
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x941fd
xorl %ebp, %ebp
cmpl $0x4, %ebx
sete %bpl
addl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq