// File: Manca[P]algorithms1/./assignment6.hpp
// Function: assignment6::computeTargetSums(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int computeTargetSums(const string& fileName)
    {
        // some defs and inits
        typedef std::unordered_map<long long, std::list<long long>> hashTable;
        typedef std::unordered_set<long long> seenSums;
        
        hashTable _hash;
        seenSums  _sums;
        
        ifstream file(fileName, ios::in);
        
        std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
        if (file.is_open())
        {
            long long num;
            while ( file >> num)
            {
                _hash[num / 20000].push_front(num);
            }
        }
        
        // for every x in our hash table, find y that satisfies t = x + y
        for (auto pair : _hash)
        {
            for (auto num : pair.second)
            {
                auto searchMin = _hash.find((-10000 - num)/20000);
                auto searchMax = _hash.find((-10000 - num)/20000 + 1);
                if (searchMin != _hash.end())
                {
                    for (auto num2 : searchMin->second)
                        if (num + num2 >= -10000 && num + num2 <= 10000)
                            _sums.insert(num+num2);
                }
                
                if (searchMax != _hash.end())
                {
                    for (auto num2 : searchMax->second)
                        if (num + num2 >= -10000 && num + num2 <= 10000)
                            _sums.insert(num+num2);
                }
            }
        }
        
        std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
        std::cout << "Done. Time took to find all the sums: "
        << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms" << endl;
        
        assert(_sums.size() == 427);
        
        return _sums.size();
    }

// Assembly:
subq $0x448, %rsp            # imm = 0x448
movq %rdi, 0x440(%rsp)
leaq 0x408(%rsp), %rdi
callq 0x8fb0
leaq 0x3d0(%rsp), %rdi
callq 0x8fc0
movq 0x440(%rsp), %rsi
leaq 0x1c8(%rsp), %rdi
movl $0x8, %edx
callq 0x22c0
jmp 0x6545
callq 0x2240
movq %rax, 0x1b0(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x22b0
movb %al, 0x8f(%rsp)
jmp 0x6568
movb 0x8f(%rsp), %al
testb $0x1, %al
jne 0x6578
jmp 0x665a
jmp 0x657a
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x2200
movq %rax, 0x80(%rsp)
jmp 0x6599
movq 0x80(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2210
movb %al, 0x7f(%rsp)
jmp 0x65b6
movb 0x7f(%rsp), %al
testb $0x1, %al
jne 0x65c3
jmp 0x6658
movq 0x1a8(%rsp), %rax
movabsq $0x346dc5d63886594b, %rcx # imm = 0x346DC5D63886594B
imulq %rcx
movq %rdx, %rax
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0xc, %rax
addq %rdx, %rax
movq %rax, 0x1a0(%rsp)
leaq 0x408(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x8fd0
movq %rax, 0x70(%rsp)
jmp 0x660d
movq 0x70(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x9000
jmp 0x6621
jmp 0x657a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x6c3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x6c2f
jmp 0x665a
leaq 0x408(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rdi
callq 0x9040
movq %rax, 0x190(%rsp)
movq 0x198(%rsp), %rdi
callq 0x9070
movq %rax, 0x188(%rsp)
leaq 0x190(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x90a0
testb $0x1, %al
jne 0x66b2
jmp 0x6aef
leaq 0x190(%rsp), %rdi
callq 0x90c0
movq %rax, %rsi
leaq 0x168(%rsp), %rdi
callq 0x90e0
jmp 0x66d1
leaq 0x168(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x160(%rsp)
movq 0x160(%rsp), %rdi
callq 0x9120
movq %rax, 0x158(%rsp)
movq 0x160(%rsp), %rdi
callq 0x9150
movq %rax, 0x150(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x9180
testb $0x1, %al
jne 0x672d
jmp 0x6ad0
leaq 0x158(%rsp), %rdi
callq 0x91a0
movq (%rax), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rcx
movq $-0x2710, %rax          # imm = 0xD8F0
subq %rcx, %rax
movabsq $0x346dc5d63886594b, %rcx # imm = 0x346DC5D63886594B
imulq %rcx
movq %rdx, %rax
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0xc, %rax
addq %rdx, %rax
movq %rax, 0x138(%rsp)
leaq 0x408(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x91c0
movq %rax, 0x68(%rsp)
jmp 0x6799
movq 0x68(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x148(%rsp), %rcx
movq $-0x2710, %rax          # imm = 0xD8F0
subq %rcx, %rax
movabsq $0x346dc5d63886594b, %rcx # imm = 0x346DC5D63886594B
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xc, %rdx
leaq 0x1(%rdx,%rax), %rax
movq %rax, 0x128(%rsp)
leaq 0x408(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x91c0
movq %rax, 0x60(%rsp)
jmp 0x67f9
movq 0x60(%rsp), %rax
movq %rax, 0x130(%rsp)
leaq 0x408(%rsp), %rdi
callq 0x9070
movq %rax, 0x120(%rsp)
leaq 0x140(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x90a0
testb $0x1, %al
jne 0x6839
jmp 0x6977
leaq 0x140(%rsp), %rdi
callq 0x91f0
addq $0x8, %rax
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
callq 0x9120
movq %rax, 0x110(%rsp)
movq 0x118(%rsp), %rdi
callq 0x9150
movq %rax, 0x108(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x9180
testb $0x1, %al
jne 0x689a
jmp 0x6975
leaq 0x110(%rsp), %rdi
callq 0x91a0
movq (%rax), %rax
movq %rax, 0x100(%rsp)
movq 0x148(%rsp), %rax
addq 0x100(%rsp), %rax
cmpq $-0x2710, %rax          # imm = 0xD8F0
jl 0x6961
movq 0x148(%rsp), %rax
addq 0x100(%rsp), %rax
cmpq $0x2710, %rax           # imm = 0x2710
jg 0x6961
movq 0x148(%rsp), %rax
movq 0x100(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0xf8(%rsp)
leaq 0x3d0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x9210
movb %dl, 0x57(%rsp)
movq %rax, 0x58(%rsp)
jmp 0x6921
movb 0x57(%rsp), %al
movq 0x58(%rsp), %rcx
movq %rcx, 0xe8(%rsp)
movb %al, 0xf0(%rsp)
jmp 0x6961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x168(%rsp), %rdi
callq 0x9280
jmp 0x6c2f
jmp 0x6963
leaq 0x110(%rsp), %rdi
callq 0x9260
jmp 0x687c
jmp 0x6977
leaq 0x408(%rsp), %rdi
callq 0x9070
movq %rax, 0xe0(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x90a0
testb $0x1, %al
jne 0x69aa
jmp 0x6abc
leaq 0x130(%rsp), %rdi
callq 0x91f0
addq $0x8, %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x9120
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rdi
callq 0x9150
movq %rax, 0xc8(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x9180
testb $0x1, %al
jne 0x6a0b
jmp 0x6aba
leaq 0xd0(%rsp), %rdi
callq 0x91a0
movq (%rax), %rax
movq %rax, 0xc0(%rsp)
movq 0x148(%rsp), %rax
addq 0xc0(%rsp), %rax
cmpq $-0x2710, %rax          # imm = 0xD8F0
jl 0x6aa6
movq 0x148(%rsp), %rax
addq 0xc0(%rsp), %rax
cmpq $0x2710, %rax           # imm = 0x2710
jg 0x6aa6
movq 0x148(%rsp), %rax
movq 0xc0(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0xb8(%rsp)
leaq 0x3d0(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x9210
movb %dl, 0x47(%rsp)
movq %rax, 0x48(%rsp)
jmp 0x6a8e
movb 0x47(%rsp), %al
movq 0x48(%rsp), %rcx
movq %rcx, 0xa8(%rsp)
movb %al, 0xb0(%rsp)
jmp 0x6aa8
leaq 0xd0(%rsp), %rdi
callq 0x9260
jmp 0x69ed
jmp 0x6abc
jmp 0x6abe
leaq 0x158(%rsp), %rdi
callq 0x9260
jmp 0x670f
leaq 0x168(%rsp), %rdi
callq 0x9280
leaq 0x190(%rsp), %rdi
callq 0x92a0
jmp 0x6694
callq 0x2240
movq %rax, 0xa0(%rsp)
movq 0x1d4d5(%rip), %rdi     # 0x23fd8
leaq 0x137f8(%rip), %rsi     # 0x1a302
callq 0x21a0
movq %rax, 0x38(%rsp)
jmp 0x6b16
leaq 0xa0(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x8b70
movq %rax, 0x30(%rsp)
jmp 0x6b32
movq 0x30(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x8b40
movq %rax, 0x28(%rsp)
jmp 0x6b53
movq 0x28(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x8bc0
movq %rax, 0x20(%rsp)
jmp 0x6b74
movq 0x20(%rsp), %rsi
movq 0x38(%rsp), %rdi
callq 0x2350
movq %rax, 0x18(%rsp)
jmp 0x6b8a
movq 0x18(%rsp), %rdi
leaq 0x13793(%rip), %rsi     # 0x1a329
callq 0x21a0
movq %rax, 0x10(%rsp)
jmp 0x6ba2
movq 0x10(%rsp), %rdi
movq 0x1d41a(%rip), %rsi     # 0x23fc8
callq 0x21d0
jmp 0x6bb5
leaq 0x3d0(%rsp), %rdi
callq 0x92d0
cmpq $0x1ab, %rax            # imm = 0x1AB
jne 0x6bcc
jmp 0x6beb
leaq 0x1375a(%rip), %rdi     # 0x1a32d
leaq 0x13767(%rip), %rsi     # 0x1a341
movl $0x64, %edx
leaq 0x1376d(%rip), %rcx     # 0x1a353
callq 0x2140
leaq 0x3d0(%rsp), %rdi
callq 0x92d0
movl %eax, 0xc(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0x2080
leaq 0x3d0(%rsp), %rdi
callq 0x92e0
leaq 0x408(%rsp), %rdi
callq 0x92f0
movl 0xc(%rsp), %eax
addq $0x448, %rsp            # imm = 0x448
retq
leaq 0x1c8(%rsp), %rdi
callq 0x2080
leaq 0x3d0(%rsp), %rdi
callq 0x92e0
leaq 0x408(%rsp), %rdi
callq 0x92f0
movq 0x1c0(%rsp), %rdi
callq 0x2330
nopw %cs:(%rax,%rax)