// File: sisong[P]ApkDiffPatch/zlib1.3.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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0xb4(%rcx), %ecx
subq %rcx, %rax
movq -0x8(%rbp), %rcx
movl 0xac(%rcx), %ecx
subq %rcx, %rax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0xac(%rax), %eax
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rdx
movl 0x50(%rdx), %edx
subl $0x106, %edx            # imm = 0x106
addl %edx, %ecx
cmpl %ecx, %eax
jb 0x93724
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rsi
movl -0x14(%rbp), %eax
addq %rax, %rsi
movl -0x14(%rbp), %eax
subl -0x10(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
callq 0x4320
movl -0x14(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0xb0(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xb0(%rax)
movl -0x14(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0xac(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0xac(%rax)
movl -0x14(%rbp), %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x98(%rax)
movq -0x8(%rbp), %rax
movl 0x172c(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0xac(%rcx), %eax
jbe 0x93712
movq -0x8(%rbp), %rax
movl 0xac(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x172c(%rax)
movq -0x8(%rbp), %rdi
callq 0x95490
movl -0x14(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpl $0x0, 0x8(%rax)
jne 0x93736
jmp 0x9391d
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rsi
movq -0x8(%rbp), %rax
movl 0xac(%rax), %eax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %eax
addq %rax, %rsi
movl -0x10(%rbp), %edx
callq 0x97050
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0xb4(%rax), %ecx
movl %ecx, 0xb4(%rax)
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x172c(%rcx), %eax
cmpl $0x3, %eax
jb 0x938ea
movq -0x8(%rbp), %rax
movl 0xac(%rax), %eax
movq -0x8(%rbp), %rcx
subl 0x172c(%rcx), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x18(%rbp), %ecx
movzbl (%rax,%rcx), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x8(%rbp), %rax
movl 0x80(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x90(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x18(%rbp), %edx
addl $0x1, %edx
movl %edx, %edx
movzbl (%rax,%rdx), %eax
xorl %eax, %ecx
movq -0x8(%rbp), %rax
andl 0x8c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x172c(%rax)
je 0x938e8
movq -0x8(%rbp), %rax
movl 0x80(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0x90(%rcx), %ecx
shll %cl, %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x18(%rbp), %edx
addl $0x3, %edx
subl $0x1, %edx
movl %edx, %edx
movzbl (%rax,%rdx), %eax
xorl %eax, %ecx
movq -0x8(%rbp), %rax
andl 0x8c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x80(%rcx), %ecx
movw (%rax,%rcx,2), %dx
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rsi
andl 0x58(%rsi), %ecx
movl %ecx, %ecx
movw %dx, (%rax,%rcx,2)
movl -0x18(%rbp), %eax
movw %ax, %dx
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0x80(%rcx), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x172c(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x172c(%rax)
movq -0x8(%rbp), %rax
movl 0xb4(%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x172c(%rcx), %eax
cmpl $0x3, %eax
jae 0x938e3
jmp 0x938e8
jmp 0x9380c
jmp 0x938ea
jmp 0x938ec
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x106, 0xb4(%rcx)      # imm = 0x106
movb %al, -0x29(%rbp)
jae 0x93912
movq -0x8(%rbp), %rax
movq (%rax), %rax
cmpl $0x0, 0x8(%rax)
setne %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x93636
movq -0x8(%rbp), %rax
movq 0x1738(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x68(%rcx), %rax
jae 0x93a5e
movq -0x8(%rbp), %rax
movl 0xac(%rax), %eax
movq -0x8(%rbp), %rcx
movl 0xb4(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x1738(%rax), %rax
cmpq -0x20(%rbp), %rax
jae 0x939b7
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
subq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x102, -0x28(%rbp)     # imm = 0x102
jbe 0x93984
movq $0x102, -0x28(%rbp)     # imm = 0x102
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
addq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x4210
movq -0x20(%rbp), %rcx
addq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1738(%rax)
jmp 0x93a5c
movq -0x8(%rbp), %rax
movq 0x1738(%rax), %rax
movq -0x20(%rbp), %rcx
addq $0x102, %rcx            # imm = 0x102
cmpq %rcx, %rax
jae 0x93a5a
movq -0x20(%rbp), %rax
addq $0x102, %rax            # imm = 0x102
movq -0x8(%rbp), %rcx
subq 0x1738(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x68(%rcx), %rcx
movq -0x8(%rbp), %rdx
subq 0x1738(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x93a22
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x8(%rbp), %rcx
subq 0x1738(%rcx), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq -0x8(%rbp), %rax
addq 0x1738(%rax), %rdi
movq -0x28(%rbp), %rax
movl %eax, %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x4210
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x1738(%rax), %rcx
movq %rcx, 0x1738(%rax)
jmp 0x93a5c
jmp 0x93a5e
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)