// File: /workspace/github_cpp_makefile_star2_O2/tomfunkhouser[P]gaps/pkgs/png/trees.c
// Function: compress_block
local void compress_block(s, ltree, dtree)
    deflate_state *s;
    ct_data *ltree; /* literal tree */
    ct_data *dtree; /* distance tree */
{
    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 code;      /* the code to send */
    int extra;          /* number of extra bits to send */

    if (s->last_lit != 0) do {
        dist = s->d_buf[lx];
        lc = s->l_buf[lx++];
        if (dist == 0) {
            send_code(s, 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(s, code+LITERALS+1, ltree); /* send the length code */
            extra = extra_lbits[code];
            if (extra != 0) {
                lc -= base_length[code];
                send_bits(s, lc, extra);       /* send the extra length bits */
            }
            dist--; /* dist is now the match distance - 1 */
            code = d_code(dist);
            Assert (code < D_CODES, "bad d_code");

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

        /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
        Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
               "pendingBuf overflow");

    } while (lx < s->last_lit);

    send_code(s, END_BLOCK, ltree);
    s->last_eob_len = ltree[END_BLOCK].Len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpl $0x0, 0x16fc(%rdi)
movl $0x10, %r15d
je 0x8ad6c
xorl %r8d, %r8d
leaq 0x17f4c(%rip), %r11     # 0xa2980
movq 0x16f0(%rdi), %rcx
movq 0x1700(%rdi), %r10
movzwl (%r10,%r8,2), %ebp
movzbl (%rcx,%r8), %r13d
testl %ebp, %ebp
je 0x8aaec
leaq 0x18125(%rip), %rax     # 0xa2b80
movzbl (%r13,%rax), %r10d
movzwl 0x406(%rsi,%r10,4), %ebx
movl 0x1724(%rdi), %ecx
movl %r15d, %eax
subl %ebx, %eax
movzwl 0x404(%rsi,%r10,4), %r14d
movl %r14d, %r12d
shll %cl, %r12d
orw 0x1720(%rdi), %r12w
movw %r12w, 0x1720(%rdi)
cmpl %eax, %ecx
jle 0x8ab6d
movq 0x10(%rdi), %rax
movl 0x28(%rdi), %ecx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1721(%rdi), %al
movq 0x10(%rdi), %rcx
movl 0x28(%rdi), %r9d
leal 0x1(%r9), %r12d
movl %r12d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1724(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r14d
movw %r14w, 0x1720(%rdi)
leal (%rbx,%rax), %ecx
addl $-0x10, %ecx
movl %r14d, %r12d
jmp 0x8ab6f
movzwl 0x2(%rsi,%r13,4), %r10d
movl 0x1724(%rdi), %ecx
movl %r15d, %r14d
subl %r10d, %r14d
movzwl (%rsi,%r13,4), %ebx
movl %ebx, %ebp
shll %cl, %ebp
orw 0x1720(%rdi), %bp
movw %bp, 0x1720(%rdi)
cmpl %r14d, %ecx
jle 0x8ac01
movq 0x10(%rdi), %rcx
movl 0x28(%rdi), %r14d
leal 0x1(%r14), %r12d
movl %r12d, 0x28(%rdi)
movb %bpl, (%rcx,%r14)
movb 0x1721(%rdi), %cl
movq 0x10(%rdi), %r14
movl 0x28(%rdi), %r12d
leal 0x1(%r12), %ebp
movl %ebp, 0x28(%rdi)
movb %cl, (%r14,%r12)
movl 0x1724(%rdi), %r14d
movb $0x10, %cl
subb %r14b, %cl
shrl %cl, %ebx
movw %bx, 0x1720(%rdi)
leal (%r10,%r14), %ecx
addl $-0x10, %ecx
jmp 0x8ad52
addl %ebx, %ecx
movl %ecx, 0x1724(%rdi)
leaq -0x1c(%r10), %rax
cmpq $-0x14, %rax
jb 0x8ac23
leaq 0x18766(%rip), %rax     # 0xa32f0
subl (%rax,%r10,4), %r13d
leaq 0x185eb(%rip), %rax     # 0xa3180
movl (%rax,%r10,4), %r10d
movl %r15d, %eax
subl %r10d, %eax
cmpl %eax, %ecx
jle 0x8ac09
movzwl %r13w, %ebx
shll %cl, %r13d
orl %r13d, %r12d
movw %r12w, 0x1720(%rdi)
movq 0x10(%rdi), %rax
movl 0x28(%rdi), %ecx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1721(%rdi), %al
movq 0x10(%rdi), %rcx
movl 0x28(%rdi), %r9d
leal 0x1(%r9), %r14d
movl %r14d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1724(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebx
movw %bx, 0x1720(%rdi)
leal (%r10,%rax), %ecx
addl $-0x10, %ecx
movl %ebx, %r12d
jmp 0x8ac1d
addl %r10d, %ecx
jmp 0x8ad52
shll %cl, %r13d
orl %r13d, %r12d
movw %r12w, 0x1720(%rdi)
addl %ecx, %r10d
movl %r10d, %ecx
movl %ecx, 0x1724(%rdi)
movl %ebp, %eax
decl %ebp
movl %ebp, %r9d
shrl $0x7, %r9d
addl $0x100, %r9d            # imm = 0x100
cmpw $0x101, %ax             # imm = 0x101
cmovbl %ebp, %r9d
movzbl (%r9,%r11), %r10d
movzwl 0x2(%rdx,%r10,4), %r13d
movl %r15d, %eax
movzwl (%rdx,%r10,4), %ebx
movl %ebx, %r9d
shll %cl, %r9d
subl %r13d, %eax
orl %r9d, %r12d
movw %r12w, 0x1720(%rdi)
cmpl %eax, %ecx
jle 0x8acb4
movq 0x10(%rdi), %rax
movl 0x28(%rdi), %ecx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1721(%rdi), %al
movq 0x10(%rdi), %rcx
movl 0x28(%rdi), %r9d
leal 0x1(%r9), %r14d
movl %r14d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1724(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebx
movw %bx, 0x1720(%rdi)
leal (%rax,%r13), %ecx
addl $-0x10, %ecx
movl %ebx, %r12d
jmp 0x8acb7
addl %r13d, %ecx
movl %ecx, 0x1724(%rdi)
cmpb $0x4, %r10b
jb 0x8ad58
leaq 0x186a2(%rip), %rax     # 0xa3370
subl (%rax,%r10,4), %ebp
leaq 0x18527(%rip), %rax     # 0xa3200
movl (%rax,%r10,4), %r10d
movl %r15d, %eax
subl %r10d, %eax
cmpl %eax, %ecx
jle 0x8ad3f
movzwl %bp, %ebx
shll %cl, %ebp
orl %ebp, %r12d
movw %r12w, 0x1720(%rdi)
movq 0x10(%rdi), %rax
movl 0x28(%rdi), %ecx
leal 0x1(%rcx), %r9d
movl %r9d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1721(%rdi), %al
movq 0x10(%rdi), %rcx
movl 0x28(%rdi), %r9d
leal 0x1(%r9), %ebp
movl %ebp, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1724(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebx
movw %bx, 0x1720(%rdi)
leal (%r10,%rax), %ecx
addl $-0x10, %ecx
jmp 0x8ad52
shll %cl, %ebp
orl %ebp, %r12d
movw %r12w, 0x1720(%rdi)
addl %ecx, %r10d
movl %r10d, %ecx
movl %ecx, 0x1724(%rdi)
incq %r8
movl 0x16fc(%rdi), %eax
cmpq %rax, %r8
jb 0x8aa34
jmp 0x8ad72
movl 0x1724(%rdi), %ecx
movzwl 0x402(%rsi), %edx
subl %edx, %r15d
movzwl 0x400(%rsi), %r8d
movl %r8d, %r9d
shll %cl, %r9d
orw 0x1720(%rdi), %r9w
movw %r9w, 0x1720(%rdi)
cmpl %r15d, %ecx
jle 0x8ade9
movq 0x10(%rdi), %rax
movl 0x28(%rdi), %ecx
leal 0x1(%rcx), %r10d
movl %r10d, 0x28(%rdi)
movb %r9b, (%rax,%rcx)
movb 0x1721(%rdi), %al
movq 0x10(%rdi), %rcx
movl 0x28(%rdi), %r9d
leal 0x1(%r9), %r10d
movl %r10d, 0x28(%rdi)
movb %al, (%rcx,%r9)
movl 0x1724(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r8d
movw %r8w, 0x1720(%rdi)
leal (%rdx,%rax), %ecx
addl $-0x10, %ecx
jmp 0x8adeb
addl %edx, %ecx
movl %ecx, 0x1724(%rdi)
movzwl 0x402(%rsi), %eax
movl %eax, 0x171c(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq