// File: 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:
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rsi, 0x58(%rsp)
movb %dl, %al
movq %rdi, 0x2d0(%rsp)
movq %rsi, 0x2c8(%rsp)
andb $0x1, %al
movb %al, 0x2c7(%rsp)
movss %xmm0, 0x2c0(%rsp)
movss %xmm1, 0x2bc(%rsp)
movq 0x2d0(%rsp), %rax
movq %rax, 0x50(%rsp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x24a30
movl %eax, %edi
movl $0x2, %esi
callq 0x24a30
movq 0x58(%rsp), %rsi
movl %eax, %edx
leaq 0xb0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x45d0
movq 0x60(%rsp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x44e0
jmp 0x1dc1a
leaq 0xb0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1dc36
leaq 0xb0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movl $0x8, %edx
callq 0x44a0
jmp 0x1dc52
movq 0x50(%rsp), %rax
movl 0xac(%rsp), %ecx
movl %ecx, 0x9c8(%rax)
movl 0xa0(%rsp), %ecx
movl %ecx, 0x9cc(%rax)
movq %rax, %rdi
addq $0xa70, %rdi            # imm = 0xA70
movl 0x9c8(%rax), %eax
incl %eax
movl %eax, %esi
callq 0x12730
jmp 0x1dc8c
movq 0x50(%rsp), %rax
movq %rax, %rdi
addq $0xa20, %rdi            # imm = 0xA20
movl 0x9c8(%rax), %eax
incl %eax
movl %eax, %esi
callq 0x12730
jmp 0x1dcac
movl $0x1, 0x88(%rsp)
movq 0x50(%rsp), %rcx
movl 0x88(%rsp), %eax
cmpl 0x9c8(%rcx), %eax
ja 0x1dd4a
leaq 0xb0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1dce7
movq 0x50(%rsp), %rdi
movl 0xac(%rsp), %eax
movl %eax, 0x4c(%rsp)
addq $0xa70, %rdi            # imm = 0xA70
movslq 0x88(%rsp), %rsi
callq 0xe3b0
movl 0x4c(%rsp), %ecx
movl %ecx, (%rax)
movl 0x88(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x88(%rsp)
jmp 0x1dcb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x4100
jmp 0x1e267
movl $0x1, 0x84(%rsp)
movq 0x50(%rsp), %rcx
movl 0x84(%rsp), %eax
cmpl 0x9c8(%rcx), %eax
ja 0x1ddc2
leaq 0xb0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1dd85
movq 0x50(%rsp), %rdi
movl 0xac(%rsp), %eax
movl %eax, 0x48(%rsp)
addq $0xa20, %rdi            # imm = 0xA20
movslq 0x84(%rsp), %rsi
callq 0xe3b0
movl 0x48(%rsp), %ecx
movl %ecx, (%rax)
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x1dd55
movq 0x50(%rsp), %rax
movq %rax, %rdi
addq $0x9d8, %rdi            # imm = 0x9D8
movl 0x9c8(%rax), %eax
incl %eax
movl %eax, %esi
callq 0x24a50
jmp 0x1dde2
movq 0x50(%rsp), %rax
movq %rax, %rdi
addq $0xa88, %rdi            # imm = 0xA88
movl 0x9c8(%rax), %eax
incl %eax
movl %eax, %esi
callq 0x24a50
jmp 0x1de02
movl $0x1, 0x80(%rsp)
movq 0x50(%rsp), %rcx
movl 0x80(%rsp), %eax
cmpl 0x9c8(%rcx), %eax
ja 0x1dff7
movq 0x50(%rsp), %rdi
addq $0x9d8, %rdi            # imm = 0x9D8
movslq 0x80(%rsp), %rsi
callq 0x24850
movq 0x50(%rsp), %rdi
movq %rax, 0x40(%rsp)
addq $0xa20, %rdi            # imm = 0xA20
movslq 0x80(%rsp), %rsi
callq 0xe3b0
movq 0x40(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12730
jmp 0x1de6b
movq 0x50(%rsp), %rdi
addq $0xa88, %rdi            # imm = 0xA88
movslq 0x80(%rsp), %rsi
callq 0x24850
movq 0x50(%rsp), %rdi
movq %rax, 0x38(%rsp)
addq $0xa70, %rdi            # imm = 0xA70
movslq 0x80(%rsp), %rsi
callq 0xe3b0
movq 0x38(%rsp), %rdi
movslq (%rax), %rsi
callq 0x12730
jmp 0x1deb1
movl $0x0, 0x7c(%rsp)
movq 0x50(%rsp), %rdi
movl 0x7c(%rsp), %eax
movl %eax, 0x34(%rsp)
addq $0xa70, %rdi            # imm = 0xA70
movslq 0x80(%rsp), %rsi
callq 0xe3b0
movq %rax, %rcx
movl 0x34(%rsp), %eax
cmpl (%rcx), %eax
jge 0x1df48
leaq 0xb0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1df01
movq 0x50(%rsp), %rdi
movl 0xac(%rsp), %eax
movl %eax, 0x30(%rsp)
addq $0xa88, %rdi            # imm = 0xA88
movslq 0x80(%rsp), %rsi
callq 0x24850
movq %rax, %rdi
movslq 0x7c(%rsp), %rsi
callq 0xe3b0
movl 0x30(%rsp), %ecx
movl %ecx, (%rax)
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x1deb9
movl $0x0, 0x78(%rsp)
movq 0x50(%rsp), %rdi
movl 0x78(%rsp), %eax
movl %eax, 0x2c(%rsp)
addq $0xa20, %rdi            # imm = 0xA20
movslq 0x80(%rsp), %rsi
callq 0xe3b0
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl (%rcx), %eax
jge 0x1dfdf
leaq 0xb0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1df98
movq 0x50(%rsp), %rdi
movl 0xac(%rsp), %eax
movl %eax, 0x28(%rsp)
addq $0x9d8, %rdi            # imm = 0x9D8
movslq 0x80(%rsp), %rsi
callq 0x24850
movq %rax, %rdi
movslq 0x78(%rsp), %rsi
callq 0xe3b0
movl 0x28(%rsp), %ecx
movl %ecx, (%rax)
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x1df50
jmp 0x1dfe1
movl 0x80(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x1de0d
movq 0x50(%rsp), %rax
movq %rax, %rdi
addq $0xaa0, %rdi            # imm = 0xAA0
movl 0x9c8(%rax), %eax
incl %eax
movl %eax, %esi
callq 0x24af0
jmp 0x1e017
movq 0x50(%rsp), %rax
movq %rax, %rdi
addq $0x9f0, %rdi            # imm = 0x9F0
movl 0x9c8(%rax), %eax
incl %eax
movl %eax, %esi
callq 0x24af0
jmp 0x1e037
testb $0x1, 0x2c7(%rsp)
je 0x1e064
movq 0x50(%rsp), %rdi
movss 0x2c0(%rsp), %xmm0
movss 0x2bc(%rsp), %xmm1
callq 0x1f310
jmp 0x1e05f
jmp 0x1e243
movl $0x1, 0x70(%rsp)
movq 0x50(%rsp), %rcx
movl 0x70(%rsp), %eax
cmpl 0x9c8(%rcx), %eax
ja 0x1e241
movq 0x50(%rsp), %rdi
addq $0xaa0, %rdi            # imm = 0xAA0
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0x24890
movq 0x50(%rsp), %rdi
movq %rax, 0x20(%rsp)
addq $0xa70, %rdi            # imm = 0xA70
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movq 0x20(%rsp), %rdi
movslq (%rax), %rsi
callq 0x244a0
jmp 0x1e0c3
movq 0x50(%rsp), %rdi
addq $0x9f0, %rdi            # imm = 0x9F0
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0x24890
movq 0x50(%rsp), %rdi
movq %rax, 0x18(%rsp)
addq $0xa20, %rdi            # imm = 0xA20
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movq 0x18(%rsp), %rdi
movslq (%rax), %rsi
callq 0x244a0
jmp 0x1e105
movl $0x0, 0x6c(%rsp)
movq 0x50(%rsp), %rdi
movl 0x6c(%rsp), %eax
movl %eax, 0x14(%rsp)
addq $0xa70, %rdi            # imm = 0xA70
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movq %rax, %rcx
movl 0x14(%rsp), %eax
cmpl (%rcx), %eax
jge 0x1e19a
leaq 0xb0(%rsp), %rdi
leaq 0x74(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1e150
movq 0x50(%rsp), %rdi
movss 0x74(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
addq $0xaa0, %rdi            # imm = 0xAA0
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0x24890
movq %rax, %rdi
movslq 0x6c(%rsp), %rsi
callq 0xf1a0
movss 0x10(%rsp), %xmm0
movss %xmm0, (%rax)
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x1e10d
movl $0x0, 0x68(%rsp)
movq 0x50(%rsp), %rdi
movl 0x68(%rsp), %eax
movl %eax, 0xc(%rsp)
addq $0xa20, %rdi            # imm = 0xA20
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movq %rax, %rcx
movl 0xc(%rsp), %eax
cmpl (%rcx), %eax
jge 0x1e22f
leaq 0xb0(%rsp), %rdi
leaq 0x74(%rsp), %rsi
movl $0x4, %edx
callq 0x44a0
jmp 0x1e1e5
movq 0x50(%rsp), %rdi
movss 0x74(%rsp), %xmm0
movss %xmm0, 0x8(%rsp)
addq $0x9f0, %rdi            # imm = 0x9F0
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0x24890
movq %rax, %rdi
movslq 0x68(%rsp), %rsi
callq 0xf1a0
movss 0x8(%rsp), %xmm0
movss %xmm0, (%rax)
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x1e1a2
jmp 0x1e231
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x1e06c
jmp 0x1e243
leaq 0xb0(%rsp), %rdi
callq 0x40d0
jmp 0x1e252
leaq 0xb0(%rsp), %rdi
callq 0x4100
addq $0x2d8, %rsp            # imm = 0x2D8
retq
movq 0x90(%rsp), %rdi
callq 0x4690
nopw %cs:(%rax,%rax)