// File: iPapatsoris[P]Maximum-Independent-Set/src/Reductions.cpp
// Function: Reductions::foldCompleteKIndependentSets2(unsigned int const&, bool const&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&, bool const&)
void Reductions::foldCompleteKIndependentSets2(const uint32_t &theta, const bool &checkAllNodes, unordered_set<uint32_t> &oldCandidateNodes, unordered_set<uint32_t> &newCandidateNodes, const bool &theta4) {
    newCandidateNodes.clear();
    Graph::GraphTraversal graphTraversal(graph);
    auto it = oldCandidateNodes.begin();
    uint32_t node = (checkAllNodes ? graphTraversal.curNode : (it == oldCandidateNodes.end() ? NONE : *it));
    while (node != NONE) {
        uint32_t k, end;
        if (theta >= 6) {
            k = 1;
            end = 2;
        }
        else if (theta == 5) {
            k = 2;
            end = 2;
        } else if ((theta == 4 || theta == 3) && !theta4) {
            k = 1;
            end = 1;
        } else if (theta == 4 && theta4) {
            k = 2;
            end = 3;
        } else if (theta == 3 && theta4) {
            k = 2;
            end = 2;
        }
        for (; k <= end ; k++) {
            if ((checkAllNodes || (!checkAllNodes && !graph.nodeIndex[graph.getPos(*it)].removed)) &&
            graph.getNodeDegree(node) == k+1 && k != 3 || k == 3 && (graph.getNodeDegree(node) == 3 || graph.getNodeDegree(node) == 4)) {
                vector<uint32_t> nodes;
                vector<uint32_t> neighbors;
                nodes.push_back(node);
                graph.gatherNeighbors(node, neighbors);
                uint32_t secondNode = NONE;
                if (k == 2 || k == 3) {
                    secondNode = graph.getNextNodeWithIdenticalNeighbors(node, neighbors);
                    if (secondNode != NONE) {
                        nodes.push_back(secondNode);
                    }
                    else {
                        continue;
                    }
                }
                if (k == 3) {
                    uint32_t thirdNode;
                    uint32_t degree = graph.getNodeDegree(node);
                    if (degree == 3) {
                        uint32_t uncommonNeighbor;
                        thirdNode = graph.getNodeWithOneUncommonNeighbor(neighbors, uncommonNeighbor);
                        neighbors.push_back(uncommonNeighbor);
                    } else if (degree == 4) {
                        thirdNode = graph.getNextNodeWithIdenticalNeighbors(secondNode, neighbors);
                    } else {
                        assert(false);
                    }
                    if (thirdNode != NONE) {
                        nodes.push_back(thirdNode);
                    } else {
                        continue;
                    }
                }
                vector<uint32_t> &mis = this->mis.getMis();
                if (graph.isIndependentSet(neighbors)) {
                    uint32_t newNode = graph.contractToSingleNode(nodes, neighbors, reduceInfo);
                    this->mis.markHypernode(newNode, nodes, neighbors);
                } else if (theta != 4) {
                    mis.insert(mis.end(), nodes.begin(), nodes.end());
                }
                neighbors.insert(neighbors.end(), nodes.begin(), nodes.end());
                graph.remove(neighbors, reduceInfo, false, &newCandidateNodes);
                break;
            }
        }
        if (checkAllNodes) {
            graph.getNextNode(graphTraversal);
            node = graphTraversal.curNode;
        } else {
            it++;
            node = (it == oldCandidateNodes.end() ? NONE : *it);
        }
    }
}

