// File: /workspace/github_cpp_makefile_star2_O3/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 $0x1, %edi
jle 0x23c2
movq 0x8(%rsi), %rbx
movq 0x5c4b(%rip), %r14      # 0x7fd8
leaq 0x2cc2(%rip), %rsi      # 0x5056
movl $0x13, %edx
movq %r14, %rdi
callq 0x2150
testq %rbx, %rbx
jne 0x23e1
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x21b0
xorl %ebx, %ebx
jmp 0x23fb
movq 0x5c0f(%rip), %rdi      # 0x7fd8
leaq 0x2c86(%rip), %rsi      # 0x5056
movl $0x13, %edx
callq 0x2150
leaq 0x2c5f(%rip), %rbx      # 0x5040
movq %rbx, %rdi
callq 0x2090
movq 0x5be8(%rip), %rdi      # 0x7fd8
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2150
leaq 0xd0(%rsp), %r14
movb $0xa, (%r14)
movq 0x5bca(%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 0x2446
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 0x40ec
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 0x28a5
movq 0x5af4(%rip), %rdi      # 0x7fd8
leaq 0x2bb6(%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 0x5ac0(%rip), %rdi      # 0x7fd8
callq 0x20c0
leaq 0x2b8b(%rip), %rsi      # 0x50af
movl $0x7, %edx
movq %rax, %rdi
callq 0x2150
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x257b
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 0x2f8f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x306c
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 0x2591
movq $0x270, 0x1450(%rsp) # imm = 0x270
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x2642
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 0x260f
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x261a
movq %rbx, %rdi
movq %r14, %rdx
callq 0x398c
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 0x25e6
movq 0x598f(%rip), %rdi      # 0x7fd8
leaq 0x2a67(%rip), %rsi      # 0x50b7
movl $0xd, %edx
callq 0x2150
movl $0x1, %r12d
leaq 0x50(%rsp), %r13
leaq 0x78(%rsp), %rbp
leal -0x1(%r12), %ebx
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rax
subq %r15, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
cmpq %rbx, %rax
jbe 0x275c
leaq (%rbx,%rbx,4), %r14
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq (%r15,%r14,8), %rsi
movq 0x8(%r15,%r14,8), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x2ae4
leaq (%r15,%r14,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 0x3ac0
testb $0x1, %dl
je 0x26e9
incq 0xc8(%rsp)
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x26fd
callq 0x2120
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movl %r12d, %r8d
callq 0x293c
movq 0xb0(%rsp), %rsi
leaq 0x79(%rsp), %rdi
callq 0x2f04
movq 0x30(%rsp), %rcx
incl %r12d
cmpl (%rcx,%rbx,4), %eax
je 0x266a
leaq 0x2981(%rip), %rdi      # 0x50c5
leaq 0x2932(%rip), %rsi      # 0x507d
leaq 0x2938(%rip), %rcx      # 0x508a
movl $0x50, %edx
callq 0x20b0
movq 0x5875(%rip), %rdi      # 0x7fd8
leaq 0x2974(%rip), %rsi      # 0x50de
movl $0x5, %edx
callq 0x2150
leaq 0x79(%rsp), %rbp
movq 0xb0(%rsp), %rsi
movq %rbp, %rdi
callq 0x2f04
movq 0x5848(%rip), %rdi      # 0x7fd8
movl %eax, %esi
callq 0x21c0
leaq 0x50(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x2150
movq 0x5825(%rip), %rdi      # 0x7fd8
leaq 0x292a(%rip), %rsi      # 0x50e4
movl $0xc, %edx
callq 0x2150
leaq 0x10(%rsp), %rbx
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %r14d # imm = 0xCCCCCCCD
leaq 0x78(%rsp), %r15
leaq 0xd0(%rsp), %r12
leaq 0x30(%rsp), %r13
decq %r14
movq 0xb0(%rsp), %rsi
testl %r14d, %r14d
js 0x2843
movq %rbp, %rdi
callq 0x2f04
movl %r14d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x30(%rsp), %rdx
cmpl (%rdx,%rcx,4), %eax
jne 0x2886
leaq (%rcx,%rcx,4), %rsi
shlq $0x3, %rsi
addq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x2a38
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
movl %r14d, %r8d
callq 0x293c
jmp 0x27ed
movq %rbp, %rdi
callq 0x2f04
testl %eax, %eax
jne 0x28c4
leaq 0x78(%rsp), %rdi
callq 0x2a6c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2868
callq 0x2120
leaq 0x10(%rsp), %rdi
callq 0x2a9a
xorl %eax, %eax
addq $0x1458, %rsp           # imm = 0x1458
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2838(%rip), %rdi      # 0x50c5
leaq 0x27e9(%rip), %rsi      # 0x507d
leaq 0x27ef(%rip), %rcx      # 0x508a
movl $0x58, %edx
callq 0x20b0
leaq 0x27be(%rip), %rdi      # 0x506a
leaq 0x27ca(%rip), %rsi      # 0x507d
leaq 0x27d0(%rip), %rcx      # 0x508a
movl $0x3e, %edx
callq 0x20b0
leaq 0x2826(%rip), %rdi      # 0x50f1
leaq 0x27ab(%rip), %rsi      # 0x507d
leaq 0x27b1(%rip), %rcx      # 0x508a
movl $0x5d, %edx
callq 0x20b0
jmp 0x290e
jmp 0x290e
jmp 0x290e
jmp 0x290e
jmp 0x290e
jmp 0x290e
jmp 0x290e
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x2911
callq 0x2120
jmp 0x2911
jmp 0x290e
jmp 0x290e
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x2a6c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x292a
callq 0x2120
leaq 0x10(%rsp), %rdi
callq 0x2a9a
movq %rbx, %rdi
callq 0x21d0