// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/zlib-1.3.0.1/trees.c
// Function: scan_tree
local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
    int n;                     /* iterates over all tree elements */
    int prevlen = -1;          /* last emitted length */
    int curlen;                /* length of current code */
    int nextlen = tree[0].Len; /* length of next code */
    int count = 0;             /* repeat count of the current code */
    int max_count = 7;         /* max repeat count */
    int min_count = 4;         /* min repeat count */

    if (nextlen == 0) max_count = 138, min_count = 3;
    tree[max_code + 1].Len = (ush)0xffff; /* guard */

    for (n = 0; n <= max_code; n++) {
        curlen = nextlen; nextlen = tree[n + 1].Len;
        if (++count < max_count && curlen == nextlen) {
            continue;
        } else if (count < min_count) {
            s->bl_tree[curlen].Freq += count;
        } else if (curlen != 0) {
            if (curlen != prevlen) s->bl_tree[curlen].Freq++;
            s->bl_tree[REP_3_6].Freq++;
        } else if (count <= 10) {
            s->bl_tree[REPZ_3_10].Freq++;
        } else {
            s->bl_tree[REPZ_11_138].Freq++;
        }
        count = 0; prevlen = curlen;
        if (nextlen == 0) {
            max_count = 138, min_count = 3;
        } else if (curlen == nextlen) {
            max_count = 6, min_count = 3;
        } else {
            max_count = 7, min_count = 4;
        }
    }
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movl $0xffffffff, -0x1c(%rsp) # imm = 0xFFFFFFFF
movq -0x10(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x24(%rsp)
movl $0x0, -0x28(%rsp)
movl $0x7, -0x2c(%rsp)
movl $0x4, -0x30(%rsp)
cmpl $0x0, -0x24(%rsp)
jne 0xd8de2
movl $0x8a, -0x2c(%rsp)
movl $0x3, -0x30(%rsp)
movq -0x10(%rsp), %rax
movl -0x14(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw $0xffff, 0x2(%rax,%rcx,4) # imm = 0xFFFF
movl $0x0, -0x18(%rsp)
movl -0x18(%rsp), %eax
cmpl -0x14(%rsp), %eax
jg 0xd8f6b
movl -0x24(%rsp), %eax
movl %eax, -0x20(%rsp)
movq -0x10(%rsp), %rax
movl -0x18(%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl 0x2(%rax,%rcx,4), %eax
movl %eax, -0x24(%rsp)
movl -0x28(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rsp)
cmpl -0x2c(%rsp), %eax
jge 0xd8e4e
movl -0x20(%rsp), %eax
cmpl -0x24(%rsp), %eax
jne 0xd8e4e
jmp 0xd8f5b
movl -0x28(%rsp), %eax
cmpl -0x30(%rsp), %eax
jge 0xd8e7d
movl -0x28(%rsp), %esi
movq -0x8(%rsp), %rax
movslq -0x20(%rsp), %rcx
movzwl 0xabc(%rax,%rcx,4), %edx
addl %esi, %edx
movw %dx, 0xabc(%rax,%rcx,4)
jmp 0xd8f00
cmpl $0x0, -0x20(%rsp)
je 0xd8ec5
movl -0x20(%rsp), %eax
cmpl -0x1c(%rsp), %eax
je 0xd8eac
movq -0x8(%rsp), %rax
movslq -0x20(%rsp), %rcx
movw 0xabc(%rax,%rcx,4), %dx
addw $0x1, %dx
movw %dx, 0xabc(%rax,%rcx,4)
movq -0x8(%rsp), %rax
movw 0xafc(%rax), %cx
addw $0x1, %cx
movw %cx, 0xafc(%rax)
jmp 0xd8efe
cmpl $0xa, -0x28(%rsp)
jg 0xd8ee5
movq -0x8(%rsp), %rax
movw 0xb00(%rax), %cx
addw $0x1, %cx
movw %cx, 0xb00(%rax)
jmp 0xd8efc
movq -0x8(%rsp), %rax
movw 0xb04(%rax), %cx
addw $0x1, %cx
movw %cx, 0xb04(%rax)
jmp 0xd8efe
jmp 0xd8f00
jmp 0xd8f02
movl $0x0, -0x28(%rsp)
movl -0x20(%rsp), %eax
movl %eax, -0x1c(%rsp)
cmpl $0x0, -0x24(%rsp)
jne 0xd8f2b
movl $0x8a, -0x2c(%rsp)
movl $0x3, -0x30(%rsp)
jmp 0xd8f59
movl -0x20(%rsp), %eax
cmpl -0x24(%rsp), %eax
jne 0xd8f47
movl $0x6, -0x2c(%rsp)
movl $0x3, -0x30(%rsp)
jmp 0xd8f57
movl $0x7, -0x2c(%rsp)
movl $0x4, -0x30(%rsp)
jmp 0xd8f59
jmp 0xd8f5b
movl -0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rsp)
jmp 0xd8e00
retq
nopl (%rax)