// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1458, %rsp           # imm = 0x1458
cmpl $0x2, %edi
jl 0x2388
movq 0x8(%rsi), %rbx
jmp 0x238f
leaq 0x2cb1(%rip), %rbx      # 0x5040
movq 0x5c42(%rip), %r14      # 0x7fd8
leaq 0x2cb9(%rip), %rsi      # 0x5056
movl $0x13, %edx
movq %r14, %rdi
callq 0x2150
testq %rbx, %rbx
je 0x23cb
movq %rbx, %rdi
callq 0x2090
movq 0x5c1a(%rip), %rdi      # 0x7fd8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2150
jmp 0x23e3
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x21b0
leaq 0xd0(%rsp), %r14
movb $0xa, (%r14)
movq 0x5be2(%rip), %rdi      # 0x7fd8
movl $0x1, %r15d
movl $0x1, %edx
movq %r14, %rsi
callq 0x2150
xorl %eax, %eax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq $0x1571, (%r14)         # imm = 0x1571
movl $0x1571, %eax           # imm = 0x1571
movq %rax, %rcx
shrq $0x1e, %rcx
xorl %eax, %ecx
imull $0x6c078965, %ecx, %eax # imm = 0x6C078965
addl %r15d, %eax
movq %rax, 0xd0(%rsp,%r15,8)
incq %r15
cmpq $0x270, %r15            # imm = 0x270
jne 0x242e
movq $0x270, 0x1450(%rsp) # imm = 0x270
leaq 0x90(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %ecx, %ecx
movq %rcx, -0x8(%rax)
movb $0x0, (%rax)
movl $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
movq %rcx, 0x38(%rax)
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x40c4
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
cmpq $0x3e7, %rax            # imm = 0x3E7
jbe 0x2889
movq 0x5b0c(%rip), %rdi      # 0x7fd8
leaq 0x2bce(%rip), %rsi      # 0x50a1
movl $0xd, %edx
callq 0x2150
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x3, %rsi
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rsi
movq 0x5ad8(%rip), %rdi      # 0x7fd8
callq 0x20c0
leaq 0x2ba3(%rip), %rsi      # 0x50af
movl $0x7, %edx
movq %rax, %rdi
callq 0x2150
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x2563
movq %r14, %rax
subq %rbx, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2f63
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3040
movq $0x5, 0xd0(%rsp)
movl $0x1, %eax
movl $0x5, %ecx
movq %rcx, %rdx
shrq $0x1e, %rdx
xorl %ecx, %edx
imull $0x6c078965, %edx, %ecx # imm = 0x6C078965
addl %eax, %ecx
movq %rcx, 0xd0(%rsp,%rax,8)
incq %rax
cmpq $0x270, %rax            # imm = 0x270
jne 0x2579
movq $0x270, 0x1450(%rsp) # imm = 0x270
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x262a
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0x30(%rsp), %rbx
leaq 0xc(%rsp), %r14
leaq (%rcx,%rcx,4), %rdx
movl 0xc(%rsp), %ecx
addl 0x20(%rax,%rdx,8), %ecx
movl %ecx, 0xc(%rsp)
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x25f7
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x2602
movq %rbx, %rdi
movq %r14, %rdx
callq 0x397c
movl %ebp, %ecx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x25ce
movq 0x59a7(%rip), %rdi      # 0x7fd8
leaq 0x2a7f(%rip), %rsi      # 0x50b7
movl $0xd, %edx
callq 0x2150
movl $0x1, %r15d
leaq 0x50(%rsp), %r13
leaq 0x78(%rsp), %rbp
leal -0x1(%r15), %r14d
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
cmpq %r14, %rax
jbe 0x2744
leaq (%r14,%r14,4), %rbx
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq (%r12,%rbx,8), %rsi
movq 0x8(%r12,%rbx,8), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2ac2
leaq (%r12,%rbx,8), %rax
movl 0x20(%rax), %eax
movl %eax, 0x70(%rsp)
movq %rbp, %rdi
leaq 0x7a(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movq %r13, %rcx
callq 0x3ab0
testb $0x1, %dl
je 0x26d0
incq 0xc8(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x26e4
callq 0x2120
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movl %r15d, %r8d
callq 0x2920
movq 0xb0(%rsp), %rsi
leaq 0x79(%rsp), %rdi
callq 0x2eda
movq 0x30(%rsp), %rcx
incl %r15d
cmpl (%rcx,%r14,4), %eax
je 0x2652
leaq 0x2999(%rip), %rdi      # 0x50c5
leaq 0x294a(%rip), %rsi      # 0x507d
leaq 0x2950(%rip), %rcx      # 0x508a
movl $0x50, %edx
callq 0x20b0
movq 0x588d(%rip), %rdi      # 0x7fd8
leaq 0x298c(%rip), %rsi      # 0x50de
movl $0x5, %edx
callq 0x2150
leaq 0x79(%rsp), %rbx
movq 0x37(%rbx), %rsi
movq %rbx, %rdi
callq 0x2eda
movq 0x5864(%rip), %rdi      # 0x7fd8
movl %eax, %esi
callq 0x21c0
leaq 0x50(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
movq 0x5841(%rip), %rdi      # 0x7fd8
leaq 0x2946(%rip), %rsi      # 0x50e4
movl $0xc, %edx
callq 0x2150
leaq 0x10(%rsp), %r14
movq 0x8(%r14), %rax
subq (%r14), %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %r15d # imm = 0xCCCCCCCD
leaq 0x78(%rsp), %r12
leaq 0xd0(%rsp), %r13
leaq 0x30(%rsp), %rbp
decq %r15
movq 0xb0(%rsp), %rsi
testl %r15d, %r15d
js 0x2827
movq %rbx, %rdi
callq 0x2eda
movl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x30(%rsp), %rdx
cmpl (%rdx,%rcx,4), %eax
jne 0x286a
leaq (%rcx,%rcx,4), %rsi
shlq $0x3, %rsi
addq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x2a1c
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movl %r15d, %r8d
callq 0x2920
jmp 0x27d1
movq %rbx, %rdi
callq 0x2eda
testl %eax, %eax
jne 0x28a8
leaq 0x78(%rsp), %rdi
callq 0x2a50
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x284c
callq 0x2120
leaq 0x10(%rsp), %rdi
callq 0x2a7e
xorl %eax, %eax
addq $0x1458, %rsp           # imm = 0x1458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2854(%rip), %rdi      # 0x50c5
leaq 0x2805(%rip), %rsi      # 0x507d
leaq 0x280b(%rip), %rcx      # 0x508a
movl $0x58, %edx
callq 0x20b0
leaq 0x27da(%rip), %rdi      # 0x506a
leaq 0x27e6(%rip), %rsi      # 0x507d
leaq 0x27ec(%rip), %rcx      # 0x508a
movl $0x3e, %edx
callq 0x20b0
leaq 0x2842(%rip), %rdi      # 0x50f1
leaq 0x27c7(%rip), %rsi      # 0x507d
leaq 0x27cd(%rip), %rcx      # 0x508a
movl $0x5d, %edx
callq 0x20b0
jmp 0x28f2
jmp 0x28f2
jmp 0x28f2
jmp 0x28f2
jmp 0x28f2
jmp 0x28f2
jmp 0x28f2
movq %rax, %r14
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x28f5
callq 0x2120
jmp 0x28f5
jmp 0x28f2
jmp 0x28f2
movq %rax, %r14
leaq 0x78(%rsp), %rdi
callq 0x2a50
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x290e
callq 0x2120
leaq 0x10(%rsp), %rdi
callq 0x2a7e
movq %r14, %rdi
callq 0x21d0