// File: /workspace/github_cpp_makefile_star2_O1/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, 0x40(%rsp)
movss %xmm0, 0x3c(%rsp)
movl %edx, 0x44(%rsp)
movq %rdi, %r15
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
movl $0xe, %edx
callq 0x3530
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3430
leaq 0x50(%rsp), %rdi
leaq 0xc(%rsp), %rsi
movl $0x4, %edx
callq 0x3400
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movl $0x8, %edx
callq 0x3400
movl 0xc(%rsp), %esi
movl %esi, 0x9c8(%r15)
movl 0x48(%rsp), %eax
movl %eax, 0x9cc(%r15)
leaq 0xa70(%r15), %rbp
incl %esi
movq %rbp, %rdi
callq 0xb4e8
leaq 0xa20(%r15), %rdi
movl 0x9c8(%r15), %esi
incl %esi
movq %rdi, 0x10(%rsp)
callq 0xb4e8
cmpl $0x0, 0x9c8(%r15)
je 0xe267
xorl %r14d, %r14d
leaq 0x50(%rsp), %rbx
leaq 0xc(%rsp), %r12
movl $0x4, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq 0xa70(%r15), %rcx
movl %eax, 0x4(%rcx,%r14,4)
movl 0x9c8(%r15), %eax
incq %r14
cmpq %rax, %r14
jb 0xe238
movl 0x9c8(%r15), %esi
testl %esi, %esi
je 0xe2ae
xorl %r14d, %r14d
leaq 0x50(%rsp), %rbx
leaq 0xc(%rsp), %r12
movl $0x4, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq 0xa20(%r15), %rcx
movl %eax, 0x4(%rcx,%r14,4)
movl 0x9c8(%r15), %esi
incq %r14
cmpq %rsi, %r14
jb 0xe27f
leaq 0x9d8(%r15), %rdi
incl %esi
movq %rdi, 0x20(%rsp)
callq 0x129be
leaq 0xa88(%r15), %r13
movl 0x9c8(%r15), %esi
incl %esi
movq %r13, %rdi
callq 0x129be
movl 0x9c8(%r15), %esi
testl %esi, %esi
movq %rbp, 0x18(%rsp)
movq %r15, 0x30(%rsp)
je 0xe3f2
movl $0x1, %r15d
leaq 0x50(%rsp), %rbx
leaq 0xc(%rsp), %rbp
leaq (%r15,%r15,2), %r12
leaq (,%r12,8), %r14
movq 0x20(%rsp), %rax
movq (%rax), %rdi
addq %r14, %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rsi
callq 0xb4e8
addq (%r13), %r14
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rsi
movq %r14, %rdi
callq 0xb4e8
movq 0x18(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r15,4)
jle 0xe388
xorl %r14d, %r14d
movl $0x4, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq (%r13), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, (%rcx,%r14,4)
incq %r14
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r14
jl 0xe354
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r15,4)
jle 0xe3d2
xorl %r14d, %r14d
movl $0x4, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, (%rcx,%r14,4)
incq %r14
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r15,4), %rax
cmpq %rax, %r14
jl 0xe39a
leaq 0x1(%r15), %rax
movq 0x30(%rsp), %rcx
movl 0x9c8(%rcx), %esi
cmpq %rsi, %r15
movq %rax, %r15
jb 0xe302
movq 0x30(%rsp), %r15
leaq 0xaa0(%r15), %rdi
incl %esi
movq %rdi, 0x20(%rsp)
callq 0x12a40
leaq 0x9f0(%r15), %r13
movl 0x9c8(%r15), %esi
incl %esi
movq %r13, %rdi
callq 0x12a40
cmpb $0x0, 0x44(%rsp)
je 0xe43d
movq %r15, %rdi
movss 0x3c(%rsp), %xmm0
movss 0x40(%rsp), %xmm1
callq 0xef20
jmp 0xe54b
cmpl $0x0, 0x9c8(%r15)
je 0xe54b
movl $0x1, %r12d
leaq 0x50(%rsp), %rbp
leaq 0x2c(%rsp), %rbx
movl %r12d, %r12d
leaq (%r12,%r12,2), %r15
leaq (,%r15,8), %r14
movq 0x20(%rsp), %rax
movq (%rax), %rdi
addq %r14, %rdi
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r12,4), %rsi
callq 0x12824
addq (%r13), %r14
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r12,4), %rsi
movq %r14, %rdi
callq 0x12824
movq 0x18(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r12,4)
jle 0xe4ec
xorl %r14d, %r14d
movl $0x4, %edx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3400
movss 0x2c(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r15,8), %rax
movss %xmm0, (%rax,%r14,4)
incq %r14
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r12,4), %rax
cmpq %rax, %r14
jl 0xe4b0
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r12,4)
jle 0xe536
xorl %r14d, %r14d
movl $0x4, %edx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3400
movss 0x2c(%rsp), %xmm0
movq (%r13), %rax
movq (%rax,%r15,8), %rax
movss %xmm0, (%rax,%r14,4)
incq %r14
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r12,4), %rax
cmpq %rax, %r14
jl 0xe4fe
incl %r12d
movq 0x30(%rsp), %rax
cmpl 0x9c8(%rax), %r12d
jbe 0xe45b
leaq 0x50(%rsp), %rdi
callq 0x30b0
leaq 0x50(%rsp), %rdi
callq 0x30d0
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe581
jmp 0xe581
jmp 0xe581
jmp 0xe581
jmp 0xe581
jmp 0xe581
jmp 0xe581
jmp 0xe581
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x30d0
movq %rbx, %rdi
callq 0x35c0