// File: /workspace/github_cpp_makefile_star2_O2/iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::get4Cycle(std::vector<unsigned int, std::allocator<unsigned int>>&) const
bool Graph::get4Cycle(vector<uint32_t> &optimalCycle) const {
    optimalCycle.clear();
    uint32_t maxDegree3NodesCount = NONE;
    GraphTraversal graphTraversal(*this);
    while (graphTraversal.curNode != NONE) {
        if (getNodeDegree(graphTraversal.curNode) == 4) {
            vector<uint32_t> neighbors;
            gatherNeighbors(graphTraversal.curNode, neighbors);
            uint32_t b, d;
            for (uint32_t i = 0 ; i < 6 ; i++) {
                switch (i) {
                    case 0:
                        b = neighbors[0];
                        d = neighbors[1];
                        break;
                    case 1:
                        b = neighbors[0];
                        d = neighbors[2];
                        break;
                    case 2:
                        b = neighbors[0];
                        d = neighbors[3];
                        break;
                    case 3:
                        b = neighbors[1];
                        d = neighbors[2];
                        break;
                    case 4:
                        b = neighbors[1];
                        d = neighbors[3];
                        break;
                    case 5:
                        b = neighbors[2];
                        d = neighbors[3];
                        break;
                    default:
                        assert(false);
                }
                vector<uint32_t> commonNeighbors;
                getCommonNeighbors(b, d, commonNeighbors);
                for (auto c: commonNeighbors) {
                    if (c == graphTraversal.curNode) {
                        continue;
                    }
                    uint32_t degree3NodesCount = 0;
                    if (getNodeDegree(b) == 3) {
                        degree3NodesCount++;
                    }
                    if (getNodeDegree(c) == 3) {
                        degree3NodesCount++;
                    }
                    if (getNodeDegree(d) == 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);
                        if (maxDegree3NodesCount == 3) {
                            return true;
                        }
                    }
                }
            }
        }
        getNextNode(graphTraversal);
    }
    return maxDegree3NodesCount != NONE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rax
cmpq %rax, 0x8(%rsi)
je 0x40a1
movq %rax, 0x8(%rbx)
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x270e
pushq $-0x1
popq %rax
movl %eax, 0x10(%rsp)
cmpl $-0x1, 0x18(%rsp)
je 0x42bb
movq %r14, %rdi
movq %r15, %rsi
callq 0xa5ce
cmpl $0x4, %eax
jne 0x42ab
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
orl $-0x1, 0x40(%rsp)
movq %r14, %rdi
movq %r15, %rsi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x40(%rsp), %r8
callq 0xa3c8
xorl %eax, %eax
movl %eax, %edx
movl %eax, %eax
leaq 0x12f12(%rip), %rcx     # 0x17020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %rdx, 0x60(%rsp)
jmpq *%rax
movq 0x20(%rsp), %rax
movl (%rax), %ecx
movl %ecx, 0xc(%rsp)
movl 0x4(%rax), %eax
jmp 0x4168
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
jmp 0x413d
movq 0x20(%rsp), %rax
movl (%rax), %ecx
movl %ecx, 0xc(%rsp)
movl 0x8(%rax), %eax
jmp 0x4168
movq 0x20(%rsp), %rax
movl 0x8(%rax), %ecx
jmp 0x4161
movq 0x20(%rsp), %rax
movl (%rax), %ecx
jmp 0x4161
movq 0x20(%rsp), %rax
movl 0x4(%rax), %ecx
movl %ecx, 0xc(%rsp)
movl 0xc(%rax), %eax
movl %eax, 0x8(%rsp)
andq $0x0, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
andl $0x0, 0x14(%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x40(%rsp), %rcx
leaq 0x14(%rsp), %r8
callq 0x42fc
movq %rbx, %r12
movq 0x40(%rsp), %r13
movq 0x48(%rsp), %rbx
cmpq %rbx, %r13
je 0x4275
movl (%r13), %eax
movl %eax, 0x14(%rsp)
cmpl 0x18(%rsp), %eax
je 0x4265
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xa5ce
movl %eax, %r15d
movq %r14, %rdi
leaq 0x14(%rsp), %rsi
callq 0xa5ce
movl %eax, %ebp
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa5ce
xorl %ecx, %ecx
cmpl $0x3, %r15d
sete %cl
leal 0x1(%rcx), %edx
cmpl $0x3, %ebp
cmovnel %ecx, %edx
xorl %ebp, %ebp
cmpl $0x3, %eax
sete %bpl
addl %edx, %ebp
cmpl $-0x1, 0x10(%rsp)
je 0x4219
cmpl 0x10(%rsp), %ebp
jbe 0x4265
movq %r12, %rdi
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0x422b
movq %rax, 0x8(%rdi)
leaq 0x18(%rsp), %rsi
callq 0xa1ac
movq %r12, %rdi
leaq 0xc(%rsp), %rsi
callq 0xa1ac
movq %r12, %rdi
leaq 0x14(%rsp), %rsi
callq 0xa1ac
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0xa1ac
movl %ebp, 0x10(%rsp)
cmpl $0x3, %ebp
je 0x426e
addq $0x4, %r13
jmp 0x41a8
pushq $0x3
popq %rax
movl %eax, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
callq 0xb872
movq 0x60(%rsp), %rdx
leal 0x1(%rdx), %eax
cmpq %rbx, %r13
movq %r12, %rbx
leaq 0x18(%rsp), %r15
je 0x4103
leaq 0x20(%rsp), %rdi
movq %rdx, %r12
callq 0xb872
cmpl $0x5, %r12d
jbe 0x42c5
movq %r14, %rdi
movq %r15, %rsi
callq 0x9cf8
jmp 0x40b8
cmpl $-0x1, 0x10(%rsp)
setne %al
jmp 0x42c7
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x42ea
jmp 0x42dd
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xb872
leaq 0x20(%rsp), %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x22c0