// File: /workspace/github_cpp_makefile_star2_O2/ynilu[P]elastic/simulator.cpp
// Function: construct_exist_path(Event&, Phy_graph&, Aux_graph&)
void construct_exist_path(Event& event, Phy_graph& p_graph, Aux_graph& a_graph)
{
    for(auto &lp : exist_OTDM_light_path_list)
    {
        if(lp->available_bitrate < event.bandwidth)
        {
            continue;
        }

        Aux_node* a_node;
        Aux_node* d_node;
        Aux_node* t_node;
        Aux_node* r_node;
        Aux_link* aux_link;

        lp->transmitting_node_list.reserve(lp->p_path.size());
        lp->receiving_node_list.reserve(lp->p_path.size());
        int n = lp->p_path.size() - 1;
        double weight = (double)n * (1 - eps) * lp->weight;

        for(unsigned int i = 0; i < lp->p_path.size(); i++)
        {
            int phy_node_id = lp->p_path[i];

            a_node = a_graph.get_adding_node(phy_node_id);
            d_node = a_graph.get_dropping_node(phy_node_id);

            t_node = a_graph.create_aux_node(phy_node_id, Aux_node::transmitting_node);

            lp->transmitting_node_list.push_back(t_node);

            r_node = a_graph.create_aux_node(phy_node_id, Aux_node::receiving_node);
            lp->receiving_node_list.push_back(r_node);

            aux_link = a_graph.create_aux_link(r_node, t_node, -weight, Aux_link::pass_through_link);
            lp->aux_link_list.push_back(aux_link);
            aux_link->light_path = lp;              // make aux_link track light path

            if(lp->transmitter_index[i] != -1)
            {
                aux_link = a_graph.create_aux_link(a_node, t_node, used_transceiver_weight, Aux_link::adding_link);
            }
            else if(p_graph.get_node(lp->p_path[i]).num_available_transmitter > 0)
            {
                aux_link = a_graph.create_aux_link(a_node, t_node, transceiver_weight, Aux_link::virtual_adding_link);
            }
            lp->aux_link_list.push_back(aux_link);
            aux_link->light_path = lp;              // make aux_link track light path


            if(lp->receiver_index[i] != -1)
            {
                aux_link = a_graph.create_aux_link(r_node, d_node, used_transceiver_weight, Aux_link::dropping_link);
            }
            else if(p_graph.get_node(lp->p_path[i]).num_available_receiver > 0)
            {
                aux_link = a_graph.create_aux_link(r_node, d_node, transceiver_weight, Aux_link::virtual_dropping_link);
            }
            lp->aux_link_list.push_back(aux_link);
            aux_link->light_path = lp;              // make aux_link track light path
        }

        for(unsigned int i = 0; i < lp->p_path.size() - 1; i++)
        {
            t_node = lp->transmitting_node_list[i];
            r_node = lp->receiving_node_list[i + 1];
            aux_link = a_graph.create_aux_link(t_node, r_node, weight, Aux_link::spectrum_link);
            // cout << "lp : " << lp << "  link: " << aux_link << "\n";
            lp->aux_link_list.push_back(aux_link);
            aux_link->light_path = lp;              // make aux_link track light path
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq %rsi, 0x18(%rsp)
leaq 0x15001(%rip), %rdx     # 0x18408
pushq $0x3
popq %rbp
movq %rdx, %r13
movq %rdi, 0x28(%rsp)
movq (%r13), %r13
cmpq %rdx, %r13
je 0x370b
movq 0x10(%r13), %rax
movl 0x44(%rax), %ecx
cmpl 0x4c(%rdi), %ecx
jl 0x3412
leaq 0x80(%rax), %rdi
movq 0x70(%rax), %rsi
subq 0x68(%rax), %rsi
sarq $0x2, %rsi
callq 0x675c
movq 0x10(%r13), %rax
leaq 0x98(%rax), %rdi
movq 0x70(%rax), %rsi
subq 0x68(%rax), %rsi
sarq $0x2, %rsi
callq 0x675c
movq 0x10(%r13), %rax
movq 0x68(%rax), %rdx
movq 0x70(%rax), %rcx
movq %rcx, %rsi
subq %rdx, %rsi
shrq $0x2, %rsi
decl %esi
cvtsi2sd %esi, %xmm0
movsd 0xbb8d(%rip), %xmm1     # 0xf010
subsd 0x14dc5(%rip), %xmm1    # 0x18250
mulsd %xmm0, %xmm1
mulsd 0x48(%rax), %xmm1
movapd %xmm1, 0x40(%rsp)
xorpd 0xbb9e(%rip), %xmm1     # 0xf040
movapd %xmm1, 0x30(%rsp)
xorl %r12d, %r12d
movl %r12d, %r12d
movq %rcx, %rsi
subq %rdx, %rsi
sarq $0x2, %rsi
cmpq %r12, %rsi
jbe 0x367b
movl (%rdx,%r12,4), %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0xdf74
movq %rax, %r15
movq %rbx, %rdi
movl %r14d, %esi
callq 0xdf80
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
movl %r14d, %esi
pushq $0x2
popq %rdx
callq 0xdc66
movq %rax, 0x10(%rsp)
movq 0x10(%r13), %rdi
subq $-0x80, %rdi
leaq 0x10(%rsp), %rsi
callq 0x67f2
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0xdc66
movq %rax, 0x8(%rsp)
movq 0x10(%r13), %rdi
movl $0x98, %eax
addq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x67f2
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
movapd 0x30(%rsp), %xmm0
pushq $0x5
popq %rcx
callq 0xdc98
movq %rax, (%rsp)
movq 0x10(%r13), %rdi
movl $0xb0, %eax
addq %rax, %rdi
movq %rsp, %rsi
callq 0x6810
movq 0x10(%r13), %rax
movq (%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0xc8(%rax), %rcx
cmpl $-0x1, (%rcx,%r12,4)
je 0x3594
movq 0x10(%rsp), %rdx
movsd 0x14e46(%rip), %xmm0    # 0x183d0
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %ecx
jmp 0x35c2
movq 0x68(%rax), %rax
movl (%rax,%r12,4), %esi
movq 0x18(%rsp), %rdi
callq 0x98a8
cmpl $0x0, 0x28(%rax)
jle 0x35cb
movq 0x10(%rsp), %rdx
movsd 0x14e0f(%rip), %xmm0    # 0x183c8
movq %rbx, %rdi
movq %r15, %rsi
pushq $0x6
popq %rcx
callq 0xdc98
movq %rax, (%rsp)
movq 0x10(%r13), %rdi
movl $0xb0, %eax
addq %rax, %rdi
movq %rsp, %rsi
callq 0x6810
movq 0x10(%r13), %rax
movq (%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0xe0(%rax), %rcx
cmpl $-0x1, (%rcx,%r12,4)
je 0x3612
movq 0x8(%rsp), %rsi
movsd 0x14dca(%rip), %xmm0    # 0x183d0
movq %rbx, %rdi
movq 0x20(%rsp), %rdx
pushq $0x4
jmp 0x3641
movq 0x68(%rax), %rax
movl (%rax,%r12,4), %esi
movq 0x18(%rsp), %rdi
callq 0x98a8
cmpl $0x0, 0x30(%rax)
jle 0x364b
movq 0x8(%rsp), %rsi
movsd 0x14d91(%rip), %xmm0    # 0x183c8
movq %rbx, %rdi
movq 0x20(%rsp), %rdx
pushq $0x7
popq %rcx
callq 0xdc98
movq %rax, (%rsp)
movq 0x10(%r13), %rdi
movl $0xb0, %eax
addq %rax, %rdi
movq %rsp, %rsi
callq 0x6810
movq 0x10(%r13), %rax
movq (%rsp), %rcx
movq %rax, 0x8(%rcx)
incl %r12d
movq 0x68(%rax), %rdx
movq 0x70(%rax), %rcx
jmp 0x34ab
pushq $0x1
popq %r15
movl %r15d, %r14d
subq %rdx, %rcx
leal -0x1(%r14), %edx
sarq $0x2, %rcx
decq %rcx
cmpq %rdx, %rcx
jbe 0x36fa
movq 0x80(%rax), %rcx
movq (%rcx,%rdx,8), %rsi
movq %rsi, 0x10(%rsp)
movl %r14d, %ecx
movq 0x98(%rax), %rax
movq (%rax,%rcx,8), %rdx
movq %rdx, 0x8(%rsp)
movq %rbx, %rdi
movapd 0x40(%rsp), %xmm0
movl %r15d, %ecx
callq 0xdc98
movq %rax, (%rsp)
movq 0x10(%r13), %rdi
movl $0xb0, %eax
addq %rax, %rdi
movq %rsp, %rsi
callq 0x6810
movq 0x10(%r13), %rax
movq (%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0x68(%rax), %rdx
movq 0x70(%rax), %rcx
incl %r14d
jmp 0x3682
movq 0x28(%rsp), %rdi
leaq 0x14d02(%rip), %rdx     # 0x18408
jmp 0x3412
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq