// File: /workspace/github_cpp_makefile_star2_O3/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 0xefa6(%rip), %r12      # 0x152b8
leaq 0x10(%rsp), %r13
movq 0xef92(%rip), %rax      # 0x152b0
movq %rax, %rcx
subq 0xef68(%rip), %rcx      # 0x15290
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x7, %rcx
movq 0xef59(%rip), %rax      # 0x15298
subq 0xef5a(%rip), %rax      # 0x152a0
sarq $0x2, %rax
movq 0xef37(%rip), %rdx      # 0x15288
subq 0xef20(%rip), %rdx      # 0x15278
sarq $0x2, %rdx
addq %rax, %rdx
addq %rcx, %rdx
cmpq 0x18(%r14), %rdx
jae 0x63b5
movq 0x10(%r14), %rbp
testq %rbp, %rbp
je 0x6317
movl 0x8(%rbp), %eax
movl %eax, 0x10(%rsp)
leaq 0x10(%rbp), %rsi
movq %r15, %rdi
callq 0x91a2
movq %r12, %rdi
movq %r13, %rsi
callq 0xbda0
cmpb $0x0, (%rax)
jne 0x63a0
movl 0x10(%rsp), %esi
movq %r14, %rdi
callq 0x617f
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x63af
callq 0x21f0
movq (%rbp), %rbp
jmp 0x636c
leaq 0xeefc(%rip), %rdi      # 0x152b8
callq 0xa5d4
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0xeebf(%rip), %rax      # 0x15298
movb $0x1, %bpl
cmpq 0xee95(%rip), %rax      # 0x15278
je 0x650f
leaq 0xee78(%rip), %r14      # 0x15268
leaq 0xeec1(%rip), %r15      # 0x152b8
leaq 0xc(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x10(%rsp), %rbp
cmpq 0xee93(%rip), %rax      # 0x152a0
jne 0x6422
movq 0xee9a(%rip), %rax      # 0x152b0
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movl -0x4(%rax), %eax
movl %eax, 0xc(%rsp)
movq %r14, %rdi
callq 0xd8a0
movq %r15, %rdi
movq %r12, %rsi
callq 0xbda0
cmpb $0x0, (%rax)
jne 0x647b
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x6242
movq %rbp, %rdi
movq %r13, %rsi
callq 0x9176
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x647b
callq 0x21f0
movq 0xee16(%rip), %rax      # 0x15298
cmpq 0xedef(%rip), %rax      # 0x15278
jne 0x6406
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq %r15, %rbx
je 0x650c
leaq 0x30(%rsp), %r14
movb $0x1, %bpl
movq %r14, %rdi
movq %rbx, %rsi
callq 0x91a2
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rax
subq %rdi, %rax
je 0x64ee
sarq $0x2, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
xorl %ecx, %ecx
movl (%rdi,%rcx,4), %edx
xorl %esi, %esi
movl (%rdi,%rsi,4), %r8d
addl %edx, %r8d
je 0x6503
incq %rsi
cmpq %rsi, %rax
jne 0x64d3
incq %rcx
cmpq %rax, %rcx
jne 0x64ce
jmp 0x64f3
testq %rdi, %rdi
je 0x64f8
callq 0x21f0
addq $0x18, %rbx
cmpq %r15, %rbx
jne 0x64a6
jmp 0x650f
callq 0x21f0
xorl %ebp, %ebp
jmp 0x650f
movb $0x1, %bpl
leaq 0x10(%rsp), %rdi
callq 0x8e6a
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x652c
movq %rax, %rbx
jmp 0x6543
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x6543
callq 0x21f0
leaq 0x10(%rsp), %rdi
callq 0x8e6a
jmp 0x6561
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x6561
callq 0x21f0
movq %rbx, %rdi
callq 0x2350