// File: /workspace/github_cpp_makefile_star2_O2/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 %rdx, %r14
movq %rdi, %r13
callq 0xbb38
movb $0x1, (%r13)
movq (%r14), %rbx
movq 0x8(%r14), %r12
leaq 0x8(%r13), %r14
leaq 0x38(%r13), %r15
movq %r13, (%rsp)
leaq 0x68(%r13), %rax
movq %rax, 0x38(%rsp)
movabsq $0x3333333333333333, %r13 # imm = 0x3333333333333333
cmpq %r12, %rbx
je 0xba32
movq (%rbx), %rbp
movq %rbp, %rdx
shrq %rdx
movq %rbp, %rax
shrq $0x2, %rax
movabsq $0x1555555555555555, %rcx # imm = 0x1555555555555555
andq %rcx, %rax
movq %rdx, %rcx
subq %rax, %rcx
movq %rcx, %rax
andq %r13, %rax
shrq $0x2, %rcx
andq %r13, %rcx
addq %rax, %rcx
movq %rcx, %rax
shrq $0x4, %rax
addq %rcx, %rax
movabsq $0xf0f0f0f0f0f0f0f, %rcx # imm = 0xF0F0F0F0F0F0F0F
andq %rcx, %rax
movabsq $0x101010101010101, %rcx # imm = 0x101010101010101
imulq %rcx, %rax
shrq $0x38, %rax
cmpq $0x1, %rax
je 0xb9cb
testq %rax, %rax
jne 0xb9ed
testb $0x1, %bpl
je 0xba29
jmp 0xbad5
movq %rdx, %rsi
callq 0xb79c
testb $0x1, %bpl
jne 0xba17
movq %rax, 0x8(%rsp)
movq %r15, %rdi
leaq 0x8(%rsp), %rsi
callq 0xbba8
jmp 0xba29
leaq 0x8(%rsp), %rdi
callq 0xb7b6
movq 0x20(%rsp), %rsi
movq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0xbc58
leaq 0x8(%rsp), %rdi
callq 0xa31c
jmp 0xba29
movq %rax, 0x8(%rsp)
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0xbba8
addq $0x8, %rbx
jmp 0xb950
movq (%rsp), %rbx
testb $0x1, (%rbx)
je 0xbaf7
leaq 0x8(%rsp), %r8
andl $0x0, 0x8(%r8)
andq $0x0, 0x10(%r8)
leaq 0x10(%rsp), %r12
movq %r12, 0x18(%r8)
movq %r12, 0x20(%r8)
andq $0x0, 0x28(%r8)
leaq 0x10(%rbx), %rsi
movq 0x20(%rbx), %rdi
movq 0x50(%rbx), %rdx
leaq 0x40(%rbx), %rcx
movq %r12, %r9
callq 0xbd9e
movq 0x20(%rsp), %rbp
leaq 0x40(%rsp), %r13
cmpq %r12, %rbp
je 0xbac9
movq 0x20(%rbp), %rax
movq %rax, 0x40(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xbe64
movq %r14, %rdi
movq %rax, %rsi
callq 0xbeba
movq %r15, %rdi
movq %r13, %rsi
callq 0xbe64
movq %r15, %rdi
movq %rax, %rsi
callq 0xbeba
movq %rbp, %rdi
callq 0x54c0
movq %rax, %rbp
jmp 0xba82
leaq 0x8(%rsp), %rdi
callq 0xa31c
jmp 0xbaf7
movq 0x204d4(%rip), %rdi     # 0x2bfb0
leaq 0x156e3(%rip), %rsi     # 0x211c6
callq 0x5450
movq %rax, %rdi
callq 0x5230
movq (%rsp), %rbx
movb $0x0, (%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbb1a
jmp 0xbb13
jmp 0xbb13
jmp 0xbb13
jmp 0xbb1a
movq %rax, %r14
jmp 0xbb27
jmp 0xbb1a
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0xa31c
movq (%rsp), %rdi
callq 0x9850
movq %r14, %rdi
callq 0x5790