// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getNextNodeWithIdenticalNeighbors(unsigned int const&, std::vector<unsigned int, std::allocator<unsigned int>> const&) const
uint32_t Graph::getNextNodeWithIdenticalNeighbors(const uint32_t &previousNode, const vector<uint32_t> &neighbors) const {
    uint32_t pos = (!mapping ? previousNode : idToPos->at(previousNode));
    for (pos = pos+1 ; pos < nodeIndex.size() ; pos++) {
        if (!nodeIndex[pos].removed && nodeIndex[pos].edges == neighbors.size()) {
            uint32_t neighborCount = neighbors.size();
            uint32_t nextNodeOffset = (pos == nodeIndex.size()-1 ? edgeBuffer->size() : nodeIndex[pos+1].offset);
            for (uint32_t offset = nodeIndex[pos].offset ; offset  < nextNodeOffset && neighborCount; offset++) {
                uint32_t nPos = (!mapping ? (*edgeBuffer)[offset] : idToPos->at((*edgeBuffer)[offset]));
                if (!nodeIndex[nPos].removed && find(neighbors.begin(), neighbors.end(), (*edgeBuffer)[offset]) != neighbors.end()) {
                    neighborCount--;
                }
            }
            if (!neighborCount) {
                return (!mapping ? pos : posToId->at(pos));
            }
        }
    }
    return NONE;
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0x98(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x48(%rsp)
testb $0x1, 0x3c(%rax)
jne 0x4aa2
movq 0x90(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x44(%rsp)
jmp 0x4abe
movq 0x48(%rsp), %rax
movq 0x40(%rax), %rdi
movq 0x90(%rsp), %rsi
callq 0x188b0
movl (%rax), %eax
movl %eax, 0x44(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x84(%rsp)
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
movq 0x48(%rsp), %rdi
movl 0x84(%rsp), %eax
movq %rax, 0x38(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jae 0x4d9c
movq 0x48(%rsp), %rdi
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
jne 0x4d84
movq 0x48(%rsp), %rdi
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl 0x4(%rax), %eax
movq %rax, 0x30(%rsp)
movq 0x88(%rsp), %rdi
callq 0x188e0
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jne 0x4d84
movq 0x88(%rsp), %rdi
callq 0x188e0
movq 0x48(%rsp), %rdi
movl %eax, 0x80(%rsp)
movl 0x84(%rsp), %eax
movq %rax, 0x28(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x28(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x4ba7
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x188e0
movq %rax, 0x20(%rsp)
jmp 0x4bc6
movq 0x48(%rsp), %rdi
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rdi
movq 0x20(%rsp), %rax
movl %eax, 0x7c(%rsp)
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movl %eax, 0x78(%rsp)
movl 0x78(%rsp), %ecx
xorl %eax, %eax
cmpl 0x7c(%rsp), %ecx
movb %al, 0x1f(%rsp)
jae 0x4c07
cmpl $0x0, 0x80(%rsp)
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x4c14
jmp 0x4d36
movq 0x48(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x4c3b
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x78(%rsp), %eax
movl %eax, %esi
callq 0x18900
movl (%rax), %eax
movl %eax, 0x18(%rsp)
jmp 0x4c6b
movq 0x48(%rsp), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rdi
movl 0x78(%rsp), %eax
movl %eax, %esi
callq 0x18900
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x188b0
movl (%rax), %eax
movl %eax, 0x18(%rsp)
movq 0x48(%rsp), %rdi
movl 0x18(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
movl %eax, %esi
callq 0x18850
movq %rax, %rcx
xorl %eax, %eax
testb $0x1, 0x8(%rcx)
movb %al, 0xf(%rsp)
jne 0x4d09
movq 0x88(%rsp), %rdi
callq 0x193b0
movq %rax, 0x60(%rsp)
movq 0x88(%rsp), %rdi
callq 0x19420
movq %rax, %rcx
movq 0x48(%rsp), %rax
movq %rcx, 0x58(%rsp)
movq 0x18(%rax), %rdi
movl 0x78(%rsp), %eax
movl %eax, %esi
callq 0x18900
movq %rax, %rdx
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x194a0
movq %rax, 0x68(%rsp)
movq 0x88(%rsp), %rdi
callq 0x19420
movq %rax, 0x50(%rsp)
leaq 0x68(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x193e0
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x4d13
jmp 0x4d24
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
jmp 0x4d26
movl 0x78(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x78(%rsp)
jmp 0x4be8
cmpl $0x0, 0x80(%rsp)
jne 0x4d82
movq 0x48(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x4d58
movl 0x84(%rsp), %eax
movl %eax, 0x8(%rsp)
jmp 0x4d75
movq 0x48(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0x84(%rsp), %eax
movl %eax, %esi
callq 0x18870
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0xa4(%rsp)
jmp 0x4da7
jmp 0x4d84
jmp 0x4d86
movl 0x84(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x84(%rsp)
jmp 0x4ada
movl $0xffffffff, 0xa4(%rsp) # imm = 0xFFFFFFFF
movl 0xa4(%rsp), %eax
addq $0xa8, %rsp
retq
nopw %cs:(%rax,%rax)