// File: /workspace/github_cpp_makefile_star2_O2/ynilu[P]elastic/graph.cpp
// Function: Phy_graph::read_network_file(char*, int)
void Phy_graph::read_network_file(char* graph_file, int num_slots)
{
    int num_nodes;
    fstream fs;

    fs.open(graph_file, ios::in);
    if(!fs)
    {
        cerr << "Can't open file\"" << graph_file << "\"\n";
        cerr << "Please give network node file, program aborting...\n";
        exit(1);
    }

    fs >> num_nodes;

    // resize vectors according to the number of nodes
    node_list.resize(num_nodes);

    int node_a, node_b, distance;
    while(fs >> node_a >> node_b >> distance)
    {
        node_a--;
        node_b--;

        node_list[node_a].degree++;
        node_list[node_b].degree++;

        node_list[node_a].neighbor.push_back(node_b);
        node_list[node_b].neighbor.push_back(node_a);

        Phy_link new_link;

        new_link.source = node_a;
        new_link.destination = node_b;
        new_link.distance = distance;
        new_link.slot.resize(num_slots, -1);

        link_list[make_pair(node_a,node_b)] = new_link;

        new_link.source = node_b;
        new_link.destination = node_a;

        link_list[make_pair(node_b,node_a)] = new_link;
    }

    fs.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x2230
pushq $0x8
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x21d0
movq 0x58(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x78(%rsp,%rax)
jne 0x942b
leaq 0x58(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x2120
leaq 0x8(%rbx), %r14
movslq 0x1c(%rsp), %rsi
movq %r14, %rdi
callq 0x9ef6
leaq 0x40(%rsp), %r15
movslq %ebp, %rax
movq %rax, 0x20(%rsp)
addq $0x20, %rbx
leaq 0xc(%rsp), %r13
leaq 0x10(%rsp), %r12
leaq 0x28(%rsp), %rbp
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2120
movq %rax, %rdi
movq %r13, %rsi
callq 0x2120
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2120
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x9405
movslq 0x8(%rsp), %rax
decl 0xc(%rsp)
leal -0x1(%rax), %ecx
movl %ecx, 0x8(%rsp)
movq (%r14), %rcx
imulq $0x98, %rax, %rax
incl -0x90(%rax,%rcx)
movslq 0xc(%rsp), %rax
imulq $0x98, %rax, %rax
incl 0x8(%rcx,%rax)
movslq 0x8(%rsp), %rax
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x10, %rdi
movq %r13, %rsi
callq 0x9dc0
movslq 0xc(%rsp), %rax
movq (%r14), %rcx
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x10, %rdi
leaq 0x8(%rsp), %rsi
callq 0x9dc0
leaq 0xe832(%rip), %rax      # 0x17b90
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
andq $0x0, 0x10(%r15)
movl 0x8(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x38(%rsp)
orl $-0x1, 0x10(%rsp)
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq %r12, %rdx
callq 0x65c0
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x9e2a
movq %rax, %rdi
movq %rbp, %rsi
callq 0x9f30
movl 0xc(%rsp), %eax
movl %eax, 0x30(%rsp)
movl 0x8(%rsp), %ecx
movl %ecx, 0x34(%rsp)
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x9e2a
movq %rax, %rdi
movq %rbp, %rsi
callq 0x9f30
movq %rbp, %rdi
callq 0x9a8c
jmp 0x92b0
leaq 0x58(%rsp), %rdi
callq 0x2030
leaq 0x58(%rsp), %rdi
callq 0x2070
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xebbe(%rip), %rdi      # 0x17ff0
leaq 0x62b7(%rip), %rsi      # 0xf6f0
callq 0x21e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21e0
leaq 0x62b1(%rip), %rsi      # 0xf701
movq %rax, %rdi
callq 0x21e0
movq 0xeb91(%rip), %rdi      # 0x17ff0
leaq 0x629e(%rip), %rsi      # 0xf704
callq 0x21e0
pushq $0x1
popq %rdi
callq 0x2240
jmp 0x948a
jmp 0x948a
jmp 0x947b
jmp 0x947b
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x9a8c
jmp 0x948d
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x2320
nop