// File: iPapatsoris[P]Maximum-Independent-Set/src/Graph.cpp
// Function: Graph::getOptimalDegree4Node3(unsigned int&, unsigned int&) const
void Graph::getOptimalDegree4Node3(uint32_t &maxNodeWithCond, uint32_t &maxNode) const {
    uint32_t maxDegree3NeighborsWithCond = NONE;
    maxNodeWithCond = NONE;
    uint32_t maxDegree3Neighbors = NONE;
    maxNode = NONE;
    GraphTraversal graphTraversal(*this);
    while (graphTraversal.curNode != NONE) {
        if (getNodeDegree(graphTraversal.curNode) == 4) {
            vector<uint32_t> neighborsV;
            gatherNeighbors(graphTraversal.curNode, neighborsV);
            uint32_t degree3Neighbors = 0;
            for (uint32_t neighborV: neighborsV) {
                if (getNodeDegree(neighborV) == 3) {
                    degree3Neighbors++;
                }
            }
            if (maxDegree3Neighbors == NONE || degree3Neighbors > maxDegree3Neighbors) {
                maxDegree3Neighbors = degree3Neighbors;
                maxNode = graphTraversal.curNode;
            }
            if (maxDegree3NeighborsWithCond == NONE || degree3Neighbors > maxDegree3NeighborsWithCond) {
                for (uint32_t neighborV: neighborsV) {
                    if (getNodeDegree(neighborV) == 4) {
                        vector<uint32_t> neighborsN;
                        gatherNeighbors(neighborV, neighborsN);
                        uint32_t a, b, c;
                        uint32_t v = graphTraversal.curNode;
                        uint32_t i = 0;
                        for (uint32_t n: neighborsN) {
                            if (n != v) {
                                if (i == 0) {
                                    a = n;
                                } else if (i == 1) {
                                    b = n;
                                } else if (i == 2) {
                                    c = n;
                                }
                                i++;
                            }
                        }
                        bool ab = edgeExists(a, b);
                        bool bc = edgeExists(b, c);
                        bool ac = edgeExists(a, c);
                        bool va = edgeExists(v, a);
                        bool vb = edgeExists(v, b);
                        bool vc = edgeExists(v, c);
                        if (!va && !vb && !vc && (ab && !bc && !ac || bc && !ab && !ac || ac && !ab && !bc)) {
                            maxDegree3NeighborsWithCond = degree3Neighbors;
                            maxNodeWithCond = graphTraversal.curNode;
                        }
                    }
                }
            }
        }
        getNextNode(graphTraversal);
    }
}

// Assembly:
subq $0x118, %rsp            # imm = 0x118
movq %rdi, 0x110(%rsp)
movq %rsi, 0x108(%rsp)
movq %rdx, 0x100(%rsp)
movq 0x110(%rsp), %rsi
movq %rsi, 0x20(%rsp)
movl $0xffffffff, 0xfc(%rsp) # imm = 0xFFFFFFFF
movq 0x108(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, 0xf8(%rsp) # imm = 0xFFFFFFFF
movq 0x100(%rsp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
leaq 0xf0(%rsp), %rdi
callq 0x2a40
cmpl $-0x1, 0xf0(%rsp)
je 0x5d71
movq 0x20(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x1a040
cmpl $0x4, %eax
jne 0x5d5a
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x17e60
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rdx
movl $0xffffffff, 0xd4(%rsp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %ecx
leaq 0xf0(%rsp), %rsi
leaq 0xd4(%rsp), %r8
callq 0x19c30
jmp 0x58f6
movl $0x0, 0xc0(%rsp)
leaq 0xd8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x19b50
movq %rax, 0xb0(%rsp)
movq 0xb8(%rsp), %rdi
callq 0x1a0e0
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x1a110
testb $0x1, %al
jne 0x5956
jmp 0x59cd
leaq 0xb0(%rsp), %rdi
callq 0x1a150
movq 0x20(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0xa4(%rsp)
leaq 0xa4(%rsp), %rsi
callq 0x1a040
movl %eax, 0x14(%rsp)
jmp 0x5984
movl 0x14(%rsp), %eax
cmpl $0x3, %eax
jne 0x59b9
movl 0xc0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc0(%rsp)
jmp 0x59b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
jmp 0x5d4b
jmp 0x59bb
leaq 0xb0(%rsp), %rdi
callq 0x1a160
jmp 0x593b
cmpl $-0x1, 0xf8(%rsp)
je 0x59e7
movl 0xc0(%rsp), %eax
cmpl 0xf8(%rsp), %eax
jbe 0x5a06
movl 0xc0(%rsp), %eax
movl %eax, 0xf8(%rsp)
movl 0xf0(%rsp), %ecx
movq 0x100(%rsp), %rax
movl %ecx, (%rax)
cmpl $-0x1, 0xfc(%rsp)
je 0x5a24
movl 0xc0(%rsp), %eax
cmpl 0xfc(%rsp), %eax
jbe 0x5d3c
leaq 0xd8(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rdi
callq 0x19b50
movq %rax, 0x90(%rsp)
movq 0x98(%rsp), %rdi
callq 0x1a0e0
movq %rax, 0x88(%rsp)
leaq 0x90(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x1a110
testb $0x1, %al
jne 0x5a7c
jmp 0x5d3a
leaq 0x90(%rsp), %rdi
callq 0x1a150
movq 0x20(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x84(%rsp)
leaq 0x84(%rsp), %rsi
callq 0x1a040
movl %eax, 0x10(%rsp)
jmp 0x5aaa
movl 0x10(%rsp), %eax
cmpl $0x4, %eax
jne 0x5d26
leaq 0x68(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x17e60
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %ecx
leaq 0x84(%rsp), %rsi
leaq 0x64(%rsp), %r8
callq 0x19c30
jmp 0x5af0
movl 0xf0(%rsp), %eax
movl %eax, 0x54(%rsp)
movl $0x0, 0x50(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
callq 0x19b50
movq %rax, 0x40(%rsp)
movq 0x48(%rsp), %rdi
callq 0x1a0e0
movq %rax, 0x38(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x1a110
testb $0x1, %al
jne 0x5b43
jmp 0x5bd1
leaq 0x40(%rsp), %rdi
callq 0x1a150
movl (%rax), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x54(%rsp), %eax
je 0x5bc0
cmpl $0x0, 0x50(%rsp)
jne 0x5b91
movl 0x34(%rsp), %eax
movl %eax, 0x60(%rsp)
jmp 0x5bb5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc8(%rsp)
movl %eax, 0xc4(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x18520
jmp 0x5d4b
cmpl $0x1, 0x50(%rsp)
jne 0x5ba2
movl 0x34(%rsp), %eax
movl %eax, 0x5c(%rsp)
jmp 0x5bb3
cmpl $0x2, 0x50(%rsp)
jne 0x5bb1
movl 0x34(%rsp), %eax
movl %eax, 0x58(%rsp)
jmp 0x5bb3
jmp 0x5bb5
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x5bc2
leaq 0x40(%rsp), %rdi
callq 0x1a160
jmp 0x5b2b
movq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0x5c(%rsp), %rdx
callq 0x18920
movb %al, 0x7(%rsp)
jmp 0x5beb
movq 0x20(%rsp), %rdi
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x33(%rsp)
leaq 0x5c(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x18920
movb %al, 0x6(%rsp)
jmp 0x5c0f
movq 0x20(%rsp), %rdi
movb 0x6(%rsp), %al
andb $0x1, %al
movb %al, 0x32(%rsp)
leaq 0x60(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x18920
movb %al, 0x5(%rsp)
jmp 0x5c33
movq 0x20(%rsp), %rdi
movb 0x5(%rsp), %al
andb $0x1, %al
movb %al, 0x31(%rsp)
leaq 0x54(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x18920
movb %al, 0x4(%rsp)
jmp 0x5c57
movq 0x20(%rsp), %rdi
movb 0x4(%rsp), %al
andb $0x1, %al
movb %al, 0x30(%rsp)
leaq 0x54(%rsp), %rsi
leaq 0x5c(%rsp), %rdx
callq 0x18920
movb %al, 0x3(%rsp)
jmp 0x5c7b
movq 0x20(%rsp), %rdi
movb 0x3(%rsp), %al
andb $0x1, %al
movb %al, 0x2f(%rsp)
leaq 0x54(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x18920
movb %al, 0x2(%rsp)
jmp 0x5c9f
movb 0x2(%rsp), %al
andb $0x1, %al
movb %al, 0x2e(%rsp)
testb $0x1, 0x30(%rsp)
jne 0x5d1c
testb $0x1, 0x2f(%rsp)
jne 0x5d1c
testb $0x1, 0x2e(%rsp)
jne 0x5d1c
testb $0x1, 0x33(%rsp)
je 0x5cd3
testb $0x1, 0x32(%rsp)
jne 0x5cd3
testb $0x1, 0x31(%rsp)
je 0x5cfd
testb $0x1, 0x32(%rsp)
je 0x5ce8
testb $0x1, 0x33(%rsp)
jne 0x5ce8
testb $0x1, 0x31(%rsp)
je 0x5cfd
testb $0x1, 0x31(%rsp)
je 0x5d1c
testb $0x1, 0x33(%rsp)
jne 0x5d1c
testb $0x1, 0x32(%rsp)
jne 0x5d1c
movl 0xc0(%rsp), %eax
movl %eax, 0xfc(%rsp)
movl 0xf0(%rsp), %ecx
movq 0x108(%rsp), %rax
movl %ecx, (%rax)
leaq 0x68(%rsp), %rdi
callq 0x18520
jmp 0x5d28
leaq 0x90(%rsp), %rdi
callq 0x1a160
jmp 0x5a5e
jmp 0x5d3c
leaq 0xd8(%rsp), %rdi
callq 0x18520
jmp 0x5d5a
leaq 0xd8(%rsp), %rdi
callq 0x18520
jmp 0x5d79
movq 0x20(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x185f0
jmp 0x588b
addq $0x118, %rsp            # imm = 0x118
retq
movq 0xc8(%rsp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)