// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x788c
jmp 0x79fd
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0xb480
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
addq $0x68, %rdi
callq 0xb4b0
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x38(%rbp)
subq $0x3, %rax
ja 0x799a
movq -0x38(%rbp), %rax
leaq 0x257b0(%rip), %rcx     # 0x2d090
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2bad0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x2bb00
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
cmpl 0x3b8f6(%rip), %eax     # 0x4320c
jl 0x7932
movq -0x10(%rbp), %rax
movsd 0x256e4(%rip), %xmm0    # 0x2d008
mulsd 0x48(%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x48(%rax)
jmp 0x79ad
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2ba70
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x2baa0
movq %rax, -0x28(%rbp)
jmp 0x79ad
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2ba10
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x2ba40
movq %rax, -0x28(%rbp)
jmp 0x79ad
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2b9b0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x2b9e0
movq %rax, -0x28(%rbp)
jmp 0x79ad
movq 0x3b64f(%rip), %rdi     # 0x42ff0
leaq 0x25841(%rip), %rsi     # 0x2d1e9
callq 0x31f0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movsd 0x48(%rax), %xmm0
xorl %ecx, %ecx
callq 0x2b4d0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdi
addq $0xb0, %rdi
leaq -0x30(%rbp), %rsi
callq 0xb8a0
leaq 0x3ba14(%rip), %rdi     # 0x43408
leaq -0x10(%rbp), %rsi
callq 0xbb50
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)