// File: /workspace/github_cpp_makefile_star2_O3/lemire[P]runningmaxmin/./runningmaxmin.h
// Function: GilKimmel::computePrefixSuffixMax(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>> const&, int)
void computePrefixSuffixMax(std::vector<floattype> & R,
                                std::vector<floattype> & S,
                                const std::vector<floattype> & array,
                                const int width) {
        for (int j = 0; j < static_cast<int>(array.size()); j += width) {
            const int begin = j;
            const int end = std::min(static_cast<int>(array.size()), j + width);
            const int midpoint = (end - begin + 1) / 2 + begin;
            S[begin] = array[begin];
            for (int jj = begin + 1; jj < midpoint; ++jj) {
                S[jj] = std::max(array[jj], S[jj - 1]);
            }
            R[end - 1] = array[end - 1];
            for (int jj = end - 2; jj >= midpoint; --jj) {
                R[jj] = std::max(R[jj + 1], array[jj]);
            }
            if (std::max(R[midpoint], S[midpoint - 1]) == R[midpoint]) {
                for (int jj = midpoint; jj < end; ++jj)
                    S[jj] = std::max(array[jj], S[jj - 1]);
                for (int jj = midpoint - 1; jj >= begin; --jj)
                    R[jj] = R[midpoint];
            } else {
                for (int jj = midpoint - 1; jj >= begin; --jj)
                    R[jj] = std::max(R[jj + 1], array[jj]);
                for (int jj = midpoint; jj < end; ++jj)
                    S[jj] = S[midpoint - 1];
            }
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movq %rcx, -0x38(%rsp)
testl %ecx, %ecx
jle 0x611e
movq (%rdx), %rdx
movq (%rsi), %rsi
movslq %r8d, %rdi
movq -0x38(%rsp), %rcx
movl %ecx, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq %rdi, %rcx
shlq $0x20, %rcx
movq %rcx, -0x20(%rsp)
movl $0x1, %ecx
movq %rcx, -0x28(%rsp)
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movq $0x0, -0x48(%rsp)
movabsq $0x100000000, %rbx      # imm = 0x100000000
vmovaps 0x2194(%rip), %ymm0     # 0x8040
vmovddup 0x2184(%rip), %xmm1     # xmm1 = mem[0,0]
vpcmpeqd %xmm2, %xmm2, %xmm2
xorl %ebp, %ebp
movq %rdi, -0x10(%rsp)
movq %r9, -0x18(%rsp)
movl %r11d, -0x4c(%rsp)
movl %r8d, -0x3c(%rsp)
movslq %r8d, %r10
cmpq %r9, %r10
movq %r9, %r13
cmovlq %r10, %r13
movq -0x38(%rsp), %rcx
cmpl %ecx, %r10d
movl %ecx, %r11d
cmovll %r10d, %r11d
cmpq %r9, %r10
cmovgeq %r9, %r10
addq %rbp, %rdi
cmpl %ecx, %edi
movq %rdi, -0x8(%rsp)
cmovll %edi, %ecx
movl %ecx, %edi
subl %ebp, %edi
movl %edi, %r12d
incl %r12d
movl %r12d, %r8d
shrl $0x1f, %r8d
addl %r8d, %edi
incl %edi
sarl %edi
movq %rdi, -0x30(%rsp)
leal (%rdi,%rbp), %r9d
vmovsd (%rax,%rbp,8), %xmm3
vmovsd %xmm3, (%rdx,%rbp,8)
cmpl $0x4, %r12d
jl 0x5f60
movslq %r9d, %rdi
movq -0x48(%rsp), %r15
movq -0x28(%rsp), %r14
movq %r15, %r8
sarq $0x1d, %r8
vmovsd (%rdx,%r8), %xmm3
vmaxsd (%rax,%r14,8), %xmm3, %xmm3
vmovsd %xmm3, (%rdx,%r14,8)
incq %r14
addq %rbx, %r15
cmpq %rdi, %r14
jl 0x5f3c
movq %rbx, %r15
movslq %r9d, %rdi
movslq %ecx, %r8
vmovsd -0x8(%rax,%r8,8), %xmm3
vmovsd %xmm3, -0x8(%rsi,%r8,8)
leal -0x2(%rcx), %r14d
cmpl %r9d, %r14d
jl 0x5fab
addl $-0x2, %r11d
movslq %r11d, %r11
vmovsd 0x8(%rsi,%r11,8), %xmm3
incq %r11
vmovsd -0x8(%rax,%r11,8), %xmm4
vmaxsd %xmm3, %xmm4, %xmm3
vmovsd %xmm3, -0x8(%rsi,%r11,8)
decq %r11
cmpq %rdi, %r11
jg 0x5f91
vmovsd (%rsi,%rdi,8), %xmm3
vmovsd -0x8(%rdx,%rdi,8), %xmm4
vmaxsd %xmm3, %xmm4, %xmm4
vucomisd %xmm3, %xmm4
jne 0x601a
jp 0x601a
cmpl %ecx, %r9d
movl -0x4c(%rsp), %r11d
jge 0x5fe7
vmovsd -0x8(%rdx,%rdi,8), %xmm3
movq %rdi, %rcx
vmaxsd (%rax,%rcx,8), %xmm3, %xmm3
vmovsd %xmm3, (%rdx,%rcx,8)
incq %rcx
cmpq %r8, %rcx
jl 0x5fd5
cmpl $0x2, %r12d
movq %r15, %rbx
jl 0x60e7
movq -0x30(%rsp), %rcx
addl %r11d, %ecx
vmovsd (%rsi,%rdi,8), %xmm3
movslq %ecx, %rcx
incq %rcx
vmovsd %xmm3, -0x8(%rsi,%rcx,8)
decq %rcx
cmpq %rbp, %rcx
jg 0x6007
jmp 0x60e7
cmpl $0x2, %r12d
movl -0x4c(%rsp), %r11d
jl 0x6054
movq -0x30(%rsp), %r8
addl %r11d, %r8d
movslq %r8d, %r8
vmovsd 0x8(%rsi,%r8,8), %xmm3
incq %r8
vmovsd -0x8(%rax,%r8,8), %xmm4
vmaxsd %xmm3, %xmm4, %xmm3
vmovsd %xmm3, -0x8(%rsi,%r8,8)
decq %r8
cmpq %rbp, %r8
jg 0x603a
cmpl %ecx, %r9d
movq %r15, %rbx
jge 0x60e7
movq %rdi, %rcx
notq %rcx
addq %r10, %rcx
vmovq %rcx, %xmm3
vpshufd $0x44, %xmm3, %xmm4     # xmm4 = xmm3[0,1,0,1]
leaq (%rdx,%rdi,8), %rcx
vbroadcastsd -0x8(%rcx), %ymm3
vinsertf128 $0x1, %xmm4, %ymm4, %ymm5
subq %rdi, %r13
addq $0x3, %r13
andq $-0x4, %r13
vextractf128 $0x1, %ymm5, %xmm4
vxorps %xmm1, %xmm4, %xmm4
vxorps %xmm1, %xmm5, %xmm5
xorl %edi, %edi
vmovq %rdi, %xmm6
vpshufd $0x44, %xmm6, %xmm6     # xmm6 = xmm6[0,1,0,1]
vinsertf128 $0x1, %xmm6, %ymm6, %ymm6
vorps %ymm0, %ymm6, %ymm6
vextractf128 $0x1, %ymm6, %xmm7
vxorps %xmm1, %xmm7, %xmm7
vpcmpgtq %xmm4, %xmm7, %xmm7
vpxor %xmm2, %xmm7, %xmm7
vxorps %xmm1, %xmm6, %xmm6
vpcmpgtq %xmm5, %xmm6, %xmm6
vpxor %xmm2, %xmm6, %xmm6
vinsertf128 $0x1, %xmm7, %ymm6, %ymm6
vmaskmovpd %ymm3, %ymm6, (%rcx,%rdi,8)
addq $0x4, %rdi
cmpq %rdi, %r13
jne 0x609e
movq -0x10(%rsp), %rdi
addq %rdi, -0x28(%rsp)
movl -0x3c(%rsp), %r8d
addl %edi, %r8d
addl %edi, %r11d
movq -0x48(%rsp), %rcx
addq -0x20(%rsp), %rcx
movq %rcx, -0x48(%rsp)
movq -0x18(%rsp), %r9
movq -0x8(%rsp), %rbp
cmpq %r9, %rbp
jl 0x5ec4
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq