// File: /workspace/github_cpp_makefile_star2_O1/Manca[P]algorithms2/./assignment6.hpp
// Function: assignment6::Check2SAT(std::unordered_map<int, std::vector<int, std::allocator<int>>, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::vector<int, std::allocator<int>>>>>&, std::unordered_map<int, std::vector<int, std::allocator<int>>, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::vector<int, std::allocator<int>>>>>&)
bool Check2SAT(Graph& G, Graph& GRev)
    {
        // Kosaraju SCC Algorithm
        // step 1: while stack size less than graph size
        // push elements according to their finish times
        while (_S.size() < G.size())
        {
            for (auto element : G)
            {
                // if not found in stack (not explored), let's DFS
                if (!_explored[element.first])
                {
                    DFSFillStack(G, element.first);
                }
            }
        }
        
        _explored.clear();
        std::vector<std::vector<int>> allSCC;

        // step 2: pop elements from stack and DFS
        // on transposed graph
        while (!_S.empty())
        {
            int el = _S.top();
            _S.pop();
            if (_explored[el])
                continue;

            std::vector<int> scc;
            DFSSCC(GRev, el, scc);
            allSCC.push_back(scc);
        }

        // Prints SCCs on reversed graph
        /*  for (auto vec : allSCC)
        {
        for (int el : vec)
        std::cout << " " << el;
        std::cout << std::endl;
        }*/

        // step 3: added step for 2SAT problem
        // if we find X and not X in SCC then
        // 2SAT is unsatisfiable
        for (auto vec : allSCC)
        {
            for (int i = 0; i < vec.size(); i++)
            {
                for (int j = 0; j < vec.size(); j++)
                    if (vec[i] == -vec[j])
                    {
                        return false;
                    }
            }
        }
        return true;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x18(%rsp), %r15
leaq 0xeec6(%rip), %r12      # 0x152c0
leaq 0x10(%rsp), %r13
movq 0xeeb2(%rip), %rax      # 0x152b8
movq %rax, %rcx
subq 0xee88(%rip), %rcx      # 0x15298
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x7, %rcx
movq 0xee79(%rip), %rax      # 0x152a0
subq 0xee7a(%rip), %rax      # 0x152a8
sarq $0x2, %rax
movq 0xee57(%rip), %rdx      # 0x15290
subq 0xee40(%rip), %rdx      # 0x15280
sarq $0x2, %rdx
addq %rax, %rdx
addq %rcx, %rdx
cmpq 0x18(%r14), %rdx
jae 0x649d
movq 0x10(%r14), %rbp
testq %rbp, %rbp
je 0x63ff
movl 0x8(%rbp), %eax
movl %eax, 0x10(%rsp)
leaq 0x10(%rbp), %rsi
movq %r15, %rdi
callq 0x9156
movq %r12, %rdi
movq %r13, %rsi
callq 0xbd5a
cmpb $0x0, (%rax)
jne 0x6488
movl 0x10(%rsp), %esi
movq %r14, %rdi
callq 0x6267
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x6497
callq 0x2200
movq (%rbp), %rbp
jmp 0x6454
leaq 0xee1c(%rip), %rdi      # 0x152c0
callq 0xa57c
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0xeddf(%rip), %rax      # 0x152a0
cmpq 0xedb8(%rip), %rax      # 0x15280
je 0x6574
leaq 0xed9b(%rip), %r14      # 0x15270
leaq 0xede4(%rip), %r15      # 0x152c0
leaq 0xc(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x10(%rsp), %rbp
cmpq 0xedb6(%rip), %rax      # 0x152a8
jne 0x6507
movq 0xedbd(%rip), %rax      # 0x152b8
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movl -0x4(%rax), %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
callq 0xd8a2
movq %r15, %rdi
movq %r12, %rsi
callq 0xbd5a
cmpb $0x0, (%rax)
jne 0x6560
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x632a
movq %rbp, %rdi
movq %r13, %rsi
callq 0x912a
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6560
callq 0x2200
movq 0xed39(%rip), %rax      # 0x152a0
cmpq 0xed12(%rip), %rax      # 0x15280
jne 0x64eb
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq %r15, %rbx
sete %bpl
je 0x660e
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x9156
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rax
subq %rdi, %rax
setne %r12b
je 0x65e5
sarq $0x2, %rax
cmpq $0x1, %rax
movq %rax, %rcx
adcq $0x0, %rcx
xorl %edx, %edx
movl (%rdi,%rdx,4), %esi
xorl %r8d, %r8d
movl (%rdi,%r8,4), %r9d
addl %esi, %r9d
je 0x65f1
incq %r8
cmpq %r8, %rcx
jne 0x65c5
incq %rdx
cmpq %rdx, %rax
seta %r12b
cmpq %rcx, %rdx
jne 0x65bf
testq %rdi, %rdi
je 0x6601
callq 0x2200
jmp 0x6601
testq %rdi, %rdi
je 0x65fb
callq 0x2200
testb $0x1, %r12b
jne 0x660e
addq $0x18, %rbx
cmpq %r15, %rbx
sete %bpl
jne 0x6590
leaq 0x10(%rsp), %rdi
callq 0x8e2a
andb $0x1, %bpl
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x662f
movq %rax, %rbx
jmp 0x6646
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6646
callq 0x2200
leaq 0x10(%rsp), %rdi
callq 0x8e2a
jmp 0x6664
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x6664
callq 0x2200
movq %rbx, %rdi
callq 0x2360