// File: /workspace/github_cpp_makefile_star2_O1/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 $0x258, %rsp            # imm = 0x258
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x3270
movq %r15, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x31f0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0xacb9
leaq 0x48(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x3130
leaq 0x8(%rbx), %r14
movslq 0x14(%rsp), %rsi
movq %r14, %rdi
callq 0xbbc8
leaq 0x30(%rsp), %r15
movslq %ebp, %r12
addq $0x20, %rbx
leaq 0xd0af(%rip), %r13      # 0x17b80
leaq 0x8(%rsp), %rbp
leaq 0x48(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x3130
movq %rax, %rdi
movq %rsp, %rsi
callq 0x3130
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x3130
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0xac93
movslq 0x4(%rsp), %rax
decl (%rsp)
leal -0x1(%rax), %ecx
movl %ecx, 0x4(%rsp)
movq (%r14), %rcx
imulq $0x98, %rax, %rax
incl -0x90(%rax,%rcx)
movslq (%rsp), %rax
imulq $0x98, %rax, %rax
incl 0x8(%rcx,%rax)
movslq 0x4(%rsp), %rax
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x10, %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xab6b
movl (%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xab73
movq %rsp, %rdx
callq 0xd28a
movslq (%rsp), %rax
movq (%r14), %rcx
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x10, %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xaba3
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xabad
leaq 0x4(%rsp), %rdx
callq 0xd28a
movq %r13, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq $0x0, 0x10(%r15)
movl 0x4(%rsp), %eax
movl %eax, 0x20(%rsp)
movl (%rsp), %eax
movl %eax, 0x24(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x28(%rsp)
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
callq 0x85f6
movl 0x4(%rsp), %eax
movl (%rsp), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbaac
movl -0x8(%r15), %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%r15), %rcx
movq %rcx, 0x8(%rax)
addq $0x18, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0x88f4
movl (%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x4(%rsp), %ecx
movl %ecx, 0x24(%rsp)
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xbaac
movl -0x8(%r15), %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%r15), %rcx
movq %rcx, 0x8(%rax)
addq $0x18, %rax
movq %rax, %rdi
movq %r15, %rsi
callq 0x88f4
movq %r13, 0x18(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xaad6
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
jmp 0xaad6
leaq 0x48(%rsp), %rdi
callq 0x3040
leaq 0x48(%rsp), %rdi
callq 0x3080
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xd330(%rip), %rdi      # 0x17ff0
leaq 0x6a28(%rip), %rsi      # 0x116ef
movl $0x10, %edx
callq 0x3250
movq 0xd318(%rip), %rdi      # 0x17ff0
movq %r14, %rsi
callq 0x3210
leaq 0x6a19(%rip), %rsi      # 0x11700
movl $0x2, %edx
movq %rax, %rdi
callq 0x3250
movq 0xd2f5(%rip), %rdi      # 0x17ff0
leaq 0x6a01(%rip), %rsi      # 0x11703
callq 0x3210
movl $0x1, %edi
callq 0x3280
jmp 0xad3a
jmp 0xad3a
jmp 0xad19
jmp 0xad19
movq %rax, %rbx
movq %r13, 0x18(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xad3d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
jmp 0xad3d
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3080
movq %rbx, %rdi
callq 0x3370
nop