// File: /workspace/github_c_makefile_star2_O1/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
cmpl $0x1, 0xbc(%r14)
ja 0x271f
movq %r14, %rdi
callq 0x36cd
movl 0xbc(%r14), %eax
movl %eax, %ecx
orl %ebx, %ecx
je 0x280a
testl %eax, %eax
je 0x280e
movl 0xb4(%r14), %edx
addl 0xbc(%r14), %edx
movl %edx, 0xb4(%r14)
movl $0x0, 0xbc(%r14)
movq 0xa0(%r14), %rax
leaq (%rax,%r15), %rcx
testl %edx, %edx
je 0x2753
cmpq %rdx, %rcx
ja 0x27a6
subl %ecx, %edx
movl %edx, 0xbc(%r14)
movl %ecx, 0xb4(%r14)
testq %rax, %rax
js 0x2770
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x2772
xorl %esi, %esi
movl %ecx, %edx
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4c16
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x267b
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x2879
movl 0xb4(%r14), %edx
movq 0xa0(%r14), %rax
movl %edx, %ecx
subl %eax, %ecx
movl 0x38(%r14), %esi
addl %r12d, %esi
cmpl %esi, %ecx
jb 0x26f4
testq %rax, %rax
js 0x27d4
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x27d6
xorl %esi, %esi
subq %rax, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x4c16
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x267b
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
jne 0x26f4
jmp 0x2879
xorl %ebp, %ebp
jmp 0x2879
movq 0xa0(%r14), %rax
testq %rax, %rax
js 0x2822
movl %eax, %esi
addq 0x48(%r14), %rsi
jmp 0x2824
xorl %esi, %esi
movl 0xb4(%r14), %edx
subq %rax, %rdx
xorl %ecx, %ecx
cmpl $0x4, %ebx
sete %cl
movq %r14, %rdi
callq 0x4c16
movl 0xb4(%r14), %eax
movq %rax, 0xa0(%r14)
movq (%r14), %rdi
callq 0x267b
movq (%r14), %rax
cmpl $0x0, 0x20(%rax)
je 0x286e
xorl %eax, %eax
cmpl $0x4, %ebx
sete %al
leal 0x1(,%rax,2), %ebp
jmp 0x2879
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