// File: /workspace/github_cpp_makefile_star2_O1/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 0x4873
movq %rax, 0x8(%rbx)
leaq 0x18(%rsp), %r15
movq $-0x1, (%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0xc034
cmpl $-0x1, (%r15)
je 0x4b69
movl $0xffffffff, 0x14(%rsp) # imm = 0xFFFFFFFF
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
movq %rsi, %r15
callq 0xc98e
cmpl $0x4, %eax
jne 0x4902
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movl $0xffffffff, 0x30(%rsp) # imm = 0xFFFFFFFF
movq %r14, %rdi
movq %r15, %rsi
leaq 0x50(%rsp), %rdx
xorl %ecx, %ecx
leaq 0x30(%rsp), %r8
callq 0xc714
xorl %eax, %eax
movq 0x50(%rsp), %rcx
movl %eax, %edx
leaq 0x1572f(%rip), %rsi     # 0x1a020
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
movl $0x0, 0x2c(%rsp)
jmpq *%rdx
movq %r15, %rsi
jmp 0x4b47
movl (%rcx), %edx
movl %edx, 0xc(%rsp)
movl 0x4(%rcx), %ecx
movl %ecx, 0x8(%rsp)
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movl $0x0, 0x10(%rsp)
movq %r14, %r12
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x10(%rsp), %r8
callq 0x4bae
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %r14
movb $0x1, %bpl
cmpq %r14, %r13
je 0x4abc
movl (%r13), %ecx
movl %ecx, 0x10(%rsp)
movl $0x9, %eax
cmpl 0x18(%rsp), %ecx
je 0x4a9b
movq %r12, %rdi
leaq 0xc(%rsp), %rsi
callq 0xc98e
movl %eax, %r15d
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0xc98e
movl %eax, %ebp
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0xc98e
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
movl 0x14(%rsp), %ecx
cmpl $-0x1, %ecx
sete %al
cmpl %ecx, %ebp
seta %cl
orb %al, %cl
xorl %eax, %eax
cmpb $0x1, %cl
jne 0x4a9b
movq (%rbx), %rax
cmpq %rax, 0x8(%rbx)
je 0x49f3
movq %rax, 0x8(%rbx)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x4a0d
movl 0x18(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x4a1a
movq %rbx, %rdi
leaq 0x18(%rsp), %rdx
callq 0xdeac
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x4a34
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x4a41
movq %rbx, %rdi
leaq 0xc(%rsp), %rdx
callq 0xdeac
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x4a5b
movl 0x10(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x4a68
movq %rbx, %rdi
leaq 0x10(%rsp), %rdx
callq 0xdeac
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x4a82
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x4a8f
movq %rbx, %rdi
leaq 0x8(%rsp), %rdx
callq 0xdeac
xorl %eax, %eax
cmpl $0x3, %ebp
sete %al
movl %ebp, 0x14(%rsp)
cmpl $0x9, %eax
je 0x4aa4
testl %eax, %eax
jne 0x4ab6
addq $0x4, %r13
cmpq %r14, %r13
jne 0x496a
movl $0x8, %eax
testb $0x7, %al
sete %bpl
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4acb
callq 0x21a0
testb %bpl, %bpl
movq %r12, %r14
je 0x4b2c
movq 0x20(%rsp), %rcx
leal 0x1(%rcx), %eax
cmpl $0x5, %ecx
setae %cl
movl %ecx, 0x2c(%rsp)
cmpl $0x6, %eax
je 0x4b2c
movq 0x50(%rsp), %rcx
movl %eax, %edx
leaq 0x15528(%rip), %rsi     # 0x1a020
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
movl (%rcx), %edx
jmp 0x4b0d
movl 0x8(%rcx), %edx
jmp 0x4b20
movl 0x4(%rcx), %edx
movl %edx, 0xc(%rsp)
movl 0x8(%rcx), %ecx
jmp 0x4913
movl 0x4(%rcx), %edx
jmp 0x4b20
movl (%rcx), %edx
movl %edx, 0xc(%rsp)
movl 0xc(%rcx), %ecx
jmp 0x4913
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x4b3b
callq 0x21a0
testb $0x1, 0x2c(%rsp)
leaq 0x18(%rsp), %rsi
je 0x4b6d
movq %r14, %rdi
callq 0xc034
leaq 0x18(%rsp), %rsi
cmpl $-0x1, 0x18(%rsp)
jne 0x48a1
cmpl $-0x1, 0x14(%rsp)
setne %al
jmp 0x4b6f
xorl %eax, %eax
jmp 0x4b6f
movb $0x1, %al
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x4b97
jmp 0x4b85
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4b97
callq 0x21a0
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x4ba6
callq 0x21a0
movq %rbx, %rdi
callq 0x2320