// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getOptimalShortEdge(unsigned int const&, unsigned int&, unsigned int&, std::vector<unsigned int, std::allocator<unsigned int>>&) const
void Graph::getOptimalShortEdge(const uint32_t &degree, uint32_t &finalNode1, uint32_t &finalNode2, vector<uint32_t> &finalContainer) const {
    finalNode1 = NONE;
    finalNode2 = NONE;
    vector<uint32_t> commonNeighbors;
    bool done = false;
    for (uint32_t pos = 0 ; pos < nodeIndex.size() && !done ; pos++) {
        if (nodeIndex[pos].removed) {
            continue;
        }
        if (nodeIndex[pos].edges == degree) {
            uint32_t neighborCount = degree;
            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) {
                    continue;
                }
                neighborCount--;
                if (nodeIndex[nPos].edges == degree || (degree == 6 && nodeIndex[nPos].edges == 5)) {
                    uint32_t node1 = (!mapping ? pos : posToId->at(pos));
                    uint32_t node2 = (!mapping ? nPos : posToId->at(nPos));
                    if (node1 < node2) {
                        getCommonNeighbors(node1, node2, commonNeighbors);
                        if ((degree == 6 && commonNeighbors.size() >= 3 || (degree == 7 || degree == 8) && commonNeighbors.size() >= 4) &&
                        commonNeighbors.size() > finalContainer.size()) {
                            finalContainer.clear();
                            finalContainer.insert(finalContainer.end(), commonNeighbors.begin(), commonNeighbors.end());
                            finalNode1 = node1;
                            finalNode2 = node2;
                            if (finalContainer.size() == degree - 1) {
                                done = true;
                                break;
                            }
                        }
                        commonNeighbors.clear();
                    }
                }
            }
        }
    }
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq %rcx, 0xf8(%rsp)
movq %r8, 0xf0(%rsp)
movq 0x110(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x100(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq 0xf8(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0xd8(%rsp), %rdi
callq 0x17e60
movb $0x0, 0xd7(%rsp)
movl $0x0, 0xd0(%rsp)
movq 0x78(%rsp), %rdi
movl 0xd0(%rsp), %eax
movq %rax, 0x68(%rsp)
callq 0x18830
movq 0x68(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x77(%rsp)
jae 0x934e
movb 0xd7(%rsp), %al
xorb $-0x1, %al
movb %al, 0x77(%rsp)
movb 0x77(%rsp), %al
testb $0x1, %al
jne 0x935b
jmp 0x9812
movq 0x78(%rsp), %rdi
movl 0xd0(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
je 0x9379
jmp 0x97fc
movq 0x78(%rsp), %rdi
movl 0xd0(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl 0x4(%rax), %eax
movq 0x108(%rsp), %rcx
cmpl (%rcx), %eax
jne 0x97fa
movq 0x78(%rsp), %rdi
movq 0x108(%rsp), %rax
movl (%rax), %eax
movl %eax, 0xcc(%rsp)
movl 0xd0(%rsp), %eax
movq %rax, 0x60(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x60(%rsp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x93ec
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x188e0
movq %rax, 0x58(%rsp)
jmp 0x940b
movq 0x78(%rsp), %rdi
movl 0xd0(%rsp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movq %rax, 0x58(%rsp)
movq 0x78(%rsp), %rdi
movq 0x58(%rsp), %rax
movl %eax, 0xc8(%rsp)
movl 0xd0(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl (%rax), %eax
movl %eax, 0xc4(%rsp)
movl 0xc4(%rsp), %ecx
xorl %eax, %eax
cmpl 0xc8(%rsp), %ecx
movb %al, 0x57(%rsp)
jae 0x9458
cmpl $0x0, 0xcc(%rsp)
setne %al
movb %al, 0x57(%rsp)
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0x9465
jmp 0x97f8
movq 0x78(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x948f
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
movl 0xc4(%rsp), %eax
movl %eax, %esi
callq 0x18900
movl (%rax), %eax
movl %eax, 0x50(%rsp)
jmp 0x94ce
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x40(%rax), %rax
movq %rax, 0x40(%rsp)
movl 0xc4(%rsp), %eax
movl %eax, %esi
callq 0x18900
movq 0x40(%rsp), %rdi
movq %rax, %rsi
callq 0x188b0
movq %rax, 0x48(%rsp)
jmp 0x94c3
movq 0x48(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x50(%rsp)
movq 0x78(%rsp), %rdi
movl 0x50(%rsp), %eax
movl %eax, 0xc0(%rsp)
movl 0xc0(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
je 0x951d
jmp 0x97e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x18520
jmp 0x9827
movq 0x78(%rsp), %rdi
movl 0xcc(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xcc(%rsp)
movl 0xc0(%rsp), %eax
movl %eax, %esi
callq 0x18850
movl 0x4(%rax), %eax
movq 0x108(%rsp), %rcx
cmpl (%rcx), %eax
je 0x957e
movq 0x108(%rsp), %rax
cmpl $0x6, (%rax)
jne 0x97e0
movq 0x78(%rsp), %rdi
movl 0xc0(%rsp), %eax
movl %eax, %esi
callq 0x18850
cmpl $0x5, 0x4(%rax)
jne 0x97e0
movq 0x78(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x9596
movl 0xd0(%rsp), %eax
movl %eax, 0x3c(%rsp)
jmp 0x95bf
movq 0x78(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0xd0(%rsp), %eax
movl %eax, %esi
callq 0x18870
movq %rax, 0x30(%rsp)
jmp 0x95b4
movq 0x30(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0x78(%rsp), %rax
movl 0x3c(%rsp), %ecx
movl %ecx, 0xb0(%rsp)
testb $0x1, 0x3c(%rax)
jne 0x95e2
movl 0xc0(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x960b
movq 0x78(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0xc0(%rsp), %eax
movl %eax, %esi
callq 0x18870
movq %rax, 0x20(%rsp)
jmp 0x9600
movq 0x20(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
movl %eax, 0xac(%rsp)
movl 0xb0(%rsp), %eax
cmpl 0xac(%rsp), %eax
jae 0x97de
movq 0x78(%rsp), %rdi
movl $0x0, 0xa8(%rsp)
leaq 0xb0(%rsp), %rsi
leaq 0xac(%rsp), %rdx
leaq 0xd8(%rsp), %rcx
leaq 0xa8(%rsp), %r8
callq 0x62b0
jmp 0x9661
movq 0x108(%rsp), %rax
cmpl $0x6, (%rax)
jne 0x9681
leaq 0xd8(%rsp), %rdi
callq 0x188e0
cmpq $0x3, %rax
jae 0x96b6
movq 0x108(%rsp), %rax
cmpl $0x7, (%rax)
je 0x969f
movq 0x108(%rsp), %rax
cmpl $0x8, (%rax)
jne 0x97d1
leaq 0xd8(%rsp), %rdi
callq 0x188e0
cmpq $0x4, %rax
jb 0x97d1
leaq 0xd8(%rsp), %rdi
callq 0x188e0
movq %rax, 0x18(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x188e0
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jbe 0x97d1
movq 0xf0(%rsp), %rdi
callq 0x191c0
movq 0xf0(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x1a0e0
movq %rax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1aa60
leaq 0xd8(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x19b50
movq (%rsp), %rdi
movq %rax, 0x90(%rsp)
callq 0x1a0e0
movq 0x8(%rsp), %rdi
movq %rax, 0x88(%rsp)
movq 0xa0(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq 0x88(%rsp), %rcx
callq 0x1a9a0
movq %rax, 0x10(%rsp)
jmp 0x9775
movq 0x10(%rsp), %rax
movq %rax, 0x80(%rsp)
movl 0xb0(%rsp), %ecx
movq 0x100(%rsp), %rax
movl %ecx, (%rax)
movl 0xac(%rsp), %ecx
movq 0xf8(%rsp), %rax
movl %ecx, (%rax)
movq 0xf0(%rsp), %rdi
callq 0x188e0
movq 0x108(%rsp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
cmpq %rcx, %rax
jne 0x97cf
movb $0x1, 0xd7(%rsp)
jmp 0x97f8
jmp 0x97d1
leaq 0xd8(%rsp), %rdi
callq 0x191c0
jmp 0x97e0
jmp 0x97e2
movl 0xc4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc4(%rsp)
jmp 0x9433
jmp 0x97fa
jmp 0x97fc
movl 0xd0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd0(%rsp)
jmp 0x9318
leaq 0xd8(%rsp), %rdi
callq 0x18520
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xb8(%rsp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)