// File: /workspace/github_cpp_makefile_star2_O3/helchr[P]reMap/solver.cpp
// Function: Solver::getSolution(std::vector<unsigned long, std::allocator<unsigned long>> const&)
Solver::Solution Solver::getSolution(const std::vector<uint64_t> &matrix)
{
    Solution s;
    s.exists = true;
    for(auto row : matrix)
    {
        std::bitset<bitSize> bits(row>>1);
        std::bitset<1> rhs(row&1);
        if(bits.count() == 0 && rhs == 1)
        {
            // all zeros but a one in the last column
            std::cout << "No solution exists" << std::endl;
            s.exists=false;
            break;
        }
        else if(bits.count() == 1 && rhs == 0)
        {
           s.uninvolvedBits.insert(getSetBit(bits));
        }
        else if(bits.count() == 1 && rhs == 1)
        {
           s.involvedBits.insert(getSetBit(bits));
        }
        else if(bits.count() >= 2)
        {
            auto setBits = getSetBits(bits);
            s.unknownBits.insert(setBits.begin(),setBits.end());
        }
    }
    if(s.exists)
    {
        std::set<uint64_t> common;
        std::set_intersection(s.involvedBits.begin(),s.involvedBits.end(),
                              s.uninvolvedBits.begin(),s.uninvolvedBits.end(),
                              std::inserter(common,common.begin()));
        for(auto c : common)
        {
            auto it = s.involvedBits.find(c);
            s.involvedBits.erase(it);
            it = s.uninvolvedBits.find(c);
            s.uninvolvedBits.erase(it);
        }
    }
    return s;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %r14
xorl %eax, %eax
movl %eax, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %r14, 0x20(%rdi)
movq %r14, 0x28(%rdi)
movq %rax, 0x30(%rdi)
leaq 0x40(%rdi), %r15
movl %eax, 0x40(%rdi)
movq %rax, 0x48(%rdi)
movq %r15, 0x50(%rdi)
movq %r15, 0x58(%rdi)
movq %rax, 0x60(%rdi)
leaq 0x70(%rdi), %rcx
movl %eax, 0x70(%rdi)
movq %rax, 0x78(%rdi)
movq %rcx, 0x80(%rdi)
movq %rcx, 0x88(%rdi)
movq %rax, 0x90(%rdi)
movb $0x1, (%rdi)
movq (%rdx), %r13
movq 0x8(%rdx), %rbp
cmpq %rbp, %r13
je 0xc62e
leaq 0x8(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x38(%rbx), %rax
movq %rax, 0x38(%rsp)
leaq 0x68(%rbx), %rax
movq %rax, (%rsp)
movabsq $0x3333333333333333, %r12 # imm = 0x3333333333333333
movq (%r13), %rax
movq %rax, %rdx
shrq %rdx
movq %rax, %rcx
shrq $0x2, %rcx
movabsq $0x1555555555555555, %rsi # imm = 0x1555555555555555
andq %rsi, %rcx
movq %rdx, %rsi
subq %rcx, %rsi
movq %rsi, %rcx
andq %r12, %rcx
shrq $0x2, %rsi
andq %r12, %rsi
addq %rcx, %rsi
movq %rsi, %rcx
shrq $0x4, %rcx
addq %rsi, %rcx
movabsq $0xf0f0f0f0f0f0f0f, %rsi # imm = 0xF0F0F0F0F0F0F0F
andq %rsi, %rcx
movabsq $0x101010101010101, %rsi # imm = 0x101010101010101
imulq %rsi, %rcx
shrq $0x38, %rcx
cmpq $0x1, %rcx
je 0xc591
testq %rcx, %rcx
jne 0xc5c3
testb $0x1, %al
je 0xc618
jmp 0xc732
testb $0x1, %al
jne 0xc5ec
xorl %eax, %eax
btq %rax, %rdx
jb 0xc5ad
incq %rax
cmpq $0x40, %rax
jne 0xc597
movq $-0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xc7ba
jmp 0xc618
leaq 0x8(%rsp), %rdi
callq 0xc340
movq 0x20(%rsp), %rsi
movq (%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xc864
leaq 0x8(%rsp), %rdi
callq 0xb082
jmp 0xc618
xorl %eax, %eax
btq %rax, %rdx
jb 0xc604
incq %rax
cmpq $0x40, %rax
jne 0xc5ee
movq $-0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xc7ba
addq $0x8, %r13
cmpq %rbp, %r13
jne 0xc51c
testb $0x1, (%rbx)
je 0xc77b
leaq 0x10(%rsp), %r12
movl $0x0, (%r12)
xorl %eax, %eax
movq %rax, 0x8(%r12)
movq %r12, 0x10(%r12)
movq %r12, 0x18(%r12)
movq %rax, 0x20(%r12)
movq 0x20(%rbx), %rdi
movq 0x50(%rbx), %rdx
leaq 0x8(%rsp), %r8
movq %r14, %rsi
movq %r15, %rcx
movq %r12, %r9
callq 0xc9ae
movq 0x20(%rsp), %r13
cmpq %r12, %r13
je 0xc726
leaq 0x8(%rbx), %rax
movq %rax, (%rsp)
leaq 0x38(%rbx), %r12
movq 0x20(%r13), %rbp
movq 0x18(%rbx), %rcx
movq %r14, %rsi
testq %rcx, %rcx
je 0xc6c3
movq %r14, %rax
xorl %edx, %edx
cmpq %rbp, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0xc699
movq %r14, %rsi
cmpq %r14, %rax
je 0xc6c3
cmpq 0x20(%rax), %rbp
cmovbq %r14, %rax
movq %rax, %rsi
movq (%rsp), %rdi
callq 0xca50
movq 0x48(%rbx), %rcx
movq %r15, %rsi
testq %rcx, %rcx
je 0xc705
movq %r15, %rax
xorl %edx, %edx
cmpq %rbp, 0x20(%rcx)
setb %dl
cmovaeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0xc6db
movq %r15, %rsi
cmpq %r15, %rax
je 0xc705
cmpq 0x20(%rax), %rbp
cmovbq %r15, %rax
movq %rax, %rsi
movq %r12, %rdi
callq 0xca50
movq %r13, %rdi
callq 0x54e0
movq %rax, %r13
leaq 0x10(%rsp), %rax
cmpq %rax, %r13
jne 0xc686
leaq 0x8(%rsp), %rdi
callq 0xb082
jmp 0xc77b
movq 0x1f877(%rip), %r14     # 0x2bfb0
leaq 0x15a62(%rip), %rsi     # 0x221a2
movl $0x12, %edx
movq %r14, %rdi
callq 0x54c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x5440
movsbl %al, %esi
movq 0x1f845(%rip), %rdi     # 0x2bfb0
callq 0x5030
movq %rax, %rdi
callq 0x5350
movb $0x0, (%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xc79c
jmp 0xc797
jmp 0xc797
jmp 0xc797
jmp 0xc79c
movq %rax, %r14
jmp 0xc7a9
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0xb082
movq %rbx, %rdi
callq 0xa59a
movq %r14, %rdi
callq 0x5790
nop