// File: /workspace/github_cpp_makefile_star2_O1/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 $0x488, %rsp            # imm = 0x488
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq (%rsi), %rdi
leaq 0x15c6(%rip), %rsi      # 0x1a596
callq 0x2230
testq %rax, %rax
je 0x19276
movq %rax, %r13
leaq 0x80(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x22e0
testq %rax, %rax
je 0x192ab
movq %rbx, 0x38(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x22e0
testq %rax, %rax
je 0x190b1
movabsq $0x100000600, %rbx      # imm = 0x100000600
leaq 0x10(%rsp), %r14
leaq 0x48(%rsp), %r15
leaq 0x80(%rsp), %r12
movl $0x0, 0x48(%rsp)
xorl %ecx, %ecx
xorl %eax, %eax
movl %eax, %edx
movzbl 0x80(%rsp,%rdx), %edx
cmpq $0x20, %rdx
ja 0x19060
btq %rdx, %rbx
jb 0x19074
movsbl %dl, %edx
leal (%rcx,%rcx,4), %ecx
leal (%rdx,%rcx,2), %ecx
addl $-0x30, %ecx
movl %ecx, 0x48(%rsp)
incl %eax
jmp 0x1904a
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x19091
movl 0x48(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x1909c
movq %r14, %rdi
movq %r15, %rdx
callq 0xdeac
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x22e0
testq %rax, %rax
jne 0x1903e
movq %r13, 0x30(%rsp)
leaq 0x78(%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), %rbx
movq 0x18(%rsp), %r12
cmpq %r12, %rbx
je 0x19188
leaq 0x48(%rsp), %r15
leaq 0x40(%rsp), %r13
movq 0x9ed3(%rip), %rbp      # 0x22fd0
movl (%rbx), %eax
movl %eax, 0x4(%rsp)
movq %r15, 0x40(%rsp)
movq %r15, %rdi
leaq 0x4(%rsp), %rsi
movq %r13, %rdx
callq 0xdc3e
testb $0x1, %dl
jne 0x1917b
movl $0x10, %edx
movq %rbp, %rdi
leaq 0x1fa1(%rip), %rsi      # 0x1b0cd
callq 0x2200
movl 0x4(%rsp), %esi
movq %rbp, %rdi
callq 0x2120
movq %rax, %r14
movl $0x16, %edx
movq %rax, %rdi
leaq 0x1f8f(%rip), %rsi      # 0x1b0de
callq 0x2200
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
addq $0x4, %rbx
cmpq %r12, %rbx
jne 0x190fd
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rdi
addq $0x30, %rdi
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
callq 0x12d96
movq 0x30(%rsp), %rbx
testb %al, %al
je 0x191ce
movq 0x9e15(%rip), %rdi      # 0x22fd0
leaq 0x1f33(%rip), %rsi      # 0x1b0f5
movl $0x16, %edx
callq 0x2200
jmp 0x19243
movq 0x9dfb(%rip), %rdi      # 0x22fd0
leaq 0x1f30(%rip), %rsi      # 0x1b10c
movl $0x2f, %edx
callq 0x2200
movl 0xc(%rsp), %esi
movq 0x9ddf(%rip), %rdi      # 0x22fd0
callq 0x2120
movq %rax, %r14
leaq 0x1f3c(%rip), %rsi      # 0x1b13c
movl $0x5, %edx
movq %rax, %rdi
callq 0x2200
movl 0x8(%rsp), %esi
movq %r14, %rdi
callq 0x2120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %rbx, %rdi
callq 0x21d0
leaq 0x48(%rsp), %rdi
callq 0xcff8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x19264
callq 0x21a0
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9d73(%rip), %rdi      # 0x22ff0
leaq 0x1e07(%rip), %rsi      # 0x1b08b
movl $0x20, %edx
callq 0x2200
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x9d54(%rip), %rdi      # 0x22ff0
callq 0x2200
movq %rax, %rdi
callq 0x20b0
jmp 0x192de
movq 0x9d3e(%rip), %rdi      # 0x22ff0
leaq 0x1df3(%rip), %rsi      # 0x1b0ac
movl $0x20, %edx
callq 0x2200
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x9d1f(%rip), %rdi      # 0x22ff0
callq 0x2200
movq %rax, %rdi
callq 0x20b0
movl $0x1, %edi
callq 0x2240
jmp 0x192ee
jmp 0x192ee
jmp 0x192f5
movq %rax, %rbx
jmp 0x19302
jmp 0x192f5
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xcff8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x19311
callq 0x21a0
movq %rbx, %rdi
callq 0x2320
nopl (%rax)