// File: /workspace/github_cpp_makefile_star2_O2/adamiaonr[P]rid-analytics/src/rid-analytics.cpp
// Function: RID_Analytics::add_fwd(RID_Router*, int, Path_State*, std::vector<RID_Analytics::fwd_decision, std::allocator<RID_Analytics::fwd_decision>>)
void RID_Analytics::add_fwd(
    RID_Router * router,
    int in_iface,
    Path_State * state,
    std::vector<RID_Analytics::fwd_decision> fwd_decisions) {

    // forwarding file
    // forwarding header : 'from\tinprob\tinto\t<router-0>\t<router-1>\t....\t<router-n>\n'
    this->output_file[2] << router->get_id() 
        << "\t" << state->get_in_iface_prob() 
        << "\t" << router->get_next_hop(in_iface).router->get_id();

    // add routers attached to ifaces of router
    std::map<std::string, __float080> neighbor_probs;
    for (unsigned int i = 0; i < fwd_decisions.size(); i++) {

        std::string neighbor_id = fwd_decisions[i].next_router->get_id();
        neighbor_probs[neighbor_id] = fwd_decisions[i].state->get_in_iface_prob();
    }

    // add line to forwarding file
    for (auto const& r : this->routers) {
        if (neighbor_probs.count(r.second->get_id()) > 0)
            this->output_file[2] << "\t" << neighbor_probs[r.second->get_id()];
        else
            this->output_file[2] << "\t" << 0.0;
    }
    this->output_file[2] << "\n";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %r14
movq %rcx, %r12
movl %edx, 0x1c(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
movl $0x400, %r13d           # imm = 0x400
addq 0x98(%rdi), %r13
leaq 0x48(%rsp), %rbp
movq %rbp, %rdi
callq 0x4510
movq %r13, %rdi
movq %rbp, %rsi
callq 0x4360
fldz
fstp %st(0)
leaq 0xa9b6(%rip), %rsi      # 0x2a696
movq %rax, %rdi
callq 0x43a0
fldz
movq %rax, %r13
fstp %st(0)
movq %r12, %rdi
callq 0x1ab8a
fstpt (%rsp)
movq %r13, %rdi
callq 0x4220
fldz
fstp %st(0)
leaq 0xa989(%rip), %rsi      # 0x2a696
movq %rax, %rdi
callq 0x43a0
fldz
movq %rax, %r12
fstp %st(0)
movzbl 0x1c(%rsp), %eax
movq 0x30(%r15), %rcx
imulq $0xa0, %rax, %rax
movq 0x90(%rcx,%rax), %rsi
leaq 0x28(%rsp), %rdi
callq 0x4510
leaq 0x28(%rsp), %rsi
movq %r12, %rdi
callq 0x4360
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x41c0
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x41c0
leaq 0x50(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
xorl %r13d, %r13d
movl %r13d, %r13d
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %r13, %rcx
jbe 0x1fddb
movq %r13, %rbp
shlq $0x5, %rbp
movq 0x8(%rax,%rbp), %rsi
movq %r15, %rdi
callq 0x4510
movq (%r14), %rax
movq 0x18(%rax,%rbp), %rdi
callq 0x1ab8a
fstpt 0x1c(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x21a28
fldt 0x1c(%rsp)
fstpt (%rax)
movq %r15, %rdi
callq 0x41c0
incl %r13d
jmp 0x1fd82
movq 0x68(%rbx), %r15
leaq 0x58(%rbx), %r13
leaq 0x28(%rsp), %r14
leaq 0x48(%rsp), %r12
cmpq %r13, %r15
je 0x1fe90
movq 0x40(%r15), %rsi
movq %r14, %rdi
callq 0x4510
movq %r12, %rdi
movq %r14, %rsi
callq 0x21a8e
movq %rax, %rbp
movq %r14, %rdi
callq 0x41c0
movq 0x98(%rbx), %rdi
movl $0x400, %eax            # imm = 0x400
addq %rax, %rdi
testq %rbp, %rbp
je 0x1fe69
leaq 0xa863(%rip), %rsi      # 0x2a696
callq 0x43a0
movq %rax, %rbp
movq 0x40(%r15), %rsi
movq %r14, %rdi
callq 0x4510
movq %r12, %rdi
movq %r14, %rsi
callq 0x21aa8
fldt (%rax)
fstpt (%rsp)
movq %rbp, %rdi
callq 0x4220
movq %r14, %rdi
callq 0x41c0
jmp 0x1fe80
leaq 0xa826(%rip), %rsi      # 0x2a696
callq 0x43a0
xorps %xmm0, %xmm0
movq %rax, %rdi
callq 0x4640
movq %r15, %rdi
callq 0x42d0
movq %rax, %r15
jmp 0x1fded
movl $0x400, %edi            # imm = 0x400
addq 0x98(%rbx), %rdi
leaq 0xa7af(%rip), %rsi      # 0x2a652
callq 0x43a0
leaq 0x48(%rsp), %rdi
callq 0x21d2a
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1feef
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x41c0
jmp 0x1fed9
jmp 0x1fed6
fstp %st(0)
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x41c0
jmp 0x1ff0b
jmp 0x1feef
jmp 0x1feef
jmp 0x1fef4
jmp 0x1feef
jmp 0x1fef4
movq %rax, %rbx
jmp 0x1ff01
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x41c0
leaq 0x48(%rsp), %rdi
callq 0x21d2a
movq %rbx, %rdi
callq 0x4700
nop