// File: /workspace/github_c_makefile_star2_O0/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: compress_block(ct_data*, ct_data*)
void compress_block(ct_data* ltree, ct_data* dtree) {
    unsigned dist;      /* distance of matched string */
    int lc;             /* match length or unmatched char (if dist == 0) */
    unsigned lx = 0;    /* running index in l_buf */
    unsigned dx = 0;    /* running index in d_buf */
    unsigned fx = 0;    /* running index in flag_buf */
    u8 flag = 0;       /* current flags */
    unsigned code;      /* the code to send */
    int extra;          /* number of extra bits to send */

    if (last_lit != 0) do {
        if ((lx & 7) == 0) flag = flag_buf[fx++];
        lc = l_buf[lx++];
        if ((flag & 1) == 0) {
            send_code(lc, ltree); /* send a literal byte */
            //Tracecv(isgraph(lc), (stderr," '%c' ", lc));
        } else {
            /* Here, lc is the match length - MIN_MATCH */
            code = length_code[lc];
            send_code(code+LITERALS+1, ltree); /* send the length code */
            extra = extra_lbits[code];
            if (extra != 0) {
                lc -= base_length[code];
                send_bits(lc, extra);        /* send the extra length bits */
            }
            dist = d_buf[dx++];
            /* Here, dist is the match distance - 1 */
            code = d_code(dist);
            //Assert (code < D_CODES, "bad d_code");

            send_code(code, dtree);       /* send the distance code */
            extra = extra_dbits[code];
            if (extra != 0) {
                dist -= base_dist[code];
                send_bits(dist, extra);   /* send the extra distance bits */
            }
        } /* literal or match pair ? */
        flag >>= 1;
    } while (lx < last_lit);

    send_code(END_BLOCK, ltree);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
cmpl $0x0, 0x9be0(%rip)      # 0x13b40
je 0xa128
jmp 0x9f68
movl -0x1c(%rbp), %eax
andl $0x7, %eax
cmpl $0x0, %eax
jne 0x9f8f
movl -0x24(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x24(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x8bb7(%rip), %rax      # 0x12b40
movb (%rax,%rcx), %al
movb %al, -0x25(%rbp)
movq 0x1009be2(%rip), %rax   # 0x1013b78
movl -0x1c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x1c(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x18(%rbp)
movzbl -0x25(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x9fd9
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzwl (%rax,%rcx,4), %edi
movq -0x8(%rbp), %rax
movslq -0x18(%rbp), %rcx
movzwl 0x2(%rax,%rcx,4), %esi
callq 0x8ed0
jmp 0xa10e
movslq -0x18(%rbp), %rcx
leaq 0x875c(%rip), %rax      # 0x12740
movzbl (%rax,%rcx), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x100, %ecx            # imm = 0x100
addl $0x1, %ecx
movl %ecx, %ecx
movzwl (%rax,%rcx,4), %edi
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
addl $0x100, %ecx            # imm = 0x100
addl $0x1, %ecx
movl %ecx, %ecx
movzwl 0x2(%rax,%rcx,4), %esi
callq 0x8ed0
movl -0x2c(%rbp), %eax
movl %eax, %ecx
leaq 0x6477(%rip), %rax      # 0x104a0
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0xa057
movl -0x2c(%rbp), %eax
movl %eax, %ecx
leaq 0x89ff(%rip), %rax      # 0x12a40
movl (%rax,%rcx,4), %ecx
movl -0x18(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8ed0
movl -0x20(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x20(%rbp)
movl %eax, %eax
movl %eax, %ecx
leaq 0x1039b33(%rip), %rax   # 0x1043ba0
movzwl (%rax,%rcx,2), %eax
movl %eax, -0x14(%rbp)
cmpl $0x100, -0x14(%rbp)     # imm = 0x100
jae 0xa091
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x87b7(%rip), %rax      # 0x12840
movb (%rax,%rcx), %al
movb %al, -0x31(%rbp)
jmp 0xa0ad
movl -0x14(%rbp), %eax
shrl $0x7, %eax
addl $0x100, %eax            # imm = 0x100
movl %eax, %eax
movl %eax, %ecx
leaq 0x8799(%rip), %rax      # 0x12840
movb (%rax,%rcx), %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movzwl (%rax,%rcx,4), %edi
movq -0x10(%rbp), %rax
movl -0x2c(%rbp), %ecx
movzwl 0x2(%rax,%rcx,4), %esi
callq 0x8ed0
movl -0x2c(%rbp), %eax
movl %eax, %ecx
leaq 0x6442(%rip), %rax      # 0x10520
movl (%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0xa10c
movl -0x2c(%rbp), %eax
movl %eax, %ecx
leaq 0x89ca(%rip), %rax      # 0x12ac0
movl (%rax,%rcx,4), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %edi
movl -0x30(%rbp), %esi
callq 0x8ed0
jmp 0xa10e
movzbl -0x25(%rbp), %eax
sarl %eax
movb %al, -0x25(%rbp)
movl -0x1c(%rbp), %eax
cmpl 0x9a20(%rip), %eax      # 0x13b40
jb 0x9f68
jmp 0xa128
movq -0x8(%rbp), %rax
movzwl 0x400(%rax), %edi
movq -0x8(%rbp), %rax
movzwl 0x402(%rax), %esi
callq 0x8ed0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)