// File: dtsaras[P]GCW/rwgraph.cpp
// Function: HyperGraph::pollingLT(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::pollingLT(Graph &g, vector<unsigned int> & link, unsigned int k, vector<bool> &visit, vector<int> &visit_mark, sampler<int> &samp, int p)
{
    unsigned int i;
    bool t = false;
    unsigned int gSize = g.getSize();
    // unsigned int cur = sfmt_genrand_uint32(&sfmtSeed)%gSize+1;
    unsigned cur = samp();
    unsigned int num_marked = 0;
    // cout << "startLT: " << cur << endl;
    for (i = 0; i < gSize; ++i){
    	if (link[cur] < k){
            t=true;
    		break;
        }
        if (visit[cur] == true) break;
        visit[cur] = true;
        visit_mark[num_marked] = cur;
    	num_marked++;
    	int ind;

        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;

        // cur = g.invAdjList[cur][ind-1];
        cur = g.invAdjList[cur][ind];
        // cout << cur << endl;
    }
    for (i = 0; i < num_marked; ++i){
        visit[visit_mark[i]]=false;
    }
    return t;
}

// Assembly:
subq $0xa8, %rsp
movl 0xb8(%rsp), %eax
movq 0xb0(%rsp), %rax
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movl %ecx, 0x8c(%rsp)
movq %r8, 0x80(%rsp)
movq %r9, 0x78(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x20(%rsp)
movb $0x0, 0x73(%rsp)
movq 0x98(%rsp), %rdi
callq 0x1db70
movl %eax, 0x6c(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x24d10
movl %eax, 0x68(%rsp)
movl $0x0, 0x64(%rsp)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jae 0x1fcb4
movq 0x90(%rsp), %rdi
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0xee00
movl (%rax), %eax
cmpl 0x8c(%rsp), %eax
jae 0x1fb4c
movb $0x1, 0x73(%rsp)
jmp 0x1fcb4
movq 0x80(%rsp), %rdi
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0xe790
movq %rax, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
leaq 0x50(%rsp), %rdi
callq 0xeb50
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1fb82
jmp 0x1fcb4
movq 0x80(%rsp), %rdi
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0xe790
movq %rax, 0x40(%rsp)
movq %rdx, 0x48(%rsp)
leaq 0x40(%rsp), %rdi
movl $0x1, %esi
callq 0xe7f0
movl 0x68(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x78(%rsp), %rdi
movl 0x64(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x98(%rsp), %rdi
addq $0xaa0, %rdi            # imm = 0xAA0
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0x24890
movq %rax, 0x18(%rsp)
movq 0x98(%rsp), %rdi
addq $0xa70, %rdi            # imm = 0xA70
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movl (%rax), %ecx
movl 0x68(%rsp), %r8d
movl 0xb8(%rsp), %r9d
callq 0x24e30
movl %eax, 0x3c(%rsp)
movq 0x98(%rsp), %rdi
addq $0xaa0, %rdi            # imm = 0xAA0
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0x24890
movq %rax, %rdi
callq 0x24fa0
cmpq $0x20, %rax
jb 0x1fc77
cmpl $-0x1, 0x3c(%rsp)
jne 0x1fc75
jmp 0x1fcb4
jmp 0x1fc77
movq 0x98(%rsp), %rdi
addq $0xa88, %rdi            # imm = 0xA88
movl 0x68(%rsp), %eax
movl %eax, %esi
callq 0x24850
movq %rax, %rdi
movslq 0x3c(%rsp), %rsi
callq 0xe3b0
movl (%rax), %eax
movl %eax, 0x68(%rsp)
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x1fb16
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
cmpl 0x64(%rsp), %eax
jae 0x1fd11
movq 0x80(%rsp), %rax
movq %rax, (%rsp)
movq 0x78(%rsp), %rdi
movl 0x74(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movq (%rsp), %rdi
movslq (%rax), %rsi
callq 0xe790
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
callq 0xe7f0
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x1fcbc
movb 0x73(%rsp), %al
andb $0x1, %al
addq $0xa8, %rsp
retq
nop