// File: /workspace/github_cpp_makefile_star2_O3/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 0xb36a
leaq 0xa20(%r15), %rdi
movl 0x9c8(%r15), %esi
incl %esi
movq %rdi, 0x10(%rsp)
callq 0xb36a
movl $0x1, %ebx
cmpl $0x0, 0x9c8(%r15)
je 0xe0ff
xorl %r14d, %r14d
leaq 0x50(%rsp), %r12
leaq 0xc(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %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 0xe08d
testl %eax, %eax
je 0xe0ff
xorl %r14d, %r14d
leaq 0x50(%rsp), %r12
leaq 0xc(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq 0xa20(%r15), %rcx
movl %eax, 0x4(%rcx,%r14,4)
movl 0x9c8(%r15), %ebx
incq %r14
cmpq %rbx, %r14
jb 0xe0cd
incq %rbx
leaq 0x9d8(%r15), %rdi
movq %rdi, 0x20(%rsp)
movq %rbx, %rsi
callq 0x12798
leaq 0xa88(%r15), %r13
movl 0x9c8(%r15), %esi
incl %esi
movq %r13, %rdi
callq 0x12798
cmpl $0x0, 0x9c8(%r15)
movq %rbp, 0x18(%rsp)
movq %r15, 0x30(%rsp)
je 0xe248
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl $0x1, %r14d
leaq 0x50(%rsp), %rbp
leaq 0xc(%rsp), %rbx
leaq (%r14,%r14,2), %r12
leaq (,%r12,8), %r15
movq 0x20(%rsp), %rcx
movq (%rcx), %rdi
addq %r15, %rdi
movslq (%rax,%r14,4), %rsi
callq 0xb36a
addq (%r13), %r15
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rsi
movq %r15, %rdi
callq 0xb36a
movq 0x18(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r14,4)
jle 0xe1d9
xorl %r15d, %r15d
movl $0x4, %edx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq (%r13), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rax
cmpq %rax, %r15
jl 0xe1a5
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r14,4)
jle 0xe223
xorl %r15d, %r15d
movl $0x4, %edx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x3400
movl 0xc(%rsp), %eax
movq 0x20(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rcx
cmpq %rcx, %r15
jl 0xe1eb
leaq 0x1(%r14), %rcx
movq 0x30(%rsp), %rdx
movl 0x9c8(%rdx), %esi
cmpq %rsi, %r14
movq %rcx, %r14
jb 0xe15b
incq %rsi
movq 0x30(%rsp), %r15
jmp 0xe24d
movl $0x1, %esi
leaq 0xaa0(%r15), %rdi
movq %rdi, 0x20(%rsp)
callq 0x1281a
leaq 0x9f0(%r15), %r13
movl 0x9c8(%r15), %esi
incl %esi
movq %r13, %rdi
callq 0x1281a
cmpb $0x0, 0x44(%rsp)
je 0xe296
movq %r15, %rdi
movss 0x3c(%rsp), %xmm0
movss 0x40(%rsp), %xmm1
callq 0xed76
jmp 0xe3a4
cmpl $0x0, 0x9c8(%r15)
je 0xe3a4
movl $0x1, %r14d
leaq 0x50(%rsp), %rbx
leaq 0x2c(%rsp), %rbp
movl %r14d, %r14d
leaq (%r14,%r14,2), %r15
leaq (,%r15,8), %r12
movq 0x20(%rsp), %rax
movq (%rax), %rdi
addq %r12, %rdi
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rsi
callq 0x125f2
addq (%r13), %r12
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rsi
movq %r12, %rdi
callq 0x125f2
movq 0x18(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r14,4)
jle 0xe345
xorl %r12d, %r12d
movl $0x4, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3400
movss 0x2c(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq (%rax,%r15,8), %rax
movss %xmm0, (%rax,%r12,4)
incq %r12
movq 0x18(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rax
cmpq %rax, %r12
jl 0xe309
movq 0x10(%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax,%r14,4)
jle 0xe38f
xorl %r12d, %r12d
movl $0x4, %edx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3400
movss 0x2c(%rsp), %xmm0
movq (%r13), %rax
movq (%rax,%r15,8), %rax
movss %xmm0, (%rax,%r12,4)
incq %r12
movq 0x10(%rsp), %rax
movq (%rax), %rax
movslq (%rax,%r14,4), %rax
cmpq %rax, %r12
jl 0xe357
incl %r14d
movq 0x30(%rsp), %rax
cmpl 0x9c8(%rax), %r14d
jbe 0xe2b4
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 0xe3da
jmp 0xe3da
jmp 0xe3da
jmp 0xe3da
jmp 0xe3da
jmp 0xe3da
jmp 0xe3da
jmp 0xe3da
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x30d0
movq %rbx, %rdi
callq 0x35c0
nop