// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %rdx, %rbx
movq %rsi, 0x28(%rsp)
movq 0x13ccd(%rip), %r14     # 0x18430
leaq 0x13cc6(%rip), %rdx     # 0x18430
cmpq %rdx, %r14
je 0x4b60
movq %rbx, 0x20(%rsp)
movq %rdi, 0x40(%rsp)
movq 0x10(%r14), %rax
movl 0x44(%rax), %ecx
cmpl 0x4c(%rdi), %ecx
jl 0x4b54
leaq 0x80(%rax), %rdi
movq 0x70(%rax), %rsi
subq 0x68(%rax), %rsi
sarq $0x2, %rsi
callq 0x8b88
movq 0x10(%r14), %rax
leaq 0x98(%rax), %rdi
movq 0x70(%rax), %rsi
subq 0x68(%rax), %rsi
sarq $0x2, %rsi
callq 0x8b88
movq 0x10(%r14), %rax
movq 0x68(%rax), %rcx
movq 0x70(%rax), %rdx
movq %rdx, %rsi
subq %rcx, %rsi
shrq $0x2, %rsi
decl %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0xc828(%rip), %xmm1     # 0x11010
subsd 0x13a88(%rip), %xmm1    # 0x18278
mulsd %xmm0, %xmm1
mulsd 0x48(%rax), %xmm1
cmpq %rcx, %rdx
movq %r14, %r12
movq %rbx, %r14
movapd %xmm1, 0x50(%rsp)
je 0x4aa4
xorpd 0xc82a(%rip), %xmm1     # 0x11040
movapd %xmm1, 0x60(%rsp)
movl $0x1, %ebp
xorl %ebx, %ebx
movq %r14, %r13
movq %r12, %r14
movl (%rcx,%rbx,4), %r12d
movq %r13, %rdi
movl %r12d, %esi
callq 0x109be
movq %rax, 0x30(%rsp)
movq %r13, %rdi
movl %r12d, %esi
callq 0x109ca
movq %rax, 0x38(%rsp)
movq %r13, %rdi
movl %r12d, %esi
movl $0x2, %edx
callq 0x105ca
movq %rax, 0x18(%rsp)
movq 0x10(%r14), %rdi
movq 0x88(%rdi), %rsi
cmpq 0x90(%rdi), %rsi
je 0x4883
movq %rax, (%rsi)
addq $0x8, 0x88(%rdi)
jmp 0x4891
subq $-0x80, %rdi
leaq 0x18(%rsp), %rdx
callq 0xa2ca
movq %r13, %rdi
movl %r12d, %esi
movl $0x3, %edx
callq 0x105ca
movq %rax, 0x10(%rsp)
movq 0x10(%r14), %rdi
movq 0xa0(%rdi), %rsi
cmpq 0xa8(%rdi), %rsi
movl %ebp, 0xc(%rsp)
je 0x48cb
movq %rax, (%rsi)
addq $0x8, 0xa0(%rdi)
jmp 0x48dc
addq $0x98, %rdi
leaq 0x10(%rsp), %rdx
callq 0xa2ca
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rdi
movapd 0x60(%rsp), %xmm0
movl $0x5, %ecx
callq 0x105fe
movq %rax, %r12
movq 0x10(%r14), %r15
movq %r13, %rbp
leaq 0xb0(%r15), %r13
movl $0x18, %edi
callq 0x3220
movq %r12, 0x10(%rax)
movq %rax, %rdi
movq %r13, %rsi
callq 0x3050
incq 0xc0(%r15)
movq 0x10(%r14), %rax
movq %rax, 0x8(%r12)
movq 0xc8(%rax), %rcx
cmpl $-0x1, (%rcx,%rbx,4)
je 0x495c
movq 0x18(%rsp), %rdx
movsd 0x13aab(%rip), %xmm0    # 0x183f8
movq %rbp, %rdi
movq 0x30(%rsp), %rsi
movl $0x3, %ecx
jmp 0x498f
movq 0x68(%rax), %rax
movl (%rax,%rbx,4), %esi
movq 0x28(%rsp), %rdi
callq 0xba88
cmpl $0x0, 0x28(%rax)
jle 0x4997
movq 0x18(%rsp), %rdx
movsd 0x13a70(%rip), %xmm0    # 0x183f0
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl $0x6, %ecx
callq 0x105fe
movq %rax, %r12
movl 0xc(%rsp), %ebp
movq 0x10(%r14), %r13
leaq 0xb0(%r13), %r15
movl $0x18, %edi
callq 0x3220
movq %r12, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x3050
incq 0xc0(%r13)
movq 0x10(%r14), %rax
movq %rax, 0x8(%r12)
movq 0xe0(%rax), %rcx
cmpl $-0x1, (%rcx,%rbx,4)
je 0x49fd
movq 0x10(%rsp), %rsi
movsd 0x13a0f(%rip), %xmm0    # 0x183f8
movq 0x20(%rsp), %r13
movq %r13, %rdi
movq 0x38(%rsp), %rdx
movl $0x4, %ecx
jmp 0x4a33
movq 0x68(%rax), %rax
movl (%rax,%rbx,4), %esi
movq 0x28(%rsp), %rdi
callq 0xba88
cmpl $0x0, 0x30(%rax)
movq 0x20(%rsp), %r13
jle 0x4a3b
movq 0x10(%rsp), %rsi
movsd 0x139ca(%rip), %xmm0    # 0x183f0
movq %r13, %rdi
movq 0x38(%rsp), %rdx
movl $0x7, %ecx
callq 0x105fe
movq %rax, %r12
movq 0x10(%r14), %rbx
leaq 0xb0(%rbx), %r15
movl $0x18, %edi
callq 0x3220
movq %r12, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x3050
incq 0xc0(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x8(%r12)
movl %ebp, %ebx
movq 0x68(%rax), %rcx
movq 0x70(%rax), %rdx
subq %rcx, %rdx
movq %rdx, %rsi
sarq $0x2, %rsi
incl %ebp
cmpq %rbx, %rsi
ja 0x4829
cmpq $0x4, %rdx
movq %r14, %r12
movq %r13, %r14
movapd 0x50(%rsp), %xmm1
je 0x4b42
movl $0x1, %ebx
xorl %r13d, %r13d
movq %r12, 0x48(%rsp)
movq 0x80(%rax), %rcx
movq (%rcx,%r13,8), %rsi
movq %rsi, 0x18(%rsp)
movl %ebx, %r13d
movq 0x98(%rax), %rax
movq (%rax,%r13,8), %rdx
movq %rdx, 0x10(%rsp)
movq %r14, %rdi
movapd %xmm1, %xmm0
movl $0x1, %ecx
callq 0x105fe
movq %rax, %r15
movq 0x10(%r12), %rbp
leaq 0xb0(%rbp), %r12
movl $0x18, %edi
callq 0x3220
movq %r15, 0x10(%rax)
movq %rax, %rdi
movq %r12, %rsi
movq 0x48(%rsp), %r12
callq 0x3050
movapd 0x50(%rsp), %xmm1
incq 0xc0(%rbp)
movq 0x10(%r12), %rax
movq %rax, 0x8(%r15)
movq 0x70(%rax), %rcx
subq 0x68(%rax), %rcx
sarq $0x2, %rcx
decq %rcx
incl %ebx
cmpq %r13, %rcx
ja 0x4ab1
movq %r14, %rbx
movq 0x40(%rsp), %rdi
leaq 0x138df(%rip), %rdx     # 0x18430
movq %r12, %r14
movq (%r14), %r14
cmpq %rdx, %r14
jne 0x477d
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq