// File: /workspace/github_cpp_makefile_star2_O3/ynilu[P]elastic/simulator.cpp
// Function: build_candidate_link(Aux_graph&, LightPath*)
void build_candidate_link(Aux_graph& a_graph, LightPath* lpath)
{
    if(lpath == NULL)
    {
        return;
    }

    int source = lpath->p_path.front();
    int destination = lpath->p_path.back();

    Aux_node* v_t_node = NULL;
    Aux_node* v_r_node = NULL;

    switch (lpath->type)
    {
    case LightPath::OTDM:
        v_t_node = a_graph.get_OTDM_virtual_transmitting_node(source);
        v_r_node = a_graph.get_OTDM_virtual_receiving_node(destination);
        if(lpath->available_bitrate >= OTDM_threshold)
        {
            lpath->weight = lpath->weight * 0.1;
        }
        break;
    case LightPath::OFDM:
        v_t_node = a_graph.get_OFDM_virtual_transmitting_node(source);
        v_r_node = a_graph.get_OFDM_virtual_receiving_node(destination);
        break;
    case LightPath::OFDM_WB:
        v_t_node = a_graph.get_OFDM_WB_virtual_transmitting_node(source);
        v_r_node = a_graph.get_OFDM_WB_virtual_receiving_node(destination);
        break;
    case LightPath::OFDM_WOB:
        v_t_node = a_graph.get_OFDM_WOB_virtual_transmitting_node(source);
        v_r_node = a_graph.get_OFDM_WOB_virtual_receiving_node(destination);
        break;
    default:
        cerr << "undefined LightPath type\n";
        break;
    }

    Aux_link* c_link = a_graph.create_aux_link(v_t_node, v_r_node, lpath->weight, Aux_link::candidate_link);

    c_link->light_path = lpath;              // make aux_link track light path

    lpath->aux_link_list.push_back(c_link);  // make light path track aux_link

    candidate_light_path_list.push_back(lpath);
}

// Assembly:
testq %rsi, %rsi
je 0x6760
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rsi), %eax
cmpq $0x3, %rax
ja 0x66d5
movq 0x68(%rbx), %rcx
movl (%rcx), %esi
movq 0x70(%rbx), %rcx
movl -0x4(%rcx), %ebp
leaq 0xaa83(%rip), %rcx      # 0x110d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x10a2a
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x10a3a
movq %rax, %rdx
movl 0x44(%rbx), %eax
cmpl 0x11ba5(%rip), %eax     # 0x1821c
jl 0x66f2
movsd 0x48(%rbx), %xmm0
mulsd 0xa99a(%rip), %xmm0     # 0x11020
movsd %xmm0, 0x48(%rbx)
jmp 0x66f2
movq %r14, %rdi
callq 0x109ee
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x109fa
jmp 0x66d0
movq %r14, %rdi
callq 0x109d6
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x109e2
jmp 0x66d0
movq %r14, %rdi
callq 0x10a0a
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x10a1a
movq %rax, %rdx
jmp 0x66f2
movq 0x11914(%rip), %rdi     # 0x17ff0
leaq 0xab42(%rip), %rsi      # 0x11225
movl $0x19, %edx
callq 0x3250
xorl %r15d, %r15d
xorl %edx, %edx
movsd 0x48(%rbx), %xmm0
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x105fe
movq %rax, %r14
movq %rbx, 0x8(%rax)
leaq 0xb0(%rbx), %r15
movl $0x18, %edi
callq 0x3220
movq %r14, 0x10(%rax)
movq %rax, %rdi
movq %r15, %rsi
callq 0x3050
incq 0xc0(%rbx)
movl $0x18, %edi
callq 0x3220
movq %rbx, 0x10(%rax)
leaq 0x11cd1(%rip), %rsi     # 0x18418
movq %rax, %rdi
callq 0x3050
incq 0x11cd2(%rip)           # 0x18428
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq