// File: /workspace/github_c_makefile_star2_O3/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 0x26d4
movq %r14, %rdi
callq 0x362c
movl 0xbc(%r14), %ecx
movl %ecx, %eax
orl %ebx, %eax
je 0x27ba
movq 0xa0(%r14), %rax
testl %ecx, %ecx
jne 0x26db
jmp 0x27be
movq 0xa0(%r14), %rax
addl 0xb4(%r14), %ecx
movl %ecx, 0xb4(%r14)
movl $0x0, 0xbc(%r14)
leaq (%rax,%r15), %rdx
testl %ecx, %ecx
je 0x2701
cmpq %rcx, %rdx
ja 0x2762
subl %edx, %ecx
movl %ecx, 0xbc(%r14)
movl %edx, 0xb4(%r14)
testq %rax, %rax
js 0x271e
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x2720
xorl %esi, %esi
movl %edx, %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4fd7
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x2626
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x2822
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 0x269f
testq %rax, %rax
js 0x2782
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x2784
xorl %esi, %esi
movl %ecx, %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4fd7
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x2626
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
jne 0x269f
jmp 0x2822
xorl %ebp, %ebp
jmp 0x2822
testq %rax, %rax
js 0x27cb
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x27cd
xorl %esi, %esi
movl 0xb4(%r14), %edx
subq %rax, %rdx
xorl %ecx, %ecx
cmpl $0x4, %ebx
sete %cl
movq %r14, %rdi
callq 0x4fd7
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x2626
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x2817
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x2822
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