// File: /workspace/github_cpp_makefile_star2_O1/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
cmpl $0x1, 0xa4(%r14)
ja 0x94d6e
movq %r14, %rdi
callq 0x9574c
movl 0xa4(%r14), %eax
movl %eax, %ecx
orl %ebx, %ecx
je 0x94e59
testl %eax, %eax
je 0x94e5d
movl 0x9c(%r14), %edx
addl 0xa4(%r14), %edx
movl %edx, 0x9c(%r14)
movl $0x0, 0xa4(%r14)
movq 0x88(%r14), %rax
leaq (%rax,%r15), %rcx
testl %edx, %edx
je 0x94da2
cmpq %rdx, %rcx
ja 0x94df5
subl %ecx, %edx
movl %edx, 0xa4(%r14)
movl %ecx, 0x9c(%r14)
testq %rax, %rax
js 0x94dbf
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x94dc1
xorl %esi, %esi
movl %ecx, %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x988ce
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9469d
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x94ec8
movl 0x9c(%r14), %edx
movq 0x88(%r14), %rax
movl %edx, %ecx
subl %eax, %ecx
movl 0x44(%r14), %esi
addl %r12d, %esi
cmpl %esi, %ecx
jb 0x94d43
testq %rax, %rax
js 0x94e23
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x94e25
xorl %esi, %esi
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x988ce
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9469d
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
jne 0x94d43
jmp 0x94ec8
xorl %ebp, %ebp
jmp 0x94ec8
movq 0x88(%r14), %rax
testq %rax, %rax
js 0x94e71
movl %eax, %esi
addq 0x50(%r14), %rsi
jmp 0x94e73
xorl %esi, %esi
movl 0x9c(%r14), %edx
subq %rax, %rdx
xorl %ecx, %ecx
cmpl $0x4, %ebx
sete %cl
movq %r14, %rdi
callq 0x988ce
movl 0x9c(%r14), %eax
movq %rax, 0x88(%r14)
movq (%r14), %rdi
callq 0x9469d
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x94ebd
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x94ec8
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