// File: /workspace/github_c_makefile_star2_O0/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: fill_window()
void fill_window() {
    u32 n, m;
    u32 more = (u32)(window_size - (u32)lookahead - (u32)strstart);
    /* Amount of free space at the end of the window. */
    
    // printf("more = %d\n", more);
    
    if (strstart >= WSIZE+MAX_DIST) {
        /* By the IN assertion, the window is not empty so we can't confuse
         * more == 0 with more == 64K on a 16 bit machine.
         */
        //Assert(window_size == (u32)2*WSIZE, "no sliding with BIG_MEM");
        
        memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
        match_start -= WSIZE;
        strstart    -= WSIZE; /* we now have strstart >= MAX_DIST: */
        if (rsync_chunk_end != 0xFFFFFFFF) {
            rsync_chunk_end -= WSIZE;
        }

        block_start -= (long) WSIZE;

        for (n = 0; n < HASH_SIZE; n++) {
            m = head[n];
            head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
        }
        for (n = 0; n < WSIZE; n++) {
            m = prev[n];
            prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
            /* If n is not on any hash chain, prev[n] is garbage but
             * its value will never be used.
             */
        }
        more += WSIZE;
    }
    
    n = read_buf((char*)window+strstart+lookahead, more);
    if (n == 0) { // No more input
        return;
    } else {
        lookahead += n;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl 0x5e22(%rip), %eax      # 0x10440
subl 0x65f0(%rip), %eax      # 0x10c14
subl 0x65e2(%rip), %eax      # 0x10c0c
movl %eax, -0xc(%rbp)
cmpl $0xfefa, 0x65d5(%rip)   # imm = 0xFEFA
jb 0xa77b
leaq 0x100955c(%rip), %rdi   # 0x1013ba0
movq %rdi, %rsi
addq $0x8000, %rsi           # imm = 0x8000
movl $0x8000, %edx           # imm = 0x8000
callq 0x2180
movl 0x65b2(%rip), %eax      # 0x10c10
subl $0x8000, %eax           # imm = 0x8000
movl %eax, 0x65a7(%rip)      # 0x10c10
movl 0x659d(%rip), %eax      # 0x10c0c
subl $0x8000, %eax           # imm = 0x8000
movl %eax, 0x6592(%rip)      # 0x10c0c
cmpl $-0x1, 0x65ab(%rip)     # 0x10c2c
je 0xa694
movl 0x65a3(%rip), %eax      # 0x10c2c
subl $0x8000, %eax           # imm = 0x8000
movl %eax, 0x6598(%rip)      # 0x10c2c
movl 0x6566(%rip), %eax      # 0x10c00
subq $0x8000, %rax           # imm = 0x8000
movl %eax, 0x655a(%rip)      # 0x10c00
movl $0x0, -0x4(%rbp)
cmpl $0x8000, -0x4(%rbp)     # imm = 0x8000
jae 0xa70f
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x10194de(%rip), %rax   # 0x1023ba0
movzwl 0x10000(%rax,%rcx,2), %eax
movl %eax, -0x8(%rbp)
cmpl $0x8000, -0x8(%rbp)     # imm = 0x8000
jb 0xa6e3
movl -0x8(%rbp), %eax
subl $0x8000, %eax           # imm = 0x8000
movl %eax, -0x10(%rbp)
jmp 0xa6ea
xorl %eax, %eax
movl %eax, -0x10(%rbp)
jmp 0xa6ea
movl -0x10(%rbp), %eax
movw %ax, %dx
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x10194a4(%rip), %rax   # 0x1023ba0
movw %dx, 0x10000(%rax,%rcx,2)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xa6ad
movl $0x0, -0x4(%rbp)
cmpl $0x8000, -0x4(%rbp)     # imm = 0x8000
jae 0xa770
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x1019475(%rip), %rax   # 0x1023ba0
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x8(%rbp)
cmpl $0x8000, -0x8(%rbp)     # imm = 0x8000
jb 0xa748
movl -0x8(%rbp), %eax
subl $0x8000, %eax           # imm = 0x8000
movl %eax, -0x14(%rbp)
jmp 0xa74f
xorl %eax, %eax
movl %eax, -0x14(%rbp)
jmp 0xa74f
movl -0x14(%rbp), %eax
movw %ax, %dx
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x101943f(%rip), %rax   # 0x1023ba0
movw %dx, (%rax,%rcx,2)
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0xa716
movl -0xc(%rbp), %eax
addl $0x8000, %eax           # imm = 0x8000
movl %eax, -0xc(%rbp)
movl 0x648b(%rip), %eax      # 0x10c0c
leaq 0x1009418(%rip), %rdi   # 0x1013ba0
addq %rax, %rdi
movl 0x6483(%rip), %eax      # 0x10c14
addq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x8ab0
movl %eax, -0x4(%rbp)
cmpl $0x0, -0x4(%rbp)
jne 0xa7a7
jmp 0xa7b6
movl -0x4(%rbp), %eax
addl 0x6464(%rip), %eax      # 0x10c14
movl %eax, 0x645e(%rip)      # 0x10c14
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)