// File: 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:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movl %edx, 0x60(%rsp)
movl %ecx, 0x5c(%rsp)
movl %r8d, 0x58(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x4050(%rax), %rdi
movslq 0x64(%rsp), %rsi
callq 0x30990
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movswl (%rax), %eax
cmpl $-0x1, %eax
jne 0x337ca
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x3361d
movl $0xa, %edi
leaq 0x13500(%rip), %rsi     # 0x46b09
movb $0x0, %al
callq 0x3a770
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x335f3
movq 0x30(%rsp), %rdi
addq $0x4038, %rdi           # imm = 0x4038
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
movq 0x30(%rsp), %rdi
movslq 0x90(%rax), %rax
movq %rax, 0x20(%rsp)
addq $0x4038, %rdi           # imm = 0x4038
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
movq 0x30(%rsp), %rdi
movq 0x58(%rax), %rax
movl $0x1555, %ecx           # imm = 0x1555
xorl %edx, %edx
divq %rcx
movq %rax, 0x28(%rsp)
addq $0x4038, %rdi           # imm = 0x4038
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
cmpl $0x0, 0x90(%rax)
jle 0x33737
movq 0x30(%rsp), %rdi
addq $0x4038, %rdi           # imm = 0x4038
movq %rdi, 0x8(%rsp)
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
movq 0x8(%rsp), %rdi
movq 0x58(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movslq 0x90(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %xmm0
movaps 0x13c34(%rip), %xmm1    # 0x47330
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x13c38(%rip), %xmm1    # 0x47340
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x12ac9(%rip), %xmm1    # 0x461e8
mulsd %xmm1, %xmm0
movsd 0x13bf5(%rip), %xmm1    # 0x47320
divsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0x33747
movsd 0x13bd9(%rip), %xmm0    # 0x47318
movsd %xmm0, 0x18(%rsp)
jmp 0x33747
movq 0x28(%rsp), %rcx
movq 0x20(%rsp), %rdx
movsd 0x18(%rsp), %xmm0
movl $0xa, %edi
leaq 0x14353(%rip), %rsi     # 0x47ab6
movb $0x1, %al
callq 0x3a770
movq 0x30(%rsp), %rdi
addq $0x4038, %rdi           # imm = 0x4038
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
cmpl $0x0, 0x90(%rax)
jne 0x3379d
movq $-0x64, 0x70(%rsp)
jmp 0x33902
movq 0x30(%rsp), %rdi
addq $0x4038, %rdi           # imm = 0x4038
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %eax
movl %eax, %esi
callq 0x309b0
movslq 0x90(%rax), %rax
movq %rax, 0x70(%rsp)
jmp 0x33902
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x337fc
movl $0xa, %edi
leaq 0x13321(%rip), %rsi     # 0x46b09
movb $0x0, %al
callq 0x3a770
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x337d2
movq 0x50(%rsp), %rax
movswl (%rax), %edx
movq 0x50(%rsp), %rax
movl 0x4(%rax), %ecx
movl $0xa, %edi
leaq 0x142d4(%rip), %rsi     # 0x47aec
movb $0x0, %al
callq 0x3a770
movq 0x30(%rsp), %rdi
movq $0x0, 0x40(%rsp)
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %esi
movl 0x60(%rsp), %edx
movl 0x5c(%rsp), %ecx
movl 0x58(%rsp), %r8d
addl $0x1, %r8d
callq 0x335a0
movq 0x30(%rsp), %rdi
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %esi
addl $0x1, %esi
movl 0x60(%rsp), %edx
movl 0x5c(%rsp), %ecx
movl 0x58(%rsp), %r8d
addl $0x1, %r8d
callq 0x335a0
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movslq 0x5c(%rsp), %rcx
cmpq %rcx, %rax
jge 0x338f8
movl $0x0, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x58(%rsp), %eax
jge 0x338c8
movl $0xb, %edi
leaq 0x13255(%rip), %rsi     # 0x46b09
movb $0x0, %al
callq 0x3a770
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x3389e
movl $0xb, %edi
leaq 0x1423b(%rip), %rsi     # 0x47b0f
movb $0x0, %al
callq 0x3a770
movq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rax
movw $0xffff, (%rax)         # imm = 0xFFFF
movq 0x50(%rsp), %rax
movzwl 0x2(%rax), %esi
callq 0x33910
movq 0x40(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nopl (%rax)