// File: iPapatsoris[P]Maximum-Independent-Set/src/Reductions.cpp
// Function: Reductions::removeDominatedNodes2(unsigned int const&)
bool Reductions::removeDominatedNodes2(const uint32_t &theta) {
    for (uint32_t pos1 = 0 ; pos1 < graph.nodeIndex.size() ; pos1++) {
        if (!graph.nodeIndex[pos1].edges || graph.nodeIndex[pos1].removed || theta == 3 && graph.nodeIndex[pos1].edges != 1) {
            continue;
        }
        for (uint32_t pos2 = pos1+1 ; pos2 < graph.nodeIndex.size() ; pos2++) {
            if (graph.nodeIndex[pos2].removed || graph.nodeIndex[pos1].edges > graph.nodeIndex[pos2].edges) {
                continue;
            }
            uint32_t node1 = graph.getNode(pos1);
            vector<uint32_t> neighbors1;
            uint32_t nextNodeOffset = (pos2 == graph.nodeIndex.size()-1 ? graph.edgeBuffer->size() : graph.nodeIndex[pos2+1].offset);
            graph.gatherNeighbors(node1, neighbors1);
            vector<uint32_t>::iterator begin = graph.edgeBuffer->begin();
            vector<uint32_t>::iterator end = graph.edgeBuffer->begin();
            std::advance(begin, graph.nodeIndex[pos2].offset);
            std::advance(end, nextNodeOffset);
            if (isSubsetOf(neighbors1, begin, end)) {
                uint32_t node2 = graph.getNode(pos2);
                //cout << "Dominated node " << node2 << "\n";
                graph.remove(node2, reduceInfo, (theta == 3 ? true : false));
                if (!graph.nodeIndex[pos1].edges) {
                    break;
                }
            }
        }
    }
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x0, 0x94(%rsp)
movq 0x30(%rsp), %rax
movl 0x94(%rsp), %ecx
movq %rcx, 0x28(%rsp)
movq (%rax), %rdi
callq 0x18830
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x3185a
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x94(%rsp), %eax
movl %eax, %esi
callq 0x19050
cmpl $0x0, 0x4(%rax)
je 0x3158a
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x94(%rsp), %eax
movl %eax, %esi
callq 0x19050
testb $0x1, 0x8(%rax)
jne 0x3158a
movq 0x98(%rsp), %rax
cmpl $0x3, (%rax)
jne 0x3158f
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x94(%rsp), %eax
movl %eax, %esi
callq 0x19050
cmpl $0x1, 0x4(%rax)
je 0x3158f
jmp 0x31844
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
movq 0x30(%rsp), %rax
movl 0x90(%rsp), %ecx
movq %rcx, 0x20(%rsp)
movq (%rax), %rdi
callq 0x18830
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x31842
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x90(%rsp), %eax
movl %eax, %esi
callq 0x19050
testb $0x1, 0x8(%rax)
jne 0x31628
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x94(%rsp), %eax
movl %eax, %esi
callq 0x19050
movq %rax, %rcx
movq 0x30(%rsp), %rax
movl 0x4(%rcx), %ecx
movl %ecx, 0x1c(%rsp)
movq (%rax), %rdi
movl 0x90(%rsp), %eax
movl %eax, %esi
callq 0x19050
movq %rax, %rcx
movl 0x1c(%rsp), %eax
cmpl 0x4(%rcx), %eax
jbe 0x3162d
jmp 0x3182c
movq 0x30(%rsp), %rax
movq (%rax), %rdi
leaq 0x94(%rsp), %rsi
callq 0x32f60
movl %eax, 0x8c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x17e60
movq 0x30(%rsp), %rax
movl 0x90(%rsp), %ecx
movq %rcx, 0x10(%rsp)
movq (%rax), %rdi
callq 0x18830
movq %rax, %rcx
movq 0x10(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x31695
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
callq 0x188e0
movq %rax, 0x8(%rsp)
jmp 0x316b7
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x19050
movl (%rax), %eax
movq %rax, 0x8(%rsp)
movq 0x30(%rsp), %rax
movq 0x8(%rsp), %rcx
movl %ecx, 0x6c(%rsp)
movq (%rax), %rdi
movl $0xffffffff, 0x68(%rsp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %ecx
leaq 0x8c(%rsp), %rsi
leaq 0x70(%rsp), %rdx
leaq 0x68(%rsp), %r8
callq 0x19c30
jmp 0x316ed
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
callq 0x19b50
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x50(%rsp)
movq (%rax), %rax
movq 0x18(%rax), %rdi
callq 0x19b50
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x48(%rsp)
movq (%rax), %rdi
movl 0x90(%rsp), %eax
movl %eax, %esi
callq 0x19050
movl (%rax), %esi
leaq 0x50(%rsp), %rdi
callq 0x32fc0
jmp 0x31743
movl 0x6c(%rsp), %esi
leaq 0x48(%rsp), %rdi
callq 0x32fc0
jmp 0x31753
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x45220
movb %al, 0x7(%rsp)
jmp 0x3176d
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x3177a
jmp 0x3180c
movq 0x30(%rsp), %rax
movq (%rax), %rdi
leaq 0x90(%rsp), %rsi
callq 0x32f60
movl %eax, (%rsp)
jmp 0x31794
movq 0x30(%rsp), %rdx
movl (%rsp), %eax
movl %eax, 0x44(%rsp)
movq (%rdx), %rdi
addq $0x10, %rdx
movq 0x98(%rsp), %rax
movl (%rax), %eax
subl $0x3, %eax
sete 0x43(%rsp)
leaq 0x44(%rsp), %rsi
leaq 0x43(%rsp), %rcx
callq 0x32f0
jmp 0x317ca
movq 0x30(%rsp), %rax
movq (%rax), %rdi
movl 0x94(%rsp), %eax
movl %eax, %esi
callq 0x19050
cmpl $0x0, 0x4(%rax)
jne 0x3180a
movl $0x5, 0x3c(%rsp)
jmp 0x31814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x18520
jmp 0x3185c
jmp 0x3180c
movl $0x0, 0x3c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x18520
movl 0x3c(%rsp), %eax
testl %eax, %eax
je 0x3182a
jmp 0x31828
jmp 0x31842
jmp 0x3182c
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x315a0
jmp 0x31844
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x314ff
ud2
movq 0x60(%rsp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)