// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r9d, %r15d
movl %r8d, %ebx
movq %rcx, 0x20(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
fldt 0xc0(%rsp)
fstpt 0x2c(%rsp)
movl $0x90, %edi
callq 0x43c0
movq %rax, %r14
movzbl (%rbp), %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x1aa7c
movq %r12, %rdi
callq 0x1ab16
movq %r15, 0x38(%rsp)
leal (%rax,%r15), %esi
movq %r14, %rdi
callq 0x1ab12
movl %ebx, %r15d
movslq %ebx, %rbx
imulq $0x18, %rbx, %rsi
movq 0x20(%rsp), %rax
addq (%rax), %rsi
movzbl (%rbp), %edx
movq %r14, %rdi
callq 0x1ab2e
fldt 0x2c(%rsp)
fstpt (%rsp)
movq %r14, %rdi
callq 0x1ab22
fldt 0x2c(%rsp)
fstpt (%rsp)
movq %r14, %rdi
callq 0x1ab70
movq %r12, 0x40(%rsp)
movq %r12, %rdi
callq 0x1abc4
leal -0x1(%rax), %esi
movq %r14, %rdi
callq 0x1abbc
movzbl %bl, %eax
movl %r15d, %ebx
movq 0x30(%r13), %rcx
imulq $0xa0, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $0x60, %rsi
movq 0x30(%rsi), %rax
movq %rax, 0x20(%rsp)
movzbl 0x38(%rsi), %eax
movl %eax, 0x1c(%rsp)
movq %r14, %rdi
callq 0x1abac
movq 0x1ae58(%rip), %rdi     # 0x3afb0
leaq 0xb1aa(%rip), %rsi      # 0x2b309
callq 0x43a0
leaq 0xb1df(%rip), %rsi      # 0x2b34a
movq %rax, %rdi
callq 0x43a0
movq %rax, %rbp
leaq 0x68(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x4510
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4360
movq %r13, %r15
leaq 0xb0c8(%rip), %rsi      # 0x2b263
movq %rax, %rdi
callq 0x43a0
movq %rax, %rdi
movl %ebx, %esi
callq 0x46d0
leaq 0xb19d(%rip), %rsi      # 0x2b351
movq %rax, %rdi
callq 0x43a0
movq %rax, %rbp
leaq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0x4510
leaq 0x48(%rsp), %rsi
movq %rbp, %rdi
callq 0x4360
movq 0x40(%rsp), %r12
leaq 0xb07c(%rip), %rsi      # 0x2b263
movq %rax, %rdi
callq 0x43a0
movq %rax, %rdi
movl 0x1c(%rsp), %esi
callq 0x46d0
leaq 0x765c(%rip), %rsi      # 0x2785e
movq %rax, %rdi
callq 0x43a0
leaq 0xb149(%rip), %rsi      # 0x2b35a
movq %rax, %rdi
callq 0x43a0
fldt 0x2c(%rsp)
fstpt (%rsp)
movq %rax, %rdi
callq 0x4220
leaq 0xb13a(%rip), %rsi      # 0x2b369
movq %rax, %rdi
callq 0x43a0
movq %rax, %rbp
movq %r12, %rdi
callq 0x1ab16
addl 0x38(%rsp), %eax
movq %rbp, %rdi
movl %eax, %esi
callq 0x46d0
leaq 0xb123(%rip), %rsi      # 0x2b37a
movq %rax, %rdi
callq 0x43a0
movq %rax, %r13
movq %r14, %rdi
callq 0x1abc4
movq %r13, %rdi
movl %eax, %esi
callq 0x46d0
movq %rax, %rdi
callq 0x41e0
movq 0xd0(%rsp), %r12
leaq 0x48(%rsp), %rdi
callq 0x41c0
leaq 0x68(%rsp), %r13
movq %r13, %rdi
callq 0x41c0
movq %r15, (%r13)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%r13)
movl %ebx, 0x10(%r13)
movl 0x1c(%rsp), %eax
movl %eax, 0x14(%r13)
movq %r14, 0x18(%r13)
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
callq 0x21b74
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x202ed
movq %rax, %rbx
movl $0x90, %esi
movq %r14, %rdi
callq 0x43d0
jmp 0x20309
movq %rax, %rbx
jmp 0x202ff
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x41c0
leaq 0x68(%rsp), %rdi
callq 0x41c0
movq %rbx, %rdi
callq 0x4700
nop