// File: /workspace/github_cpp_makefile_star2_O1/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 0x74bf(%rip)            # 0x31800
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 0x78(%rsp)
fldcw 0xa(%rsp)
shlq $0x3f, %rsi
xorq 0x78(%rsp), %rsi
fstpt 0x40(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x20(%rsp), %rcx
callq 0x1ddb8
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 0x80(%rsp)
fldcw 0x8(%rsp)
shlq $0x3f, %rsi
xorq 0x80(%rsp), %rsi
fstpt 0x20(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
callq 0x1ddb8
cmpb $0x1, 0xb8(%r14)
jne 0x2a435
movq (%rbx), %rax
fld1
jmp 0x2a444
fldt 0x10(%r14)
fld1
fucomi %st(1), %st
fstp %st(1)
jbe 0x2a488
movq (%rbx), %rax
fstpt (%rax)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2a45d
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x2a474
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
xorl %eax, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
fstp %st(0)
fldt 0x90(%r15)
flds 0x7369(%rip)            # 0x31800
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 0x70(%rsp)
fldcw 0x6(%rsp)
shlq $0x3f, %rsi
xorq 0x70(%rsp), %rsi
fld1
fstpt 0xa0(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0xa0(%rsp), %rdx
leaq 0x17(%rsp), %rcx
callq 0x1ddb8
leaq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1e548
leaq 0x58(%rsp), %rdx
leaq 0xb0(%rsp), %r12
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x29e64
movq (%r12), %rdi
testq %rdi, %rdi
je 0x2a535
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
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), %edx
testl %edx, %edx
fldz
js 0x2a59a
fstp %st(0)
movq 0x40(%rsp), %rax
movq 0x58(%rsp), %rcx
movl %edx, %edx
movq %rdx, %rsi
shlq $0x4, %rsi
fldt 0x10(%rax,%rsi)
incq %rdx
fldt (%rcx,%rsi)
faddp %st, %st(1)
fld %st(0)
fstpt (%rax,%rsi)
addq $-0x10, %rsi
decq %rdx
jg 0x2a587
fstp %st(0)
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
testl %r15d, %r15d
js 0x2a5fc
movzbl %bpl, %ebp
leaq 0x58(%rsp), %r12
leaq 0x40(%rsp), %r13
movl %r15d, %edi
movl %ebp, %esi
movq %r14, %rdx
movq %r12, %rcx
movq %r13, %r8
movq %rbx, %r9
callq 0x2a261
leal -0x1(%r15), %eax
testl %r15d, %r15d
movl %eax, %r15d
jg 0x2a5da
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2a446
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
jmp 0x2a446
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2a63b
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
jmp 0x2a63b
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x2a657
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
jmp 0x2a657
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x2a66e
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq %rbx, %rdi
callq 0x4700