// File: /workspace/github_cpp_makefile_star2_O3/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
movl %r8d, %r14d
movq %rdi, %r12
movq 0x4050(%rdi), %rax
movslq %esi, %r15
movq (%rax), %rbx
movzwl (%rbx,%r15,8), %eax
cmpw $-0x1, %ax
je 0x1b171
movl %edx, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
movq %r12, 0x18(%rsp)
testl %r14d, %r14d
jle 0x1b095
leaq 0xab60(%rip), %r12      # 0x25bd9
movl %r14d, %r13d
movl $0xa, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1cede
decl %r13d
jne 0x1b07c
movzwl (%rbx,%r15,8), %eax
movswl %ax, %edx
movl 0x4(%rbx,%r15,8), %ecx
leaq 0xbb4a(%rip), %rsi      # 0x26bee
movl $0xa, %edi
xorl %eax, %eax
callq 0x1cede
movzwl 0x2(%rbx,%r15,8), %esi
leal 0x1(%r14), %r8d
movl %r8d, 0xc(%rsp)
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movl 0x10(%rsp), %r12d
movl %r12d, %edx
movl 0x14(%rsp), %r13d
movl %r13d, %ecx
callq 0x1b030
movq %rax, 0x30(%rsp)
movq %r15, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movzwl 0x2(%rbx,%r15,8), %esi
incl %esi
movq %rbp, %rdi
movl %r12d, %edx
movl %r13d, %ecx
movl 0xc(%rsp), %r8d
callq 0x1b030
movq %rax, %r15
addq 0x30(%rsp), %r15
movslq %r13d, %rax
cmpq %rax, %r15
jge 0x1b258
testl %r14d, %r14d
jle 0x1b13a
leaq 0xaab3(%rip), %r12      # 0x25bd9
movl $0xb, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1cede
decl %r14d
jne 0x1b126
leaq 0xbad0(%rip), %rsi      # 0x26c11
movl $0xb, %edi
xorl %eax, %eax
callq 0x1cede
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movw $0xffff, (%rcx,%rax,8)  # imm = 0xFFFF
movzwl 0x2(%rcx,%rax,8), %esi
movq 0x18(%rsp), %rdi
callq 0x1b26a
jmp 0x1b258
movq %r15, %r13
testl %r14d, %r14d
jle 0x1b194
leaq 0xaa59(%rip), %r15      # 0x25bd9
movl $0xa, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1cede
decl %r14d
jne 0x1b180
movq %r13, %r14
movzwl 0x2(%rbx,%r13,8), %eax
movq 0x4038(%r12), %rcx
imulq $0x98, %rax, %rdi
movq 0x58(%rcx,%rdi), %rsi
movabsq $-0x7ff9ffe7ff9ffe7f, %rdx # imm = 0x8006001800600181
movq %rsi, %rax
mulq %rdx
movslq 0x90(%rcx,%rdi), %r8
movq %rsi, %rcx
subq %rdx, %rcx
shrq %rcx
addq %rdx, %rcx
shrq $0xc, %rcx
testq %r8, %r8
jle 0x1b211
movq %rsi, %rax
xorl %edx, %edx
divq %r8
movq %rax, %xmm1
punpckldq 0xb1cd(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xb1d5(%rip), %xmm1     # 0x263d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
divsd 0xb249(%rip), %xmm0     # 0x26458
jmp 0x1b219
movsd 0xb237(%rip), %xmm0     # 0x26450
leaq 0xb998(%rip), %rsi      # 0x26bb8
movl $0xa, %edi
movq %r8, %rdx
movb $0x1, %al
callq 0x1cede
movzwl 0x2(%rbx,%r14,8), %eax
movq 0x4038(%r12), %rcx
imulq $0x98, %rax, %rax
movl 0x90(%rcx,%rax), %eax
testl %eax, %eax
movl $0xffffff9c, %ecx       # imm = 0xFFFFFF9C
cmovnel %eax, %ecx
movslq %ecx, %r15
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq