// File: /workspace/github_cpp_makefile_star2_O3/iPapatsoris[P]Maximum-Independent-Set/src/Reductions.cpp
// Function: Reductions::removeDesks()
bool Reductions::removeDesks() {
    Graph::GraphTraversal graphTraversal(graph);
    while (graphTraversal.curNode != NONE) {
        bool valid = true;
        if (graph.getNodeDegree(graphTraversal.curNode) >= 3) {
            vector<uint32_t> neighbors;
            graph.gatherNeighbors(graphTraversal.curNode, neighbors);
            if (valid) {
                uint32_t b, d;
                for (uint32_t i = 0 ; i < neighbors.size() ; i++) {
                    b = neighbors[i];
                    if (graph.getNodeDegree(b) < 3) {
                        continue;
                    }
                    for (uint32_t j = i+1 ; j < neighbors.size() ; j++) {
                        d = neighbors[j];
                        if (graph.getNodeDegree(d) < 3) {
                            continue;
                        }
                        vector<uint32_t> commonNeighbors;
                        graph.getCommonNeighbors(b, d, commonNeighbors);
                        for (auto c: commonNeighbors) {
                            if (c == graphTraversal.curNode || graph.getNodeDegree(c) < 3) {
                                continue;
                            }
                            if (!graph.edgeExists(graphTraversal.curNode, c) && !graph.edgeExists(b, d)) {
                                set<uint32_t> neighborsAC;
                                set<uint32_t> neighborsBD;
                                graph.gatherNeighbors(graphTraversal.curNode, neighborsAC);
                                graph.gatherNeighbors(c, neighborsAC);
                                graph.gatherNeighbors(b, neighborsBD);
                                graph.gatherNeighbors(d, neighborsBD);
                                if (neighborsAC.size() <= 4 && neighborsBD.size() <= 4) {
                                    for (auto n: neighborsAC) {
                                        if (neighborsBD.find(n) != neighborsBD.end()) {
                                            valid = false;
                                            break;
                                        }
                                    }
                                    if (valid) {
                                        //cout << "reducing desk " << graphTraversal.curNode << "-" << b << "-" << c << "-" << d << "\n";
                                        graph.remove(neighborsAC, reduceInfo);
                                        graph.remove(neighborsBD, reduceInfo);
                                        std::unordered_map<uint32_t, uint32_t> &subsequentNodes = mis.getSubsequentNodes();
                                        for (auto neighborAC: neighborsAC) {
                                            subsequentNodes.insert({neighborAC, b});
                                            subsequentNodes.insert({neighborAC, d});
                                            graph.addEdges(neighborAC, vector<uint32_t>(neighborsBD.begin(), neighborsBD.end()));
                                        }
                                        for (auto neighborBD: neighborsBD) {
                                            subsequentNodes.insert({neighborBD, graphTraversal.curNode});
                                            subsequentNodes.insert({neighborBD, c});
                                            graph.addEdges(neighborBD, vector<uint32_t>(neighborsAC.begin(), neighborsAC.end()));
                                        }
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        graph.getNextNode(graphTraversal);
    }
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %r15
movq (%rdi), %rsi
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x29d8
xorl %eax, %eax
cmpl $-0x1, (%rbx)
je 0x10fd6
leaq 0x10(%r15), %r14
leaq 0x20(%rsp), %r13
leaq 0x40(%rsp), %rbx
leaq 0x14(%rsp), %rbp
movq %r15, 0x18(%rsp)
movq %r14, 0xd8(%rsp)
movq (%r15), %rdi
movq %r13, %rsi
callq 0xc2d2
cmpl $0x3, %eax
jb 0x10fba
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
movq (%r15), %rdi
movl $0xffffffff, 0x40(%rsp) # imm = 0xFFFFFFFF
movq %r13, %rsi
leaq 0x70(%rsp), %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0xc092
movq 0x70(%rsp), %rdi
xorl %ecx, %ecx
cmpq %rdi, 0x78(%rsp)
je 0x10fa6
movb $0x1, %al
movl %eax, 0xc(%rsp)
movl (%rdi,%rcx,4), %eax
movl %eax, 0x14(%rsp)
movq (%r15), %rdi
movq %rbp, %rsi
movq %rcx, %r12
callq 0xc2d2
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rcx
incl %r12d
subq %rdi, %rcx
sarq $0x2, %rcx
cmpl $0x3, %eax
movq %r12, 0xe0(%rsp)
jb 0x10f87
movq %r12, %rax
movl %r12d, %edx
cmpq %r12, %rcx
movq %rdx, %r12
jbe 0x10f87
movl (%rdi,%rax,4), %eax
movl %eax, 0x8(%rsp)
movq (%r15), %rdi
leaq 0x8(%rsp), %rsi
callq 0xc2d2
cmpl $0x3, %eax
jb 0x10f61
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movq $0x0, 0xd0(%rsp)
movq (%r15), %rdi
movl $0x0, 0x40(%rsp)
movq %rbp, %rsi
leaq 0x8(%rsp), %rdx
leaq 0xc0(%rsp), %rcx
movq %rbx, %r8
callq 0x4c42
movq 0xc0(%rsp), %rbx
movq 0xc8(%rsp), %r14
cmpq %r14, %rbx
je 0x10f3d
movq %r12, 0xf0(%rsp)
movq %r14, 0xe8(%rsp)
movl (%rbx), %eax
movl %eax, 0x10(%rsp)
cmpl 0x20(%rsp), %eax
je 0x10f23
movq (%r15), %rdi
leaq 0x10(%rsp), %rsi
callq 0xc2d2
cmpl $0x3, %eax
jb 0x10f23
movq (%r15), %rdi
movq %r13, %rsi
leaq 0x10(%rsp), %rdx
callq 0xbf3a
cmpl $-0x1, %eax
jne 0x10f23
movq (%r15), %rdi
movq %rbp, %rsi
leaq 0x8(%rsp), %rdx
callq 0xbf3a
cmpl $-0x1, %eax
jne 0x10f23
xorl %ecx, %ecx
movl %ecx, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, 0x58(%rsp)
movq %rax, 0x60(%rsp)
movq %rcx, 0x68(%rsp)
movl %ecx, 0x98(%rsp)
movq %rcx, 0xa0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
movq %rcx, 0xb8(%rsp)
movq (%r15), %rdi
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movq %r13, %rsi
leaq 0x40(%rsp), %r13
movq %r13, %rdx
xorl %ecx, %ecx
leaq 0x28(%rsp), %r12
movq %r12, %r8
callq 0xc9b2
movq (%r15), %rdi
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
leaq 0x10(%rsp), %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0xc9b2
movq (%r15), %rdi
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movq %rbp, %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0xc9b2
movq (%r15), %rdi
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0xc9b2
leaq 0x7(%rsp), %r12
cmpq $0x4, 0x68(%rsp)
movb $0x1, %bpl
ja 0x10ef2
cmpq $0x4, 0xb8(%rsp)
ja 0x10ef2
movq 0x58(%rsp), %rax
leaq 0x48(%rsp), %rcx
cmpq %rcx, %rax
je 0x10d29
movq 0xa0(%rsp), %r15
testq %r15, %r15
je 0x10d17
movl 0x20(%rax), %ecx
movq %r15, %r9
leaq 0x98(%rsp), %r8
movq %r8, %rdx
movq %r9, %rsi
movl 0x20(%r9), %edi
xorl %r9d, %r9d
cmpl %ecx, %edi
setb %r9b
movq %rsi, %r8
cmovbq %rdx, %r8
movq 0x10(%rsi,%r9,8), %r9
testq %r9, %r9
jne 0x10cd7
leaq 0x98(%rsp), %r9
cmpq %r9, %r8
je 0x10d17
cmpl %ecx, %edi
cmovbq %rdx, %rsi
cmpl 0x20(%rsi), %ecx
jae 0x10e31
movq %rax, %rdi
callq 0x2210
leaq 0x48(%rsp), %rcx
cmpq %rcx, %rax
jne 0x10cc4
testb $0x1, 0xc(%rsp)
je 0x10e31
movq 0x18(%rsp), %r15
movq (%r15), %rdi
movq %r12, %r9
xorl %r12d, %r12d
movb %r12b, 0x28(%rsp)
movb %r12b, 0x7(%rsp)
leaq 0x40(%rsp), %rsi
movq 0xd8(%rsp), %r13
movq %r13, %rdx
leaq 0x28(%rsp), %rbp
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0x1217c
movq (%r15), %rdi
movb %r12b, 0x28(%rsp)
movb %r12b, 0x7(%rsp)
movq %r14, %rsi
movq %r13, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
leaq 0x7(%rsp), %r9
callq 0x1217c
movq 0x8(%r15), %r15
addq $0x50, %r15
movq 0x58(%rsp), %r12
leaq 0x48(%rsp), %rax
cmpq %rax, %r12
je 0x10e43
movl 0x20(%r12), %r13d
movl %r13d, 0x28(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xd8cc
movl %r13d, 0x28(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xd8cc
movq 0x18(%rsp), %rax
movq (%rax), %r14
movq 0xa8(%rsp), %rsi
movq %rbp, %rdi
leaq 0x98(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x123ee
movq %r14, %rdi
movl %r13d, %esi
movq %rbp, %rdx
callq 0x6c96
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x10e21
callq 0x21a0
movq %r12, %rdi
callq 0x2210
movq %rax, %r12
jmp 0x10d9c
movl $0x0, 0xc(%rsp)
movq 0x18(%rsp), %r15
jmp 0x10ef2
movq 0xa8(%rsp), %r12
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x98(%rsp), %rax
cmpq %rax, %r12
je 0x10ee3
movl 0x20(%r12), %r13d
movl %r13d, 0x28(%rsp)
movl 0x20(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xd8cc
movl %r13d, 0x28(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x2c(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xd8cc
movq 0x18(%rsp), %rax
movq (%rax), %r14
movq 0x58(%rsp), %rsi
movq %rbp, %rdi
leaq 0x48(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x123ee
movq %r14, %rdi
movl %r13d, %esi
movq %rbp, %rdx
callq 0x6c96
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x10ed3
callq 0x21a0
movq %r12, %rdi
callq 0x2210
movq %rax, %r12
jmp 0x10e51
xorl %ebp, %ebp
movq 0x18(%rsp), %r15
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0xc906
leaq 0x40(%rsp), %rdi
callq 0xc906
testb %bpl, %bpl
movq 0xf0(%rsp), %r12
je 0x10f83
leaq 0x20(%rsp), %r13
leaq 0x14(%rsp), %rbp
movq 0xe8(%rsp), %r14
addq $0x4, %rbx
cmpq %r14, %rbx
jne 0x10b62
movb $0x1, %bpl
movq 0xc0(%rsp), %rbx
jmp 0x10f40
movb $0x1, %bpl
testq %rbx, %rbx
je 0x10f4d
movq %rbx, %rdi
callq 0x21a0
testb %bpl, %bpl
leaq 0x20(%rsp), %r13
leaq 0x40(%rsp), %rbx
leaq 0x14(%rsp), %rbp
je 0x10f9f
incl %r12d
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rcx
subq %rdi, %rcx
sarq $0x2, %rcx
movq %r12, %rax
cmpq %r12, %rcx
ja 0x10ae2
jmp 0x10f87
xorl %ebp, %ebp
jmp 0x10f33
movq 0xe0(%rsp), %rax
cmpq %rax, %rcx
movq %rax, %rcx
ja 0x10a96
xorl %ecx, %ecx
jmp 0x10fa6
movb $0x1, %cl
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x10fb6
movq %rcx, %r12
callq 0x21a0
movq %r12, %rcx
testb %cl, %cl
jne 0x10fd4
movq (%r15), %rdi
movq %r13, %rsi
callq 0xb94a
cmpl $-0x1, 0x20(%rsp)
jne 0x10a39
xorl %eax, %eax
jmp 0x10fd6
movb $0x1, %al
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x10ffa
jmp 0x1101f
jmp 0x1101f
jmp 0x10ffa
jmp 0x1101f
jmp 0x1101f
jmp 0x1101f
jmp 0x1101f
jmp 0x1103b
movq %rax, %rbx
jmp 0x11050
jmp 0x1101f
jmp 0x11005
jmp 0x1101f
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x11022
callq 0x21a0
jmp 0x11022
jmp 0x1101f
jmp 0x1101f
jmp 0x1101f
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xc906
leaq 0x40(%rsp), %rdi
callq 0xc906
jmp 0x1103e
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x11050
callq 0x21a0
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1105f
callq 0x21a0
movq %rbx, %rdi
callq 0x2320
nop