// Assembly:
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, 0x1a0(%rsp)
movq %rsi, 0x198(%rsp)
movq %rdx, 0x190(%rsp)
movq %rcx, 0x188(%rsp)
movq %r8, 0x180(%rsp)
movq %r9, 0x178(%rsp)
movq 0x1a0(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x180(%rsp), %rdi
callq 0x1aed0
movq 0x78(%rsp), %rax
movq (%rax), %rsi
leaq 0x170(%rsp), %rdi
callq 0x2a40
movq 0x188(%rsp), %rdi
callq 0x19220
movq %rax, 0x168(%rsp)
movq 0x190(%rsp), %rax
testb $0x1, (%rax)
je 0x32105
movl 0x170(%rsp), %eax
movl %eax, 0x74(%rsp)
jmp 0x3215b
movq 0x188(%rsp), %rdi
callq 0x19250
movq %rax, 0x158(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0x1a690
testb $0x1, %al
jne 0x32135
jmp 0x32140
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x70(%rsp)
jmp 0x32153
leaq 0x168(%rsp), %rdi
callq 0x192a0
movl (%rax), %eax
movl %eax, 0x70(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x164(%rsp)
cmpl $-0x1, 0x164(%rsp)
je 0x328a3
movq 0x198(%rsp), %rax
cmpl $0x6, (%rax)
jb 0x3219c
movl $0x1, 0x154(%rsp)
movl $0x2, 0x150(%rsp)
jmp 0x3226d
movq 0x198(%rsp), %rax
cmpl $0x5, (%rax)
jne 0x321c4
movl $0x2, 0x154(%rsp)
movl $0x2, 0x150(%rsp)
jmp 0x3226b
movq 0x198(%rsp), %rax
cmpl $0x4, (%rax)
je 0x321de
movq 0x198(%rsp), %rax
cmpl $0x3, (%rax)
jne 0x32203
movq 0x178(%rsp), %rax
testb $0x1, (%rax)
jne 0x32203
movl $0x1, 0x154(%rsp)
movl $0x1, 0x150(%rsp)
jmp 0x32269
movq 0x198(%rsp), %rax
cmpl $0x4, (%rax)
jne 0x32235
movq 0x178(%rsp), %rax
testb $0x1, (%rax)
je 0x32235
movl $0x2, 0x154(%rsp)
movl $0x3, 0x150(%rsp)
jmp 0x32267
movq 0x198(%rsp), %rax
cmpl $0x3, (%rax)
jne 0x32265
movq 0x178(%rsp), %rax
testb $0x1, (%rax)
je 0x32265
movl $0x2, 0x154(%rsp)
movl $0x2, 0x150(%rsp)
jmp 0x32267
jmp 0x32269
jmp 0x3226b
jmp 0x3226d
jmp 0x3226f
movl 0x154(%rsp), %eax
cmpl 0x150(%rsp), %eax
ja 0x327fc
movq 0x190(%rsp), %rax
testb $0x1, (%rax)
jne 0x322e0
movq 0x190(%rsp), %rax
testb $0x1, (%rax)
jne 0x3230d
movq 0x78(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x68(%rsp)
movq (%rax), %rax
movq %rax, 0x60(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x192a0
movq 0x60(%rsp), %rdi
movq %rax, %rsi
callq 0x339a0
movq 0x68(%rsp), %rdi
movl %eax, %eax
movl %eax, %esi
callq 0x19050
testb $0x1, 0x8(%rax)
jne 0x3230d
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164(%rsp), %rsi
callq 0x1a040
movl 0x154(%rsp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3230d
cmpl $0x3, 0x154(%rsp)
jne 0x32353
cmpl $0x3, 0x154(%rsp)
jne 0x327e4
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164(%rsp), %rsi
callq 0x1a040
cmpl $0x3, %eax
je 0x32353
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164(%rsp), %rsi
callq 0x1a040
cmpl $0x4, %eax
jne 0x327e4
leaq 0x138(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x17e60
leaq 0x120(%rsp), %rdi
callq 0x17e60
movq 0x58(%rsp), %rdi
leaq 0x164(%rsp), %rsi
callq 0x19070
jmp 0x32386
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl $0xffffffff, 0x110(%rsp) # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %ecx
leaq 0x164(%rsp), %rsi
leaq 0x120(%rsp), %rdx
leaq 0x110(%rsp), %r8
callq 0x19c30
jmp 0x323bc
movl $0xffffffff, 0x10c(%rsp) # imm = 0xFFFFFFFF
cmpl $0x2, 0x154(%rsp)
je 0x323df
cmpl $0x3, 0x154(%rsp)
jne 0x32475
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x4a60
movl %eax, 0x54(%rsp)
jmp 0x32402
movl 0x54(%rsp), %eax
movl %eax, 0x10c(%rsp)
cmpl $-0x1, 0x10c(%rsp)
je 0x32463
leaq 0x138(%rsp), %rdi
leaq 0x10c(%rsp), %rsi
callq 0x19070
jmp 0x3242e
jmp 0x32473
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x18520
leaq 0x138(%rsp), %rdi
callq 0x18520
jmp 0x328ab
movl $0x6, 0x108(%rsp)
jmp 0x327ba
jmp 0x32475
cmpl $0x3, 0x154(%rsp)
jne 0x3258a
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x164(%rsp), %rsi
callq 0x1a040
movl %eax, 0x50(%rsp)
jmp 0x3249e
movl 0x50(%rsp), %eax
movl %eax, 0x100(%rsp)
cmpl $0x3, 0x100(%rsp)
jne 0x324fa
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x120(%rsp), %rsi
leaq 0xfc(%rsp), %rdx
callq 0x4dc0
movl %eax, 0x4c(%rsp)
jmp 0x324d6
movl 0x4c(%rsp), %eax
movl %eax, 0x104(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0xfc(%rsp), %rsi
callq 0x19070
jmp 0x324f8
jmp 0x32555
cmpl $0x4, 0x100(%rsp)
jne 0x32534
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x10c(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x4a60
movl %eax, 0x48(%rsp)
jmp 0x32527
movl 0x48(%rsp), %eax
movl %eax, 0x104(%rsp)
jmp 0x32553
leaq 0x13c4b(%rip), %rdi     # 0x46186
leaq 0x143d2(%rip), %rsi     # 0x46914
movl $0x20c, %edx            # imm = 0x20C
leaq 0x14400(%rip), %rcx     # 0x4694e
callq 0x2110
jmp 0x32555
cmpl $-0x1, 0x104(%rsp)
je 0x32578
leaq 0x138(%rsp), %rdi
leaq 0x104(%rsp), %rsi
callq 0x19070
jmp 0x32576
jmp 0x32588
movl $0x6, 0x108(%rsp)
jmp 0x327ba
jmp 0x3258a
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x33930
movq %rax, 0x40(%rsp)
jmp 0x3259f
movq 0x78(%rsp), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %ecx
leaq 0x120(%rsp), %rsi
movq %rcx, %rdx
callq 0x339f0
movb %al, 0x3f(%rsp)
jmp 0x325ce
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x325d8
jmp 0x32637
movq 0x78(%rsp), %rcx
movq (%rcx), %rdi
addq $0x10, %rcx
leaq 0x138(%rsp), %rsi
leaq 0x120(%rsp), %rdx
callq 0x41e0
movl %eax, 0x38(%rsp)
jmp 0x325ff
movq 0x78(%rsp), %rax
movl 0x38(%rsp), %ecx
movl %ecx, 0xec(%rsp)
movq 0x8(%rax), %rdi
leaq 0xec(%rsp), %rsi
leaq 0x138(%rsp), %rdx
leaq 0x120(%rsp), %rcx
callq 0x40fd0
jmp 0x32632
jmp 0x326db
movq 0x198(%rsp), %rax
cmpl $0x4, (%rax)
je 0x326d9
movq 0xf0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x1a0e0
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1aa60
leaq 0x138(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x19b50
movq 0x20(%rsp), %rdi
movq %rax, 0xd0(%rsp)
callq 0x1a0e0
movq 0x28(%rsp), %rdi
movq %rax, 0xc8(%rsp)
movq 0xe0(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
callq 0x1a9a0
movq %rax, 0x30(%rsp)
jmp 0x326cc
movq 0x30(%rsp), %rax
movq %rax, 0xc0(%rsp)
jmp 0x326db
leaq 0x120(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x1a0e0
movq %rax, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1aa60
leaq 0x138(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x19b50
movq 0x8(%rsp), %rdi
movq %rax, 0xa8(%rsp)
callq 0x1a0e0
movq 0x10(%rsp), %rdi
movq %rax, 0xa0(%rsp)
movq 0xb8(%rsp), %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
callq 0x1a9a0
movq %rax, 0x18(%rsp)
jmp 0x3275f
movq 0x78(%rsp), %rdx
movq 0x18(%rsp), %rax
movq %rax, 0x98(%rsp)
movq (%rdx), %rdi
addq $0x10, %rdx
movb $0x0, 0x97(%rsp)
movq 0x180(%rsp), %r8
movb $0x0, 0x96(%rsp)
leaq 0x120(%rsp), %rsi
leaq 0x97(%rsp), %rcx
leaq 0x96(%rsp), %r9
callq 0x189b0
jmp 0x327af
movl $0x4, 0x108(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x18520
leaq 0x138(%rsp), %rdi
callq 0x18520
movl 0x108(%rsp), %eax
subl $0x4, %eax
je 0x327fc
jmp 0x327e2
jmp 0x327e6
jmp 0x327e6
movl 0x154(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x154(%rsp)
jmp 0x3226f
movq 0x190(%rsp), %rax
testb $0x1, (%rax)
je 0x3282e
movq 0x78(%rsp), %rax
movq (%rax), %rdi
leaq 0x170(%rsp), %rsi
callq 0x185f0
movl 0x170(%rsp), %eax
movl %eax, 0x164(%rsp)
jmp 0x3289e
leaq 0x168(%rsp), %rdi
xorl %esi, %esi
callq 0x1a5d0
movq %rax, 0x88(%rsp)
movq 0x188(%rsp), %rdi
callq 0x19250
movq %rax, 0x80(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1a690
testb $0x1, %al
jne 0x32875
jmp 0x32880
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x4(%rsp)
jmp 0x32893
leaq 0x168(%rsp), %rdi
callq 0x192a0
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x164(%rsp)
jmp 0x32166
addq $0x1a8, %rsp            # imm = 0x1A8
retq
movq 0x118(%rsp), %rdi
callq 0x2310
nopl (%rax,%rax)