// File: /workspace/github_cpp_makefile_star2_O1/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 0x5f97
movq (%rdx), %rdx
movq (%rsi), %rsi
movslq %r8d, %rdi
movq -0x38(%rsp), %rcx
movl %ecx, %r11d
andl $0x7fffffff, %r11d      # imm = 0x7FFFFFFF
movq %rdi, %rcx
shlq $0x20, %rcx
movq %rcx, -0x20(%rsp)
movl $0x1, %ecx
movq %rcx, -0x30(%rsp)
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq $0x0, -0x48(%rsp)
movabsq $0x100000000, %rbx      # imm = 0x100000000
vmovaps 0x231a(%rip), %ymm0     # 0x8040
vmovddup 0x230a(%rip), %xmm1     # xmm1 = mem[0,0]
vpcmpeqd %xmm2, %xmm2, %xmm2
xorl %ebp, %ebp
movq %rdi, -0x10(%rsp)
movq %r11, -0x18(%rsp)
movq %r14, -0x28(%rsp)
movl %r8d, -0x3c(%rsp)
movslq %r8d, %r10
cmpq %r11, %r10
movq %r11, %r9
cmovlq %r10, %r9
movq -0x38(%rsp), %rcx
cmpl %ecx, %r10d
movl %ecx, %r14d
cmovll %r10d, %r14d
cmpq %r11, %r10
cmovgeq %r11, %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
leal (%rdi,%rbp), %r8d
vmovsd (%rax,%rbp,8), %xmm3
vmovsd %xmm3, (%rdx,%rbp,8)
movl %r8d, -0x40(%rsp)
movslq %r8d, %r13
cmpl $0x4, %r12d
jl 0x5dda
movq -0x48(%rsp), %r15
movq -0x30(%rsp), %r8
movq %r15, %r11
sarq $0x1d, %r11
vmovsd (%rdx,%r11), %xmm3
vmaxsd (%rax,%r8,8), %xmm3, %xmm3
vmovsd %xmm3, (%rdx,%r8,8)
incq %r8
addq %rbx, %r15
cmpq %r13, %r8
jl 0x5db6
movq %rbx, %r15
movslq %ecx, %r11
vmovsd -0x8(%rax,%r11,8), %xmm3
vmovsd %xmm3, -0x8(%rsi,%r11,8)
leal -0x2(%rcx), %r8d
movl -0x40(%rsp), %ebx
cmpl %ebx, %r8d
jl 0x5e26
addl $-0x2, %r14d
movslq %r14d, %r14
vmovsd 0x8(%rsi,%r14,8), %xmm3
incq %r14
vmovsd -0x8(%rax,%r14,8), %xmm4
vmaxsd %xmm3, %xmm4, %xmm3
vmovsd %xmm3, -0x8(%rsi,%r14,8)
decq %r14
cmpq %r13, %r14
jg 0x5e0c
vmovsd (%rsi,%r13,8), %xmm3
vmovsd -0x8(%rdx,%r13,8), %xmm4
vmaxsd %xmm3, %xmm4, %xmm4
vucomisd %xmm3, %xmm4
jne 0x5e95
jp 0x5e95
cmpl %ecx, %ebx
movq -0x28(%rsp), %r14
jge 0x5e66
leal (%rdi,%rbp), %ecx
movslq %ecx, %rcx
vmovsd -0x8(%rdx,%rcx,8), %xmm3
vmaxsd (%rax,%rcx,8), %xmm3, %xmm3
vmovsd %xmm3, (%rdx,%rcx,8)
incq %rcx
cmpq %r11, %rcx
jl 0x5e54
cmpl $0x2, %r12d
movq %r15, %rbx
jl 0x5f60
addl %r14d, %edi
movslq %edi, %rcx
incq %rcx
vmovsd (%rsi,%r13,8), %xmm3
vmovsd %xmm3, -0x8(%rsi,%rcx,8)
decq %rcx
cmpq %rbp, %rcx
jg 0x5e7c
jmp 0x5f60
cmpl $0x2, %r12d
movq -0x28(%rsp), %r14
jl 0x5ecb
leal (%rdi,%r14), %r8d
movslq %r8d, %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 %rbp, %r11
jg 0x5eb1
cmpl %ecx, %ebx
movq %r15, %rbx
jge 0x5f60
addl %ebp, %edi
movslq %edi, %rcx
notq %rcx
addq %r10, %rcx
vmovq %rcx, %xmm3
vpshufd $0x44, %xmm3, %xmm3     # xmm3 = xmm3[0,1,0,1]
vinsertf128 $0x1, %xmm3, %ymm3, %ymm4
leaq (%rdx,%r13,8), %rcx
subq %r13, %r9
addq $0x3, %r9
andq $-0x4, %r9
vextractf128 $0x1, %ymm4, %xmm3
vxorps %xmm1, %xmm3, %xmm3
vxorps %xmm1, %xmm4, %xmm4
xorl %edi, %edi
vmovq %rdi, %xmm5
vpshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
vinsertf128 $0x1, %xmm5, %ymm5, %ymm5
vorps %ymm0, %ymm5, %ymm5
vextractf128 $0x1, %ymm5, %xmm6
vxorps %xmm1, %xmm6, %xmm6
vpcmpgtq %xmm3, %xmm6, %xmm6
vpxor %xmm2, %xmm6, %xmm6
vxorps %xmm1, %xmm5, %xmm5
vpcmpgtq %xmm4, %xmm5, %xmm5
vpxor %xmm2, %xmm5, %xmm5
vinsertf128 $0x1, %xmm6, %ymm5, %ymm5
vbroadcastsd -0x8(%rdx,%r13,8), %ymm6
vmaskmovpd %ymm6, %ymm5, (%rcx,%rdi,8)
addq $0x4, %rdi
cmpq %rdi, %r9
jne 0x5f10
movq -0x10(%rsp), %rdi
addq %rdi, -0x30(%rsp)
movl -0x3c(%rsp), %r8d
addl %edi, %r8d
addl %edi, %r14d
movq -0x48(%rsp), %rcx
addq -0x20(%rsp), %rcx
movq %rcx, -0x48(%rsp)
movq -0x18(%rsp), %r11
movq -0x8(%rsp), %rbp
cmpq %r11, %rbp
jl 0x5d3e
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
vzeroupper
retq
nop