// File: /workspace/github_cpp_makefile_star2_O2/dlbeer[P]summary_map/test_sum.cpp
// Function: main
int main(int argc, char **argv)
{
    const char *path = "/usr/share/dict/words";

    if (argc > 1)
	path = argv[1];

    std::cout << "Loading words from " << path << '\n';

    test_vector vec;
    std::vector<int> series;
    std::mt19937 rnd;
    test_map m;

    load_words(path, vec);
    assert(vec.size() >= 1000);
    std::cout << "Working with " << vec.size() << " items\n";

    std::sort(vec.begin(), vec.end());
    rnd.seed(5);

    int all_sum = 0;

    for (unsigned int i = 0; i < vec.size(); i++) {
	all_sum += vec[i].second;
	series.push_back(all_sum);
    }

    std::cout << "Inserting...\n";

    for (unsigned int i = 0; i < vec.size(); i++) {
	m.insert(vec[i]);
	range_test(rnd, m, vec, series, i + 1);
	assert(m.sum().sum == series[i]);
    }

    std::cout << "Sum: " << m.sum().sum << '\n';

    std::cout << "Removing...\n";

    for (int i = vec.size() - 1; i >= 0; i--) {
	assert(m.sum().sum == series[i]);
	m.erase(vec[i].first);
	range_test(rnd, m, vec, series, i);
    }

    assert(m.sum().sum == 0);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1448, %rsp           # imm = 0x1448
cmpl $0x2, %edi
jl 0x2338
movq 0x8(%rsi), %rbx
jmp 0x233f
leaq 0x1cc5(%rip), %rbx      # 0x4004
movq 0x4c92(%rip), %rdi      # 0x6fd8
leaq 0x1ccd(%rip), %rsi      # 0x401a
callq 0x2120
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2120
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2140
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x27a6
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andl $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
andq $0x0, 0x38(%rax)
movq %rsp, %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x3b08
movq 0x8(%rsp), %rax
subq (%rsp), %rax
pushq $0x28
popq %r12
cqto
idivq %r12
cmpq $0x3e7, %rax            # imm = 0x3E7
jbe 0x2644
movq 0x4bf3(%rip), %rdi      # 0x6fd8
leaq 0x1c79(%rip), %rsi      # 0x4065
callq 0x2120
movq %rax, %rdi
movq 0x8(%rsp), %rax
subq (%rsp), %rax
cqto
idivq %r12
movq %rax, %rsi
callq 0x20d0
leaq 0x1c62(%rip), %rsi      # 0x4073
movq %rax, %rdi
callq 0x2120
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x2d11
leaq 0xc0(%rsp), %rdi
pushq $0x5
popq %rsi
callq 0x27b0
leaq 0x1c(%rsp), %rbx
andl $0x0, (%rbx)
xorl %r15d, %r15d
leaq 0x20(%rsp), %r14
movl %r15d, %r15d
movq (%rsp), %rcx
movq 0x8(%rsp), %rax
subq %rcx, %rax
cqto
idivq %r12
cmpq %r15, %rax
jbe 0x247c
imulq $0x28, %r15, %rax
movl 0x20(%rcx,%rax), %eax
addl %eax, 0x1c(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x27e8
incl %r15d
jmp 0x2447
movq 0x4b55(%rip), %rdi      # 0x6fd8
leaq 0x1bf1(%rip), %rsi      # 0x407b
callq 0x2120
pushq $0x1
popq %rbx
leaq 0x98(%rsp), %r14
leaq 0x40(%rsp), %r15
movq %rsp, %r13
leaq 0x20(%rsp), %rbp
leal -0x1(%rbx), %r12d
movq (%rsp), %rsi
movq 0x8(%rsp), %rax
subq %rsi, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq %r12, %rax
jbe 0x2530
imulq $0x28, %r12, %rax
addq %rax, %rsi
movq %r14, %rdi
callq 0x2826
movq %r15, %rdi
movq %r14, %rsi
callq 0x2806
movq %r14, %rdi
callq 0x20a0
leaq 0xc0(%rsp), %rdi
movq %r15, %rsi
movq %r13, %rdx
movq %rbp, %rcx
movl %ebx, %r8d
callq 0x26c6
movq %r15, %rdi
callq 0x2844
movq 0x20(%rsp), %rcx
incl %ebx
cmpl (%rcx,%r12,4), %eax
je 0x24a7
leaq 0x1b6e(%rip), %rdi      # 0x4089
leaq 0x1b1f(%rip), %rsi      # 0x4041
leaq 0x1b25(%rip), %rcx      # 0x404e
pushq $0x50
jmp 0x263e
movq 0x4aa1(%rip), %rdi      # 0x6fd8
leaq 0x1b64(%rip), %rsi      # 0x40a2
callq 0x2120
pushq $0x28
popq %r14
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2844
movq %rbx, %rdi
movl %eax, %esi
callq 0x21c0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x2140
movq 0x4a68(%rip), %rdi      # 0x6fd8
leaq 0x1b31(%rip), %rsi      # 0x40a8
callq 0x2120
movq %rsp, %rbx
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cqto
idivq %r14
movl %eax, %r14d
leaq 0x40(%rsp), %r15
leaq 0xc0(%rsp), %r12
leaq 0x20(%rsp), %r13
decq %r14
testl %r14d, %r14d
js 0x25e9
movq %r15, %rdi
callq 0x2844
movl %r14d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x20(%rsp), %rdx
cmpl (%rdx,%rcx,4), %eax
jne 0x2627
imulq $0x28, %rcx, %rsi
addq (%rsp), %rsi
movq %r15, %rdi
callq 0x2850
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movl %r14d, %r8d
callq 0x26c6
jmp 0x25a0
leaq 0x40(%rsp), %rdi
callq 0x2844
testl %eax, %eax
jne 0x265d
leaq 0x40(%rsp), %rdi
callq 0x2876
leaq 0x20(%rsp), %rdi
callq 0x2cb6
movq %rsp, %rdi
callq 0x289c
xorl %eax, %eax
addq $0x1448, %rsp           # imm = 0x1448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a5b(%rip), %rdi      # 0x4089
leaq 0x1a0c(%rip), %rsi      # 0x4041
leaq 0x1a12(%rip), %rcx      # 0x404e
pushq $0x58
popq %rdx
callq 0x20c0
leaq 0x19e3(%rip), %rdi      # 0x402e
leaq 0x19ef(%rip), %rsi      # 0x4041
leaq 0x19f5(%rip), %rcx      # 0x404e
pushq $0x3e
jmp 0x263e
leaq 0x1a51(%rip), %rdi      # 0x40b5
leaq 0x19d6(%rip), %rsi      # 0x4041
leaq 0x19dc(%rip), %rcx      # 0x404e
pushq $0x5d
jmp 0x263e
jmp 0x269f
movq %rax, %rbx
jmp 0x26ac
jmp 0x269f
jmp 0x269f
jmp 0x269f
jmp 0x269f
jmp 0x269f
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x20a0
jmp 0x26a2
jmp 0x269f
jmp 0x269f
jmp 0x269f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2876
leaq 0x20(%rsp), %rdi
callq 0x2cb6
movq %rsp, %rdi
callq 0x289c
movq %rbx, %rdi
callq 0x21d0