// File: /workspace/github_c_makefile_star2_O0/snej[P]zdelta/trees.c
// Function: scan_tree
local void scan_tree (s, tree, max_code)
     deflate_state *s;
     ct_data *tree;   /* the tree to be scanned */
     int max_code;    /* and its largest code of non zero frequency */
{
  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:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movzwl 0x2(%rax), %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x7, -0x2c(%rbp)
movl $0x4, -0x30(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xa0ca
movl $0x8a, -0x2c(%rbp)
movl $0x3, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movw $0xffff, 0x2(%rax,%rcx,4) # imm = 0xFFFF
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0xa225
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzwl 0x2(%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl -0x2c(%rbp), %eax
jge 0xa127
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0xa127
jmp 0xa217
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0xa14e
movl -0x28(%rbp), %esi
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movzwl 0xd90(%rax,%rcx,4), %edx
addl %esi, %edx
movw %dx, 0xd90(%rax,%rcx,4)
jmp 0xa1c8
cmpl $0x0, -0x20(%rbp)
je 0xa190
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0xa178
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movw 0xd90(%rax,%rcx,4), %dx
addw $0x1, %dx
movw %dx, 0xd90(%rax,%rcx,4)
movq -0x8(%rbp), %rax
movw 0xdd0(%rax), %cx
addw $0x1, %cx
movw %cx, 0xdd0(%rax)
jmp 0xa1c6
cmpl $0xa, -0x28(%rbp)
jg 0xa1ae
movq -0x8(%rbp), %rax
movw 0xdd4(%rax), %cx
addw $0x1, %cx
movw %cx, 0xdd4(%rax)
jmp 0xa1c4
movq -0x8(%rbp), %rax
movw 0xdd8(%rax), %cx
addw $0x1, %cx
movw %cx, 0xdd8(%rax)
jmp 0xa1c6
jmp 0xa1c8
jmp 0xa1ca
movl $0x0, -0x28(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0xa1ed
movl $0x8a, -0x2c(%rbp)
movl $0x3, -0x30(%rbp)
jmp 0xa215
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0xa205
movl $0x6, -0x2c(%rbp)
movl $0x3, -0x30(%rbp)
jmp 0xa213
movl $0x7, -0x2c(%rbp)
movl $0x4, -0x30(%rbp)
jmp 0xa215
jmp 0xa217
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xa0e5
popq %rbp
retq
nopw (%rax,%rax)