// File: helchr[P]reMap/main.cpp
// Function: calculateAddressingFunction(std::map<unsigned long, std::vector<unsigned long, std::allocator<unsigned long>>, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::vector<unsigned long, std::allocator<unsigned long>>>>> const&, unsigned long, unsigned long)
std::vector<Solver::Solution> calculateAddressingFunction(const std::map<size_t,std::vector<size_t>>& addresses, size_t addrFuncBits, size_t usableBits)
{
    std::vector<Solver::Solution> sList;
    for(size_t bit = 0; bit < addrFuncBits; bit++)
    {
        std::vector<uint64_t> matrix;
        Solver s;
        for(auto adrList : addresses)
        {
            uint64_t mask = 1ULL << bit;
            auto bitValue = (adrList.first & mask) >> bit;
            for(auto row : adrList.second)
            {
                auto rowWithResult = (row << 1ULL) | bitValue;
                matrix.push_back(rowWithResult);
            }
        }
        s.solve(matrix,usableBits);
        auto sol = s.getSolution(matrix);
        sList.push_back(sol);
    }
    return sList;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x178(%rbp)
movq %rdi, %rax
movq %rax, -0x170(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
callq 0xcbb0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x9ff2
leaq -0x48(%rbp), %rdi
callq 0xc710
leaq -0x49(%rbp), %rdi
callq 0xcbd0
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0xcbf0
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
callq 0xcc20
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xcc50
testb $0x1, %al
jne 0x9e15
jmp 0x9f59
leaq -0x60(%rbp), %rdi
callq 0xcc80
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0xc7e0
jmp 0x9e2f
movq -0x30(%rbp), %rcx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0xa0(%rbp)
movq -0x88(%rbp), %rax
andq -0xa0(%rbp), %rax
movq -0x30(%rbp), %rcx
shrq %cl, %rax
movq %rax, -0xa8(%rbp)
leaq -0x88(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0xcad0
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
callq 0xcb00
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xcb30
testb $0x1, %al
jne 0x9eb2
jmp 0x9f3f
leaq -0xb8(%rbp), %rdi
callq 0xcb70
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
addq %rax, %rax
movq -0xa8(%rbp), %rcx
orq %rcx, %rax
movq %rax, -0xd0(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0xc860
jmp 0x9ef5
jmp 0x9ef7
leaq -0xb8(%rbp), %rdi
callq 0xcb90
jmp 0x9e96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x9fdb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xc8d0
jmp 0x9fdb
leaq -0x88(%rbp), %rdi
callq 0xc8d0
leaq -0x60(%rbp), %rdi
callq 0xccb0
jmp 0x9dff
movq -0x20(%rbp), %rdx
leaq -0x49(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x178a0
jmp 0x9f6c
leaq -0x168(%rbp), %rdi
leaq -0x49(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x179f0
jmp 0x9f82
movq -0x178(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0xcce0
jmp 0x9f97
leaq -0x168(%rbp), %rdi
callq 0xcd50
leaq -0x48(%rbp), %rdi
callq 0xc920
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x9dbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x168(%rbp), %rdi
callq 0xcd50
leaq -0x48(%rbp), %rdi
callq 0xc920
movq -0x178(%rbp), %rdi
callq 0xcd90
jmp 0xa018
movb $0x1, -0x21(%rbp)
testb $0x1, -0x21(%rbp)
jne 0xa008
movq -0x178(%rbp), %rdi
callq 0xcd90
movq -0x170(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x6950
nopw %cs:(%rax,%rax)