// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x5f63(%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 0x555c
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 0x555c
cmpl $0x40, %ebp
ja 0x50a9
cmpl $0x2, %ebp
jb 0x4ed3
movq (%r12), %rcx
movl $0x1, %esi
xorl %edx, %edx
xorl %eax, %eax
vmovsd (%rcx,%rsi,8), %xmm0
addq %rax, %rax
vucomisd -0x8(%rcx,%rsi,8), %xmm0
jbe 0x4e82
orq $0x2, %rax
addq %rdx, %rdx
testq %rdx, %rdx
je 0x4ebf
movq %rdx, %rdi
negq %rdi
andq %rdx, %rdi
leaq -0x1(%rdi), %r8
popcntq %r8, %r8
movl %esi, %r9d
subl %r8d, %r9d
vmovsd (%rcx,%r9,8), %xmm1
vucomisd %xmm0, %xmm1
jb 0x4e77
xorl %edi, %edi
xorq %rdi, %rdx
vucomisd %xmm0, %xmm1
jb 0x4e4c
jmp 0x4ec5
addq %rdx, %rdx
orq $0x2, %rdx
testq %rax, %rax
je 0x4ec3
movq %rax, %rdi
negq %rdi
andq %rax, %rdi
leaq -0x1(%rdi), %r8
popcntq %r8, %r8
movl %esi, %r9d
subl %r8d, %r9d
vmovsd (%rcx,%r9,8), %xmm1
vucomisd %xmm1, %xmm0
jb 0x4eb4
xorl %edi, %edi
xorq %rdi, %rax
vucomisd %xmm1, %xmm0
jb 0x4e89
jmp 0x4ec5
xorl %edx, %edx
jmp 0x4ec5
xorl %eax, %eax
incq %rsi
cmpq %r15, %rsi
jne 0x4e35
jmp 0x4ed7
xorl %eax, %eax
xorl %edx, %edx
movq $-0x1, %r8
movl %r15d, %ecx
shlq %cl, %r8
movq $-0x1, %rcx
cmpl $0x40, %ebp
notq %r8
cmoveq %rcx, %r8
movq (%r12), %rsi
movq 0x8(%r12), %rcx
subq %rsi, %rcx
movq %rcx, 0x10(%rsp)
sarq $0x3, %rcx
cmpq %r15, %rcx
movq %rbx, 0x20(%rsp)
movq %r14, 0x18(%rsp)
jbe 0x502b
movq (%r14), %r9
movq (%rbx), %r10
movq $-0x200, %r11           # imm = 0xFE00
movq %r15, %r13
movl %ebp, %r12d
andq %r8, %rdx
andq %r8, %rax
bsrq %rdx, %r14
notl %r14d
shll $0x3, %r14d
orq %r11, %r14
leaq (%rsi,%r13,8), %r13
addq %r13, %r14
leal -0x1(%r12), %ebx
testq %rdx, %rdx
leaq (%rsi,%rbx,8), %rbx
cmoveq %rbx, %r14
vmovsd (%r14), %xmm0
movl %r12d, %r14d
subl %ebp, %r14d
vmovsd %xmm0, (%r9,%r14,8)
bsrq %rax, %rdi
notl %edi
shll $0x3, %edi
orq %r11, %rdi
addq %r13, %rdi
testq %rax, %rax
cmoveq %rbx, %rdi
vmovsd (%rdi), %xmm0
vmovsd %xmm0, (%r10,%r14,8)
vmovsd (%r13), %xmm0
vucomisd (%rbx), %xmm0
jbe 0x4fd7
addq %rax, %rax
orq $0x2, %rax
addq %rdx, %rdx
testq %rdx, %rdx
je 0x5016
movq %rdx, %r13
negq %r13
andq %rdx, %r13
leaq -0x1(%r13), %rdi
popcntq %rdi, %rdi
movl %r12d, %ebx
subl %edi, %ebx
vmovsd (%rsi,%rbx,8), %xmm1
vucomisd %xmm0, %xmm1
jb 0x4fcc
xorl %r13d, %r13d
xorq %r13, %rdx
vucomisd %xmm0, %xmm1
jb 0x4fa2
jmp 0x501c
addq %rdx, %rdx
orq $0x2, %rdx
addq %rax, %rax
testq %rax, %rax
je 0x501a
movq %rax, %r13
negq %r13
andq %rax, %r13
leaq -0x1(%r13), %rdi
popcntq %rdi, %rdi
movl %r12d, %ebx
subl %edi, %ebx
vmovsd (%rsi,%rbx,8), %xmm1
vucomisd %xmm1, %xmm0
jb 0x500b
xorl %r13d, %r13d
xorq %r13, %rax
vucomisd %xmm1, %xmm0
jb 0x4fe1
jmp 0x501c
xorl %edx, %edx
jmp 0x501c
xorl %eax, %eax
incl %r12d
movq %r12, %r13
cmpq %r12, %rcx
ja 0x4f30
andq %r8, %rdx
andq %r8, %rax
bsrq %rdx, %r8
notl %r8d
shll $0x3, %r8d
movq $-0x200, %r9            # imm = 0xFE00
orq %r9, %r8
movq 0x10(%rsp), %rdi
leaq (%rsi,%rdi), %r10
addq %r10, %r8
testq %rdx, %rdx
leaq -0x8(%rsi,%rdi), %rdx
cmoveq %rdx, %r8
vmovsd (%r8), %xmm0
subq %r15, %rcx
movq 0x18(%rsp), %rsi
movq (%rsi), %rsi
bsrq %rax, %rdi
notl %edi
shll $0x3, %edi
orq %r9, %rdi
addq %r10, %rdi
testq %rax, %rax
cmoveq %rdx, %rdi
vmovsd %xmm0, (%rsi,%rcx,8)
vmovsd (%rdi), %xmm0
movq 0x20(%rsp), %rax
movq (%rax), %rax
vmovsd %xmm0, (%rax,%rcx,8)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3171(%rip), %rdi      # 0x8221
leaq 0x30dd(%rip), %rsi      # 0x8194
leaq 0x3186(%rip), %rcx      # 0x8244
movl $0x1d6, %edx            # imm = 0x1D6
callq 0x20a0
movq %rax, %rbx
movq (%r14), %rdi
testq %rdi, %rdi
je 0x50d8
callq 0x20e0
movq %rbx, %rdi
callq 0x2190