// File: /workspace/github_c_makefile_star2_O0/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: deflate()
void deflate() {
    IPos hash_head;          /* head of hash chain */
    IPos prev_match;         /* previous match */
    int flush;               /* set if current block must be flushed */
    int match_available = 0; /* set if previous match exists */
    u32 match_length = MIN_MATCH-1; /* length of best match */

    /*
    if (compr_level <= 3){ 
        deflate_fast();
        return;
    }
    */
    
    /* Process the input block. */
    while (lookahead != 0) {
        
        /* Insert the string window[strstart .. strstart+2] in the
         * dictionary, and set hash_head to the head of the hash chain:
         */
        INSERT_STRING(strstart, hash_head);

        /* Find the longest match, discarding those <= prev_length.
         */
        prev_length = match_length, prev_match = match_start;
        match_length = MIN_MATCH-1;
        
        if (hash_head != NIL && prev_length < max_lazy_match &&
            strstart - hash_head <= MAX_DIST &&
	    strstart <= window_size - MIN_LOOKAHEAD) {
            /* To simplify the code, we prevent matches with the string
             * of window index 0 (in particular we have to avoid a match
             * of the string with itself at the start of the input file).
             */
             
            match_length = longest_match (hash_head);
            
            /* longest_match() sets match_start */
            if (match_length > lookahead) match_length = lookahead;

            /* Ignore a length 3 match if it is too distant: */
            if (match_length == MIN_MATCH && strstart-match_start > TOO_FAR){
                /* If prev_match is also MIN_MATCH, match_start is garbage
                 * but we will ignore the current match anyway.
                 */
                match_length--;
            }
        }
        
        /* If there was a match at the previous step and the current
         * match is not better, output the previous match:
         */
        if (prev_length >= MIN_MATCH && match_length <= prev_length) {

            flush = ct_tally(strstart-1-prev_match, prev_length - MIN_MATCH);
            
            /* Insert in hash table all strings up to the end of the match.
             * strstart-1 and strstart are already inserted.
             */
            lookahead -= prev_length-1;
            prev_length -= 2;
            RSYNC_ROLL(strstart, prev_length+1);
            do {
                strstart++;
                INSERT_STRING(strstart, hash_head);
                /* strstart never exceeds WSIZE-MAX_MATCH, so there are
                 * always MIN_MATCH bytes ahead. If lookahead < MIN_MATCH
                 * these bytes are garbage, but it does not matter since the
                 * next lookahead bytes will always be emitted as literals.
                 */
            } while (--prev_length != 0);
            match_available = 0;
            match_length = MIN_MATCH-1;
            strstart++;

            if (rsync && strstart > rsync_chunk_end) {
                rsync_chunk_end = 0xFFFFFFFF;
                flush = 2;
            }
            if (flush) FLUSH_BLOCK(0), block_start = strstart;
        } else if (match_available) {
            /* If there was no match at the previous position, output a
             * single literal. If there was a match but the current match
             * is longer, truncate the previous match to a single literal.
             */
            //Tracevv((stderr,"%c",window[strstart-1]));
            
            flush = ct_tally (0, window[strstart-1]);
            if (rsync && strstart > rsync_chunk_end) {
                rsync_chunk_end = 0xFFFFFFFF;
                flush = 2;
            }
            if (flush) FLUSH_BLOCK(0), block_start = strstart;
            RSYNC_ROLL(strstart, 1);
            strstart++;
            lookahead--;
        } else {
        
            /* There is no previous match to compare with, wait for
             * the next step to decide.
             */
            if (rsync && strstart > rsync_chunk_end) {
                /* Reset huffman tree */
                rsync_chunk_end = 0xFFFFFFFF;
                flush = 2;
                FLUSH_BLOCK(0), block_start = strstart;
            }
            match_available = 1;
            RSYNC_ROLL(strstart, 1);
            strstart++;
            lookahead--;
        }
        // Assert (strstart <= bytes_in && lookahead <= bytes_in, "a bit too far");

        /* Make sure that we always have enough lookahead, except
         * at the end of the input file. We need MAX_MATCH bytes
         * for the next match, plus MIN_MATCH bytes to insert the
         * string following the next match.
         */
        
        while (lookahead < MIN_LOOKAHEAD && !NO_MORE_INPUT) { 
            fill_window();
        }
    }
    if (match_available) {
        ct_tally (0, window[strstart-1]);
    }

    FLUSH_BLOCK(1);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x10(%rbp)
movl $0x2, -0x14(%rbp)
cmpl $0x0, 0x6337(%rip)      # 0x10c14
je 0xadc5
movl 0x631b(%rip), %eax      # 0x10c04
shll $0x5, %eax
movl 0x631a(%rip), %ecx      # 0x10c0c
addl $0x3, %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x100929d(%rip), %rcx   # 0x1013ba0
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x62f0(%rip)      # 0x10c04
movl 0x62ea(%rip), %eax      # 0x10c04
movl %eax, %ecx
leaq 0x101927d(%rip), %rax   # 0x1023ba0
movzwl 0x10000(%rax,%rcx,2), %eax
movl %eax, -0x4(%rbp)
movw %ax, %dx
movl 0x62d5(%rip), %eax      # 0x10c0c
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, %eax
movl %eax, %ecx
leaq 0x1019259(%rip), %rax   # 0x1023ba0
movw %dx, (%rax,%rcx,2)
movl 0x62bb(%rip), %eax      # 0x10c0c
movw %ax, %dx
movl 0x62aa(%rip), %eax      # 0x10c04
movl %eax, %ecx
leaq 0x101923d(%rip), %rax   # 0x1023ba0
movw %dx, 0x10000(%rax,%rcx,2)
movl -0x14(%rbp), %eax
movl %eax, 0x6294(%rip)      # 0x10c08
movl 0x6296(%rip), %eax      # 0x10c10
movl %eax, -0x8(%rbp)
movl $0x2, -0x14(%rbp)
cmpl $0x0, -0x4(%rbp)
je 0xaa01
movl 0x6278(%rip), %eax      # 0x10c08
cmpl 0x6286(%rip), %eax      # 0x10c1c
jae 0xaa01
movl 0x626e(%rip), %eax      # 0x10c0c
subl -0x4(%rbp), %eax
cmpl $0x7efa, %eax           # imm = 0x7EFA
ja 0xaa01
movl 0x625e(%rip), %eax      # 0x10c0c
movl 0x5a8c(%rip), %ecx      # 0x10440
subl $0x106, %ecx            # imm = 0x106
cmpl %ecx, %eax
ja 0xaa01
movl -0x4(%rbp), %edi
callq 0x8b30
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x6242(%rip), %eax      # 0x10c14
jbe 0xa9dd
movl 0x623a(%rip), %eax      # 0x10c14
movl %eax, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jne 0xa9ff
movl 0x6223(%rip), %eax      # 0x10c0c
subl 0x6221(%rip), %eax      # 0x10c10
cmpl $0x1000, %eax           # imm = 0x1000
jbe 0xa9ff
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xaa01
cmpl $0x3, 0x6200(%rip)      # 0x10c08
jb 0xabd7
movl -0x14(%rbp), %eax
cmpl 0x61f1(%rip), %eax      # 0x10c08
ja 0xabd7
movl 0x61e9(%rip), %edi      # 0x10c0c
subl $0x1, %edi
subl -0x8(%rbp), %edi
movl 0x61d9(%rip), %esi      # 0x10c08
subl $0x3, %esi
callq 0xa3b0
movl %eax, -0xc(%rbp)
movl 0x61c8(%rip), %ecx      # 0x10c08
subl $0x1, %ecx
movl 0x61cb(%rip), %eax      # 0x10c14
subl %ecx, %eax
movl %eax, 0x61c3(%rip)      # 0x10c14
movl 0x61b1(%rip), %eax      # 0x10c08
subl $0x2, %eax
movl %eax, 0x61a8(%rip)      # 0x10c08
cmpl $0x0, 0x1049139(%rip)   # 0x1053ba0
je 0xaa7d
movl 0x619d(%rip), %edi      # 0x10c0c
movl 0x6193(%rip), %esi      # 0x10c08
addl $0x1, %esi
callq 0xa7c0
jmp 0xaa7f
jmp 0xaa81
movl 0x6185(%rip), %eax      # 0x10c0c
addl $0x1, %eax
movl %eax, 0x617c(%rip)      # 0x10c0c
movl 0x616e(%rip), %eax      # 0x10c04
shll $0x5, %eax
movl 0x616d(%rip), %ecx      # 0x10c0c
addl $0x3, %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x10090f0(%rip), %rcx   # 0x1013ba0
movzbl (%rcx,%rdx), %ecx
xorl %ecx, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, 0x6143(%rip)      # 0x10c04
movl 0x613d(%rip), %eax      # 0x10c04
movl %eax, %ecx
leaq 0x10190d0(%rip), %rax   # 0x1023ba0
movzwl 0x10000(%rax,%rcx,2), %eax
movl %eax, -0x4(%rbp)
movw %ax, %dx
movl 0x6128(%rip), %eax      # 0x10c0c
andl $0x7fff, %eax           # imm = 0x7FFF
movl %eax, %eax
movl %eax, %ecx
leaq 0x10190ac(%rip), %rax   # 0x1023ba0
movw %dx, (%rax,%rcx,2)
movl 0x610e(%rip), %eax      # 0x10c0c
movw %ax, %dx
movl 0x60fd(%rip), %eax      # 0x10c04
movl %eax, %ecx
leaq 0x1019090(%rip), %rax   # 0x1023ba0
movw %dx, 0x10000(%rax,%rcx,2)
movl 0x60ea(%rip), %eax      # 0x10c08
addl $-0x1, %eax
movl %eax, 0x60e1(%rip)      # 0x10c08
cmpl $0x0, %eax
jne 0xaa81
movl $0x0, -0x10(%rbp)
movl $0x2, -0x14(%rbp)
movl 0x60c8(%rip), %eax      # 0x10c0c
addl $0x1, %eax
movl %eax, 0x60bf(%rip)      # 0x10c0c
cmpl $0x0, 0x104904c(%rip)   # 0x1053ba0
je 0xab75
movl 0x60b0(%rip), %eax      # 0x10c0c
cmpl 0x60ca(%rip), %eax      # 0x10c2c
jbe 0xab75
movl $0xffffffff, 0x60be(%rip) # imm = 0xFFFFFFFF
movl $0x2, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0xabd2
cmpl $0x0, 0x607e(%rip)      # 0x10c00
jb 0xab9c
movl 0x6076(%rip), %eax      # 0x10c00
movl %eax, %ecx
leaq 0x100900d(%rip), %rax   # 0x1013ba0
addq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0xaba4
xorl %eax, %eax
movq %rax, -0x20(%rbp)
jmp 0xaba4
movq -0x20(%rbp), %rdi
movl 0x605e(%rip), %eax      # 0x10c0c
movl 0x604c(%rip), %ecx      # 0x10c00
subq %rcx, %rax
movl %eax, %esi
movl -0xc(%rbp), %edx
subl $0x1, %edx
xorl %ecx, %ecx
callq 0xa150
movl 0x6040(%rip), %eax      # 0x10c0c
movl %eax, 0x602e(%rip)      # 0x10c00
jmp 0xad89
cmpl $0x0, -0x10(%rbp)
je 0xacc8
movl 0x6025(%rip), %eax      # 0x10c0c
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1008fab(%rip), %rax   # 0x1013ba0
movzbl (%rax,%rcx), %esi
xorl %edi, %edi
callq 0xa3b0
movl %eax, -0xc(%rbp)
cmpl $0x0, 0x1048f96(%rip)   # 0x1053ba0
je 0xac2b
movl 0x5ffa(%rip), %eax      # 0x10c0c
cmpl 0x6014(%rip), %eax      # 0x10c2c
jbe 0xac2b
movl $0xffffffff, 0x6008(%rip) # imm = 0xFFFFFFFF
movl $0x2, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0xac88
cmpl $0x0, 0x5fc8(%rip)      # 0x10c00
jb 0xac52
movl 0x5fc0(%rip), %eax      # 0x10c00
movl %eax, %ecx
leaq 0x1008f57(%rip), %rax   # 0x1013ba0
addq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0xac5a
xorl %eax, %eax
movq %rax, -0x28(%rbp)
jmp 0xac5a
movq -0x28(%rbp), %rdi
movl 0x5fa8(%rip), %eax      # 0x10c0c
movl 0x5f96(%rip), %ecx      # 0x10c00
subq %rcx, %rax
movl %eax, %esi
movl -0xc(%rbp), %edx
subl $0x1, %edx
xorl %ecx, %ecx
callq 0xa150
movl 0x5f8a(%rip), %eax      # 0x10c0c
movl %eax, 0x5f78(%rip)      # 0x10c00
jmp 0xac8a
cmpl $0x0, 0x1048f0f(%rip)   # 0x1053ba0
je 0xaca3
movl 0x5f73(%rip), %edi      # 0x10c0c
movl $0x1, %esi
callq 0xa7c0
jmp 0xaca5
movl 0x5f61(%rip), %eax      # 0x10c0c
addl $0x1, %eax
movl %eax, 0x5f58(%rip)      # 0x10c0c
movl 0x5f5a(%rip), %eax      # 0x10c14
addl $-0x1, %eax
movl %eax, 0x5f51(%rip)      # 0x10c14
jmp 0xad87
cmpl $0x0, 0x1048ed1(%rip)   # 0x1053ba0
je 0xad47
movl 0x5f35(%rip), %eax      # 0x10c0c
cmpl 0x5f4f(%rip), %eax      # 0x10c2c
jbe 0xad47
movl $0xffffffff, 0x5f43(%rip) # imm = 0xFFFFFFFF
movl $0x2, -0xc(%rbp)
cmpl $0x0, 0x5f09(%rip)      # 0x10c00
jb 0xad11
movl 0x5f01(%rip), %eax      # 0x10c00
movl %eax, %ecx
leaq 0x1008e98(%rip), %rax   # 0x1013ba0
addq %rcx, %rax
movq %rax, -0x30(%rbp)
jmp 0xad19
xorl %eax, %eax
movq %rax, -0x30(%rbp)
jmp 0xad19
movq -0x30(%rbp), %rdi
movl 0x5ee9(%rip), %eax      # 0x10c0c
movl 0x5ed7(%rip), %ecx      # 0x10c00
subq %rcx, %rax
movl %eax, %esi
movl -0xc(%rbp), %edx
subl $0x1, %edx
xorl %ecx, %ecx
callq 0xa150
movl 0x5ecb(%rip), %eax      # 0x10c0c
movl %eax, 0x5eb9(%rip)      # 0x10c00
movl $0x1, -0x10(%rbp)
cmpl $0x0, 0x1048e4b(%rip)   # 0x1053ba0
je 0xad67
movl 0x5eaf(%rip), %edi      # 0x10c0c
movl $0x1, %esi
callq 0xa7c0
jmp 0xad69
movl 0x5e9d(%rip), %eax      # 0x10c0c
addl $0x1, %eax
movl %eax, 0x5e94(%rip)      # 0x10c0c
movl 0x5e96(%rip), %eax      # 0x10c14
addl $-0x1, %eax
movl %eax, 0x5e8d(%rip)      # 0x10c14
jmp 0xad89
jmp 0xad8b
xorl %eax, %eax
cmpl $0x106, 0x5e7d(%rip)    # imm = 0x106
movb %al, -0x31(%rbp)
jae 0xadb0
movl 0x1008de2(%rip), %eax   # 0x1013b84
cmpl 0x1008dd8(%rip), %eax   # 0x1013b80
sete %al
xorb $-0x1, %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xadb9
jmp 0xadc0
callq 0xa610
jmp 0xad8b
jmp 0xa8d6
cmpl $0x0, -0x10(%rbp)
je 0xadea
movl 0x5e3b(%rip), %eax      # 0x10c0c
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x1008dc1(%rip), %rax   # 0x1013ba0
movzbl (%rax,%rcx), %esi
xorl %edi, %edi
callq 0xa3b0
cmpl $0x0, 0x5e0f(%rip)      # 0x10c00
jb 0xae0b
movl 0x5e07(%rip), %eax      # 0x10c00
movl %eax, %ecx
leaq 0x1008d9e(%rip), %rax   # 0x1013ba0
addq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0xae13
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0xae13
movq -0x40(%rbp), %rdi
movl 0x5def(%rip), %eax      # 0x10c0c
movl 0x5ddd(%rip), %ecx      # 0x10c00
subq %rcx, %rax
movl %eax, %esi
movl -0xc(%rbp), %edx
subl $0x1, %edx
movl $0x1, %ecx
callq 0xa150
addq $0x40, %rsp
popq %rbp
retq
nop