// File: /workspace/github_cpp_makefile_star2_O3/adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::run_rec(RID_Router*, unsigned char, Path_State*)
int RID_Analytics::run_rec(
    RID_Router * router,
    uint8_t in_iface,
    Path_State * prev_state) {

    std::cout << "\nRID_Analytics::run_rec() : forward operation by router : " 
        << router->get_id() << std::endl;

    uint8_t iface_num = router->get_iface_num();
    __float080 in_prob = prev_state->get_in_iface_prob();
    std::vector<__float080> * in_fptree_prob = prev_state->get_in_fptree_prob();
    // tree bitmask of the path tells us which sources are accessible over 
    // the followed path.
    std::map<int, std::vector<uint8_t> > * tree_bitmasks = prev_state->get_tree_bitmasks();

    // run the forward() operation on this router & collect: 
    //  - iface probs
    //  - event probs
    //  - out fp tree probs 
    std::vector<std::vector<__float080> > iface_probs(iface_num, std::vector<__float080> (3, 0.0));
    std::vector<std::vector<__float080> > out_fptree_probs(iface_num, std::vector<__float080> (this->request_size + 1, 0.0));
    router->forward(
        in_iface,           // INPUTS
        tree_bitmasks,
        in_prob,
        in_fptree_prob,
        iface_probs,        // OUTPUTS
        out_fptree_probs);

    // make fwd decisions
    std::vector<RID_Analytics::fwd_decision> fwd_decisions;
    make_fwd_decision(router, prev_state, in_iface, iface_probs, out_fptree_probs, fwd_decisions);
    // recursively call run_rec() to resume fwd decisions
    for (unsigned int k = 0; k < fwd_decisions.size(); k++) {

        std::cout << "RID_Analytics::run_rec() : [INFO] on router[" << router->get_id() 
            << "], forwarding to router[" << fwd_decisions[k].next_router->get_id() 
            << "], ttl = " << (int) fwd_decisions[k].state->get_ttl() << std::endl;

        run_rec(fwd_decisions[k].next_router, fwd_decisions[k].in_iface, fwd_decisions[k].state);
    }

    delete prev_state;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, 0x60(%rsp)
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, 0x68(%rsp)
movq 0x179e4(%rip), %rbx     # 0x3efb8
leaq 0x9cba(%rip), %rsi      # 0x31295
movl $0x3a, %edx
movq %rbx, %rdi
callq 0x4400
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x1bdb4
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x4400
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42a0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2765f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43a0
movzbl 0x24(%r14), %ebp
movq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x1ef86
fstpt 0xcc(%rsp)
movq %rbx, %rdi
callq 0x1ef74
movq %rax, %r12
movq %rbx, %rdi
callq 0x1efb0
movq %rax, %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x30, %edi
callq 0x4390
movq %rax, 0x10(%rsp)
movq %rax, %rcx
addq $0x30, %rcx
movq %rcx, 0x20(%rsp)
xorl %edx, %edx
fldz
fld %st(0)
fstpt (%rax,%rdx)
addq $0x10, %rdx
cmpq $0x30, %rdx
jne 0x276be
fstp %st(0)
leaq 0x10(%rsp), %rdx
movq %rcx, 0x8(%rdx)
leaq 0xb0(%rsp), %rdi
leaq 0x70(%rsp), %rcx
movq %rbp, %rsi
callq 0x1dca0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27704
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
movq 0x68(%rsp), %rax
movzbl (%rax), %esi
incq %rsi
fldz
fstpt 0x70(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x70(%rsp), %rdx
leaq 0x40(%rsp), %rbx
movq %rbx, %rcx
callq 0x1d906
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x3f(%rsp), %rcx
movq %rbp, %rsi
callq 0x1dca0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2775d
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
fldt 0xcc(%rsp)
fstpt (%rsp)
movzbl %r15b, %ebp
leaq 0xb0(%rsp), %r8
leaq 0x98(%rsp), %r9
movq %r14, %rdi
movl %ebp, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0x1cb74
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x2835c
leaq 0xd8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x2835c
movq %rbx, (%rsp)
leaq 0xf0(%rsp), %r8
leaq 0xd8(%rsp), %r9
movq 0x68(%rsp), %rdi
movq %r14, %rsi
movq 0x60(%rsp), %rdx
movl %ebp, %ecx
callq 0x263a4
leaq 0xd8(%rsp), %rdi
callq 0x1dd38
leaq 0xf0(%rsp), %rdi
callq 0x1dd38
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x2798e
movl $0x1, %ebp
leaq 0x80(%rsp), %r13
xorl %r15d, %r15d
movq 0x17789(%rip), %r12     # 0x3efb8
movl $0x2c, %edx
movq %r12, %rdi
leaq 0x9a92(%rip), %rsi      # 0x312d0
callq 0x4400
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x1bdb4
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r12, %rdi
callq 0x4400
movq %rax, %rbx
movl $0x18, %edx
movq %rax, %rdi
leaq 0x9a78(%rip), %rsi      # 0x312fd
callq 0x4400
movq 0x40(%rsp), %rax
shlq $0x5, %r15
movq 0x8(%rax,%r15), %rax
movq %r13, 0x70(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x70(%rsp), %rdi
callq 0x1bdb4
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq %rbx, %rdi
callq 0x4400
movq %rax, %rbx
movl $0x9, %edx
movq %rax, %rdi
leaq 0x9a41(%rip), %rsi      # 0x31316
callq 0x4400
movq 0x40(%rsp), %rax
movq 0x18(%rax,%r15), %rdi
callq 0x1efc0
movq %rbx, %rdi
movl %eax, %esi
callq 0x46d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4370
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x42a0
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x27937
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x27953
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x40(%rsp), %rax
movzbl 0x14(%rax,%r15), %edx
movq 0x8(%rax,%r15), %rsi
movq 0x18(%rax,%r15), %rcx
movq 0x68(%rsp), %rdi
callq 0x275ac
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
movl %ebp, %r15d
sarq $0x5, %rax
incl %ebp
cmpq %r15, %rax
ja 0x2782f
movq 0x60(%rsp), %rbx
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x279a8
movq 0x60(%rbx), %rsi
subq %rdi, %rsi
callq 0x43a0
movl $0x90, %esi
movq %rbx, %rdi
callq 0x43a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x279cc
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
leaq 0x98(%rsp), %rdi
callq 0x1dd38
leaq 0xb0(%rsp), %rdi
callq 0x1dd38
xorl %eax, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x1dd38
jmp 0x27a0f
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x1dd38
jmp 0x27ae8
jmp 0x27aaa
movq %rax, %rbx
jmp 0x27aff
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27b0c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
jmp 0x27b0c
movq %rax, %rbx
jmp 0x27b0c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x27b19
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
jmp 0x27a9a
movq %rax, %rbx
jmp 0x27b19
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x27b19
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43a0
jmp 0x27b19
jmp 0x27aaa
jmp 0x27aa5
movq %rax, %rbx
jmp 0x27acc
movq %rax, %rbx
jmp 0x27ae8
movq %rax, %rbx
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x27acc
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x27ae8
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x43a0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x27aff
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x43a0
leaq 0x98(%rsp), %rdi
callq 0x1dd38
leaq 0xb0(%rsp), %rdi
callq 0x1dd38
movq %rbx, %rdi
callq 0x4700
nop