// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x351b0
movq -0x10(%rbp), %rdi
callq 0x351d0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x35230
movq %rax, -0x30(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x35200
testb $0x1, %al
jne 0x59f15
jmp 0x5a047
leaq -0x20(%rbp), %rdi
callq 0x352a0
movl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jne 0x59f2e
jmp 0x5a033
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x354a0
movq %rax, %rdi
callq 0x35580
movq %rax, %rcx
movq -0x58(%rbp), %rax
cmpq %rcx, %rax
jae 0x59ffa
movq -0x8(%rbp), %rdi
addq $0x60, %rdi
leaq -0x34(%rbp), %rsi
callq 0x354a0
movq %rax, %rdi
movl -0x40(%rbp), %eax
movl %eax, %esi
callq 0x34d30
movzbl (%rax), %edi
callq 0x59b20
addl -0x38(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x354a0
movq %rax, %rdi
movl -0x40(%rbp), %eax
movl %eax, %esi
callq 0x34d30
movzbl (%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x60, %rdi
leaq -0x34(%rbp), %rsi
callq 0x354a0
movq %rax, %rdi
movl -0x40(%rbp), %eax
movl %eax, %esi
callq 0x34d30
movl -0x5c(%rbp), %edi
movzbl (%rax), %eax
andl %eax, %edi
callq 0x59b20
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x59f43
cmpl $0x0, -0x38(%rbp)
jle 0x5a031
movl -0x38(%rbp), %eax
movl -0x3c(%rbp), %edx
movl %eax, %ecx
subl %edx, %ecx
movl %ecx, -0x4c(%rbp)
fildl -0x4c(%rbp)
movl %eax, -0x50(%rbp)
fildl -0x50(%rbp)
fdivrp %st, %st(1)
fstpt -0x68(%rbp)
movq -0x18(%rbp), %rdi
movl -0x34(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0x34c70
fldt -0x68(%rbp)
fstpt (%rax)
jmp 0x5a033
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x35320
movq %rax, -0x48(%rbp)
jmp 0x59ef2
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)