// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::get4CycleTheta3(std::vector<unsigned int, std::allocator<unsigned int>>&) const
bool Graph::get4CycleTheta3(vector<uint32_t> &optimalCycle) const {
    optimalCycle.clear();
    uint32_t maxDegree3NodesCount = NONE;
    GraphTraversal graphTraversal(*this);
    while (graphTraversal.curNode != NONE) {
        vector<uint32_t> neighbors;
        gatherNeighbors(graphTraversal.curNode, neighbors);
        uint32_t b, d;
        for (uint32_t i = 0 ; i < neighbors.size() ; i++) {
            for (uint32_t j = i+1 ; j < neighbors.size() ; j++) {
                b = neighbors[i];
                d = neighbors[j];
                vector<uint32_t> commonNeighbors;
                getCommonNeighbors(b, d, commonNeighbors);
                for (auto c: commonNeighbors) {
                    if (c == graphTraversal.curNode) {
                        continue;
                    }
                    uint32_t degreeA = getNodeDegree(graphTraversal.curNode);
                    uint32_t degreeB = getNodeDegree(b);
                    uint32_t degreeC = getNodeDegree(c);
                    uint32_t degreeD = getNodeDegree(d);
                    if (degreeA == 3 && degreeC == 3 || degreeB == 3 && degreeD == 3) {
                        optimalCycle.clear();
                        optimalCycle.push_back(graphTraversal.curNode);
                        optimalCycle.push_back(b);
                        optimalCycle.push_back(c);
                        optimalCycle.push_back(d);
                        return true;
                    }
                    uint32_t degree3NodesCount = 0;
                    if (degreeA == 3) {
                        degree3NodesCount++;
                    }
                    if (degreeB == 3) {
                        degree3NodesCount++;
                    }
                    if (degreeC == 3) {
                        degree3NodesCount++;
                    }
                    if (degreeD == 3) {
                        degree3NodesCount++;
                    }
                    if (maxDegree3NodesCount == NONE || degree3NodesCount > maxDegree3NodesCount) {
                        maxDegree3NodesCount = degree3NodesCount;
                        optimalCycle.clear();
                        optimalCycle.push_back(graphTraversal.curNode);
                        optimalCycle.push_back(b);
                        optimalCycle.push_back(c);
                        optimalCycle.push_back(d);
                    }
                }
            }
        }
        getNextNode(graphTraversal);
    }
    return maxDegree3NodesCount != NONE;
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0xf8(%rsp)
movq %rsi, 0xf0(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x191c0
movq 0x40(%rsp), %rsi
movl $0xffffffff, 0xec(%rsp) # imm = 0xFFFFFFFF
leaq 0xe4(%rsp), %rdi
callq 0x2a40
cmpl $-0x1, 0xe4(%rsp)
je 0x6a03
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x17e60
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rdx
movl $0xffffffff, 0xc4(%rsp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %ecx
leaq 0xe4(%rsp), %rsi
leaq 0xc4(%rsp), %r8
callq 0x19c30
jmp 0x65ce
movl $0x0, 0xa8(%rsp)
movl 0xa8(%rsp), %eax
movq %rax, 0x30(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x188e0
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x69ba
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
movq %rax, 0x28(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x188e0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x69a2
movl 0xa8(%rsp), %eax
movl %eax, %esi
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x18900
movq 0x18(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0xb0(%rsp)
movl 0xa4(%rsp), %eax
movl %eax, %esi
callq 0x18900
movl (%rax), %eax
movl %eax, 0xac(%rsp)
leaq 0x88(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x17e60
movq 0x40(%rsp), %rdi
movq 0x20(%rsp), %rcx
movl $0x0, 0x84(%rsp)
leaq 0xb0(%rsp), %rsi
leaq 0xac(%rsp), %rdx
leaq 0x84(%rsp), %r8
callq 0x62b0
jmp 0x66c4
leaq 0x88(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x19b50
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
callq 0x1a0e0
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1a110
testb $0x1, %al
jne 0x6707
jmp 0x696b
leaq 0x70(%rsp), %rdi
callq 0x1a150
movl (%rax), %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0xe4(%rsp), %eax
jne 0x6768
jmp 0x695c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
jmp 0x69f4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb8(%rsp)
movl %eax, 0xb4(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x18520
jmp 0x69f4
movq 0x40(%rsp), %rdi
leaq 0xe4(%rsp), %rsi
callq 0x1a040
movl %eax, 0x14(%rsp)
jmp 0x6780
movq 0x40(%rsp), %rdi
movl 0x14(%rsp), %eax
movl %eax, 0x60(%rsp)
leaq 0xb0(%rsp), %rsi
callq 0x1a040
movl %eax, 0x10(%rsp)
jmp 0x67a0
movq 0x40(%rsp), %rdi
movl 0x10(%rsp), %eax
movl %eax, 0x5c(%rsp)
leaq 0x64(%rsp), %rsi
callq 0x1a040
movl %eax, 0xc(%rsp)
jmp 0x67bd
movq 0x40(%rsp), %rdi
movl 0xc(%rsp), %eax
movl %eax, 0x58(%rsp)
leaq 0xac(%rsp), %rsi
callq 0x1a040
movl %eax, 0x8(%rsp)
jmp 0x67dd
movl 0x8(%rsp), %eax
movl %eax, 0x54(%rsp)
cmpl $0x3, 0x60(%rsp)
jne 0x67f3
cmpl $0x3, 0x58(%rsp)
je 0x6805
cmpl $0x3, 0x5c(%rsp)
jne 0x6880
cmpl $0x3, 0x54(%rsp)
jne 0x6880
movq 0xf0(%rsp), %rdi
callq 0x191c0
movq 0xf0(%rsp), %rdi
leaq 0xe4(%rsp), %rsi
callq 0x19070
jmp 0x6829
movq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x19070
jmp 0x6840
movq 0xf0(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x19070
jmp 0x6854
movq 0xf0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
callq 0x19070
jmp 0x686b
movb $0x1, 0x107(%rsp)
movl $0x1, 0x50(%rsp)
jmp 0x6973
movl $0x0, 0x4c(%rsp)
cmpl $0x3, 0x60(%rsp)
jne 0x689a
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
cmpl $0x3, 0x5c(%rsp)
jne 0x68ac
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
cmpl $0x3, 0x58(%rsp)
jne 0x68be
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
cmpl $0x3, 0x54(%rsp)
jne 0x68d0
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
cmpl $-0x1, 0xec(%rsp)
je 0x68e7
movl 0x4c(%rsp), %eax
cmpl 0xec(%rsp), %eax
jbe 0x695a
movl 0x4c(%rsp), %eax
movl %eax, 0xec(%rsp)
movq 0xf0(%rsp), %rdi
callq 0x191c0
movq 0xf0(%rsp), %rdi
leaq 0xe4(%rsp), %rsi
callq 0x19070
jmp 0x6916
movq 0xf0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x19070
jmp 0x692d
movq 0xf0(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x19070
jmp 0x6941
movq 0xf0(%rsp), %rdi
leaq 0xac(%rsp), %rsi
callq 0x19070
jmp 0x6958
jmp 0x695a
jmp 0x695c
leaq 0x70(%rsp), %rdi
callq 0x1a160
jmp 0x66ef
movl $0x0, 0x50(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x18520
movl 0x50(%rsp), %eax
testl %eax, %eax
jne 0x69d6
jmp 0x698a
jmp 0x698c
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x6614
jmp 0x69a4
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x65d9
movq 0x40(%rsp), %rdi
leaq 0xe4(%rsp), %rsi
callq 0x185f0
jmp 0x69ce
movl $0x0, 0x50(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x18520
movl 0x50(%rsp), %eax
testl %eax, %eax
je 0x69ef
jmp 0x69ed
jmp 0x6a17
jmp 0x657e
leaq 0xc8(%rsp), %rdi
callq 0x18520
jmp 0x6a28
cmpl $-0x1, 0xec(%rsp)
setne %al
andb $0x1, %al
movb %al, 0x107(%rsp)
movb 0x107(%rsp), %al
andb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
retq
movq 0xb8(%rsp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)