// File: /workspace/github_cpp_makefile_star2_O2/iPapatsoris[P]Maximum-Independent-Set/src/ControlUnit.cpp
// Function: ControlUnit::checkIndependentSet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) const
void ControlUnit::checkIndependentSet(const string &misInputFile) const {
    /* Build mis from input file */
    vector<uint32_t> mis;
    FILE *f;
    f = fopen(misInputFile.c_str(), "r");
    if (f == NULL) {
        cerr << "Error in opening MIS input file " << misInputFile << endl;
        exit(EXIT_FAILURE);
    }
    char buf[MAXLINE];
    if (fgets(buf, MAXLINE, f) == NULL) {
        cerr << "Error in parsing MIS input file " << misInputFile << endl;
        exit(EXIT_FAILURE);
    }
    while(fgets(buf, MAXLINE, f) != NULL) {
        uint32_t node = 0;
        for (uint32_t i = 0; buf[i] != ' ' && buf[i] != '\t' && buf[i] != '\n' ; i++) {
            node = node * 10 + (buf[i] - '0');
        }
        mis.push_back(node);
    }
    uint32_t node1, node2;
    unordered_set<uint32_t> set;
    for (auto node: mis) {
        if (!set.insert(node).second) {
            cout << "NOT a set! Node " << node << " exists more than once" << endl;
        }
    }

    bool independentSet = alg.getSearchTree()[0]->getGraph().isIndependentSet(mis, &node1, &node2);
    if (independentSet) {
        cout << "Valid independent set\n";
    } else {
        cout << "NOT an independent set!\nConflict between nodes " << node1 << " and " << node2 << endl;
    }
    fclose(f);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movq %rsi, %r14
movq %rdi, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq (%rsi), %rdi
leaq 0x1889(%rip), %rsi      # 0x1759a
callq 0x21d0
testq %rax, %rax
je 0x15eeb
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x2280
testq %rax, %rax
je 0x15f13
leaq 0x70(%rsp), %r14
movabsq $0x100000600, %r13      # imm = 0x100000600
leaq 0x10(%rsp), %r15
leaq 0x38(%rsp), %r12
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdx
callq 0x2280
testq %rax, %rax
je 0x15da7
andl $0x0, 0x38(%rsp)
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %edx
movzbl 0x70(%rsp,%rdx), %edx
cmpq $0x20, %rdx
ja 0x15d87
btq %rdx, %r13
jb 0x15d9a
movsbl %dl, %edx
imull $0xa, %ecx, %ecx
addl %edx, %ecx
addl $-0x30, %ecx
movl %ecx, 0x38(%rsp)
incl %eax
jmp 0x15d74
movq %r15, %rdi
movq %r12, %rsi
callq 0xa1ac
jmp 0x15d56
movq %rbp, 0x30(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbp
leaq 0x38(%rsp), %r15
leaq 0x4(%rsp), %r12
leaq 0x22e4(%rip), %r14      # 0x180ce
cmpq %rbp, %r13
je 0x15e3f
movl (%r13), %eax
movl %eax, 0x4(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xbc1a
testb $0x1, %dl
jne 0x15e39
movq 0xc1c2(%rip), %rdi      # 0x21fd0
leaq 0x22a8(%rip), %rsi      # 0x180bd
callq 0x2170
movl 0x4(%rsp), %esi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
movq %r14, %rsi
callq 0x2170
movq %rax, %rdi
callq 0x20a0
addq $0x4, %r13
jmp 0x15dea
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x30, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x10664
testb %al, %al
je 0x15e7b
movq 0xc163(%rip), %rdi      # 0x21fd0
leaq 0x2271(%rip), %rsi      # 0x180e5
callq 0x2170
jmp 0x15ebd
movq 0xc14e(%rip), %rdi      # 0x21fd0
leaq 0x2273(%rip), %rsi      # 0x180fc
callq 0x2170
movl 0xc(%rsp), %esi
movq %rax, %rdi
callq 0x2110
leaq 0x228b(%rip), %rsi      # 0x1812c
movq %rax, %rdi
callq 0x2170
movl 0x8(%rsp), %esi
movq %rax, %rdi
callq 0x2110
movq %rax, %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2180
leaq 0x38(%rsp), %rdi
callq 0xad26
leaq 0x10(%rsp), %rdi
callq 0xb872
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xc0fe(%rip), %rdi      # 0x21ff0
leaq 0x2182(%rip), %rsi      # 0x1807b
callq 0x2170
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20a0
jmp 0x15f39
movq 0xc0d6(%rip), %rdi      # 0x21ff0
leaq 0x217b(%rip), %rsi      # 0x1809c
callq 0x2170
movq %rax, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20a0
pushq $0x1
popq %rdi
callq 0x21e0
jmp 0x15f49
jmp 0x15f49
jmp 0x15f4e
jmp 0x15f4e
movq %rax, %rbx
jmp 0x15f5b
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xad26
leaq 0x10(%rsp), %rdi
callq 0xb872
movq %rbx, %rdi
callq 0x22c0
nopl (%rax)