// File: /workspace/github_cpp_makefile_star2_O1/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 0x67ab
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rsi), %eax
cmpq $0x3, %rax
ja 0x6720
movq 0x68(%rbx), %rcx
movl (%rcx), %esi
movq 0x70(%rbx), %rcx
movl -0x4(%rcx), %ebp
leaq 0xaa08(%rip), %rcx      # 0x110a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x1034a
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x1035a
movq %rax, %rdx
movl 0x44(%rbx), %eax
cmpl 0x11b5a(%rip), %eax     # 0x1821c
jl 0x673d
movsd 0x48(%rbx), %xmm0
mulsd 0xa94f(%rip), %xmm0     # 0x11020
movsd %xmm0, 0x48(%rbx)
jmp 0x673d
movq %r14, %rdi
callq 0x1030e
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x1031a
jmp 0x671b
movq %r14, %rdi
callq 0x102f6
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x10302
jmp 0x671b
movq %r14, %rdi
callq 0x1032a
movq %rax, %r15
movq %r14, %rdi
movl %ebp, %esi
callq 0x1033a
movq %rax, %rdx
jmp 0x673d
movq 0x118c9(%rip), %rdi     # 0x17ff0
leaq 0xaac7(%rip), %rsi      # 0x111f5
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 0xff6e
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 0x11c86(%rip), %rsi     # 0x18418
movq %rax, %rdi
callq 0x3050
incq 0x11c87(%rip)           # 0x18428
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq