// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, 0x40(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdx, 0x50(%rsp)
orl $-0x1, (%rdx)
movq %rdi, %r13
movq %rcx, 0x58(%rsp)
orl $-0x1, (%rcx)
leaq 0x20(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
xorl %edi, %edi
xorl %ecx, %ecx
movl %edi, %r9d
movq (%r13), %rsi
movq 0x8(%r13), %rax
subq %rsi, %rax
cqto
pushq $0xc
popq %r8
idivq %r8
cmpq %r9, %rax
jbe 0x5e01
testb $0x1, %cl
jne 0x5e01
imulq $0xc, %r9, %rcx
cmpb $0x0, 0x8(%rsi,%rcx)
movq %rdi, 0x48(%rsp)
jne 0x5c3f
addq %rsi, %rcx
movl 0x4(%rcx), %ebx
movq 0x10(%rsp), %rdx
cmpl (%rdx), %ebx
jne 0x5c3f
decq %rax
cmpq %r9, %rax
movq %r9, 0x60(%rsp)
jne 0x5c4a
movq 0x18(%r13), %rdx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
shrq $0x2, %rax
jmp 0x5c54
xorl %ecx, %ecx
movq 0x48(%rsp), %rdi
incl %edi
jmp 0x5bd9
leal 0x1(%rdi), %eax
imulq $0xc, %rax, %rax
movl (%rsi,%rax), %eax
movl (%rcx), %r12d
movl %eax, %ebp
leaq (,%r12,4), %r15
xorl %ecx, %ecx
cmpq %rbp, %r12
jae 0x5c41
testl %ebx, %ebx
je 0x5c41
cmpb $0x0, 0x3c(%r13)
je 0x5c88
movq 0x18(%r13), %rax
movq 0x40(%r13), %rdi
movq (%rax), %rsi
addq %r15, %rsi
callq 0xb880
jmp 0x5c92
movq 0x18(%r13), %rax
movq (%rax), %rax
addq %r15, %rax
movl (%rax), %r14d
movq (%r13), %rax
imulq $0xc, %r14, %rcx
cmpb $0x0, 0x8(%rax,%rcx)
jne 0x5dee
addq %rcx, %rax
decl %ebx
movl 0x4(%rax), %eax
movq 0x10(%rsp), %rcx
movl (%rcx), %ecx
cmpl %ecx, %eax
je 0x5cc9
xorl $0x6, %ecx
xorl $0x5, %eax
orl %ecx, %eax
jne 0x5dee
movb 0x3c(%r13), %cl
movq 0x48(%rsp), %rax
cmpb $0x1, %cl
jne 0x5ceb
movq 0x48(%r13), %rdi
movq 0x60(%rsp), %rsi
callq 0x9e18
movl (%rax), %eax
movb 0x3c(%r13), %cl
movl %eax, 0x8(%rsp)
testb $0x1, %cl
je 0x5d07
movq 0x48(%r13), %rdi
movq %r14, %rsi
callq 0x9e18
movl (%rax), %r14d
movl 0x8(%rsp), %eax
movl %r14d, 0xc(%rsp)
cmpl %r14d, %eax
jae 0x5dee
andl $0x0, 0x1c(%rsp)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x1c(%rsp), %r8
callq 0x42fc
movq 0x10(%rsp), %rax
movl (%rax), %eax
cmpl $0x6, %eax
jne 0x5d5d
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq %rcx, %rax
subq %rdx, %rax
cmpq $0x8, %rax
ja 0x5d7b
jmp 0x5de4
addl $-0x7, %eax
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
cmpl $0x1, %eax
ja 0x5de4
movq %rcx, %rax
subq %rdx, %rax
cmpq $0xd, %rax
jb 0x5de4
movq 0x40(%rsp), %rsi
movq (%rsi), %r9
movq 0x8(%rsi), %rsi
movq %rsi, %r8
subq %r9, %r8
cmpq %r8, %rax
jbe 0x5de4
cmpq %r9, %rsi
movq 0x40(%rsp), %rdi
je 0x5da3
movq %r9, 0x8(%rdi)
movq %r9, %rsi
movq %rdi, %r14
callq 0xa81c
movl 0x8(%rsp), %eax
movq 0x50(%rsp), %rcx
movl %eax, (%rcx)
movl 0xc(%rsp), %eax
movq 0x58(%rsp), %rcx
movl %eax, (%rcx)
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x2, %rax
movq 0x10(%rsp), %rcx
movl (%rcx), %ecx
decl %ecx
cmpq %rcx, %rax
je 0x5dfa
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
cmpq %rdx, %rcx
je 0x5dee
movq %rdx, 0x28(%rsp)
incq %r12
addq $0x4, %r15
jmp 0x5c61
movb $0x1, %cl
jmp 0x5c41
leaq 0x20(%rsp), %rdi
callq 0xb872
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5e22
jmp 0x5e22
jmp 0x5e22
jmp 0x5e22
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x22c0
nop