// File: /workspace/github_cpp_makefile_star2_O3/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 0xb3e7
leaq 0x48(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x3130
leaq 0x8(%rbx), %r14
movslq 0x14(%rsp), %rsi
movq %r14, %rdi
callq 0xc3c8
leaq 0x30(%rsp), %r15
movslq %ebp, %r12
addq $0x20, %rbx
leaq 0xc983(%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 0xb3c1
movslq 0x4(%rsp), %rcx
decl (%rsp)
leal -0x1(%rcx), %eax
movl %eax, 0x4(%rsp)
movq (%r14), %rax
imulq $0x98, %rcx, %rcx
incl -0x90(%rcx,%rax)
movslq (%rsp), %rcx
imulq $0x98, %rcx, %rcx
incl 0x8(%rax,%rcx)
movslq 0x4(%rsp), %rcx
imulq $0x98, %rcx, %rcx
leaq (%rax,%rcx), %rdi
addq $0x10, %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xb297
movl (%rsp), %ecx
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xb2a5
movq %rsp, %rdx
callq 0xdad4
movl (%rsp), %ecx
movq (%r14), %rax
movslq %ecx, %rcx
imulq $0x98, %rcx, %rcx
leaq (%rax,%rcx), %rdi
addq $0x10, %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0xb2d1
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0xb2df
leaq 0x4(%rsp), %rdx
callq 0xdad4
movl 0x4(%rsp), %eax
movq %r13, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq $0x0, 0x10(%r15)
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 0x8998
movl 0x4(%rsp), %eax
movl (%rsp), %ecx
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x8(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xc2b4
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 0x8c9c
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 0xc2b4
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 0x8c9c
movq %r13, 0x18(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb202
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
jmp 0xb202
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 0xcc02(%rip), %rdi      # 0x17ff0
leaq 0x632a(%rip), %rsi      # 0x1171f
movl $0x10, %edx
callq 0x3250
movq 0xcbea(%rip), %rdi      # 0x17ff0
movq %r14, %rsi
callq 0x3210
leaq 0x631b(%rip), %rsi      # 0x11730
movl $0x2, %edx
movq %rax, %rdi
callq 0x3250
movq 0xcbc7(%rip), %rdi      # 0x17ff0
leaq 0x6303(%rip), %rsi      # 0x11733
callq 0x3210
movl $0x1, %edi
callq 0x3280
jmp 0xb468
jmp 0xb468
jmp 0xb447
jmp 0xb447
movq %rax, %rbx
movq %r13, 0x18(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0xb46b
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x3230
jmp 0xb46b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x3080
movq %rbx, %rdi
callq 0x3370
nop