// File: /workspace/github_cpp_makefile_star2_O2/dtsaras[P]GCW/rwgraph.cpp
// Function: Graph::readGraph_IC(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, float, float)
void Graph::readGraph_IC(const string filename, bool rand_edges, float m, float s){
    ifstream infile(filename, ios::in|ios::binary|ios::ate);
    int v;
    long long u;
    float prob;
    infile.seekg(0, ios::beg);

    // Read Num Nodes + Num Edges
    infile.read(reinterpret_cast<char*>(&v), sizeof(int));
    infile.read(reinterpret_cast<char*>(&u), sizeof(long long));

    numNodes = v;
    numEdges = u;

    // Read Node degrees
    inv_node_deg.resize(numNodes + 1);
    node_deg.resize(numNodes + 1);
    for (int i = 1; i <= numNodes; i++){
        infile.read(reinterpret_cast<char*>(&v), sizeof(int));
        inv_node_deg[i] = v;
    }
    for (int i = 1; i <= numNodes; i++){
        infile.read(reinterpret_cast<char*>(&v), sizeof(int));
        node_deg[i] = v;
    }


    // Read Neighbors
    adjList.resize(numNodes + 1);
    invAdjList.resize(numNodes + 1);
    for (int i = 1; i <= numNodes; i++){
        adjList[i].resize(node_deg[i]);
        invAdjList[i].resize(inv_node_deg[i]);
        // Incoming neighbors
        for (int j = 0; j < inv_node_deg[i]; ++j){
            infile.read(reinterpret_cast<char*>(&v), sizeof(int));
            invAdjList[i][j] = v;
        }
        // Outgoing neighbors
        for (int j = 0; j < node_deg[i]; ++j){
            infile.read(reinterpret_cast<char*>(&v), sizeof(int));
            adjList[i][j] = v;
        }
    }

    weights.resize(numNodes + 1);
    probabilities.resize(numNodes + 1);

    if (rand_edges)
        rand_graph(m, s);
    else{
        float tmp;
        // vector<UI> b;
        // invProbabilities.resize(numNodes + 1);
        for (unsigned int i = 1; i <= numNodes; ++i){
            weights[i].resize(inv_node_deg[i]);
            // invProbabilities[i].resize(inv_node_deg[i]);
            probabilities[i].resize(node_deg[i]);

            // vector<UI> tmp1(inv_node_deg[i] + 1, 0);
            for(int j = 0; j < inv_node_deg[i]; ++j){
                infile.read(reinterpret_cast<char*>(&tmp), sizeof(float));
                weights[i][j] = tmp;
                // weights[i][j] = tmp*UI_MAX;
                // invProbabilities[i][j] = tmp;
                // if (weights[i][j] <= 0)
                //     weights[i][j] = UI_MAX;
            }

            for(int j = 0; j < node_deg[i]; ++j){
                infile.read(reinterpret_cast<char*>(&tmp), sizeof(float));
                probabilities[i][j] = tmp;
            }
        }

    }
    

    infile.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movss %xmm1, 0x44(%rsp)
movss %xmm0, 0x40(%rsp)
movl %edx, %ebp
movq %rdi, %r13
leaq 0x50(%rsp), %rbx
pushq $0xe
popq %rdx
movq %rbx, %rdi
callq 0x3500
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3410
leaq 0x50(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x33e0
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0x33e0
movl 0x8(%rsp), %esi
movl %esi, 0x9c8(%r13)
movl 0x48(%rsp), %eax
movl %eax, 0x9cc(%r13)
leaq 0xa70(%r13), %rdi
incl %esi
movq %rdi, 0x20(%rsp)
callq 0x9252
leaq 0xa20(%r13), %rdi
movl 0x9c8(%r13), %esi
incl %esi
movq %rdi, 0x30(%rsp)
callq 0x9252
pushq $0x1
popq %r15
leaq 0x50(%rsp), %rbx
leaq 0x8(%rsp), %r14
pushq $0x4
popq %r12
movl 0x9c8(%r13), %esi
cmpq %rsi, %r15
ja 0xbb74
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x33e0
movl 0x8(%rsp), %eax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
jmp 0xbb45
pushq $0x1
popq %r15
leaq 0x50(%rsp), %rbx
leaq 0x8(%rsp), %r14
pushq $0x4
popq %r12
movl %esi, %eax
cmpq %rax, %r15
ja 0xbbb6
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x33e0
movl 0x8(%rsp), %eax
movq 0xa20(%r13), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
movl 0x9c8(%r13), %esi
jmp 0xbb86
leaq 0x9d8(%r13), %rdi
incl %esi
movq %rdi, 0x10(%rsp)
callq 0xebd4
leaq 0xa88(%r13), %rdi
movl 0x9c8(%r13), %esi
incl %esi
movq %rdi, 0x18(%rsp)
callq 0xebd4
movl %ebp, 0xc(%rsp)
movq %r13, 0x38(%rsp)
pushq $0x1
popq %r15
leaq 0x50(%rsp), %rbp
leaq 0x8(%rsp), %rbx
pushq $0x4
popq %r14
movq 0x38(%rsp), %rax
movl 0x9c8(%rax), %esi
cmpq %rsi, %r15
ja 0xbccc
imulq $0x18, %r15, %r12
movq 0x10(%rsp), %rax
movq (%rax), %rdi
addq %r12, %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rsi
callq 0x9252
movq 0x18(%rsp), %rax
movq (%rax), %rdi
addq %r12, %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rsi
callq 0x9252
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r13
jge 0xbc89
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x33e0
movl 0x8(%rsp), %eax
movq 0x18(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r12), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
jmp 0xbc51
xorl %r13d, %r13d
movq 0x30(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r13
jge 0xbcc4
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x33e0
movl 0x8(%rsp), %eax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r12), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
jmp 0xbc8c
incq %r15
jmp 0xbbfe
movq 0x38(%rsp), %rbx
leaq 0xaa0(%rbx), %rdi
incq %rsi
movq %rdi, 0x18(%rsp)
callq 0xec0a
movl 0xc(%rsp), %ebp
leaq 0x9f0(%rbx), %rdi
movl 0x9c8(%rbx), %esi
incl %esi
movq %rdi, 0x10(%rsp)
callq 0xec0a
testb %bpl, %bpl
je 0xbd41
movq %rbx, %rdi
movss 0x40(%rsp), %xmm0
movss 0x44(%rsp), %xmm1
callq 0xc67e
leaq 0x50(%rsp), %rdi
callq 0x30b0
leaq 0x50(%rsp), %rdi
callq 0x30e0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rcx
leaq 0x50(%rsp), %rbp
leaq 0x2c(%rsp), %rbx
pushq $0x4
popq %r14
movq 0x38(%rsp), %rax
cmpl 0x9c8(%rax), %ecx
ja 0xbd1b
movl %ecx, 0xc(%rsp)
movl %ecx, %r15d
imulq $0x18, %r15, %r12
movq 0x18(%rsp), %rax
movq (%rax), %rdi
addq %r12, %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rsi
callq 0xea98
movq 0x10(%rsp), %rax
movq (%rax), %rdi
addq %r12, %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rsi
callq 0xea98
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r13
jge 0xbde1
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x33e0
movss 0x2c(%rsp), %xmm0
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r12), %rax
movss %xmm0, (%rax,%r13,4)
incq %r13
jmp 0xbda5
xorl %r13d, %r13d
movq 0x30(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r13
jge 0xbe20
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x33e0
movss 0x2c(%rsp), %xmm0
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r12), %rax
movss %xmm0, (%rax,%r13,4)
incq %r13
jmp 0xbde4
movl 0xc(%rsp), %ecx
incl %ecx
jmp 0xbd52
jmp 0xbe3b
jmp 0xbe3b
jmp 0xbe3b
jmp 0xbe3b
jmp 0xbe3b
jmp 0xbe3b
jmp 0xbe3b
jmp 0xbe3b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x30e0
movq %rbx, %rdi
callq 0x3590