// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/deflate.c
// Function: fill_window
local void fill_window(deflate_state *s) {
    unsigned n;
    unsigned more;    /* Amount of free space at the end of the window. */
    uInt wsize = s->w_size;

    Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");

    do {
        more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);

        /* Deal with !@#$% 64K limit: */
        if (sizeof(int) <= 2) {
            if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
                more = wsize;

            } else if (more == (unsigned)(-1)) {
                /* Very unlikely, but possible on 16 bit machine if
                 * strstart == 0 && lookahead == 1 (input done a byte at time)
                 */
                more--;
            }
        }

        /* If the window is almost full and there is insufficient lookahead,
         * move the upper half to the lower one to make room in the upper half.
         */
        if (s->strstart >= wsize + MAX_DIST(s)) {

            zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
            s->match_start -= wsize;
            s->strstart    -= wsize; /* we now have strstart >= MAX_DIST */
            s->block_start -= (long) wsize;
            if (s->insert > s->strstart)
                s->insert = s->strstart;
            slide_hash(s);
            more += wsize;
        }
        if (s->strm->avail_in == 0) break;

        /* If there was no sliding:
         *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
         *    more == window_size - lookahead - strstart
         * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
         * => more >= window_size - 2*WSIZE + 2
         * In the BIG_MEM or MMAP case (not yet supported),
         *   window_size == input_size + MIN_LOOKAHEAD  &&
         *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
         * Otherwise, window_size == 2*WSIZE so more >= 2.
         * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
         */
        Assert(more >= 2, "more < 2");

        n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
        s->lookahead += n;

        /* Initialize the hash value now that we have some input: */
        if (s->lookahead + s->insert >= MIN_MATCH) {
            uInt str = s->strstart - s->insert;
            s->ins_h = s->window[str];
            UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
#if MIN_MATCH != 3
            Call UPDATE_HASH() MIN_MATCH-3 more times
#endif
            while (s->insert) {
                UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
#ifndef FASTEST
                s->prev[str & s->w_mask] = s->head[s->ins_h];
#endif
                s->head[s->ins_h] = (Pos)str;
                str++;
                s->insert--;
                if (s->lookahead + s->insert < MIN_MATCH)
                    break;
            }
        }
        /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
         * but this is not important since only literal bytes will be emitted.
         */

    } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);

    /* If the WIN_INIT bytes after the end of the current data have never been
     * written, then zero those bytes in order to avoid memory check reports of
     * the use of uninitialized (or uninitialised as Julian writes) bytes by
     * the longest match routines.  Update the high water mark for the next
     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
     */
    if (s->high_water < s->window_size) {
        ulg curr = s->strstart + (ulg)(s->lookahead);
        ulg init;

        if (s->high_water < curr) {
            /* Previous high water mark below current data -- zero WIN_INIT
             * bytes or up to end of window, whichever is less.
             */
            init = s->window_size - curr;
            if (init > WIN_INIT)
                init = WIN_INIT;
            zmemzero(s->window + curr, (unsigned)init);
            s->high_water = curr + init;
        }
        else if (s->high_water < (ulg)curr + WIN_INIT) {
            /* High water mark at or above current data, but below current data
             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
             * to end of window, whichever is less.
             */
            init = (ulg)curr + WIN_INIT - s->high_water;
            if (init > s->window_size - s->high_water)
                init = s->window_size - s->high_water;
            zmemzero(s->window + s->high_water, (unsigned)init);
            s->high_water += init;
        }
    }

    Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
           "not enough room for search");
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq 0x30(%rsp), %rax
movl 0x50(%rax), %eax
movl %eax, 0x24(%rsp)
movq 0x30(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x30(%rsp), %rcx
movl 0xb4(%rcx), %ecx
subq %rcx, %rax
movq 0x30(%rsp), %rcx
movl 0xac(%rcx), %ecx
subq %rcx, %rax
movl %eax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movl 0xac(%rax), %eax
movl 0x24(%rsp), %ecx
movq 0x30(%rsp), %rdx
movl 0x50(%rdx), %edx
subl $0x106, %edx            # imm = 0x106
addl %edx, %ecx
cmpl %ecx, %eax
jb 0xd0b0d
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rsi
movl 0x24(%rsp), %eax
addq %rax, %rsi
movl 0x24(%rsp), %eax
subl 0x28(%rsp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0xb500
movl 0x24(%rsp), %edx
movq 0x30(%rsp), %rax
movl 0xb0(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xb0(%rax)
movl 0x24(%rsp), %edx
movq 0x30(%rsp), %rax
movl 0xac(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xac(%rax)
movl 0x24(%rsp), %eax
movl %eax, %edx
movq 0x30(%rsp), %rax
movq 0x98(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x98(%rax)
movq 0x30(%rsp), %rax
movl 0x172c(%rax), %eax
movq 0x30(%rsp), %rcx
cmpl 0xac(%rcx), %eax
jbe 0xd0af7
movq 0x30(%rsp), %rax
movl 0xac(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x172c(%rax)
movq 0x30(%rsp), %rdi
callq 0xd2aa0
movl 0x24(%rsp), %eax
addl 0x28(%rsp), %eax
movl %eax, 0x28(%rsp)
movq 0x30(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, 0x8(%rax)
jne 0xd0b20
jmp 0xd0d36
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rsi
movq 0x30(%rsp), %rax
movl 0xac(%rax), %eax
addq %rax, %rsi
movq 0x30(%rsp), %rax
movl 0xb4(%rax), %eax
addq %rax, %rsi
movl 0x28(%rsp), %edx
callq 0xd4910
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %ecx
movq 0x30(%rsp), %rax
addl 0xb4(%rax), %ecx
movl %ecx, 0xb4(%rax)
movq 0x30(%rsp), %rax
movl 0xb4(%rax), %eax
movq 0x30(%rsp), %rcx
addl 0x172c(%rcx), %eax
cmpl $0x3, %eax
jb 0xd0cfe
movq 0x30(%rsp), %rax
movl 0xac(%rax), %eax
movq 0x30(%rsp), %rcx
subl 0x172c(%rcx), %eax
movl %eax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rax
movl 0x20(%rsp), %ecx
movzbl (%rax,%rcx), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x80(%rax)
movq 0x30(%rsp), %rax
movl 0x80(%rax), %eax
movq 0x30(%rsp), %rcx
movl 0x90(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rax
movl 0x20(%rsp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rax,%rdx), %eax
xorl %eax, %ecx
movq 0x30(%rsp), %rax
andl 0x8c(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x80(%rax)
movq 0x30(%rsp), %rax
cmpl $0x0, 0x172c(%rax)
je 0xd0cfc
movq 0x30(%rsp), %rax
movl 0x80(%rax), %eax
movq 0x30(%rsp), %rcx
movl 0x90(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rax
movl 0x20(%rsp), %edx
addl $0x3, %edx
subl $0x1, %edx
movl %edx, %edx
movzbl (%rax,%rdx), %eax
xorl %eax, %ecx
movq 0x30(%rsp), %rax
andl 0x8c(%rax), %ecx
movq 0x30(%rsp), %rax
movl %ecx, 0x80(%rax)
movq 0x30(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x30(%rsp), %rcx
movl 0x80(%rcx), %ecx
movw (%rax,%rcx,2), %dx
movq 0x30(%rsp), %rax
movq 0x70(%rax), %rax
movl 0x20(%rsp), %ecx
movq 0x30(%rsp), %rsi
andl 0x58(%rsi), %ecx
movl %ecx, %ecx
movw %dx, (%rax,%rcx,2)
movl 0x20(%rsp), %eax
movw %ax, %dx
movq 0x30(%rsp), %rax
movq 0x78(%rax), %rax
movq 0x30(%rsp), %rcx
movl 0x80(%rcx), %ecx
movw %dx, (%rax,%rcx,2)
movl 0x20(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movl 0x172c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x172c(%rax)
movq 0x30(%rsp), %rax
movl 0xb4(%rax), %eax
movq 0x30(%rsp), %rcx
addl 0x172c(%rcx), %eax
cmpl $0x3, %eax
jae 0xd0cf7
jmp 0xd0cfc
jmp 0xd0c0c
jmp 0xd0cfe
jmp 0xd0d00
movq 0x30(%rsp), %rcx
xorl %eax, %eax
cmpl $0x106, 0xb4(%rcx)      # imm = 0x106
movb %al, 0xf(%rsp)
jae 0xd0d2a
movq 0x30(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, 0x8(%rax)
setne %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xd0a05
movq 0x30(%rsp), %rax
movq 0x1738(%rax), %rax
movq 0x30(%rsp), %rcx
cmpq 0x68(%rcx), %rax
jae 0xd0e99
movq 0x30(%rsp), %rax
movl 0xac(%rax), %eax
movq 0x30(%rsp), %rcx
movl 0xb4(%rcx), %ecx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x30(%rsp), %rax
movq 0x1738(%rax), %rax
cmpq 0x18(%rsp), %rax
jae 0xd0de2
movq 0x30(%rsp), %rax
movq 0x68(%rax), %rax
subq 0x18(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq $0x102, 0x10(%rsp)      # imm = 0x102
jbe 0xd0da9
movq $0x102, 0x10(%rsp)      # imm = 0x102
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rdi
addq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rax
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0xb2d0
movq 0x18(%rsp), %rcx
addq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x1738(%rax)
jmp 0xd0e97
movq 0x30(%rsp), %rax
movq 0x1738(%rax), %rax
movq 0x18(%rsp), %rcx
addq $0x102, %rcx            # imm = 0x102
cmpq %rcx, %rax
jae 0xd0e95
movq 0x18(%rsp), %rax
addq $0x102, %rax            # imm = 0x102
movq 0x30(%rsp), %rcx
subq 0x1738(%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
movq 0x68(%rcx), %rcx
movq 0x30(%rsp), %rdx
subq 0x1738(%rdx), %rcx
cmpq %rcx, %rax
jbe 0xd0e58
movq 0x30(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x30(%rsp), %rcx
subq 0x1738(%rcx), %rax
movq %rax, 0x10(%rsp)
movq 0x30(%rsp), %rax
movq 0x60(%rax), %rdi
movq 0x30(%rsp), %rax
addq 0x1738(%rax), %rdi
movq 0x10(%rsp), %rax
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0xb2d0
movq 0x10(%rsp), %rcx
movq 0x30(%rsp), %rax
addq 0x1738(%rax), %rcx
movq %rcx, 0x1738(%rax)
jmp 0xd0e97
jmp 0xd0e99
addq $0x38, %rsp
retq
nop