// File: adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::add_fwd_decision(RID_Router*, Path_State*, std::vector<std::vector<long double, std::allocator<long double>>, std::allocator<std::vector<long double, std::allocator<long double>>>>, int, long double, int, std::vector<RID_Analytics::fwd_decision, std::allocator<RID_Analytics::fwd_decision>>&)
int RID_Analytics::add_fwd_decision(
    RID_Router * router,
    Path_State * prev_state,
    std::vector<std::vector<__float080> > out_fptree_probs,
    int iface,
    __float080 path_prob,
    int latency_incr,
    std::vector<RID_Analytics::fwd_decision> & fwd_decisions) {

    Path_State * next_state = new Path_State(router, this->request_size);

    next_state->set_length(prev_state->get_length() + latency_incr);
    next_state->set_in_fptree_prob(&out_fptree_probs[iface], this->request_size);
    next_state->set_path_prob(path_prob);
    next_state->set_in_iface_prob(path_prob);
    next_state->set_ttl(prev_state->get_ttl() - 1);

    RID_Router::nw_address next_hop = router->get_next_hop(iface);
    next_state->set_tree_bitmasks(router->get_tree_bitmasks(iface));

    std::cout << "RID_Analytics::add_fwd_decision() : [INFO] saving fwd decision :"
        << "\n\tout[" << router->get_id() << "][" << iface << "] -> in[" << next_hop.router->get_id() << "][" << (int) next_hop.iface << "]"
        << "\n\tpath prob = " << path_prob
        << "\n\tpath length = " << prev_state->get_length() + latency_incr
        << "\n\tttl = " << (int) next_state->get_ttl() << std::endl;

    RID_Analytics::fwd_decision fd = {router, next_hop.router, iface, next_hop.iface, next_state};
    fwd_decisions.push_back(fd);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rcx, -0xe8(%rbp)
movq 0x20(%rbp), %rax
fldt 0x10(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
fstpt -0x40(%rbp)
movl %r9d, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movl $0x90, %edi
callq 0x54a0
movq %rax, %rdi
movq -0xe0(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0xd8(%rbp)
movq -0x10(%rbp), %rsi
movzbl (%rax), %edx
callq 0x3f4b0
jmp 0x4f14b
movq -0xd8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3f5c0
movq -0x120(%rbp), %rdi
movl %eax, %esi
movl -0x44(%rbp), %eax
addl %eax, %esi
callq 0x3f5a0
movq -0xe8(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x118(%rbp)
movslq -0x24(%rbp), %rsi
callq 0x358a0
movq -0x118(%rbp), %rdi
movq %rax, %rsi
movq -0xe0(%rbp), %rax
movzbl (%rax), %edx
callq 0x3f660
movq -0x50(%rbp), %rdi
fldt -0x40(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x3f620
movq -0x50(%rbp), %rdi
fldt -0x40(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x3f720
movq -0x50(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rdi
callq 0x3f8c0
movq -0x110(%rbp), %rdi
movl %eax, %esi
decl %esi
callq 0x3f8a0
movq -0x10(%rbp), %rdi
movzbl -0x24(%rbp), %esi
callq 0x35610
movq %rax, -0x70(%rbp)
movb %dl, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x10(%rbp), %rdi
movzbl -0x24(%rbp), %esi
callq 0x528f0
movq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x3f860
movq 0x32d7f(%rip), %rdi     # 0x81fb8
leaq 0x15010(%rip), %rsi     # 0x64250
callq 0x5480
movq %rax, %rdi
leaq 0x15042(%rip), %rsi     # 0x64291
callq 0x5480
movq %rax, -0x100(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x35650
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0x5430
movq %rax, -0xf0(%rbp)
jmp 0x4f28e
movq -0xf0(%rbp), %rdi
leaq 0x14f0e(%rip), %rsi     # 0x641aa
callq 0x5480
movq %rax, -0x128(%rbp)
jmp 0x4f2aa
movq -0x128(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x58f0
movq %rax, -0x130(%rbp)
jmp 0x4f2c2
movq -0x130(%rbp), %rdi
leaq 0x14fc8(%rip), %rsi     # 0x64298
callq 0x5480
movq %rax, -0x138(%rbp)
jmp 0x4f2de
movq -0x70(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x35650
jmp 0x4f2f0
movq -0x138(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5430
movq %rax, -0x140(%rbp)
jmp 0x4f30c
movq -0x140(%rbp), %rdi
leaq 0x14e90(%rip), %rsi     # 0x641aa
callq 0x5480
movq %rax, -0x148(%rbp)
jmp 0x4f328
movq -0x148(%rbp), %rdi
movzbl -0x68(%rbp), %esi
callq 0x58f0
movq %rax, -0x150(%rbp)
jmp 0x4f341
movq -0x150(%rbp), %rdi
leaq 0x109a2(%rip), %rsi     # 0x5fcf1
callq 0x5480
movq %rax, -0x158(%rbp)
jmp 0x4f35d
movq -0x158(%rbp), %rdi
leaq 0x14f36(%rip), %rsi     # 0x642a1
callq 0x5480
movq %rax, -0x160(%rbp)
jmp 0x4f379
movq -0x160(%rbp), %rdi
fldt -0x40(%rbp)
movq %rsp, %rax
fstpt (%rax)
callq 0x55b0
movq %rax, -0x168(%rbp)
jmp 0x4f396
movq -0x168(%rbp), %rdi
leaq 0x14f0c(%rip), %rsi     # 0x642b0
callq 0x5480
movq %rax, -0x170(%rbp)
jmp 0x4f3b2
movq -0x18(%rbp), %rdi
callq 0x3f5c0
movl %eax, -0x174(%rbp)
jmp 0x4f3c3
movq -0x170(%rbp), %rdi
movl -0x174(%rbp), %esi
movl -0x44(%rbp), %eax
addl %eax, %esi
callq 0x58f0
movq %rax, -0x180(%rbp)
jmp 0x4f3e3
movq -0x180(%rbp), %rdi
leaq 0x14ed0(%rip), %rsi     # 0x642c1
callq 0x5480
movq %rax, -0x188(%rbp)
jmp 0x4f3ff
movq -0x50(%rbp), %rdi
callq 0x3f8c0
movl %eax, -0x18c(%rbp)
jmp 0x4f410
movl -0x18c(%rbp), %esi
movq -0x188(%rbp), %rdi
callq 0x58f0
movq %rax, -0x198(%rbp)
jmp 0x4f42b
movq -0x198(%rbp), %rdi
movq 0x32b57(%rip), %rsi     # 0x81f90
callq 0x54f0
jmp 0x4f440
leaq -0xb0(%rbp), %rdi
callq 0x52f0
leaq -0x90(%rbp), %rdi
callq 0x52f0
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0xc0(%rbp)
movzbl -0x68(%rbp), %eax
movl %eax, -0xbc(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq 0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x52920
xorl %eax, %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
movl $0x90, %esi
callq 0x54b0
jmp 0x4f4f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x4f4ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x52f0
leaq -0x90(%rbp), %rdi
callq 0x52f0
movq -0x58(%rbp), %rdi
callq 0x5920
nopw %cs:(%rax,%rax)