// File: /workspace/github_cpp_makefile_star2_O2/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, %r13
movq (%rdi), %rsi
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x270e
leaq 0x10(%r13), %rax
leaq 0x50(%rsp), %rbx
leaq 0x68(%rsp), %r12
movq %r13, 0x40(%rsp)
movq %rax, 0xf0(%rsp)
movl 0x38(%rsp), %ebp
cmpl $-0x1, %ebp
je 0xf568
movq (%r13), %rdi
movq %r15, %rsi
callq 0xa5ce
cmpl $0x3, %eax
jb 0xf53c
movl %ebp, 0x48(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
movq (%r13), %rdi
orl $-0x1, 0x68(%rsp)
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
movq %r12, %r8
callq 0xa3c8
movb $0x1, %bpl
xorl %r14d, %r14d
leaq 0xc(%rsp), %rbx
movl %r14d, %eax
movq 0x50(%rsp), %rcx
movq 0x58(%rsp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rax, %rdx
jbe 0xf52f
movl (%rcx,%rax,4), %eax
movl %eax, 0x10(%rsp)
movq (%r13), %rdi
leaq 0x10(%rsp), %rsi
callq 0xa5ce
movl %r14d, 0x4c(%rsp)
cmpl $0x3, %eax
jae 0xf109
movl 0x4c(%rsp), %r14d
incl %r14d
jmp 0xf0c3
incl %r14d
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0xf0ff
movl (%rax,%r14,4), %eax
movl %eax, 0xc(%rsp)
movq (%r13), %rdi
movq %rbx, %rsi
callq 0xa5ce
cmpl $0x3, %eax
jb 0xf109
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
andq $0x0, 0xe0(%rsp)
movq (%r13), %rdi
andl $0x0, 0x68(%rsp)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdx
leaq 0xd0(%rsp), %rcx
movq %r12, %r8
callq 0x42fc
movq 0xd0(%rsp), %rbx
movq 0xd8(%rsp), %rcx
movq %rcx, 0x30(%rsp)
cmpq %rcx, %rbx
je 0xf518
movl (%rbx), %eax
movl %eax, 0x14(%rsp)
cmpl 0x38(%rsp), %eax
je 0xf1de
movq (%r13), %rdi
leaq 0x14(%rsp), %rsi
callq 0xa5ce
cmpl $0x3, %eax
jb 0xf1d9
movq (%r13), %rdi
movq %r15, %rsi
leaq 0x14(%rsp), %rdx
callq 0x9e3a
testb %al, %al
jne 0xf1d9
movq (%r13), %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
callq 0x9e3a
testb %al, %al
je 0xf1e4
movq 0x30(%rsp), %rcx
addq $0x4, %rbx
jmp 0xf185
andl $0x0, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x80(%rsp)
movq %rax, 0x88(%rsp)
andq $0x0, 0x90(%rsp)
andl $0x0, 0xa8(%rsp)
andq $0x0, 0xb0(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
andq $0x0, 0xc8(%rsp)
movq (%r13), %rdi
orl $-0x1, 0x18(%rsp)
movq %r15, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
leaq 0x18(%rsp), %r15
movq %r15, %r8
callq 0xadc0
movq (%r13), %rdi
orl $-0x1, 0x18(%rsp)
leaq 0x14(%rsp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0xadc0
movq (%r13), %rdi
orl $-0x1, 0x18(%rsp)
leaq 0x10(%rsp), %rsi
leaq 0xa0(%rsp), %r12
movq %r12, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0xadc0
movq (%r13), %rdi
orl $-0x1, 0x18(%rsp)
leaq 0xc(%rsp), %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movq %r15, %r8
callq 0xadc0
cmpq $0x4, 0x90(%rsp)
movb $0x1, %r12b
ja 0xf4e6
cmpq $0x4, 0xc8(%rsp)
ja 0xf4e6
movq 0x80(%rsp), %r15
leaq 0x70(%rsp), %rax
cmpq %rax, %r15
je 0xf321
movl 0x20(%r15), %eax
movl %eax, 0x18(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x10bb6
leaq 0xa8(%rsp), %rcx
cmpq %rcx, %rax
jne 0xf436
movq %r15, %rdi
callq 0x21b0
movq %rax, %r15
jmp 0xf2df
testb $0x1, %bpl
je 0xf436
movq (%r13), %rdi
xorl %eax, %eax
movb %al, 0x18(%rsp)
movb %al, 0xb(%rsp)
leaq 0x68(%rsp), %rsi
movq 0xf0(%rsp), %r15
movq %r15, %rdx
leaq 0x18(%rsp), %rbp
movq %rbp, %rcx
xorl %r8d, %r8d
leaq 0xb(%rsp), %r12
movq %r12, %r9
callq 0x103da
movq (%r13), %rdi
xorl %eax, %eax
movb %al, 0x18(%rsp)
movb %al, 0xb(%rsp)
leaq 0xa0(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x103da
movq 0x8(%r13), %r13
addq $0x50, %r13
movq 0x80(%rsp), %r12
movq %r13, 0x98(%rsp)
leaq 0x70(%rsp), %rax
cmpq %rax, %r12
je 0xf43d
movl 0x20(%r12), %r15d
movl %r15d, 0x18(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xbfd8
movl %r15d, 0x18(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xbfd8
movq 0x40(%rsp), %rax
movq (%rax), %r13
movq 0xb8(%rsp), %rsi
movq %rbp, %rdi
leaq 0xa8(%rsp), %rdx
leaq 0xb(%rsp), %rcx
callq 0x105ae
movq %r13, %rdi
movl %r15d, %esi
movq %rbp, %rdx
callq 0x5e38
movq %rbp, %rdi
callq 0xb872
movq %r12, %rdi
callq 0x21b0
movq %rax, %r12
movq 0x98(%rsp), %r13
jmp 0xf3a0
xorl %ebp, %ebp
jmp 0xf4e6
movq 0xb8(%rsp), %r12
leaq 0xa8(%rsp), %rax
cmpq %rax, %r12
je 0xf4db
movl 0x20(%r12), %r15d
movl %r15d, 0x18(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xbfd8
movl %r15d, 0x18(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0xbfd8
movq 0x40(%rsp), %rax
movq (%rax), %r13
movq 0x80(%rsp), %rsi
movq %rbp, %rdi
leaq 0x70(%rsp), %rdx
leaq 0xb(%rsp), %rcx
callq 0x105ae
movq %r13, %rdi
movl %r15d, %esi
movq %rbp, %rdx
callq 0x5e38
movq %rbp, %rdi
callq 0xb872
movq %r12, %rdi
callq 0x21b0
movq %rax, %r12
movq 0x98(%rsp), %r13
jmp 0xf445
movb $0x1, %bpl
xorl %r12d, %r12d
movq 0x40(%rsp), %r13
leaq 0xa0(%rsp), %rdi
callq 0xacde
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0xacde
testb %r12b, %r12b
movq %r15, %r12
leaq 0x38(%rsp), %r15
movq 0x30(%rsp), %rcx
jne 0xf1de
jmp 0xf54d
leaq 0xd0(%rsp), %rdi
callq 0xb872
leaq 0xc(%rsp), %rbx
jmp 0xf109
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0xb872
movq (%r13), %rdi
movq %r15, %rsi
callq 0x9cf8
jmp 0xf06b
leaq 0xd0(%rsp), %rdi
callq 0xb872
leaq 0x50(%rsp), %rdi
callq 0xb872
movl 0x48(%rsp), %ebp
cmpl $-0x1, %ebp
setne %al
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf5dd
jmp 0xf5af
jmp 0xf5af
jmp 0xf5cb
jmp 0xf5af
jmp 0xf5af
jmp 0xf5af
jmp 0xf5af
jmp 0xf5dd
jmp 0xf5af
jmp 0xf5af
jmp 0xf5af
jmp 0xf59a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xb872
jmp 0xf5b2
jmp 0xf5af
jmp 0xf5af
jmp 0xf5af
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xacde
leaq 0x68(%rsp), %rdi
callq 0xacde
jmp 0xf5ce
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xb872
jmp 0xf5e0
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x22c0