// File: /workspace/github_cpp_makefile_star2_O2/adamiaonr[P]rid-analytics/src/prob.cpp
// Function: Prob::calc_log_prob_fp_neq(Prob::fp_data*, std::vector<long double, std::allocator<long double>>&, std::vector<long double, std::allocator<long double>>)
void Prob::calc_log_prob_fp_neq(
    Prob::fp_data * iface_fp_data,
    std::vector<__float080> & log_prob_fp_neq,
    std::vector<__float080> lt_ratios) {

    // as a precaution, reset log_prob_fp_neq to 0.0
    std::fill(log_prob_fp_neq.begin(), log_prob_fp_neq.end(), 0.0);

    for (uint8_t f = 0; f < log_prob_fp_neq.size(); f++) {

        // total nr. of entries w/ size f
        __float080 num_entries = iface_fp_data->num_entries * iface_fp_data->f_distr[f] * lt_ratios[f];
        // std::cout << "Prob::calc_log_prob_fp_neq() : num_entries[" << f << "] = " 
        //     << num_entries << " (out of " << iface_fp_data->num_entries << ")" << std::endl;

        if (f == 0) {
            
            log_prob_fp_neq[f] += num_entries * log(1.0 - fp_rate(this->m, this->n, this->k, (__float080) (f + 1)));

        } else {

            // for entries w/ size f, we can have entries w/ |f\r| in the 
            // interval [1, f]. remember: the fp rates vary w/ |f\r|.
            __float080 subtotal_f_r = 0.0;
            // % of entries (of those w/ size = f) which have |f\r| <= f
            for (uint8_t j = 0; j <= f; j++) 
                subtotal_f_r += iface_fp_data->f_r_distr[j];

            for (uint8_t j = 0; j <= f; j++) {
                // total nr. of entries w/ size f and |f\r| = j
                __float080 num_fr_entries = (__float080) num_entries * (iface_fp_data->f_r_distr[j] / subtotal_f_r);
                // fp rate for size f, |f\r| = j
                log_prob_fp_neq[f] += num_fr_entries * log(1.0 - fp_rate(this->m, this->n, this->k, (__float080) (j + 1)));
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rcx, 0x58(%rsp)
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
movq %rax, %rdx
fldz
cmpq %rcx, %rdx
je 0x23419
fld %st(0)
fstpt (%rdx)
addq $0x10, %rdx
jmp 0x2340a
fstp %st(0)
movb $0x1, %dl
xorl %ebx, %ebx
subq %rax, %rcx
sarq $0x4, %rcx
cmpq %rbx, %rcx
jbe 0x23579
fldt 0x10(%r15)
movq 0x30(%r15), %rcx
movq %rbx, %r13
shlq $0x4, %r13
fldt (%rcx,%r13)
fmulp %st, %st(1)
movq 0x58(%rsp), %rcx
movq (%rcx), %rcx
fldt (%rcx,%r13)
fmulp %st, %st(1)
testq %rbx, %rbx
movb %dl, 0x47(%rsp)
fld %st(0)
fstpt 0x4c(%rsp)
je 0x23514
movzbl %dl, %ecx
shll $0x4, %ecx
movq 0x48(%r15), %rdx
xorl %esi, %esi
fldz
cmpq %rsi, %rcx
je 0x23483
fldt (%rdx,%rsi)
faddp %st, %st(1)
addq $0x10, %rsi
jmp 0x23473
xorl %ecx, %ecx
fld %st(0)
fstpt 0x60(%rsp)
movzbl %cl, %ebp
cmpq %rbp, %rbx
jb 0x23563
movq 0x48(%r15), %rax
movl %ebp, %ecx
shll $0x4, %ecx
fldt (%rax,%rcx)
fdivp %st, %st(1)
fmulp %st, %st(1)
fstpt 0x6c(%rsp)
fldt 0x80(%r12)
fldt 0x90(%r12)
fldt 0xa0(%r12)
movl %ebp, %eax
incl %eax
movl %eax, 0x48(%rsp)
fildl 0x48(%rsp)
fstpt 0x30(%rsp)
fstpt 0x20(%rsp)
fstpt 0x10(%rsp)
fstpt (%rsp)
callq 0x23378
fld1
fsubp %st, %st(1)
fstpt (%rsp)
callq 0x4200
fldt 0x60(%rsp)
movq (%r14), %rax
fldt (%rax,%r13)
fldt 0x6c(%rsp)
fmulp %st, %st(3)
faddp %st, %st(2)
fldt 0x4c(%rsp)
fxch %st(2)
fstpt (%rax,%r13)
leal 0x1(%rbp), %ecx
jmp 0x2348b
fstp %st(0)
fldt 0x80(%r12)
fldt 0x90(%r12)
fldt 0xa0(%r12)
fld1
fstpt 0x30(%rsp)
fstpt 0x20(%rsp)
fstpt 0x10(%rsp)
fstpt (%rsp)
callq 0x23378
fld1
fsubp %st, %st(1)
fstpt (%rsp)
callq 0x4200
movq (%r14), %rax
fldt (%rax)
fldt 0x4c(%rsp)
fmulp %st, %st(2)
faddp %st, %st(1)
fstpt (%rax)
fldz
fldz
fstp %st(1)
fstp %st(0)
incq %rbx
movb 0x47(%rsp), %dl
incb %dl
movq 0x8(%r14), %rcx
jmp 0x2341f
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq