// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/zlib1.3.1/trees.c
// Function: send_tree
local void send_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 */

    /* 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++) {
        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, %r13d
cmovel %eax, %r13d
addl $0x3, %ecx
movslq %edx, %rdx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r11d, %r11d
movl $0x10, %r8d
movl %eax, %r10d
movl %eax, %ebp
movl %eax, %r12d
cmpq %rdx, %r11
jg 0x48b3d
movl %r9d, %r15d
movl %ebp, %eax
movzwl 0x6(%rsi,%r11,4), %r9d
incq %r11
leal 0x2(%r12), %ebp
incl %r12d
cmpl %r13d, %ebp
jge 0x486a8
leal -0x1(%rax), %ebp
cmpl %r9d, %r15d
je 0x4867c
leal 0x1(%r12), %ebp
movl %r15d, %r13d
cmpl %ecx, %ebp
jge 0x48750
movl 0x1734(%rdi), %ecx
movzwl 0xabe(%rdi,%r13,4), %r10d
movl %r8d, %ebx
subl %r10d, %ebx
movzwl 0xabc(%rdi,%r13,4), %ebp
movl %ebp, %r12d
shll %cl, %r12d
orw 0x1730(%rdi), %r12w
movw %r12w, 0x1730(%rdi)
cmpl %ebx, %ecx
jle 0x4873a
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %r12b, (%rcx,%rbx)
movb 0x1731(%rdi), %cl
movq 0x10(%rdi), %rbx
movq 0x28(%rdi), %r14
leaq 0x1(%r14), %r12
movq %r12, 0x28(%rdi)
movb %cl, (%rbx,%r14)
movl 0x1734(%rdi), %ebx
movb $0x10, %cl
subb %bl, %cl
shrl %cl, %ebp
movw %bp, 0x1730(%rdi)
leal (%r10,%rbx), %ecx
addl $-0x10, %ecx
jmp 0x4873d
addl %r10d, %ecx
movl %ecx, 0x1734(%rdi)
incl %eax
jne 0x486be
jmp 0x48b06
movl 0x1734(%rdi), %eax
testl %r15d, %r15d
je 0x4876c
cmpl %r10d, %r15d
jne 0x487f3
movl %ebp, %r12d
jmp 0x488f1
movzwl 0x1730(%rdi), %r13d
cmpl $0x9, %r12d
ja 0x48873
movzwl 0xb02(%rdi), %r10d
movzwl 0xb00(%rdi), %ebp
movl %ebp, %ebx
movl %eax, %ecx
shll %cl, %ebx
movl %r8d, %ecx
subl %r10d, %ecx
orl %ebx, %r13d
cmpl %ecx, %eax
jle 0x489f1
movw %r13w, 0x1730(%rdi)
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
addl %r10d, %eax
addl $-0x10, %eax
movl %ebp, %r13d
jmp 0x489f4
movzwl 0xabe(%rdi,%r13,4), %r10d
movl %r8d, %ebx
subl %r10d, %ebx
movzwl 0xabc(%rdi,%r13,4), %ebp
movl %ebp, %r13d
movl %eax, %ecx
shll %cl, %r13d
orw 0x1730(%rdi), %r13w
movw %r13w, 0x1730(%rdi)
cmpl %ebx, %eax
jle 0x488e8
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
movw %bp, 0x1730(%rdi)
addl %r10d, %eax
addl $-0x10, %eax
jmp 0x488eb
movzwl 0xb06(%rdi), %r10d
movzwl 0xb04(%rdi), %ebp
movl %ebp, %ebx
movl %eax, %ecx
shll %cl, %ebx
movl %r8d, %ecx
subl %r10d, %ecx
orl %ebx, %r13d
cmpl %ecx, %eax
jle 0x48a68
movw %r13w, 0x1730(%rdi)
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
addl %r10d, %eax
addl $-0x10, %eax
movl %ebp, %r13d
jmp 0x48a6b
addl %r10d, %eax
movl %eax, 0x1734(%rdi)
movzwl 0xafe(%rdi), %r10d
movl %r8d, %ebx
movzwl 0xafc(%rdi), %ebp
movl %ebp, %r13d
movl %eax, %ecx
shll %cl, %r13d
subl %r10d, %ebx
orw 0x1730(%rdi), %r13w
cmpl %ebx, %eax
jle 0x48966
movw %r13w, 0x1730(%rdi)
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %ebp
addl %r10d, %eax
addl $-0x10, %eax
movl %ebp, %r13d
jmp 0x48969
addl %r10d, %eax
movl %eax, 0x1734(%rdi)
addl $0xfffd, %r12d          # imm = 0xFFFD
cmpl $0xf, %eax
jl 0x489d9
movzwl %r12w, %r10d
movl %eax, %ecx
shll %cl, %r12d
orl %r12d, %r13d
movw %r13w, 0x1730(%rdi)
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r10d
movw %r10w, 0x1730(%rdi)
addl $-0xe, %eax
jmp 0x48b00
movl %eax, %ecx
shll %cl, %r12d
orl %r12d, %r13d
movw %r13w, 0x1730(%rdi)
addl $0x2, %eax
jmp 0x48b00
addl %r10d, %eax
movl %eax, 0x1734(%rdi)
addl $0xfffe, %r12d          # imm = 0xFFFE
cmpl $0xe, %eax
jl 0x48ad8
movzwl %r12w, %r10d
movl %eax, %ecx
shll %cl, %r12d
orl %r12d, %r13d
movw %r13w, 0x1730(%rdi)
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r10d
movw %r10w, 0x1730(%rdi)
addl $-0xd, %eax
jmp 0x48b00
addl %r10d, %eax
movl %eax, 0x1734(%rdi)
addl $0xfff6, %r12d          # imm = 0xFFF6
cmpl $0xa, %eax
jl 0x48aed
movzwl %r12w, %r10d
movl %eax, %ecx
shll %cl, %r12d
orl %r12d, %r13d
movw %r13w, 0x1730(%rdi)
movq 0x10(%rdi), %rax
movq 0x28(%rdi), %rcx
leaq 0x1(%rcx), %rbx
movq %rbx, 0x28(%rdi)
movb %r13b, (%rax,%rcx)
movb 0x1731(%rdi), %al
movq 0x10(%rdi), %rcx
movq 0x28(%rdi), %rbx
leaq 0x1(%rbx), %r14
movq %r14, 0x28(%rdi)
movb %al, (%rcx,%rbx)
movl 0x1734(%rdi), %eax
movb $0x10, %cl
subb %al, %cl
shrl %cl, %r10d
movw %r10w, 0x1730(%rdi)
addl $-0x9, %eax
jmp 0x48b00
movl %eax, %ecx
shll %cl, %r12d
orl %r12d, %r13d
movw %r13w, 0x1730(%rdi)
addl $0x3, %eax
jmp 0x48b00
movl %eax, %ecx
shll %cl, %r12d
orl %r12d, %r13d
movw %r13w, 0x1730(%rdi)
addl $0x7, %eax
movl %eax, 0x1734(%rdi)
xorl %r13d, %r13d
cmpl %r9d, %r15d
sete %r13b
movl $0x4, %ecx
subl %r13d, %ecx
xorl $0x7, %r13d
testl %r9d, %r9d
movl $0x3, %eax
cmovel %eax, %ecx
movl $0x8a, %eax
cmovel %eax, %r13d
movl %r15d, %r10d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x48677
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq