// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/encoding/../maniac/compound_enc.h
// Function: PropertySymbolCoder<SimpleBitChance, RacDummy<DummyIO>, 15>::simplify_subtree(int, int, int, int)
long long int simplify_subtree(int pos, int divisor, int min_size, int indent) {
        PropertyDecisionNode &n = inner_node[pos];
        if (n.property == -1) {
            for (int i=0;i<indent;i++) v_printf(10,"  ");
            v_printf(10,"* leaf: count=%lli, size=%llu bits, bits per int: %f\n", (long long int)leaf_node[n.childID].count, (unsigned long long int)leaf_node[n.childID].realSize/5461, (leaf_node[n.childID].count > 0 ? leaf_node[n.childID].realSize/leaf_node[n.childID].count*1.0/5461 : -1));
/*
            if (leaf_node[n.childID].count > 100) {
            for (int i=0;i<indent;i++) v_printf(10,"  ");
            v_printf(10,"  chances: ");
            v_printf(10," zero=%i",leaf_node[n.childID].realChances.bit_zero);
            v_printf(10," sign=%i",leaf_node[n.childID].realChances.bit_sign);
            for (int i=0; i<5; i++)
            v_printf(10," exp%i=%i",i,leaf_node[n.childID].realChances.bit_exp[i]);
            v_printf(10," mant=");
            for (int i=0; i<8; i++)
            v_printf(10,"%i ",leaf_node[n.childID].realChances.bit_mant[i]);
            v_printf(10,"\n");
            }
*/
            if (leaf_node[n.childID].count == 0) return -100; // avoid empty leafs by giving them an extra penalty
            return leaf_node[n.childID].count;


        } else {
            for (int i=0;i<indent;i++) v_printf(10,"  ");
            v_printf(10,"* test: property %i, value > %i ?\n", n.property, n.splitval);
            long long int subtree_size = 0;
            subtree_size += simplify_subtree(n.childID, divisor, min_size, indent+1);
            subtree_size += simplify_subtree(n.childID+1, divisor, min_size, indent+1);
/*
            n.count /= divisor;
            n.count = pow(n.count,CONTEXT_TREE_COUNT_POWER);
            if (n.count > CONTEXT_TREE_MAX_COUNT) {
               n.count = CONTEXT_TREE_MAX_COUNT;
            }
            if (n.count < CONTEXT_TREE_MIN_COUNT_ENCODER) n.count=CONTEXT_TREE_MIN_COUNT_ENCODER;
            if (n.count < CONTEXT_TREE_MIN_COUNT) n.count=CONTEXT_TREE_MIN_COUNT;
            if (n.count > 0xf) n.count &= 0xfff8; // remove some lsb entropy
//            assert(n.count == -1);
//            printf("%li COUNT\n",n.count);
*/
            if (subtree_size < min_size) {
                for (int i=0;i<indent;i++) v_printf(11,"  ");
                v_printf(11,"[PRUNING THE ABOVE SUBTREE]\n");
                n.property = -1; // procedure is destructive because the childID is not set
                kill_children(n.childID);
            }
//            else v_printf(9,"PROPERTY %i\n",n.property);
            return subtree_size;
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x4050(%rdi), %rax
movslq %esi, %rsi
movq (%rax), %rax
xorl %r15d, %r15d
testl %r8d, %r8d
cmovgl %r8d, %r15d
movq %rsi, 0x18(%rsp)
movq %rax, 0x10(%rsp)
cmpw $-0x1, (%rax,%rsi,8)
je 0x149cc
movl %r8d, %r14d
movl %ecx, 0x24(%rsp)
movl %edx, 0xc(%rsp)
movq %rbx, 0x30(%rsp)
leaq 0x924b(%rip), %r12      # 0x1db59
pushq $0xa
popq %r13
movl %r15d, %ebx
subl $0x1, %ebx
jb 0x14929
movl %r13d, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x16c30
jmp 0x14915
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r13
movswl (%r13,%rbx,8), %edx
movl 0x4(%r13,%rbx,8), %ecx
leaq 0xa259(%rip), %rsi      # 0x1eb9e
pushq $0xa
popq %rdi
xorl %eax, %eax
callq 0x16c30
movzwl 0x2(%r13,%rbx,8), %esi
incl %r14d
movq 0x30(%rsp), %rbp
movq %rbp, %rdi
movl 0xc(%rsp), %edx
movl 0x24(%rsp), %r12d
movl %r12d, %ecx
movl %r14d, %r8d
callq 0x148ba
movq %rax, 0x28(%rsp)
movzwl 0x2(%r13,%rbx,8), %esi
movq %rbp, %r13
incl %esi
movq %rbp, %rdi
movl 0xc(%rsp), %edx
movl %r12d, %ecx
movl %r14d, %r8d
callq 0x148ba
movq %rax, %r14
addq 0x28(%rsp), %r14
movslq %r12d, %rax
cmpq %rax, %r14
jge 0x14ad9
leaq 0x91a8(%rip), %rbx      # 0x1db59
pushq $0xb
popq %rbp
subl $0x1, %r15d
jb 0x14a5c
movl %ebp, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x16c30
jmp 0x149b4
leaq 0x9186(%rip), %r14      # 0x1db59
pushq $0xa
popq %rbp
subl $0x1, %r15d
jb 0x149ea
movl %ebp, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x16c30
jmp 0x149d6
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movzwl 0x2(%rcx,%rax,8), %eax
movq 0x4038(%rbx), %rdx
imulq $0x98, %rax, %rax
movslq 0x90(%rdx,%rax), %rcx
movq 0x58(%rdx,%rax), %rsi
movl $0x1555, %edi           # imm = 0x1555
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movq %rax, %r8
testq %rcx, %rcx
jle 0x14a8b
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %xmm1
punpckldq 0x9902(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x990a(%rip), %xmm1     # 0x1e350
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0x99ae(%rip), %xmm0     # 0x1e408
jmp 0x14a93
leaq 0xa15e(%rip), %rsi      # 0x1ebc1
pushq $0xb
popq %rdi
xorl %eax, %eax
callq 0x16c30
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
orw $-0x1, (%rcx,%rax,8)
movzwl 0x2(%rcx,%rax,8), %esi
movq %r13, %rdi
callq 0x14aec
jmp 0x14ad9
movsd 0x996d(%rip), %xmm0     # 0x1e400
leaq 0xa0ce(%rip), %rsi      # 0x1eb68
pushq $0xa
popq %rdi
movq %rcx, %rdx
movq %r8, %rcx
movb $0x1, %al
callq 0x16c30
movq 0x18(%rsp), %rax
movq 0x10(%rsp), %rcx
movzwl 0x2(%rcx,%rax,8), %eax
movq 0x4038(%rbx), %rcx
imulq $0x98, %rax, %rax
movl 0x90(%rcx,%rax), %eax
testl %eax, %eax
pushq $-0x64
popq %rcx
cmovnel %eax, %ecx
movslq %ecx, %r14
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop