// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getNeighborsAtDistance2(unsigned int const&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, unsigned int const&, unsigned int*) const
void Graph::getNeighborsAtDistance2(const uint32_t &node, unordered_set<uint32_t> &neighbors, const uint32_t &degree, uint32_t *count) const {
    if (degree != NONE && count != NULL) {
        *count = 0;
    }
    uint32_t pos = (!mapping ? node : idToPos->at(node));
    uint32_t neighborCount = nodeIndex[pos].edges;
    uint32_t nextNodeOffset = (pos == nodeIndex.size()-1 ? edgeBuffer->size() : nodeIndex[pos+1].offset);
    for (uint32_t i = nodeIndex[pos].offset ; i < nextNodeOffset && neighborCount ; i++) {
        uint32_t nPos = (!mapping ? (*edgeBuffer)[i] : idToPos->at((*edgeBuffer)[i]));
        if (!nodeIndex[nPos].removed) {
            neighborCount--;
            uint32_t neighborCount2 = nodeIndex[nPos].edges;
            uint32_t nextNodeOffset2 = (nPos == nodeIndex.size()-1 ? edgeBuffer->size() : nodeIndex[nPos+1].offset);
            for (uint32_t j = nodeIndex[nPos].offset ; j < nextNodeOffset2 && neighborCount2 ; j++) {
                uint32_t id = (*edgeBuffer)[j];
                uint32_t nPos2 = (!mapping ? id : idToPos->at(id));
                if (!nodeIndex[nPos2].removed) {
                    neighborCount2--;
                    if (id != node && !edgeExists(id, node)) {
                        neighbors.insert(id);
                        if (degree != NONE && count != NULL && nodeIndex[nPos2].edges < degree) {
                            (*count)++;
                        }
                    }
                }
            }
        }
    }
}

// Assembly:
subq $0xa8, %rsp
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movq %rcx, 0x88(%rsp)
movq %r8, 0x80(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x88(%rsp), %rax
cmpl $-0x1, (%rax)
je 0x2f92
cmpq $0x0, 0x80(%rsp)
je 0x2f92
movq 0x80(%rsp), %rax
movl $0x0, (%rax)
movq 0x40(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x2fad
movq 0x98(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x3c(%rsp)
jmp 0x2fc9
movq 0x40(%rsp), %rax
movq 0x40(%rax), %rdi
movq 0x98(%rsp), %rsi
callq 0x188b0
movl (%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0x40(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, 0x7c(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, %esi
callq 0x18850
movq 0x40(%rsp), %rdi
movl 0x4(%rax), %eax
movl %eax, 0x78(%rsp)
movl 0x7c(%rsp), %eax
movq %rax, 0x30(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x30(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x3021
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x188e0
movq %rax, 0x28(%rsp)
jmp 0x303d
movq 0x40(%rsp), %rdi
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movq %rax, 0x28(%rsp)
movq 0x40(%rsp), %rdi
movq 0x28(%rsp), %rax
movl %eax, 0x74(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movl %eax, 0x70(%rsp)
movl 0x70(%rsp), %ecx
xorl %eax, %eax
cmpl 0x74(%rsp), %ecx
movb %al, 0x27(%rsp)
jae 0x3078
cmpl $0x0, 0x78(%rsp)
setne %al
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x3085
jmp 0x32e8
movq 0x40(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x30ac
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0x18900
movl (%rax), %eax
movl %eax, 0x20(%rsp)
jmp 0x30dc
movq 0x40(%rsp), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x18(%rax), %rdi
movl 0x70(%rsp), %eax
movl %eax, %esi
callq 0x18900
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x188b0
movl (%rax), %eax
movl %eax, 0x20(%rsp)
movq 0x40(%rsp), %rdi
movl 0x20(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
jne 0x32d6
movq 0x40(%rsp), %rdi
movl 0x78(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x78(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, %esi
callq 0x18850
movq 0x40(%rsp), %rdi
movl 0x4(%rax), %eax
movl %eax, 0x68(%rsp)
movl 0x6c(%rsp), %eax
movq %rax, 0x10(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x10(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x3159
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x188e0
movq %rax, 0x8(%rsp)
jmp 0x3175
movq 0x40(%rsp), %rdi
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rdi
movq 0x8(%rsp), %rax
movl %eax, 0x64(%rsp)
movl 0x6c(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movl %eax, 0x60(%rsp)
movl 0x60(%rsp), %ecx
xorl %eax, %eax
cmpl 0x64(%rsp), %ecx
movb %al, 0x7(%rsp)
jae 0x31b0
cmpl $0x0, 0x68(%rsp)
setne %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x31bd
jmp 0x32d4
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0x60(%rsp), %eax
movl %eax, %esi
callq 0x18900
movq %rax, %rcx
movq 0x40(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0x5c(%rsp)
testb $0x1, 0x3c(%rax)
jne 0x31ee
movl 0x5c(%rsp), %eax
movl %eax, (%rsp)
jmp 0x3206
movq 0x40(%rsp), %rax
movq 0x40(%rax), %rdi
leaq 0x5c(%rsp), %rsi
callq 0x188b0
movl (%rax), %eax
movl %eax, (%rsp)
movq 0x40(%rsp), %rdi
movl (%rsp), %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
jne 0x32c2
movl 0x68(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x68(%rsp)
movl 0x5c(%rsp), %eax
movq 0x98(%rsp), %rcx
cmpl (%rcx), %eax
je 0x32c0
movq 0x40(%rsp), %rdi
movq 0x98(%rsp), %rdx
leaq 0x5c(%rsp), %rsi
callq 0x18920
testb $0x1, %al
jne 0x32c0
movq 0x90(%rsp), %rdi
leaq 0x5c(%rsp), %rsi
callq 0x18960
movq %rax, 0x48(%rsp)
movb %dl, 0x50(%rsp)
movq 0x88(%rsp), %rax
cmpl $-0x1, (%rax)
je 0x32be
cmpq $0x0, 0x80(%rsp)
je 0x32be
movq 0x40(%rsp), %rdi
movl 0x58(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl 0x4(%rax), %eax
movq 0x88(%rsp), %rcx
cmpl (%rcx), %eax
jae 0x32be
movq 0x80(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x32c0
jmp 0x32c2
jmp 0x32c4
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x3194
jmp 0x32d6
jmp 0x32d8
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x305c
addq $0xa8, %rsp
retq