// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x6fbb(%rip), %rax      # 0xad28
addq $0x10, %rax
movq %rax, (%rdi)
leaq 0x8(%rdi), %r14
movq 0x8(%rsi), %rsi
subq (%r12), %rsi
sarq $0x3, %rsi
movl %edx, %r15d
subq %r15, %rsi
incq %rsi
leaq 0xf(%rsp), %rdx
movq %r14, %rdi
callq 0x4392
movq 0x8(%r12), %rsi
subq (%r12), %rsi
addq $0x20, %rbx
sarq $0x3, %rsi
subq %r15, %rsi
incq %rsi
leaq 0xe(%rsp), %rdx
movq %rbx, %rdi
callq 0x4392
cmpl $0x40, %ebp
ja 0x401c
movq (%r12), %rdx
pushq $0x1
popq %rcx
xorl %eax, %eax
xorl %esi, %esi
cmpq %r15, %rcx
jae 0x3e65
vmovsd (%rdx,%rcx,8), %xmm0
addq %rax, %rax
vucomisd -0x8(%rdx,%rcx,8), %xmm0
jbe 0x3e23
orq $0x2, %rax
addq %rsi, %rsi
movq %rsi, %rdi
testq %rdi, %rdi
je 0x3e57
movq %rdi, %rsi
negq %rdi
andq %rsi, %rdi
leaq -0x1(%rdi), %r8
popcntq %r8, %r8
movl %ecx, %r9d
subl %r8d, %r9d
vmovsd (%rdx,%r9,8), %xmm1
xorq %rsi, %rdi
vucomisd %xmm0, %xmm1
jb 0x3df5
jmp 0x3e5d
addq %rsi, %rsi
orq $0x2, %rsi
testq %rax, %rax
je 0x3e5b
movq %rax, %rdi
negq %rax
andq %rdi, %rax
leaq -0x1(%rax), %r8
popcntq %r8, %r8
movl %ecx, %r9d
subl %r8d, %r9d
xorq %rdi, %rax
vucomisd (%rdx,%r9,8), %xmm0
jb 0x3e2a
movq %rdi, %rax
jmp 0x3e5d
xorl %esi, %esi
jmp 0x3e5d
xorl %eax, %eax
incq %rcx
jmp 0x3dd2
pushq $-0x1
popq %rdi
movq %rdi, %r8
movl %r15d, %ecx
shlq %cl, %r8
cmpl $0x40, %ebp
notq %r8
cmoveq %rdi, %r8
movq 0x8(%r12), %rdi
subq %rdx, %rdi
movq %rdi, %rcx
sarq $0x3, %rcx
movq %r14, 0x10(%rsp)
movq (%r14), %r9
movq (%rbx), %r10
movl %ebp, %r14d
movl %r14d, %r14d
andq %r8, %rsi
andq %r8, %rax
bsrq %rsi, %r12
notl %r12d
shll $0x3, %r12d
orq $-0x200, %r12           # imm = 0xFE00
addq %rdx, %r12
cmpq %r14, %rcx
jbe 0x3fbc
leal -0x1(%r14), %r13d
testq %rsi, %rsi
leaq (%r12,%r14,8), %r12
leaq (%rdx,%r13,8), %r13
cmovneq %r12, %r13
vmovsd (%r13), %xmm0
movl %r14d, %r12d
subl %ebp, %r12d
vmovsd %xmm0, (%r9,%r12,8)
testq %rax, %rax
je 0x3f16
bsrq %rax, %r12
notl %r12d
shll $0x3, %r12d
orq $-0x200, %r12           # imm = 0xFE00
addq %rdx, %r12
vmovsd (%r12,%r14,8), %xmm0
movl %r14d, %r12d
subl %ebp, %r12d
vmovsd %xmm0, (%r10,%r12,8)
leal -0x1(%r14), %r12d
jmp 0x3f2c
leal -0x1(%r14), %r12d
vmovsd (%rdx,%r12,8), %xmm0
movl %r14d, %r13d
subl %ebp, %r13d
vmovsd %xmm0, (%r10,%r13,8)
vmovsd (%rdx,%r14,8), %xmm0
vucomisd (%rdx,%r12,8), %xmm0
jbe 0x3f76
addq %rax, %rax
orq $0x2, %rax
addq %rsi, %rsi
movq %rsi, %r12
testq %r12, %r12
je 0x3fae
movq %r12, %rsi
negq %r12
andq %rsi, %r12
leaq -0x1(%r12), %r13
popcntq %r13, %r13
movl %r14d, %r11d
subl %r13d, %r11d
vmovsd (%rdx,%r11,8), %xmm1
xorq %rsi, %r12
vucomisd %xmm0, %xmm1
jb 0x3f47
jmp 0x3fb4
addq %rsi, %rsi
orq $0x2, %rsi
addq %rax, %rax
movq %rax, %r12
testq %r12, %r12
je 0x3fb2
movq %r12, %rax
negq %r12
andq %rax, %r12
leaq -0x1(%r12), %r11
popcntq %r11, %r11
movl %r14d, %r13d
subl %r11d, %r13d
xorq %rax, %r12
vucomisd (%rdx,%r13,8), %xmm0
jb 0x3f83
jmp 0x3fb4
xorl %esi, %esi
jmp 0x3fb4
xorl %eax, %eax
incl %r14d
jmp 0x3e98
addq %rdi, %r12
testq %rsi, %rsi
leaq -0x8(%rdx,%rdi), %rsi
cmoveq %rsi, %r12
addq %rdi, %rdx
vmovsd (%r12), %xmm0
subq %r15, %rcx
movq 0x10(%rsp), %rdi
movq (%rdi), %rdi
bsrq %rax, %r8
notl %r8d
shll $0x3, %r8d
orq $-0x200, %r8            # imm = 0xFE00
addq %rdx, %r8
testq %rax, %rax
cmoveq %rsi, %r8
vmovsd %xmm0, (%rdi,%rcx,8)
vmovsd (%r8), %xmm0
movq (%rbx), %rax
vmovsd %xmm0, (%rax,%rcx,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31a2(%rip), %rdi      # 0x71c5
leaq 0x310e(%rip), %rsi      # 0x7138
leaq 0x31b7(%rip), %rcx      # 0x71e8
movl $0x1d6, %edx            # imm = 0x1D6
callq 0x2090
movq %rax, %rbx
movq %r14, %rdi
callq 0x60f0
movq %rbx, %rdi
callq 0x2160