// File: /workspace/github_cpp_makefile_star2_O2/adamiaonr[P]rid-analytics/src/prob.cpp
// Function: Prob::calc_lm_prob(unsigned char, unsigned char, Prob::fp_data*, std::vector<long double, std::allocator<long double>>*)
int Prob::calc_lm_prob(
    uint8_t i, 
    uint8_t t,
    Prob::fp_data * iface_fp_data,
    std::vector<__float080> * lmp) {

    // aux. arrays used in fp rate calculation:
    //  - P(|FP| =/= f) = (1.0 - P(|FP| = f)) : prob of not having an fp match of size f
    std::vector<__float080> log_prob_fp_neq(n, 0.0);
    //  - P(|FP| <= f) : prob of fp match smaller than or equal to f
    std::vector<__float080> log_prob_fp_smeq(n + 1, 0.0);

    if (iface_fp_data->is_blocked) { (*lmp)[0] = 1.0; return 0; }
    if (iface_fp_data->num_entries < 1.0) { (*lmp)[0] = 1.0; return 0; }

    // fill P(|FP| =/= f) = (1.0 - P(|FP| = f)), for all f
    std::vector<__float080> lt_ratios = std::vector<__float080>(n, 1.0);
    calc_log_prob_fp_neq(iface_fp_data, log_prob_fp_neq, lt_ratios);
    // calc P(|FP| <= f), for all f
    for (int f = (int) (this->n - 1); f >= 0; f--)
        log_prob_fp_smeq[f] = log_prob_fp_smeq[f + 1] + log_prob_fp_neq[f];

    for (int f = (int) this->n; f >= 0; f--) {

        _calc_lm_prob(
            f, t, 
            iface_fp_data, 
            &log_prob_fp_neq, &log_prob_fp_smeq,
            lmp);
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r8, %rbx
movq %rdi, %r15
fldt 0x90(%rdi)
flds 0x6f95(%rip)            # 0x2a7a0
fld %st(0)
fstpt 0x94(%rsp)
xorl %esi, %esi
fucomi %st(1), %st
setbe %sil
fldz
fld %st(0)
fld %st(1)
fstpt 0x88(%rsp)
fcmovbe %st(2), %st
fstp %st(2)
fxch %st(2)
fsubp %st, %st(1)
fnstcw 0xa(%rsp)
movzwl 0xa(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0x14(%rsp)
fldcw 0x14(%rsp)
movq %rcx, %r14
movl %edx, %ebp
fistpll 0x60(%rsp)
fldcw 0xa(%rsp)
shlq $0x3f, %rsi
xorq 0x60(%rsp), %rsi
fstpt 0x40(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x18df8
fldt 0x90(%r15)
fld1
faddp %st, %st(1)
xorl %esi, %esi
fldt 0x94(%rsp)
fxch %st(1)
fucomi %st(1), %st
fldt 0x88(%rsp)
fld %st(0)
fcmovnb %st(3), %st
fstp %st(3)
fxch %st(1)
fsubp %st, %st(2)
setae %sil
fnstcw 0x8(%rsp)
movzwl 0x8(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0x12(%rsp)
fldcw 0x12(%rsp)
fxch %st(1)
fistpll 0x68(%rsp)
fldcw 0x8(%rsp)
shlq $0x3f, %rsi
xorq 0x68(%rsp), %rsi
fstpt 0x20(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
callq 0x18df8
cmpb $0x1, 0xb8(%r14)
jne 0x238f9
movq (%rbx), %rax
fld1
jmp 0x23908
fldt 0x10(%r14)
fld1
fucomi %st(1), %st
fstp %st(1)
jbe 0x2390f
movq (%rbx), %rax
fstpt (%rax)
jmp 0x23a67
fstp %st(0)
fldt 0x90(%r15)
flds 0x6e82(%rip)            # 0x2a7a0
xorl %esi, %esi
fucomi %st(1), %st
setbe %sil
fldz
fcmovbe %st(1), %st
fstp %st(1)
fsubrp %st, %st(1)
fnstcw 0x6(%rsp)
movzwl 0x6(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0x10(%rsp)
fldcw 0x10(%rsp)
fistpll 0x58(%rsp)
fldcw 0x6(%rsp)
shlq $0x3f, %rsi
xorq 0x58(%rsp), %rsi
fld1
fstpt 0xa0(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
leaq 0x17(%rsp), %rcx
callq 0x18df8
leaq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x19582
leaq 0x70(%rsp), %r12
leaq 0xb0(%rsp), %r13
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x233e2
movq %r13, %rdi
callq 0x195d0
fldt 0x90(%r15)
fld1
fchs
faddp %st, %st(1)
fnstcw 0x4(%rsp)
movzwl 0x4(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0xe(%rsp)
fldcw 0xe(%rsp)
fistpl 0x1c(%rsp)
fldcw 0x4(%rsp)
movl 0x1c(%rsp), %eax
movq 0x40(%rsp), %rcx
leaq 0x10(%rcx), %rdx
movq (%r12), %rsi
testl %eax, %eax
js 0x23a04
movl %eax, %edi
shlq $0x4, %rdi
fldt (%rdx,%rdi)
fldt (%rsi,%rdi)
faddp %st, %st(1)
fstpt (%rcx,%rdi)
decl %eax
jmp 0x239eb
fldt 0x90(%r15)
fnstcw 0x2(%rsp)
movzwl 0x2(%rsp), %eax
orl $0xc00, %eax            # imm = 0xC00
movw %ax, 0xc(%rsp)
fldcw 0xc(%rsp)
fistpl 0x18(%rsp)
fldcw 0x2(%rsp)
movl 0x18(%rsp), %r15d
movzbl %bpl, %ebp
leaq 0x70(%rsp), %r12
leaq 0x40(%rsp), %r13
testl %r15d, %r15d
js 0x23a5d
movl %r15d, %edi
movl %ebp, %esi
movq %r14, %rdx
movq %r12, %rcx
movq %r13, %r8
movq %rbx, %r9
callq 0x2372a
decl %r15d
jmp 0x23a3d
leaq 0x20(%rsp), %rdi
callq 0x195d0
leaq 0x40(%rsp), %rdi
callq 0x195d0
leaq 0x70(%rsp), %rdi
callq 0x195d0
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x195d0
jmp 0x23aa1
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x195d0
jmp 0x23ab0
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x195d0
movq %rbx, %rdi
callq 0x4700