// File: /workspace/github_cpp_makefile_star2_O1/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 $0x58, %rsp
movq %r8, 0x28(%rsp)
movq %rsi, 0x8(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rdx, 0x40(%rsp)
movl %eax, (%rdx)
movq %rcx, 0x48(%rsp)
movl %eax, (%rcx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
je 0x6c7f
movq %rdi, %r13
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
xorl %ebp, %ebp
movq $0x0, 0x38(%rsp)
leaq (,%rbp,2), %rdx
addq %rbp, %rdx
cmpb $0x0, 0x8(%rax,%rdx,4)
jne 0x6c50
leaq (%rax,%rdx,4), %rdx
movq 0x8(%rsp), %rsi
movl (%rsi), %r14d
cmpl %r14d, 0x4(%rdx)
jne 0x6c50
decq %rcx
cmpq %rbp, %rcx
jne 0x6a47
movq 0x18(%r13), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
shrq $0x2, %rax
jmp 0x6a51
leal 0x1(%rbp), %ecx
leaq (%rcx,%rcx,2), %rcx
movl (%rax,%rcx,4), %eax
movl (%rdx), %ebx
cmpl %eax, %ebx
setae %cl
testl %r14d, %r14d
sete %dl
orb %cl, %dl
jne 0x6c50
movl %eax, %eax
movq %rax, 0x50(%rsp)
leaq (,%rbx,4), %r12
incq %rbx
cmpb $0x0, 0x3c(%r13)
je 0x6a94
movq 0x18(%r13), %rax
movq 0x40(%r13), %rdi
movq (%rax), %rsi
addq %r12, %rsi
callq 0xda16
jmp 0x6a9e
movq 0x18(%r13), %rax
movq (%rax), %rax
addq %r12, %rax
movl (%rax), %esi
movq (%r13), %rax
leaq (%rsi,%rsi,2), %rcx
movl $0x7, %r15d
cmpb $0x0, 0x8(%rax,%rcx,4)
jne 0x6c2e
leaq (%rax,%rcx,4), %rax
decl %r14d
movl 0x4(%rax), %eax
movq 0x8(%rsp), %rcx
movl (%rcx), %ecx
cmpl %ecx, %eax
je 0x6adf
xorl $0x6, %ecx
xorl $0x5, %eax
xorl %r15d, %r15d
orl %ecx, %eax
jne 0x6c2e
movb 0x3c(%r13), %cl
movl %ebp, %eax
cmpb $0x1, %cl
jne 0x6b08
movq 0x48(%r13), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0x6cab
movl (%rax,%rbp,4), %eax
movl %eax, 0x4(%rsp)
testb %cl, %cl
je 0x6b2e
movq 0x48(%r13), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rsi, %rdx
jbe 0x6c9d
movl (%rcx,%rsi,4), %esi
movl %esi, (%rsp)
xorl %r15d, %r15d
cmpl %esi, %eax
jae 0x6c2e
movl $0x0, 0x34(%rsp)
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
movq %rsp, %rdx
leaq 0x10(%rsp), %rcx
leaq 0x34(%rsp), %r8
callq 0x4bae
movq 0x8(%rsp), %rax
movl (%rax), %eax
cmpl $0x6, %eax
jne 0x6b7a
movq 0x18(%rsp), %rcx
subq 0x10(%rsp), %rcx
cmpq $0x8, %rcx
ja 0x6b9a
addl $-0x7, %eax
cmpl $0x1, %eax
ja 0x6c1d
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
cmpq $0xd, %rax
jb 0x6c1d
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %rcx, %rdi
subq %rdx, %rdi
movq 0x28(%rsp), %rsi
movq (%rsi), %rax
movq 0x8(%rsi), %rsi
movq %rsi, %r8
subq %rax, %r8
cmpq %r8, %rdi
jbe 0x6c1d
cmpq %rax, %rsi
movq 0x28(%rsp), %rdi
je 0x6bcf
movq %rax, 0x8(%rdi)
movq 0x8(%rdi), %rsi
callq 0xeb0c
movq 0x28(%rsp), %rsi
movq (%rsi), %rax
movl 0x4(%rsp), %ecx
movq 0x40(%rsp), %rdx
movl %ecx, (%rdx)
movl (%rsp), %ecx
movq 0x48(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x8(%rsi), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movq 0x8(%rsp), %rax
movl (%rax), %eax
decl %eax
cmpq %rax, %rcx
jne 0x6c1d
movb $0x1, %al
movq %rax, 0x38(%rsp)
movl $0x5, %r15d
jmp 0x6c2e
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x6c2e
movq %rax, 0x18(%rsp)
cmpl $0x7, %r15d
je 0x6c39
testl %r15d, %r15d
jne 0x6c50
cmpq 0x50(%rsp), %rbx
jae 0x6c50
addq $0x4, %r12
incq %rbx
testl %r14d, %r14d
jne 0x6a78
incl %ebp
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rbp, %rcx
jbe 0x6c7f
testb $0x1, 0x38(%rsp)
je 0x6a02
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6c8e
callq 0x21a0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x13b3a(%rip), %rdi     # 0x1a7de
xorl %eax, %eax
callq 0x22a0
leaq 0x13b2c(%rip), %rdi     # 0x1a7de
movq %rbp, %rsi
xorl %eax, %eax
callq 0x22a0
jmp 0x6cc4
jmp 0x6cc4
jmp 0x6cc4
jmp 0x6cc4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6cd6
callq 0x21a0
movq %rbx, %rdi
callq 0x2320