// File: dlbeer[P]summary_map/test_sum.cpp
// Function: range_test(std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&, summary_map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, summary, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, aggregator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>, summary>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>&, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int>>> const&, std::vector<int, std::allocator<int>> const&, unsigned int)
static void range_test(std::mt19937& rnd, test_map& m,
		       const test_vector& vec,
		       const std::vector<int>& series,
		       unsigned int limit)
{
    int a = rnd() % (limit + 1);
    int b = rnd() % (limit + 1);

    if (a > b)
	std::swap(a, b);

    test_map::const_iterator ia = m.find(vec[a].first);
    test_map::const_iterator ib = m.find(vec[b].first);

    const int sa = a ? series[a - 1] : 0;
    const int sb = b ? series[b - 1] : 0;

    const int vsum = sb - sa;
    const int msum = m.sum(ia, ib).sum;

    assert(vsum == msum);
}

// Assembly:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq %rdx, 0x80(%rsp)
movq %rcx, 0x78(%rsp)
movl %r8d, 0x74(%rsp)
movq 0x90(%rsp), %rdi
callq 0x3250
movl 0x74(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0x70(%rsp)
movq 0x90(%rsp), %rdi
callq 0x3250
movl 0x74(%rsp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
xorl %edx, %edx
divq %rcx
movl %edx, %eax
movl %eax, 0x6c(%rsp)
movl 0x70(%rsp), %eax
cmpl 0x6c(%rsp), %eax
jle 0x2a24
leaq 0x70(%rsp), %rdi
leaq 0x6c(%rsp), %rsi
callq 0x3320
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x80(%rsp), %rdi
movslq 0x70(%rsp), %rsi
callq 0x3390
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x3350
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0x33b0
movq 0x88(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x80(%rsp), %rdi
movslq 0x6c(%rsp), %rsi
callq 0x3390
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x3350
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x33b0
cmpl $0x0, 0x70(%rsp)
je 0x2ac7
movq 0x78(%rsp), %rdi
movl 0x70(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x33d0
movl (%rax), %eax
movl %eax, 0xc(%rsp)
jmp 0x2acf
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0x2acf
movl 0xc(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x6c(%rsp)
je 0x2afa
movq 0x78(%rsp), %rdi
movl 0x6c(%rsp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x33d0
movl (%rax), %eax
movl %eax, 0x8(%rsp)
jmp 0x2b02
xorl %eax, %eax
movl %eax, 0x8(%rsp)
jmp 0x2b02
movl 0x8(%rsp), %eax
movl %eax, 0x40(%rsp)
movl 0x40(%rsp), %eax
subl 0x44(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x88(%rsp), %rdi
movq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x33f0
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x38(%rsp), %eax
jne 0x2b59
jmp 0x2b78
leaq 0x6566(%rip), %rdi      # 0x90c6
leaq 0x64da(%rip), %rsi      # 0x9041
movl $0x2c, %edx
leaq 0x6560(%rip), %rcx      # 0x90d3
callq 0x20e0
addq $0x98, %rsp
retq