// File: /workspace/github_c_makefile_star2_O2/snej[P]zdelta/trees.c
// Function: send_tree
local void send_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 */

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

  for (n = 0; n <= max_code; n++) {
    Tracevv((stderr, "code: %3u len: %3u\n", n, tree[n].Len));
    curlen = nextlen; nextlen = tree[n+1].Len;
    if (++count < max_count && curlen == nextlen) {
      continue;
    } else if (count < min_count) {
      do { send_code(s, curlen, s->bl_tree); 
      } while (--count != 0);
      
    } else if (curlen != 0) {
      if (curlen != prevlen) {
	send_code(s, curlen, s->bl_tree); count--; 
      }
      Assert(count >= 3 && count <= 6, " 3_6?");
      send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
    } else if (count <= 10) {
      send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
    } else {
      send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
    }

    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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movzwl 0x2(%rsi), %r9d
xorl %ecx, %ecx
testl %r9d, %r9d
setne %cl
movl $0x8a, %eax
movl $0x7, %r12d
cmovel %eax, %r12d
addl $0x3, %ecx
movslq %edx, %rdx
addq $0x6, %rsi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r10d, %r10d
movl $0x10, %r8d
leaq (%rsi,%r10,4), %rbx
xorl %r15d, %r15d
movl %r9d, %r14d
leaq (%r10,%r15), %r9
cmpq %rdx, %r9
jg 0x6022
movq %r15, %rax
movzwl (%rbx,%r15,4), %r9d
incq %r15
cmpl %r12d, %r15d
jge 0x5b64
cmpl %r9d, %r14d
je 0x5b3f
movl %r14d, %r12d
cmpl %ecx, %r15d
jge 0x5c0e
movl 0x1a74(%rdi), %ecx
notl %eax
movzwl 0xd92(%rdi,%r12,4), %r13d
movl %r8d, %r11d
subl %r13d, %r11d
movzwl 0xd90(%rdi,%r12,4), %ebx
movl %ebx, %ebp
shll %cl, %ebp
orw 0x1a70(%rdi), %bp
movw %bp, 0x1a70(%rdi)
cmpl %r11d, %ecx
jle 0x5bf8
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r11
leal 0x1(%r11), %r8d
movl %r8d, 0x28(%rdi)
movb %bpl, (%rcx,%r11)
movb 0x1a71(%rdi), %cl
movq 0x10(%rdi), %r8
movslq 0x28(%rdi), %r11
leal 0x1(%r11), %ebp
movl %ebp, 0x28(%rdi)
movb %cl, (%r8,%r11)
movl 0x1a74(%rdi), %r8d
movb $0x10, %cl
subb %r8b, %cl
shrl %cl, %ebx
movw %bx, 0x1a70(%rdi)
leal (%r8,%r13), %ecx
addl $-0x10, %ecx
movl $0x10, %r8d
jmp 0x5bfb
addl %r13d, %ecx
movl %ecx, 0x1a74(%rdi)
incl %eax
jne 0x5b78
jmp 0x5fed
leaq -0x1(%r15), %r13
movl 0x1a74(%rdi), %eax
testl %r14d, %r14d
je 0x5c2e
cmpl %ebp, %r14d
jne 0x5cba
movl %r15d, %r13d
jmp 0x5dc0
movzwl 0x1a70(%rdi), %r12d
cmpl $0x9, %r13d
ja 0x5d38
movzwl 0xdd6(%rdi), %r13d
movzwl 0xdd4(%rdi), %ebp
movl %ebp, %r8d
movl %eax, %ecx
shll %cl, %r8d
movl $0x10, %ecx
subl %r13d, %ecx
orl %r8d, %r12d
cmpl %ecx, %eax
jle 0x5ec4
movw %r12w, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r8d
movl %r8d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r8)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
addl %r13d, %eax
addl $-0x10, %eax
movl %ebp, %r12d
jmp 0x5ec7
movzwl 0xd92(%rdi,%r12,4), %ebp
subl %ebp, %r8d
movzwl 0xd90(%rdi,%r12,4), %ebx
movl %ebx, %r12d
movl %eax, %ecx
shll %cl, %r12d
orw 0x1a70(%rdi), %r12w
movw %r12w, 0x1a70(%rdi)
cmpl %r8d, %eax
jle 0x5db2
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r8d
movl %r8d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r8)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebx
movw %bx, 0x1a70(%rdi)
addl %ebp, %eax
addl $-0x10, %eax
jmp 0x5db4
movzwl 0xdda(%rdi), %r13d
movzwl 0xdd8(%rdi), %ebp
movl %ebp, %r8d
movl %eax, %ecx
shll %cl, %r8d
movl $0x10, %ecx
subl %r13d, %ecx
orl %r8d, %r12d
cmpl %ecx, %eax
jle 0x5f3b
movw %r12w, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r8d
movl %r8d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r8)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
addl %r13d, %eax
addl $-0x10, %eax
movl %ebp, %r12d
jmp 0x5f3e
addl %ebp, %eax
movl %eax, 0x1a74(%rdi)
movl $0x10, %r8d
movzwl 0xdd2(%rdi), %ebp
movzwl 0xdd0(%rdi), %ebx
movl %ebx, %r12d
movl %eax, %ecx
shll %cl, %r12d
subl %ebp, %r8d
orw 0x1a70(%rdi), %r12w
cmpl %r8d, %eax
jle 0x5e32
movw %r12w, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r8d
movl %r8d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r8)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebx
addl %ebp, %eax
addl $-0x10, %eax
movl %ebx, %r12d
jmp 0x5e34
addl %ebp, %eax
movl %eax, 0x1a74(%rdi)
cmpl $0xf, %eax
jl 0x5ea5
addl $-0x3, %r13d
movl %r13d, %r8d
movl %eax, %ecx
shll %cl, %r8d
orl %r8d, %r12d
movw %r12w, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r8d
movl %r8d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r8
leal 0x1(%r8), %r11d
movl %r11d, 0x28(%rdi)
movb %al, (%rcx,%r8)
movzwl %r13w, %r8d
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
addl $-0xe, %eax
jmp 0x5fe1
addl $0xfffd, %r13d          # imm = 0xFFFD
movl %eax, %ecx
shll %cl, %r13d
orl %r13d, %r12d
movw %r12w, 0x1a70(%rdi)
addl $0x2, %eax
jmp 0x5fe1
addl %r13d, %eax
movl %eax, 0x1a74(%rdi)
cmpl $0xe, %eax
jl 0x5fab
leal -0x3(%r15), %ecx
movzwl %cx, %r8d
movl %ecx, %r11d
movl %eax, %ecx
shll %cl, %r11d
orl %r11d, %r12d
movw %r12w, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r11d
movl %r11d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r11
leal 0x1(%r11), %ebx
movl %ebx, 0x28(%rdi)
movb %al, (%rcx,%r11)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
addl $-0xd, %eax
jmp 0x5fe1
addl %r13d, %eax
movl %eax, 0x1a74(%rdi)
cmpl $0xa, %eax
jl 0x5fc7
leal -0xb(%r15), %ecx
movzwl %cx, %r8d
movl %ecx, %r11d
movl %eax, %ecx
shll %cl, %r11d
orl %r11d, %r12d
movw %r12w, 0x1a70(%rdi)
movq 0x10(%rdi), %rax
movslq 0x28(%rdi), %rcx
leal 0x1(%rcx), %r11d
movl %r11d, 0x28(%rdi)
movb %r12b, (%rax,%rcx)
movb 0x1a71(%rdi), %al
movq 0x10(%rdi), %rcx
movslq 0x28(%rdi), %r11
leal 0x1(%r11), %ebx
movl %ebx, 0x28(%rdi)
movb %al, (%rcx,%r11)
movl 0x1a74(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r8d
movw %r8w, 0x1a70(%rdi)
addl $-0x9, %eax
jmp 0x5fe1
leal 0xfffd(%r15), %r8d
movl %eax, %ecx
shll %cl, %r8d
orl %r8d, %r12d
movw %r12w, 0x1a70(%rdi)
addl $0x3, %eax
jmp 0x5fe1
leal 0xfff5(%r15), %r8d
movl %eax, %ecx
shll %cl, %r8d
orl %r8d, %r12d
movw %r12w, 0x1a70(%rdi)
addl $0x7, %eax
movl $0x10, %r8d
movl %eax, 0x1a74(%rdi)
addq %r15, %r10
xorl %r12d, %r12d
cmpl %r9d, %r14d
sete %r12b
movl $0x4, %ecx
subl %r12d, %ecx
xorl $0x7, %r12d
testl %r9d, %r9d
movl $0x3, %eax
cmovel %eax, %ecx
movl $0x8a, %eax
cmovel %eax, %r12d
movl %r14d, %ebp
jmp 0x5b38
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)