// File: lemire[P]runningmaxmin/./runningmaxmin.h
// Function: lemirebitmapmaxmin::lemirebitmapmaxmin(std::vector<double, std::allocator<double>>&, unsigned int)
lemirebitmapmaxmin(std::vector<floattype> & array, const uint width)
        : maxvalues(array.size() - width + 1),
          minvalues(array.size() - width + 1) {
        assert(width <= sizeof(unsigned long) * 8);
        unsigned long maxfifo = 0;
        unsigned long minfifo = 0;
        for (uint i = 1; i < width; ++i) {
            if (array[i] > array[i - 1]) { // overshoot
                minfifo |= 1;
                minfifo <<= 1;
                maxfifo <<= 1;
                while (maxfifo != 0) {
                    const long t = maxfifo & -maxfifo;
                    const int bitpos = __builtin_popcountl(t - 1);
                    if (array[i] <= array[i - bitpos]) {
                        break;
                    }
                    maxfifo ^= t;
                }
            } else {
                maxfifo |= 1;
                minfifo <<= 1;
                maxfifo <<= 1;
                while (minfifo != 0) {
                    const long t = minfifo & -minfifo;
                    const int bitpos = __builtin_popcountl(t - 1);
                    if (array[i] >= array[i - bitpos]) {
                        break;
                    }
                    minfifo ^= t;
                }
            }
        }
        unsigned long mask = ~0l;
        if (width < sizeof(unsigned long) * 8) {
            mask = (1UL << width) - 1;
        }
        for (uint i = width; i < array.size(); ++i) {
            maxfifo &= mask;
            minfifo &= mask;
            if (maxfifo == 0)
                maxvalues[i - width] = array[i - 1];
            else {
                maxvalues[i - width] = array[i - (sizeof(unsigned long) * 8 -
                                                  __builtin_clzl(maxfifo))];
            }
            if (minfifo == 0)
                minvalues[i - width] = array[i - 1];
            else {
                minvalues[i - width] = array[i - (sizeof(unsigned long) * 8 -
                                                  __builtin_clzl(minfifo))];
            }
            if (array[i] > array[i - 1]) { // overshoot
                minfifo |= 1;
                minfifo <<= 1;
                maxfifo <<= 1;
                while (maxfifo != 0) {
                    const long t = maxfifo & -maxfifo;
                    const int bitpos = __builtin_popcountl(t - 1);
                    if (array[i] <= array[i - bitpos]) {
                        break;
                    }
                    maxfifo ^= t;
                }
            } else {
                maxfifo |= 1;
                maxfifo <<= 1;
                minfifo <<= 1;
                while (minfifo != 0) {
                    const long t = minfifo & -minfifo;
                    const int bitpos = __builtin_popcountl(t - 1);
                    if (array[i] >= array[i - bitpos]) {
                        break;
                    }
                    minfifo ^= t;
                }
            }
        }
        maxfifo = maxfifo & mask;
        minfifo = minfifo & mask;
        if (maxfifo == 0)
            maxvalues[array.size() - width] = array[array.size() - 1];
        else
            maxvalues[array.size() - width] =
                array[array.size() -
                      (sizeof(unsigned long) * 8 - __builtin_clzl(maxfifo))];
        if (minfifo == 0)
            minvalues[array.size() - width] = array[array.size() - 1];
        else
            minvalues[array.size() - width] =
                array[array.size() -
                      (sizeof(unsigned long) * 8 - __builtin_clzl(minfifo))];
    }

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x180(%rsp)
movq %rsi, 0x178(%rsp)
movl %edx, 0x174(%rsp)
movq 0x180(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x77c0
movq 0xd8(%rsp), %rax
leaq 0xd9fe(%rip), %rcx      # 0x13d20
addq $0x10, %rcx
movq %rcx, (%rax)
addq $0x8, %rax
movq %rax, 0xe0(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movl 0x174(%rsp), %ecx
subq %rcx, %rax
incq %rax
movq %rax, 0xe8(%rsp)
leaq 0x173(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
callq 0x74c0
movq 0xe0(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0xf0(%rsp), %rdx
callq 0x74d0
jmp 0x638b
leaq 0x173(%rsp), %rdi
callq 0x7550
movq 0xd8(%rsp), %rax
addq $0x20, %rax
movq %rax, 0xc0(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movl 0x174(%rsp), %ecx
subq %rcx, %rax
incq %rax
movq %rax, 0xc8(%rsp)
leaq 0x163(%rsp), %rdi
movq %rdi, 0xd0(%rsp)
callq 0x74c0
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdx
callq 0x74d0
jmp 0x6402
leaq 0x163(%rsp), %rdi
callq 0x7550
movl 0x174(%rsp), %eax
cmpq $0x40, %rax
ja 0x641e
jmp 0x6496
leaq 0x8da0(%rip), %rdi      # 0xf1c5
leaq 0x8d0c(%rip), %rsi      # 0xf138
movl $0x1d6, %edx            # imm = 0x1D6
leaq 0x8db0(%rip), %rcx      # 0xf1e8
callq 0x2090
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0x173(%rsp), %rdi
callq 0x7550
jmp 0x6e13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
leaq 0x163(%rsp), %rdi
callq 0x7550
movq 0xe0(%rsp), %rdi
callq 0x7660
jmp 0x6e13
movq $0x0, 0x158(%rsp)
movq $0x0, 0x150(%rsp)
movl $0x1, 0x14c(%rsp)
movl 0x14c(%rsp), %eax
cmpl 0x174(%rsp), %eax
jae 0x671d
movq 0x178(%rsp), %rdi
movl 0x14c(%rsp), %eax
movl %eax, %esi
callq 0x3430
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0xb8(%rsp)
movq 0x178(%rsp), %rdi
movl 0x14c(%rsp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0xb8(%rsp), %xmm0
vucomisd (%rax), %xmm0
jbe 0x6615
movq 0x150(%rsp), %rax
orq $0x1, %rax
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rax
shlq %rax
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rax
shlq %rax
movq %rax, 0x158(%rsp)
cmpq $0x0, 0x158(%rsp)
je 0x6610
movq 0x158(%rsp), %rax
xorl %ecx, %ecx
subq 0x158(%rsp), %rcx
andq %rcx, %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rax
subq $0x1, %rax
popcntq %rax, %rax
movl %eax, 0x13c(%rsp)
movq 0x178(%rsp), %rdi
movl 0x14c(%rsp), %eax
movl %eax, %esi
callq 0x3430
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0xb0(%rsp)
movq 0x178(%rsp), %rdi
movl 0x14c(%rsp), %eax
subl 0x13c(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0xb0(%rsp), %xmm1
vmovsd (%rax), %xmm0
vucomisd %xmm1, %xmm0
jb 0x65f3
jmp 0x6610
movq 0x140(%rsp), %rax
xorq 0x158(%rsp), %rax
movq %rax, 0x158(%rsp)
jmp 0x6558
jmp 0x6705
movq 0x158(%rsp), %rax
orq $0x1, %rax
movq %rax, 0x158(%rsp)
movq 0x150(%rsp), %rax
shlq %rax
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rax
shlq %rax
movq %rax, 0x158(%rsp)
cmpq $0x0, 0x150(%rsp)
je 0x6703
movq 0x150(%rsp), %rax
xorl %ecx, %ecx
subq 0x150(%rsp), %rcx
andq %rcx, %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rax
subq $0x1, %rax
popcntq %rax, %rax
movl %eax, 0x12c(%rsp)
movq 0x178(%rsp), %rdi
movl 0x14c(%rsp), %eax
movl %eax, %esi
callq 0x3430
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0xa8(%rsp)
movq 0x178(%rsp), %rdi
movl 0x14c(%rsp), %eax
subl 0x12c(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0xa8(%rsp), %xmm0
vucomisd (%rax), %xmm0
jb 0x66e6
jmp 0x6703
movq 0x130(%rsp), %rax
xorq 0x150(%rsp), %rax
movq %rax, 0x150(%rsp)
jmp 0x664f
jmp 0x6705
jmp 0x6707
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14c(%rsp)
jmp 0x64b9
movq $-0x1, 0x120(%rsp)
movl 0x174(%rsp), %eax
cmpq $0x40, %rax
jae 0x6753
movl 0x174(%rsp), %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, 0x120(%rsp)
movl 0x174(%rsp), %eax
movl %eax, 0x11c(%rsp)
movl 0x11c(%rsp), %eax
movq %rax, 0xa0(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq %rax, %rcx
movq 0xa0(%rsp), %rax
cmpq %rcx, %rax
jae 0x6bab
movq 0x120(%rsp), %rax
andq 0x158(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x120(%rsp), %rax
andq 0x150(%rsp), %rax
movq %rax, 0x150(%rsp)
cmpq $0x0, 0x158(%rsp)
jne 0x6826
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
movq 0xd8(%rsp), %rdi
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x98(%rsp)
addq $0x8, %rdi
movl 0x11c(%rsp), %eax
subl 0x174(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x98(%rsp), %xmm0
vmovsd %xmm0, (%rax)
jmp 0x6897
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
movl %eax, %esi
movq 0x158(%rsp), %rax
bsrq %rax, %rax
xorq $0x3f, %rax
movslq %eax, %rcx
movl $0x40, %eax
subq %rcx, %rax
subq %rax, %rsi
callq 0x3430
movq 0xd8(%rsp), %rdi
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x90(%rsp)
addq $0x8, %rdi
movl 0x11c(%rsp), %eax
subl 0x174(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x90(%rsp), %xmm0
vmovsd %xmm0, (%rax)
cmpq $0x0, 0x150(%rsp)
jne 0x68fc
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
movq 0xd8(%rsp), %rdi
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x88(%rsp)
addq $0x20, %rdi
movl 0x11c(%rsp), %eax
subl 0x174(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x88(%rsp), %xmm0
vmovsd %xmm0, (%rax)
jmp 0x696d
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
movl %eax, %esi
movq 0x150(%rsp), %rax
bsrq %rax, %rax
xorq $0x3f, %rax
movslq %eax, %rcx
movl $0x40, %eax
subq %rcx, %rax
subq %rax, %rsi
callq 0x3430
movq 0xd8(%rsp), %rdi
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x80(%rsp)
addq $0x20, %rdi
movl 0x11c(%rsp), %eax
subl 0x174(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x80(%rsp), %xmm0
vmovsd %xmm0, (%rax)
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
movl %eax, %esi
callq 0x3430
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x78(%rsp)
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x78(%rsp), %xmm0
vucomisd (%rax), %xmm0
jbe 0x6aa9
movq 0x150(%rsp), %rax
orq $0x1, %rax
movq %rax, 0x150(%rsp)
movq 0x150(%rsp), %rax
shlq %rax
movq %rax, 0x150(%rsp)
movq 0x158(%rsp), %rax
shlq %rax
movq %rax, 0x158(%rsp)
cmpq $0x0, 0x158(%rsp)
je 0x6aa4
movq 0x158(%rsp), %rax
xorl %ecx, %ecx
subq 0x158(%rsp), %rcx
andq %rcx, %rax
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
subq $0x1, %rax
popcntq %rax, %rax
movl %eax, 0x10c(%rsp)
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
movl %eax, %esi
callq 0x3430
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x70(%rsp)
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
subl 0x10c(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x70(%rsp), %xmm1
vmovsd (%rax), %xmm0
vucomisd %xmm1, %xmm0
jb 0x6a87
jmp 0x6aa4
movq 0x110(%rsp), %rax
xorq 0x158(%rsp), %rax
movq %rax, 0x158(%rsp)
jmp 0x69f2
jmp 0x6b93
movq 0x158(%rsp), %rax
orq $0x1, %rax
movq %rax, 0x158(%rsp)
movq 0x158(%rsp), %rax
shlq %rax
movq %rax, 0x158(%rsp)
movq 0x150(%rsp), %rax
shlq %rax
movq %rax, 0x150(%rsp)
cmpq $0x0, 0x150(%rsp)
je 0x6b91
movq 0x150(%rsp), %rax
xorl %ecx, %ecx
subq 0x150(%rsp), %rcx
andq %rcx, %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
subq $0x1, %rax
popcntq %rax, %rax
movl %eax, 0xfc(%rsp)
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
movl %eax, %esi
callq 0x3430
vmovsd (%rax), %xmm0
vmovsd %xmm0, 0x68(%rsp)
movq 0x178(%rsp), %rdi
movl 0x11c(%rsp), %eax
subl 0xfc(%rsp), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x3430
vmovsd 0x68(%rsp), %xmm0
vucomisd (%rax), %xmm0
jb 0x6b74
jmp 0x6b91
movq 0x100(%rsp), %rax
xorq 0x150(%rsp), %rax
movq %rax, 0x150(%rsp)
jmp 0x6ae3
jmp 0x6b93
jmp 0x6b95
movl 0x11c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x11c(%rsp)
jmp 0x6761
movq 0x158(%rsp), %rax
andq 0x120(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x150(%rsp), %rax
andq 0x120(%rsp), %rax
movq %rax, 0x150(%rsp)
cmpq $0x0, 0x158(%rsp)
jne 0x6c62
movq 0x178(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x50(%rsp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x3430
movq %rax, %rcx
movq 0xd8(%rsp), %rax
vmovsd (%rcx), %xmm0
vmovsd %xmm0, 0x60(%rsp)
addq $0x8, %rax
movq %rax, 0x58(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x58(%rsp), %rdi
movq %rax, %rsi
movl 0x174(%rsp), %eax
subq %rax, %rsi
callq 0x3430
vmovsd 0x60(%rsp), %xmm0
vmovsd %xmm0, (%rax)
jmp 0x6cf3
movq 0x178(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x38(%rsp), %rdi
movq %rax, %rsi
movq 0x158(%rsp), %rax
bsrq %rax, %rax
xorq $0x3f, %rax
movslq %eax, %rcx
movl $0x40, %eax
subq %rcx, %rax
subq %rax, %rsi
callq 0x3430
movq %rax, %rcx
movq 0xd8(%rsp), %rax
vmovsd (%rcx), %xmm0
vmovsd %xmm0, 0x48(%rsp)
addq $0x8, %rax
movq %rax, 0x40(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x40(%rsp), %rdi
movq %rax, %rsi
movl 0x174(%rsp), %eax
subq %rax, %rsi
callq 0x3430
vmovsd 0x48(%rsp), %xmm0
vmovsd %xmm0, (%rax)
cmpq $0x0, 0x150(%rsp)
jne 0x6d7a
movq 0x178(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x20(%rsp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x3430
movq %rax, %rcx
movq 0xd8(%rsp), %rax
vmovsd (%rcx), %xmm0
vmovsd %xmm0, 0x30(%rsp)
addq $0x20, %rax
movq %rax, 0x28(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x28(%rsp), %rdi
movq %rax, %rsi
movl 0x174(%rsp), %eax
subq %rax, %rsi
callq 0x3430
vmovsd 0x30(%rsp), %xmm0
vmovsd %xmm0, (%rax)
jmp 0x6e0b
movq 0x178(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x8(%rsp), %rdi
movq %rax, %rsi
movq 0x150(%rsp), %rax
bsrq %rax, %rax
xorq $0x3f, %rax
movslq %eax, %rcx
movl $0x40, %eax
subq %rcx, %rax
subq %rax, %rsi
callq 0x3430
movq %rax, %rcx
movq 0xd8(%rsp), %rax
vmovsd (%rcx), %xmm0
vmovsd %xmm0, 0x18(%rsp)
addq $0x20, %rax
movq %rax, 0x10(%rsp)
movq 0x178(%rsp), %rdi
callq 0x3410
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movl 0x174(%rsp), %eax
subq %rax, %rsi
callq 0x3430
vmovsd 0x18(%rsp), %xmm0
vmovsd %xmm0, (%rax)
addq $0x188, %rsp            # imm = 0x188
retq
movq 0xd8(%rsp), %rdi
callq 0x7830
movq 0x168(%rsp), %rdi
callq 0x2160
nopl (%rax)