// File: iPapatsoris[P]Maximum-Independent-Set/src/Reductions.cpp
// Function: Reductions::removeLineGraphs(unsigned int const&)
void Reductions::removeLineGraphs(const uint32_t &theta) {
    //cout << "\n**Performing line graph reduction**" << endl;
    vector<unordered_map<uint32_t, vector<uint32_t>* >::iterator> removedCCs;
    for (auto it = ccToNodes.begin() ; it != ccToNodes.end() ; it++) {
        vector<uint32_t> *cc = it->second;
        vector<Graph::GraphTraversal> clique1;
        vector<Graph::GraphTraversal> clique2;
        clique1.reserve(5);
        clique2.reserve(5);
        uint32_t checks;
        if (theta >= 6) {
            checks = 3;
        } else {
            checks = 1;
        }
        for (uint32_t i = 0 ; i < checks ; i++) {
            uint32_t nodes, degree, clique1Size, clique2Size;
            if (theta >= 6) {
                switch (i) {
                    case 0:
                        nodes = 10;
                        degree = 6;
                        clique1Size = clique2Size = 4;
                        break;
                    case 1:
                        nodes = 15;
                        degree = 8;
                        clique1Size = clique2Size = 5;
                        break;
                    case 2:
                        nodes = 20;
                        degree = 7;
                        clique1Size = 5;
                        clique2Size = 4;
                        break;
                }
            } else if (theta == 5) {
                nodes = 12;
                degree = 5;
                clique1Size = 4;
                clique2Size = 3;
            } else if (theta <= 4) {
                nodes = 6;
                degree = 4;
                clique1Size = clique2Size = 3;
            }
            if (cc->size() == nodes && nodeDegreesEqualTo(*cc, degree, graph)) {
                bool foundCliques = true;
                for (auto node : *cc) {
                    clique1.clear();
                    clique2.clear();
                    clique1.push_back(Graph::GraphTraversal(graph, node));
                    if (!findClique(clique1, NULL, clique1Size)) {
                        foundCliques = false;
                        break;
                    }
                    clique2.push_back(Graph::GraphTraversal(graph, node));
                    if (!findClique(clique2, &clique1, clique2Size)) {
                        foundCliques = false;
                        break;
                    }
                }
                if (foundCliques) {
                    //cout << "Removing component " << it->first << "\n";
                    findMisInComponent(*cc);
                    graph.remove(*cc, reduceInfo, true);
                    removedCCs.push_back(it);
                    break;
                } else {
                    break;
                }
            }
        }
    }
    if (removedCCs.empty()) {
        //cout << "No nodes removed" << endl;
    } else {
        for (auto cc : removedCCs) {
            delete cc->second;
            ccToNodes.erase(cc);
        }
    }
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq %rsi, 0x118(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x334c0
movq 0x20(%rsp), %rdi
addq $0x18, %rdi
callq 0x334d0
movq %rax, 0xf8(%rsp)
movq 0x20(%rsp), %rdi
addq $0x18, %rdi
callq 0x33520
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x33500
testb $0x1, %al
jne 0x2f20b
jmp 0x2f68a
leaq 0xf8(%rsp), %rdi
callq 0x33550
movq 0x8(%rax), %rax
movq %rax, 0xe8(%rsp)
leaq 0xd0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x33c90
leaq 0xb8(%rsp), %rdi
callq 0x33c90
movq 0x18(%rsp), %rdi
movl $0x5, %esi
callq 0x33ca0
jmp 0x2f254
leaq 0xb8(%rsp), %rdi
movl $0x5, %esi
callq 0x33ca0
jmp 0x2f268
movq 0x118(%rsp), %rax
cmpl $0x6, (%rax)
jb 0x2f2b5
movl $0x3, 0xa8(%rsp)
jmp 0x2f2c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x33ea0
leaq 0xd0(%rsp), %rdi
callq 0x33ea0
jmp 0x2f78c
movl $0x1, 0xa8(%rsp)
movl $0x0, 0xa4(%rsp)
movl 0xa4(%rsp), %eax
cmpl 0xa8(%rsp), %eax
jae 0x2f657
movq 0x118(%rsp), %rax
cmpl $0x6, (%rax)
jb 0x2f3a4
movl 0xa4(%rsp), %eax
movl %eax, 0x14(%rsp)
testl %eax, %eax
je 0x2f31a
jmp 0x2f301
movl 0x14(%rsp), %eax
subl $0x1, %eax
je 0x2f348
jmp 0x2f30c
movl 0x14(%rsp), %eax
subl $0x2, %eax
je 0x2f376
jmp 0x2f3a2
movl $0xa, 0xa0(%rsp)
movl $0x6, 0x9c(%rsp)
movl $0x4, 0x94(%rsp)
movl $0x4, 0x98(%rsp)
jmp 0x2f3a2
movl $0xf, 0xa0(%rsp)
movl $0x8, 0x9c(%rsp)
movl $0x5, 0x94(%rsp)
movl $0x5, 0x98(%rsp)
jmp 0x2f3a2
movl $0x14, 0xa0(%rsp)
movl $0x7, 0x9c(%rsp)
movl $0x5, 0x98(%rsp)
movl $0x4, 0x94(%rsp)
jmp 0x2f41c
movq 0x118(%rsp), %rax
cmpl $0x5, (%rax)
jne 0x2f3df
movl $0xc, 0xa0(%rsp)
movl $0x5, 0x9c(%rsp)
movl $0x4, 0x98(%rsp)
movl $0x3, 0x94(%rsp)
jmp 0x2f41a
movq 0x118(%rsp), %rax
cmpl $0x4, (%rax)
ja 0x2f418
movl $0x6, 0xa0(%rsp)
movl $0x4, 0x9c(%rsp)
movl $0x3, 0x94(%rsp)
movl $0x3, 0x98(%rsp)
jmp 0x2f41a
jmp 0x2f41c
movq 0xe8(%rsp), %rdi
callq 0x188e0
movl 0xa0(%rsp), %ecx
cmpq %rcx, %rax
jne 0x2f63f
movq 0x20(%rsp), %rax
movq 0xe8(%rsp), %rdi
movq (%rax), %rdx
leaq 0x9c(%rsp), %rsi
callq 0x33db0
movb %al, 0x13(%rsp)
jmp 0x2f45c
movb 0x13(%rsp), %al
testb $0x1, %al
jne 0x2f469
jmp 0x2f63f
movb $0x1, 0x93(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
callq 0x19b50
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rdi
callq 0x1a0e0
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1a110
testb $0x1, %al
jne 0x2f4c3
jmp 0x2f5d2
leaq 0x80(%rsp), %rdi
callq 0x1a150
movl (%rax), %eax
movl %eax, 0x74(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x33e50
leaq 0xb8(%rsp), %rdi
callq 0x33e50
movq 0x20(%rsp), %rax
movq (%rax), %rsi
leaq 0x6c(%rsp), %rdi
leaq 0x74(%rsp), %rdx
callq 0x2a70
jmp 0x2f509
leaq 0xd0(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
callq 0x33e70
jmp 0x2f51d
movq 0x20(%rsp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq 0xd0(%rsp), %rsi
leaq 0x98(%rsp), %rcx
callq 0x32a20
movb %al, 0x12(%rsp)
jmp 0x2f541
movb 0x12(%rsp), %al
testb $0x1, %al
jne 0x2f555
jmp 0x2f54b
movb $0x0, 0x93(%rsp)
jmp 0x2f5d2
movq 0x20(%rsp), %rax
movq (%rax), %rsi
leaq 0x64(%rsp), %rdi
leaq 0x74(%rsp), %rdx
callq 0x2a70
jmp 0x2f56e
leaq 0xb8(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x33e70
jmp 0x2f582
movq 0x20(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0xd0(%rsp), %rdx
leaq 0x94(%rsp), %rcx
callq 0x32a20
movb %al, 0x11(%rsp)
jmp 0x2f5aa
movb 0x11(%rsp), %al
testb $0x1, %al
jne 0x2f5be
jmp 0x2f5b4
movb $0x0, 0x93(%rsp)
jmp 0x2f5d2
jmp 0x2f5c0
leaq 0x80(%rsp), %rdi
callq 0x1a160
jmp 0x2f4a8
testb $0x1, 0x93(%rsp)
je 0x2f63d
movq 0x20(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x32b70
jmp 0x2f5f0
movq 0x20(%rsp), %rdx
movq (%rdx), %rdi
movq 0xe8(%rsp), %rsi
addq $0x10, %rdx
movb $0x1, 0x63(%rsp)
movb $0x0, 0x62(%rsp)
xorl %eax, %eax
movl %eax, %r8d
leaq 0x63(%rsp), %rcx
leaq 0x62(%rsp), %r9
callq 0x189b0
jmp 0x2f624
leaq 0x100(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x33570
jmp 0x2f63b
jmp 0x2f657
jmp 0x2f657
jmp 0x2f641
movl 0xa4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa4(%rsp)
jmp 0x2f2cb
leaq 0xb8(%rsp), %rdi
callq 0x33ea0
leaq 0xd0(%rsp), %rdi
callq 0x33ea0
leaq 0xf8(%rsp), %rdi
xorl %esi, %esi
callq 0x335e0
movq %rax, 0x58(%rsp)
jmp 0x2f1d7
leaq 0x100(%rsp), %rdi
callq 0x33610
testb $0x1, %al
jne 0x2f69d
jmp 0x2f6a2
jmp 0x2f777
leaq 0x100(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rdi
callq 0x33660
movq %rax, 0x48(%rsp)
movq 0x50(%rsp), %rdi
callq 0x33690
movq %rax, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x336c0
testb $0x1, %al
jne 0x2f6e5
jmp 0x2f775
leaq 0x48(%rsp), %rdi
callq 0x33700
movq (%rax), %rax
movq %rax, 0x38(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x33550
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x2f724
movq 0x8(%rsp), %rdi
callq 0x18520
movq 0x8(%rsp), %rdi
callq 0x2180
movq 0x20(%rsp), %rdi
addq $0x18, %rdi
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rsi
callq 0x33710
movq %rax, (%rsp)
jmp 0x2f747
movq (%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x33750
jmp 0x2f6cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
jmp 0x2f78c
jmp 0x2f777
leaq 0x100(%rsp), %rdi
callq 0x33770
addq $0x128, %rsp            # imm = 0x128
retq
leaq 0x100(%rsp), %rdi
callq 0x33770
movq 0xb0(%rsp), %rdi
callq 0x2310
nopw %cs:(%rax,%rax)