// File: /workspace/github_cpp_makefile_star2_O2/dtsaras[P]GCW/rwgraph.cpp
// Function: HyperGraph::pollingLT2(Graph&, std::vector<unsigned int, std::allocator<unsigned int>>&, unsigned int, std::vector<bool, std::allocator<bool>>&, std::vector<int, std::allocator<int>>&, sampler<int>&, int)
bool HyperGraph::pollingLT2(Graph &g, vector<unsigned int> & link, unsigned int k, vector<bool> &visit, vector<int> &visit_mark, sampler<int> &samp, int p)
{   
    // cout << "&&&&&&&&&&&&&&&&&& 1" << endl;
    unsigned int i;
    bool t = false;
    unsigned int gSize = g.getSize();
    // cout << "&&&&&&&&&&&&&&&&&& 2" << endl;
    // unsigned int cur = sfmt_genrand_uint32(&sfmtSeed)%gSize+1; // rand node
    unsigned cur = samp();
    unsigned int num_marked = 0;
    // cout << "startLT2: " << cur << endl;
    for (i = 0; i < gSize; ++i){ // Goes over all nodes
        // cout << cur << " &&&&&&&&&&&&&&&&&& 3" << endl;
        if (visit[cur] == true) break; // Only unvisited
        // cout << "&&&&&&&&&&&&&&&&&& 3" << endl;
        visit[cur] = true;  // marks it visited
        // cout << "&&&&&&&&&&&&&&&&&& 3" << endl;
        visit_mark[num_marked] = cur; // tracks which one was marked at each iteration
        // cout << "&&&&&&&&&&&&&&&&&& 3" << endl;
        num_marked++; // How many were visited
        // cout << "&&&&&&&&&&&&&&&&&& 4" << endl;
        if (link[cur] < k) // Has been influenced
            t=true;
        int ind;
        // cout << "&&&&&&&&&&&&&&&&&& 5" << endl;
        ind = randIndex_lin(g, g.weights[cur],g.inv_node_deg[cur], cur, p);
        // if (g.weights[cur].size() >= 32)
        //     ind = randIndex_bin(g, g.weights[cur],g.inv_node_deg[cur], cur, p);
        // else
        //     ind = randIndex_lin(g, g.weights[cur],g.inv_node_deg[cur], cur, p);

        if (ind == -1)
            break;
        // cout << "&&&&&&&&&&&&&&&&&& 6" << endl;
        // cur = g.invAdjList[cur][ind-1];
        cur = g.invAdjList[cur][ind];
        // cout << "&&&&&&&&&&&&&&&&&& 7" << endl;
        // cout << cur << endl;
    }
    // cout << "&&&&&&&&&&&&&&&&&& 8" << endl;
    edge_node.push_back(vector<int>(visit_mark.begin(),visit_mark.begin()+num_marked));
    for (i = 0; i < num_marked; ++i){
        visit[visit_mark[i]]=false;
    }
    // cout << "&&&&&&&&&&&&&&&&&& 9" << endl;
    return t;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, %r14
movq %r8, 0x30(%rsp)
movl %ecx, 0x1c(%rsp)
movq %rdx, 0x38(%rsp)
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
movq 0x90(%rsp), %rdi
movl 0x9c8(%rsi), %eax
movq %rax, 0x28(%rsp)
callq 0xecc6
movl %eax, %ebp
xorl %r15d, %r15d
movq $0x0, 0x10(%rsp)
cmpq %r15, 0x28(%rsp)
je 0xce3f
movl %ebp, %r13d
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x85d6
testq %rdx, (%rax)
jne 0xce4c
movq %rbx, %rdi
movq %r13, %rsi
callq 0x85d6
orq %rdx, (%rax)
movq %r14, %rbx
movq (%r14), %rax
movl %ebp, (%rax,%r15,4)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movl 0x1c(%rsp), %ecx
cmpl %ecx, (%rax,%r13,4)
setb %al
movq 0x10(%rsp), %rcx
orb %al, %cl
movq %rcx, 0x10(%rsp)
imulq $0x18, %r13, %r14
movq 0xaa0(%r12), %rdx
addq %r14, %rdx
movq 0xa70(%r12), %rax
movl (%rax,%r13,4), %ecx
movq 0x20(%rsp), %rdi
movq %r12, %rsi
movl %ebp, %r8d
movl 0x98(%rsp), %r9d
callq 0xed9c
cmpl $-0x1, %eax
je 0xce46
incq %r15
movq 0xa88(%r12), %rcx
cltq
movq (%rcx,%r14), %rcx
movl (%rcx,%rax,4), %ebp
movq %rbx, %r14
jmp 0xcd8d
movq 0x28(%rsp), %r15
jmp 0xce4c
incl %r15d
movq %rbx, %r14
movq (%r14), %rsi
movl %r15d, %ebx
leaq (%rsi,%rbx,4), %rdx
leaq 0x40(%rsp), %r12
leaq 0xf(%rsp), %rcx
movq %r12, %rdi
callq 0xee22
movq 0x20(%rsp), %rdi
addq $0x18, %rdi
movq %r12, %rsi
callq 0x103fa
movq 0x30(%rsp), %r13
leaq 0x40(%rsp), %rdi
callq 0x90a0
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0xceaa
movq (%r14), %rax
movslq (%rax,%r12,4), %rsi
movq %r13, %rdi
callq 0x85d6
notq %rdx
andq %rdx, (%rax)
incq %r12
jmp 0xce8b
movq 0x10(%rsp), %rax
andb $0x1, %al
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x90a0
movq %rbx, %rdi
callq 0x3590
nop