// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rsi, 0x28(%rsp)
movq 0x13cb8(%rip), %r14     # 0x18430
leaq 0x13cb1(%rip), %rdx     # 0x18430
cmpq %rdx, %r14
je 0x4b88
movq %r13, 0x20(%rsp)
movq %rdi, 0x40(%rsp)
movq 0x10(%r14), %rax
movl 0x44(%rax), %ecx
cmpl 0x4c(%rdi), %ecx
jl 0x4b7c
leaq 0x80(%rax), %rdi
movq 0x70(%rax), %rsi
subq 0x68(%rax), %rsi
sarq $0x2, %rsi
callq 0x87e6
movq 0x10(%r14), %rax
leaq 0x98(%rax), %rdi
movq 0x70(%rax), %rsi
subq 0x68(%rax), %rsi
sarq $0x2, %rsi
callq 0x87e6
movq 0x10(%r14), %rcx
movq 0x68(%rcx), %rax
movq 0x70(%rcx), %rdx
movq %rdx, %rsi
subq %rax, %rsi
shrq $0x2, %rsi
decl %esi
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd 0xc813(%rip), %xmm1     # 0x11010
subsd 0x13a73(%rip), %xmm1    # 0x18278
mulsd %xmm0, %xmm1
mulsd 0x48(%rcx), %xmm1
movapd %xmm1, 0x50(%rsp)
cmpq %rax, %rdx
je 0x4aaf
movaps 0x50(%rsp), %xmm0
xorps 0xc817(%rip), %xmm0     # 0x11040
movaps %xmm0, 0x60(%rsp)
movl $0x1, %ebp
xorl %ebx, %ebx
movl %ebp, 0x1c(%rsp)
movl (%rax,%rbx,4), %r12d
movq %r13, %rdi
movl %r12d, %esi
callq 0x102de
movq %rax, 0x30(%rsp)
movq %r13, %rdi
movl %r12d, %esi
callq 0x102ea
movq %rax, 0x38(%rsp)
movq %r13, %rdi
movl %r12d, %esi
movl $0x2, %edx
callq 0xff3a
movq %rax, 0x10(%rsp)
movq 0x10(%r14), %rdi
movq 0x88(%rdi), %rsi
cmpq 0x90(%rdi), %rsi
je 0x4893
movq %rax, (%rsi)
addq $0x8, 0x88(%rdi)
jmp 0x48a1
subq $-0x80, %rdi
leaq 0x10(%rsp), %rdx
callq 0x9b7a
movq %r13, %rdi
movl %r12d, %esi
movl $0x3, %edx
callq 0xff3a
movq %rax, 0x8(%rsp)
movq 0x10(%r14), %rdi
movq 0xa0(%rdi), %rsi
cmpq 0xa8(%rdi), %rsi
je 0x48d7
movq %rax, (%rsi)
addq $0x8, 0xa0(%rdi)
jmp 0x48e8
addq $0x98, %rdi
leaq 0x8(%rsp), %rdx
callq 0x9b7a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r13, %rdi
movapd 0x60(%rsp), %xmm0
movl $0x5, %ecx
callq 0xff6e
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 0x10(%r14), %rax
movq 0xc8(%rax), %rcx
cmpl $-0x1, (%rcx,%rbx,4)
je 0x496c
movq 0x10(%rsp), %rdx
movsd 0x13a9b(%rip), %xmm0    # 0x183f8
movq %rbp, %rdi
movq 0x30(%rsp), %rsi
movl $0x3, %ecx
jmp 0x499f
movq 0x68(%rax), %rax
movl (%rax,%rbx,4), %esi
movq 0x28(%rsp), %rdi
callq 0xb390
cmpl $0x0, 0x28(%rax)
jle 0x49a7
movq 0x10(%rsp), %rdx
movsd 0x13a60(%rip), %xmm0    # 0x183f0
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl $0x6, %ecx
callq 0xff6e
movq %rax, %r12
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 0x10(%r14), %rax
movq 0xe0(%rax), %rcx
cmpl $-0x1, (%rcx,%rbx,4)
je 0x4a19
movq 0x8(%rsp), %rsi
movsd 0x139ff(%rip), %xmm0    # 0x183f8
movq 0x20(%rsp), %r13
movq %r13, %rdi
movq 0x38(%rsp), %rdx
movl $0x4, %ecx
callq 0xff6e
movq %rax, %r12
movl 0x1c(%rsp), %ebp
jmp 0x4a5b
movq 0x68(%rax), %rax
movl (%rax,%rbx,4), %esi
movq 0x28(%rsp), %rdi
callq 0xb390
cmpl $0x0, 0x30(%rax)
movq 0x20(%rsp), %r13
movl 0x1c(%rsp), %ebp
jle 0x4a5b
movq 0x8(%rsp), %rsi
movsd 0x139aa(%rip), %xmm0    # 0x183f0
movq %r13, %rdi
movq 0x38(%rsp), %rdx
movl $0x7, %ecx
callq 0xff6e
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 0x10(%r14), %rcx
movq 0x68(%rcx), %rax
movq 0x70(%rcx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
incl %ebp
cmpq %rbx, %rcx
ja 0x4835
movq 0x10(%r14), %rax
movq 0x70(%rax), %rcx
subq 0x68(%rax), %rcx
cmpq $0x4, %rcx
movq %r14, %r12
movq %r13, %r14
je 0x4b6a
movl $0x1, %ebx
xorl %r13d, %r13d
movq %r12, 0x48(%rsp)
movq 0x80(%rax), %rcx
movq (%rcx,%r13,8), %rsi
movq %rsi, 0x10(%rsp)
movl %ebx, %r13d
movq 0x98(%rax), %rax
movq (%rax,%r13,8), %rdx
movq %rdx, 0x8(%rsp)
movq %r14, %rdi
movapd 0x50(%rsp), %xmm0
movl $0x1, %ecx
callq 0xff6e
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
incq 0xc0(%rbp)
movq 0x10(%r12), %rax
movq %rax, 0x8(%r15)
movq 0x10(%r12), %rax
movq 0x70(%rax), %rcx
subq 0x68(%rax), %rcx
sarq $0x2, %rcx
decq %rcx
incl %ebx
cmpq %r13, %rcx
ja 0x4ad8
movq %r14, %r13
movq 0x40(%rsp), %rdi
leaq 0x138b7(%rip), %rdx     # 0x18430
movq %r12, %r14
movq (%r14), %r14
cmpq %rdx, %r14
jne 0x4792
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq