// File: travisdowns[P]avx-turbo/./util.hpp
// Function: std::iterator_traits<__gnu_cxx::__normal_iterator<std::pair<unsigned long, unsigned long>*, std::vector<std::pair<unsigned long, unsigned long>, std::allocator<std::pair<unsigned long, unsigned long>>>>>::value_type nested_concurrency<__gnu_cxx::__normal_iterator<std::pair<unsigned long, unsigned long>*, std::vector<std::pair<unsigned long, unsigned long>, std::allocator<std::pair<unsigned long, unsigned long>>>>>(__gnu_cxx::__normal_iterator<std::pair<unsigned long, unsigned long>*, std::vector<std::pair<unsigned long, unsigned long>, std::allocator<std::pair<unsigned long, unsigned long>>>>, __gnu_cxx::__normal_iterator<std::pair<unsigned long, unsigned long>*, std::vector<std::pair<unsigned long, unsigned long>, std::allocator<std::pair<unsigned long, unsigned long>>>>, __gnu_cxx::__normal_iterator<std::pair<unsigned long, unsigned long>*, std::vector<std::pair<unsigned long, unsigned long>, std::allocator<std::pair<unsigned long, unsigned long>>>>, __gnu_cxx::__normal_iterator<std::pair<unsigned long, unsigned long>*, std::vector<std::pair<unsigned long, unsigned long>, std::allocator<std::pair<unsigned long, unsigned long>>>>)
static inline auto nested_concurrency(Itr starto, Itr stopo, Itr starti, Itr stopi) -> typename std::iterator_traits<Itr>::value_type {
    if (starti == stopi) {
        return {0, 0}; // early out for empty range simplifies some logic below
    }

    using T1 = decltype(nested_concurrency(stopo, stopo, stopo, stopo).first);

    struct event {
        T1 stamp;
        enum Type { STARTO, STOPO, STARTI, STOPI } type;
        event(T1 stamp, Type type) : stamp{stamp}, type{type} {}
    };

    std::vector<event> events;
    events.reserve(std::distance(starto, stopo) + std::distance(starti, stopi));
    for (Itr i = starto; i != stopo; i++) {
        events.emplace_back(i->first, event::STARTO);
        events.emplace_back(i->second,event::STOPO);
    }
    T1 sum_top{}, sum_bottom{};
    for (Itr i = starti; i != stopi; i++) {
        sum_bottom += i->second - i->first;
        events.emplace_back(i->first, event::STARTI);
        events.emplace_back(i->second,event::STOPI);
    }

    std::sort(events.begin(), events.end(), [](event l, event r){ return l.stamp < r.stamp; });

    /*     00011242110  == 12 (out of a possible 11 * 2 == 22)
     *        IIIII
     *          IIIIII
     *       CCCCC
     *           CCC
     */
    size_t ocount = 0, icount = 0;
    T1 last_stamp = events.front().stamp;
    for (auto& event : events) {
        sum_top += ocount * icount * (event.stamp - last_stamp);
        switch (event.type) {
        case event::STARTO:
            ocount++;
            break;
        case event::STOPO:
            assert(ocount > 0);
            ocount--;
            break;
        case event::STARTI:
            icount++;
            break;
        case event::STOPI:
            assert(icount > 0);
            icount--;
            break;
        }
        last_stamp = event.stamp;
    }

    assert(ocount == 0);
    assert(icount == 0);

    return {sum_top, sum_bottom};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x20310
testb $0x1, %al
jne 0xdd5e
jmp 0xdd82
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x20350
jmp 0xe215
leaq -0x50(%rbp), %rdi
callq 0xe280
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x20290
movq %rax, -0x118(%rbp)
jmp 0xddb1
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x20290
movq %rax, -0x120(%rbp)
jmp 0xddd7
movq -0x120(%rbp), %rax
movq -0x118(%rbp), %rsi
addq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0xe2a0
jmp 0xddf3
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x20380
testb $0x1, %al
jne 0xde17
jmp 0xdea7
leaq -0x88(%rbp), %rdi
callq 0x203c0
movq %rax, %rsi
movl $0x0, -0x8c(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x8c(%rbp), %rdx
callq 0xe3a0
jmp 0xde42
leaq -0x88(%rbp), %rdi
callq 0x203c0
movq %rax, %rsi
addq $0x8, %rsi
movl $0x1, -0x90(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0xe3a0
jmp 0xde71
jmp 0xde73
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x203e0
movq %rax, -0x98(%rbp)
jmp 0xddfe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xe570
jmp 0xe226
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x20380
testb $0x1, %al
jne 0xdee1
jmp 0xdf9f
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x203c0
movq -0x128(%rbp), %rdi
movq 0x8(%rax), %rax
movq %rax, -0x130(%rbp)
callq 0x203c0
movq -0x130(%rbp), %rcx
movq -0x128(%rbp), %rdi
movq (%rax), %rax
subq %rax, %rcx
movq -0xa8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xa8(%rbp)
callq 0x203c0
movq %rax, %rsi
movl $0x2, -0xb4(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0xb4(%rbp), %rdx
callq 0xe3a0
jmp 0xdf54
leaq -0xb0(%rbp), %rdi
callq 0x203c0
movq %rax, %rsi
addq $0x8, %rsi
movl $0x3, -0xb8(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0xe3a0
jmp 0xdf83
jmp 0xdf85
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x203e0
movq %rax, -0xc0(%rbp)
jmp 0xdec8
leaq -0x50(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0xe460
movq -0x138(%rbp), %rdi
movq %rax, -0xc8(%rbp)
callq 0xe490
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0xe420
jmp 0xdfde
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xe4c0
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
leaq -0x50(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rdi
callq 0xe460
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rdi
callq 0xe490
movq %rax, -0x108(%rbp)
leaq -0x100(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xe4f0
testb $0x1, %al
jne 0xe054
jmp 0xe19d
leaq -0x100(%rbp), %rdi
callq 0xe530
movq %rax, -0x110(%rbp)
movq -0xe0(%rbp), %rcx
movq -0xe8(%rbp), %rax
imulq %rax, %rcx
movq -0x110(%rbp), %rax
movq (%rax), %rax
movq -0xf0(%rbp), %rdx
subq %rdx, %rax
imulq %rax, %rcx
movq -0xa0(%rbp), %rax
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
movq -0x110(%rbp), %rax
movl 0x8(%rax), %eax
movq %rax, -0x140(%rbp)
subq $0x3, %rax
ja 0xe17b
movq -0x140(%rbp), %rax
leaq 0x31fc9(%rip), %rcx     # 0x40094
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0xe17b
cmpq $0x0, -0xe0(%rbp)
jbe 0xe0f7
jmp 0xe116
leaq 0x3323f(%rip), %rdi     # 0x4133d
leaq 0x33243(%rip), %rsi     # 0x41348
movl $0xae, %edx
leaq 0x33242(%rip), %rcx     # 0x41353
callq 0x72e0
movq -0xe0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0xe17b
movq -0xe8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe8(%rbp)
jmp 0xe17b
cmpq $0x0, -0xe8(%rbp)
jbe 0xe14a
jmp 0xe169
leaq 0x332de(%rip), %rdi     # 0x4142f
leaq 0x331f0(%rip), %rsi     # 0x41348
movl $0xb5, %edx
leaq 0x331ef(%rip), %rcx     # 0x41353
callq 0x72e0
movq -0xe8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xe8(%rbp)
movq -0x110(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
leaq -0x100(%rbp), %rdi
callq 0xe550
jmp 0xe038
cmpq $0x0, -0xe0(%rbp)
jne 0xe1a9
jmp 0xe1c8
leaq 0x3328a(%rip), %rdi     # 0x4143a
leaq 0x33191(%rip), %rsi     # 0x41348
movl $0xbc, %edx
leaq 0x33190(%rip), %rcx     # 0x41353
callq 0x72e0
cmpq $0x0, -0xe8(%rbp)
jne 0xe1d4
jmp 0xe1f3
leaq 0x3326b(%rip), %rdi     # 0x41446
leaq 0x33166(%rip), %rsi     # 0x41348
movl $0xbd, %edx
leaq 0x33165(%rip), %rcx     # 0x41353
callq 0x72e0
leaq -0x10(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x20420
jmp 0xe20c
leaq -0x50(%rbp), %rdi
callq 0xe570
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x77b0
nop