// File: /workspace/github_c_makefile_star2_O2/snej[P]zdelta/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 == ZD_FINISH);
    return flush == ZD_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 $0xffffeffa, %r12d      # imm = 0xFFFFEFFA
movl 0xbc(%r14), %ecx
cmpl $0x2, %ecx
jae 0x2577
movq %r14, %rdi
callq 0x34e5
movl 0xbc(%r14), %ecx
movl %ecx, %eax
orl %ebx, %eax
je 0x265a
movq 0xa0(%r14), %rax
testl %ecx, %ecx
jne 0x257e
jmp 0x265e
movq 0xa0(%r14), %rax
addl 0xb4(%r14), %ecx
movl %ecx, 0xb4(%r14)
andl $0x0, 0xbc(%r14)
leaq (%rax,%r15), %rdx
testl %ecx, %ecx
je 0x25a1
cmpq %rcx, %rdx
ja 0x2602
subl %edx, %ecx
movl %ecx, 0xbc(%r14)
movl %edx, 0xb4(%r14)
testq %rax, %rax
js 0x25be
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x25c0
xorl %esi, %esi
movl %edx, %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x49d2
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x24c9
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x26c2
movl 0xb4(%r14), %ecx
movq 0xa0(%r14), %rax
movl %ecx, %edx
subl %eax, %edx
movl 0x38(%r14), %esi
addl %r12d, %esi
cmpl %esi, %edx
jb 0x2542
testq %rax, %rax
js 0x2622
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x2624
xorl %esi, %esi
movl %ecx, %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x49d2
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x24c9
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
jne 0x2542
jmp 0x26c2
xorl %ebp, %ebp
jmp 0x26c2
testq %rax, %rax
js 0x266b
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x266d
xorl %esi, %esi
movl 0xb4(%r14), %edx
subq %rax, %rdx
xorl %ecx, %ecx
cmpl $0x4, %ebx
sete %cl
movq %r14, %rdi
callq 0x49d2
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x24c9
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x26b7
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x26c2
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