// File: /workspace/github_cpp_makefile_star2_O3/adamiaonr[P]rid-analytics/src/prob.cpp
// Function: local_tree_ratios(Prob::fp_data*, std::map<int, std::vector<unsigned char, std::allocator<unsigned char>>, std::less<int>, std::allocator<std::pair<int const, std::vector<unsigned char, std::allocator<unsigned char>>>>>*, std::vector<long double, std::allocator<long double>>&)
void local_tree_ratios(
    Prob::fp_data * iface_fp_data,
    std::map<int, std::vector<uint8_t> > * tree_bitmasks,
    std::vector<__float080> & lt_ratios) {

    std::map<int, std::vector<uint8_t> >::iterator itr;
    for (itr = (*tree_bitmasks).begin(); itr != (*tree_bitmasks).end(); itr++) {

        // isolate the tree size
        int t = itr->first;
        // skip 'union' of tree bitmasks
        if (t == 0) continue;
        // count trees & shared trees which pass through iface
        int trees = 0, shared_trees = 0;
        for (unsigned int k = 0; k < (*tree_bitmasks)[t].size(); k++) {
            trees += count_set_bits((int) iface_fp_data->tree_bitmasks[t][k]);
            shared_trees += count_set_bits((int) (((*tree_bitmasks)[t][k]) & (iface_fp_data->tree_bitmasks[t][k])));
        }

        if (trees > 0)
            lt_ratios[t - 1] = (__float080) (trees - shared_trees) / (__float080) (trees);
        // std::cout << "\t [# trees] : " << trees
        //     << "\n\t [# shared trees] : " << shared_trees
        //     << "\n\t [lt ratios[" << (t) << "]] : " << lt_ratios[t - 1] << std::endl;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
movq 0x18(%rsi), %r12
leaq 0x8(%rsi), %r15
cmpq %r15, %r12
je 0x29d6f
movq %rsi, %r14
addq $0x60, 0x8(%rsp)
leaq 0x4(%rsp), %r13
movq %r15, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
movl 0x20(%r12), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x29d5b
movq %r14, %rdi
movq %r13, %rsi
callq 0x1db98
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x29d5b
movq %r12, 0x28(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x1db98
movq (%rax), %rax
movzbl (%rax,%r12), %eax
movl $0x0, %r15d
testl %eax, %eax
je 0x29cb5
xorl %r15d, %r15d
leal 0x7fffffff(%rax), %ecx
incl %r15d
andl %eax, %ecx
movl %ecx, %eax
jne 0x29ca6
movq %r14, %rdi
leaq 0x4(%rsp), %r13
movq %r13, %rsi
callq 0x1db98
movq (%rax), %rax
movzbl (%rax,%r12), %r14d
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x1db98
movq (%rax), %rax
movzbl (%rax,%r12), %ecx
xorl %eax, %eax
andl %r14d, %ecx
je 0x29cf7
leal 0x7fffffff(%rcx), %edx
incl %eax
andl %ecx, %edx
movl %edx, %ecx
jne 0x29ce9
addl %eax, %ebp
addl %r15d, %ebx
incl %r12d
movq 0x30(%rsp), %r14
movq %r14, %rdi
leaq 0x4(%rsp), %r13
movq %r13, %rsi
callq 0x1db98
movq 0x8(%rax), %rcx
subq (%rax), %rcx
cmpq %r12, %rcx
ja 0x29c84
testl %ebx, %ebx
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %r12
jle 0x29d5b
movl %ebx, %eax
subl %ebp, %eax
movl %eax, 0x14(%rsp)
fildl 0x14(%rsp)
movl %ebx, 0x10(%rsp)
fidivl 0x10(%rsp)
movslq 0x4(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
shlq $0x4, %rax
fstpt -0x10(%rcx,%rax)
movq %r12, %rdi
callq 0x42b0
movq %rax, %r12
cmpq %r15, %rax
jne 0x29c4f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq