// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getGoodPair(unsigned int&, unsigned int&, std::vector<unsigned int, std::allocator<unsigned int>>&) const
bool Graph::getGoodPair(uint32_t &node1, uint32_t &node2, vector<uint32_t> &commonNeighbors) const {
    for (uint32_t pos1 = 0 ; pos1 < nodeIndex.size() ; pos1++) {
        if (nodeIndex[pos1].removed) {
            continue;
        }
        for (uint32_t pos2 = pos1+1 ; pos2 < nodeIndex.size() ; pos2++) {
            if (nodeIndex[pos2].removed) {
                continue;
            }
            if (nodeIndex[pos1].edges == 5 || nodeIndex[pos2].edges == 5) {
                uint32_t nodeA = (!mapping ? pos1 : posToId->at(pos1));
                uint32_t nodeB = (!mapping ? pos2 : posToId->at(pos2));
                if (edgeExists(nodeA, nodeB)) {
                    continue;
                }
                commonNeighbors.clear();
                getCommonNeighbors(nodeA, nodeB, commonNeighbors);
                if (commonNeighbors.size() >= 3) {
                    node1 = nodeA;
                    node2 = nodeB;
                    //cout << "branching on a good pair " << node1 << "-" << node2 << "\n";
                    return true;
                }
            }
        }
    }
    return false;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movq %rsi, 0x50(%rsp)
movq %rdx, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x3c(%rsp)
movq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %eax
movq %rax, 0x18(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
jae 0x8660
movq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
je 0x84d9
jmp 0x8650
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %eax
movq %rax, 0x10(%rsp)
callq 0x18830
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x864e
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0x18850
testb $0x1, 0x8(%rax)
je 0x8523
jmp 0x863e
movq 0x20(%rsp), %rdi
movl 0x3c(%rsp), %eax
movl %eax, %esi
callq 0x18850
cmpl $0x5, 0x4(%rax)
je 0x8553
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0x18850
cmpl $0x5, 0x4(%rax)
jne 0x863c
movq 0x20(%rsp), %rax
testb $0x1, 0x3c(%rax)
jne 0x8568
movl 0x3c(%rsp), %eax
movl %eax, 0xc(%rsp)
jmp 0x8582
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0x3c(%rsp), %eax
movl %eax, %esi
callq 0x18870
movl (%rax), %eax
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, 0x34(%rsp)
testb $0x1, 0x3c(%rax)
jne 0x859f
movl 0x38(%rsp), %eax
movl %eax, 0x8(%rsp)
jmp 0x85b9
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rdi
movl 0x38(%rsp), %eax
movl %eax, %esi
callq 0x18870
movl (%rax), %eax
movl %eax, 0x8(%rsp)
movq 0x20(%rsp), %rdi
movl 0x8(%rsp), %eax
movl %eax, 0x30(%rsp)
leaq 0x34(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x18920
testb $0x1, %al
jne 0x85db
jmp 0x85dd
jmp 0x863e
movq 0x40(%rsp), %rdi
callq 0x191c0
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rcx
movl $0x0, 0x2c(%rsp)
leaq 0x34(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x2c(%rsp), %r8
callq 0x62b0
movq 0x40(%rsp), %rdi
callq 0x188e0
cmpq $0x3, %rax
jb 0x863a
movl 0x34(%rsp), %ecx
movq 0x50(%rsp), %rax
movl %ecx, (%rax)
movl 0x30(%rsp), %ecx
movq 0x48(%rsp), %rax
movl %ecx, (%rax)
movb $0x1, 0x67(%rsp)
jmp 0x8665
jmp 0x863c
jmp 0x863e
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x84e4
jmp 0x8650
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x849a
movb $0x0, 0x67(%rsp)
movb 0x67(%rsp), %al
andb $0x1, %al
addq $0x68, %rsp
retq