// File: /workspace/github_cpp_makefile_star2_O3/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 0x134e(%rip), %rsi      # 0x19596
callq 0x2230
testq %rax, %rax
je 0x184ea
movq %rax, %r13
leaq 0x80(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %rax, %rdx
callq 0x22e0
testq %rax, %rax
je 0x1851f
movq %rbx, 0x38(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x22e0
testq %rax, %rax
je 0x18325
movabsq $0x100000600, %rbx      # imm = 0x100000600
leaq 0x10(%rsp), %r14
leaq 0x48(%rsp), %r15
leaq 0x80(%rsp), %r12
movl $0x0, 0x48(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
movl %ecx, %edx
movzbl 0x80(%rsp,%rdx), %edx
cmpq $0x20, %rdx
ja 0x182d8
btq %rdx, %rbx
jb 0x182ec
movsbl %dl, %edx
leal (%rax,%rax,4), %eax
leal (%rdx,%rax,2), %eax
addl $-0x30, %eax
movl %eax, 0x48(%rsp)
incl %ecx
jmp 0x182c2
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x18305
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x18310
movq %r14, %rdi
movq %r15, %rdx
callq 0xd7b4
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x22e0
testq %rax, %rax
jne 0x182b6
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 0x183fc
leaq 0x48(%rsp), %r15
leaq 0x40(%rsp), %r13
movq 0x9c5f(%rip), %rbp      # 0x21fd0
movl (%rbx), %eax
movl %eax, 0x4(%rsp)
movq %r15, 0x40(%rsp)
movq %r15, %rdi
leaq 0x4(%rsp), %rsi
movq %r13, %rdx
callq 0xd538
testb $0x1, %dl
jne 0x183ef
movl $0x10, %edx
movq %rbp, %rdi
leaq 0x1d2d(%rip), %rsi      # 0x1a0cd
callq 0x2200
movl 0x4(%rsp), %esi
movq %rbp, %rdi
callq 0x2120
movq %rax, %r14
movl $0x16, %edx
movq %rax, %rdi
leaq 0x1d1b(%rip), %rsi      # 0x1a0de
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 0x18371
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 0x1858e
movq 0x30(%rsp), %rbx
testb %al, %al
je 0x18442
movq 0x9ba1(%rip), %rdi      # 0x21fd0
leaq 0x1cbf(%rip), %rsi      # 0x1a0f5
movl $0x16, %edx
callq 0x2200
jmp 0x184b7
movq 0x9b87(%rip), %rdi      # 0x21fd0
leaq 0x1cbc(%rip), %rsi      # 0x1a10c
movl $0x2f, %edx
callq 0x2200
movl 0xc(%rsp), %esi
movq 0x9b6b(%rip), %rdi      # 0x21fd0
callq 0x2120
movq %rax, %r14
leaq 0x1cc8(%rip), %rsi      # 0x1a13c
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 0xc950
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x184d8
callq 0x21a0
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x9aff(%rip), %rdi      # 0x21ff0
leaq 0x1b93(%rip), %rsi      # 0x1a08b
movl $0x20, %edx
callq 0x2200
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x9ae0(%rip), %rdi      # 0x21ff0
callq 0x2200
movq %rax, %rdi
callq 0x20b0
jmp 0x18552
movq 0x9aca(%rip), %rdi      # 0x21ff0
leaq 0x1b7f(%rip), %rsi      # 0x1a0ac
movl $0x20, %edx
callq 0x2200
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x9aab(%rip), %rdi      # 0x21ff0
callq 0x2200
movq %rax, %rdi
callq 0x20b0
movl $0x1, %edi
callq 0x2240
jmp 0x18562
jmp 0x18562
jmp 0x18569
movq %rax, %rbx
jmp 0x18576
jmp 0x18569
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xc950
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18585
callq 0x21a0
movq %rbx, %rdi
callq 0x2320
nop