// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %rbx
movl %ecx, %r15d
movq %rdx, 0x48(%rsp)
movq %rdi, %r14
movq 0xa0(%rsp), %rdi
movq %rsi, 0x20(%rsp)
movl 0x9c8(%rsi), %r12d
callq 0x12bb8
movq %r12, 0x28(%rsp)
testq %r12, %r12
movq %rbx, 0x18(%rsp)
je 0xfba6
movl %eax, %ecx
leaq 0x40(%r14), %rax
movq %rax, 0x30(%rsp)
movslq 0xa8(%rsp), %rax
movq %rax, 0x38(%rsp)
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r8d, %r8d
movq %r14, %r9
movq 0x20(%rsp), %r10
movl %r15d, 0x10(%rsp)
movq (%rbx), %rax
movl $0x1, %edx
shlq %cl, %rdx
movl %ecx, %r11d
shrl $0x6, %r11d
movq (%rax,%r11,8), %rsi
btq %rcx, %rsi
jb 0xfbb0
movl %ecx, %edi
orq %rdx, %rsi
movq %rsi, (%rax,%r11,8)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movl %ecx, (%rax,%rbp,4)
movq 0x48(%rsp), %rax
movq (%rax), %rax
cmpl %r15d, (%rax,%rdi,4)
movzbl %r8b, %r8d
movl $0x1, %eax
cmovbl %eax, %r8d
leaq (%rdi,%rdi,2), %r11
leaq (,%r11,8), %r14
movq 0xa70(%r10), %rax
movl (%rax,%rdi,4), %r12d
addq 0xaa0(%r10), %r14
cmpl $0x270, 0xa00(%r9) # imm = 0x270
jl 0xfadc
movq 0x30(%rsp), %rdi
movl %r8d, %ebx
movl %r13d, 0x14(%rsp)
movq %r9, %r13
movq %rcx, 0x40(%rsp)
movq %r11, %r15
callq 0x16314
movq %r15, %r11
movq 0x40(%rsp), %rcx
movq 0x20(%rsp), %r10
movq %r13, %r9
movl 0x14(%rsp), %r13d
movl 0x10(%rsp), %r15d
movl %ebx, %r8d
movq 0x18(%rsp), %rbx
movl $0x0, 0xa00(%r9)
movslq 0xa00(%r9), %rdx
leal 0x1(%rdx), %eax
movl %eax, 0xa00(%r9)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r12, %r12
je 0xfb6d
movq 0x30(%rsp), %rsi
movl (%rsi,%rdx,4), %edx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
mulsd 0x8c11(%rip), %xmm0     # 0x18720
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
leal -0x1(%r12), %edx
movq (%r14), %rdi
xorps %xmm2, %xmm2
cvtss2sd (%rdi,%rdx,4), %xmm2
movslq %ecx, %rdx
movq 0xae0(%r10), %rsi
leaq (%rdx,%rdx,2), %rdx
movq (%rsi,%rdx,8), %rdx
movq 0x38(%rsp), %rsi
movsd (%rdx,%rsi,8), %xmm1
mulsd %xmm1, %xmm2
ucomisd %xmm2, %xmm0
ja 0xfb6d
xorl %edx, %edx
xorps %xmm2, %xmm2
cvtss2sd (%rdi,%rdx,4), %xmm2
mulsd %xmm1, %xmm2
ucomisd %xmm0, %xmm2
jae 0xfb6b
incq %rdx
cmpq %rdx, %r12
jne 0xfb4f
jmp 0xfb6d
movl %edx, %eax
cmpl $-0x1, %eax
je 0xfb83
movq 0xa88(%r10), %rcx
movslq %eax, %rdx
movq (%rcx,%r11,8), %rcx
movl (%rcx,%rdx,4), %ecx
incl %r13d
cmpl $-0x1, %eax
je 0xfbb8
incq %rbp
cmpq 0x28(%rsp), %rbp
jne 0xfa1a
movq %r9, %r15
movq 0x28(%rsp), %rax
movl %eax, %r13d
jmp 0xfbbb
movq %r14, %r15
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0xfbbe
movq %r9, %r15
movl %ebp, %r13d
jmp 0xfbbb
movq %r9, %r15
movl %r8d, %ebp
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movl %r13d, %ebx
leaq (%rsi,%rbx,4), %rdx
leaq 0x50(%rsp), %r14
leaq 0x7(%rsp), %rcx
movq %r14, %rdi
callq 0x12cc4
movq %r15, %rdi
addq $0x18, %rdi
movq %r14, %rsi
callq 0x1426c
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xfbfd
callq 0x3340
testl %r13d, %r13d
je 0xfc60
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
movq 0x18(%rsp), %rcx
movq (%rcx), %rsi
xorl %edi, %edi
leaq 0x3f(%rax), %r8
movslq (%rdx,%rdi,4), %rcx
leaq 0x3f(%rcx), %r9
testq %rcx, %rcx
cmovnsq %rcx, %r9
sarq $0x6, %r9
movq %rcx, %r10
andq %r8, %r10
xorl %r11d, %r11d
cmpq %rax, %r10
setbe %r11b
movq $-0x2, %r10
rolq %cl, %r10
leaq (%rsi,%r9,8), %rcx
andq %r10, -0x8(%rcx,%r11,8)
incq %rdi
cmpq %rdi, %rbx
jne 0xfc22
movl %ebp, %eax
andb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0xfc85
callq 0x3340
movq %rbx, %rdi
callq 0x35c0
nop