// File: /workspace/github_cpp_makefile_star2_O2/lemire[P]runningmaxmin/runningmaxmin.cpp
// Function: main
int main(int params, char ** args) {
    int whitesize = 0;
    int walksize = 0;
    int times = 1;
    int sinesize = 0;
    floattype sineperiod = 0.0;
    int windowbegin = 10;
    int windowend = 11;
    bool doslow = true;
    bool cininput = false;
    std::vector<floattype> data(0);
    for (int i = 1; i < params; ++i) {
        if (strcmp(args[i], "--skipslow") == 0) {
            doslow = false;
        }
        if (strcmp(args[i], "--pipedata") == 0) {
            cininput = true;
        }
        if (strcmp(args[i], "--unit") == 0) {
            std::cout << "OK " << std::endl;
            return 0;
        }
        if (strcmp(args[i], "--window") == 0) {
            if (params - i > 1) {
                windowbegin = atoi(args[++i]);
                windowend = windowbegin + 1;
            } else {
                std::cerr << "--window expects an integer (length)"
                          << std::endl;
                return -1;
            }
            continue;
        }
        if (strcmp(args[i], "--windowrange") == 0) {
            if (params - i > 2) {
                windowbegin = atoi(args[++i]);
                windowend = atoi(args[++i]) + 1;
            } else {
                std::cerr << "--windowrange expects two integers (length)"
                          << std::endl;
                return -1;
            }
            continue;
        }
        if (strcmp(args[i], "--white") == 0) {
            if (params - i > 1)
                whitesize = atoi(args[++i]);
            else {
                std::cerr << "--white expects an integer (length)" << std::endl;
                return -1;
            }
            continue;
        }
        if (strcmp(args[i], "--walk") == 0) {
            if (params - i > 1)
                walksize = atoi(args[++i]);
            else {
                std::cerr << "--walk expects an integer (length)" << std::endl;
                return -1;
            }
            continue;
        }
        if (strcmp(args[i], "--sine") == 0) {
            if (params - i > 1)
                sinesize = atoi(args[++i]);
            else {
                std::cerr << "--sine expects an integer (length)" << std::endl;
                return -1;
            }
            if (params - i > 1)
                sineperiod = atof(args[++i]);
            else {
                std::cerr << "--sine expects an integer (length) followed by a "
                             "float (freq) "
                          << std::endl;
                return -1;
            }
            continue;
        }
        if (strcmp(args[i], "--times") == 0) {
            if (params - i > 1)
                times = atoi(args[++i]);
            else {
                std::cerr << "--times expects an integer" << std::endl;
                return -1;
            }
            continue;
        }
    }
    std::cout << "# we report timings (in seconds) so lower is better" << std::endl;
    for (int window = windowbegin; window < windowend; ++window) {
        if (whitesize > 0) {
            std::cout << "# window = " << window << " whitesize = " << whitesize
                      << " times = " << times << " doslow = " << doslow
                      << std::endl;
            assert(window + 1 < whitesize);
            timings(window, whitesize, times, doslow);
        } else if (walksize > 0) {
            std::cout << "# window = " << window << " walksize = " << walksize
                      << " times = " << times << " doslow = " << doslow
                      << std::endl;
            walktimings(window, walksize, times, doslow);

        } else if (sinesize > 0) {
            std::cout << "# window = " << window << " sinesize = " << sinesize
                      << " sine period " << sineperiod << " times = " << times
                      << " doslow = " << doslow << std::endl;
            assert(window + 1 < sinesize);
            sinetimings(window, sinesize, sineperiod, times, doslow);
        } else {
            if ((data.empty()) && cininput) {
                data = getcin();
                std::cout << "# window = " << window << " times = " << times
                          << " doslow = " << doslow << std::endl;
                process(data, window, times, doslow);
            } else {
                std::cout << "Generating sine waves." << std::endl;
                for (uint width = 3; width <= 100; ++width) {
                    std::cout << "Using a min/max width of " << width
                              << std::endl;
                    sinetimings(width);
                }
            }
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r12
movl %edi, 0x2c(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
leaq 0x60(%rsp), %rdx
xorl %esi, %esi
callq 0x36e6
movb $0x1, %bl
pushq $0xb
popq %rax
movl %eax, 0x24(%rsp)
pushq $0xa
popq %rax
movq %rax, 0x18(%rsp)
vxorps %xmm0, %xmm0, %xmm0
vmovsd %xmm0, 0x30(%rsp)
pushq $0x1
popq %rax
movl $0x0, 0x14(%rsp)
xorl %ecx, %ecx
movq $0x0, 0x38(%rsp)
movl %eax, 0x28(%rsp)
movl %eax, %ebp
movl %ecx, 0x10(%rsp)
movl 0x2c(%rsp), %r15d
movzbl %bl, %ebx
subl %ebp, %r15d
jle 0x32c8
movslq %ebp, %r13
movq %r12, %r14
movq (%r12,%r13,8), %r12
movq %r12, %rdi
leaq 0x3fec(%rip), %rsi      # 0x70d4
callq 0x2150
testl %eax, %eax
cmovel %eax, %ebx
movq %r12, %rdi
leaq 0x3fe3(%rip), %rsi      # 0x70df
callq 0x2150
testl %eax, %eax
sete 0xf(%rsp)
movq %r12, %rdi
leaq 0x3fd8(%rip), %rsi      # 0x70ea
callq 0x2150
testl %eax, %eax
je 0x35fd
movq %r12, %rdi
leaq 0x3fcc(%rip), %rsi      # 0x70f5
callq 0x2150
testl %eax, %eax
je 0x31b6
movq %r12, %rdi
leaq 0x3fe3(%rip), %rsi      # 0x7123
callq 0x2150
testl %eax, %eax
je 0x31d4
movq %r12, %rdi
leaq 0x4006(%rip), %rsi      # 0x715d
callq 0x2150
testl %eax, %eax
je 0x3206
movq %r12, %rdi
leaq 0x401b(%rip), %rsi      # 0x7189
callq 0x2150
testl %eax, %eax
je 0x3226
movq %r12, %rdi
leaq 0x402e(%rip), %rsi      # 0x71b3
callq 0x2150
testl %eax, %eax
je 0x3245
movq %r12, %rdi
leaq 0x4080(%rip), %rsi      # 0x721c
callq 0x2150
testl %eax, %eax
je 0x3288
movq 0x18(%rsp), %r15
movq %r14, %r12
jmp 0x32aa
cmpl $0x2, %r15d
jl 0x361c
incl %ebp
movq %r14, %r12
movq 0x8(%r14,%r13,8), %rdi
callq 0x2180
movl %eax, %r15d
jmp 0x31fb
cmpl $0x3, %r15d
jl 0x3625
movq %r14, %r12
movq 0x8(%r14,%r13,8), %rdi
callq 0x2180
movl %eax, %r15d
addl $0x2, %ebp
movq 0x10(%r14,%r13,8), %rdi
callq 0x2180
incl %eax
movl %eax, 0x24(%rsp)
jmp 0x32aa
cmpl $0x2, %r15d
jl 0x362e
incl %ebp
movq %r14, %r12
movq 0x8(%r14,%r13,8), %rdi
callq 0x2180
movq %rax, 0x40(%rsp)
jmp 0x32a5
cmpl $0x2, %r15d
jl 0x3637
incl %ebp
movq %r14, %r12
movq 0x8(%r14,%r13,8), %rdi
callq 0x2180
movl %eax, 0x14(%rsp)
jmp 0x32a5
cmpl $0x2, %r15d
jl 0x3640
leal 0x1(%rbp), %eax
movl 0x2c(%rsp), %ecx
subl %eax, %ecx
cmpl $0x2, %ecx
jl 0x3649
movq %r14, %r12
cltq
movq (%r14,%rax,8), %rdi
callq 0x2180
movl %eax, 0x10(%rsp)
addl $0x2, %ebp
movq 0x10(%r14,%r13,8), %rdi
callq 0x2130
vmovsd %xmm0, 0x30(%rsp)
jmp 0x32a5
cmpl $0x2, %r15d
jl 0x3652
movq %r14, %r12
incl %ebp
movq 0x8(%r14,%r13,8), %rdi
callq 0x2180
movl %eax, 0x28(%rsp)
movq 0x18(%rsp), %r15
movq %r15, 0x18(%rsp)
movq 0x38(%rsp), %rax
orb 0xf(%rsp), %al
movq %rax, 0x38(%rsp)
incl %ebp
movl 0x10(%rsp), %ecx
jmp 0x30bf
movq 0x7cf9(%rip), %rdi      # 0xafc8
leaq 0x3f69(%rip), %rsi      # 0x723f
callq 0x2100
movq %rax, %rdi
callq 0x2080
movq 0x7cde(%rip), %r13      # 0xafc8
andl $0x1, %ebx
movq 0x40(%rsp), %r14
movl 0x28(%rsp), %r15d
movq 0x18(%rsp), %rax
cmpl 0x24(%rsp), %eax
jge 0x3618
movq %rax, %rbp
testl %r14d, %r14d
jle 0x33a1
movq %r13, %rdi
leaq 0x3f57(%rip), %rsi      # 0x7273
callq 0x2100
movq %rax, %rdi
movl %ebp, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3f4a(%rip), %rsi      # 0x727f
callq 0x2100
movq %rax, %rdi
movl %r14d, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3f3e(%rip), %rsi      # 0x728d
callq 0x2100
movq %rax, %rdi
movl %r15d, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3f2e(%rip), %rsi      # 0x7297
callq 0x2100
movq %rax, %rdi
movl %ebx, %esi
callq 0x21c0
movq %rax, %rdi
callq 0x2080
leal 0x1(%rbp), %eax
cmpl %r14d, %eax
jge 0x368b
movq %rbp, %rdi
movl %r14d, %esi
movl %r15d, %edx
movl %ebx, %ecx
callq 0x28d4
jmp 0x358e
cmpl $0x0, 0x14(%rsp)
jle 0x3430
movq %r13, %rdi
leaq 0x3ebd(%rip), %rsi      # 0x7273
callq 0x2100
movq %rax, %rdi
movl %ebp, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3f13(%rip), %rsi      # 0x72e2
callq 0x2100
movq %rax, %rdi
movl 0x14(%rsp), %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3ea3(%rip), %rsi      # 0x728d
callq 0x2100
movq %rax, %rdi
movl %r15d, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3e93(%rip), %rsi      # 0x7297
callq 0x2100
movq %rax, %rdi
movl %ebx, %esi
callq 0x21c0
movq %rax, %rdi
callq 0x2080
movl %ebp, %edi
movl 0x14(%rsp), %esi
movl %r15d, %edx
movl %ebx, %ecx
callq 0x2ab4
jmp 0x358e
cmpl $0x0, 0x10(%rsp)
jle 0x34ee
movq %r13, %rdi
leaq 0x3e2e(%rip), %rsi      # 0x7273
callq 0x2100
movq %rax, %rdi
movl %ebp, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3e91(%rip), %rsi      # 0x72ef
callq 0x2100
movq %rax, %rdi
movl 0x10(%rsp), %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3e83(%rip), %rsi      # 0x72fc
callq 0x2100
movq %rax, %rdi
vmovsd 0x30(%rsp), %xmm0
callq 0x2190
movq %rax, %rdi
leaq 0x3df7(%rip), %rsi      # 0x728d
callq 0x2100
movq %rax, %rdi
movl %r15d, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3de7(%rip), %rsi      # 0x7297
callq 0x2100
movq %rax, %rdi
movl %ebx, %esi
callq 0x21c0
movq %rax, %rdi
callq 0x2080
leal 0x1(%rbp), %eax
movl 0x10(%rsp), %esi
cmpl %esi, %eax
jge 0x36aa
movq %rbp, %rdi
vmovsd 0x30(%rsp), %xmm0
movl %r15d, %edx
movl %ebx, %ecx
callq 0x2c94
jmp 0x358e
movq 0x48(%rsp), %rax
cmpq 0x50(%rsp), %rax
sete %al
andb 0x38(%rsp), %al
cmpb $0x1, %al
jne 0x3598
leaq 0x60(%rsp), %r12
movq %r12, %rdi
callq 0x23eb
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x6d0c
movq %r12, %rdi
callq 0x6b18
movq %r13, %rdi
leaq 0x3d40(%rip), %rsi      # 0x7273
callq 0x2100
movq %rax, %rdi
movl %ebp, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3d41(%rip), %rsi      # 0x728d
callq 0x2100
movq %rax, %rdi
movl %r15d, %esi
callq 0x21d0
movq %rax, %rdi
leaq 0x3d31(%rip), %rsi      # 0x7297
callq 0x2100
movq %rax, %rdi
movl %ebx, %esi
callq 0x21c0
movq %rax, %rdi
callq 0x2080
leaq 0x48(%rsp), %rdi
movl %ebp, %esi
movl %r15d, %edx
movl %ebx, %ecx
callq 0x27a5
movq %rbp, %rax
incl %eax
jmp 0x32fc
movq %r13, %rdi
leaq 0x3d7e(%rip), %rsi      # 0x7320
callq 0x2100
movq %rax, %rdi
callq 0x2080
pushq $0x3
popq %r12
cmpq $0x65, %r12
je 0x358e
movq %r13, %rdi
leaq 0x3d74(%rip), %rsi      # 0x7337
callq 0x2100
movq %rax, %rdi
movq %r12, %rsi
callq 0x20c0
movq %rax, %rdi
callq 0x2080
movl %r12d, %edi
movl $0x2710, %esi           # imm = 0x2710
vmovsd 0x3a3d(%rip), %xmm0     # 0x7028
movl $0x1f4, %edx            # imm = 0x1F4
pushq $0x1
popq %rcx
callq 0x2c94
incq %r12
jmp 0x35b3
movq 0x79c4(%rip), %rdi      # 0xafc8
leaq 0x3ae6(%rip), %rsi      # 0x70f1
callq 0x2100
movq %rax, %rdi
callq 0x2080
xorl %ebx, %ebx
jmp 0x3670
leaq 0x3adb(%rip), %rsi      # 0x70fe
jmp 0x3659
leaq 0x3b05(%rip), %rsi      # 0x7131
jmp 0x3659
leaq 0x3b30(%rip), %rsi      # 0x7165
jmp 0x3659
leaq 0x3b52(%rip), %rsi      # 0x7190
jmp 0x3659
leaq 0x3b73(%rip), %rsi      # 0x71ba
jmp 0x3659
leaq 0x3b8d(%rip), %rsi      # 0x71dd
jmp 0x3659
leaq 0x3bcb(%rip), %rsi      # 0x7224
movq 0x7990(%rip), %rdi      # 0xaff0
callq 0x2100
movq %rax, %rdi
callq 0x2080
pushq $-0x1
popq %rbx
leaq 0x48(%rsp), %rdi
callq 0x6b18
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c10(%rip), %rdi      # 0x72a2
leaq 0x3c20(%rip), %rsi      # 0x72b9
leaq 0x3c2b(%rip), %rcx      # 0x72cb
movl $0x11e, %edx            # imm = 0x11E
callq 0x20a0
leaq 0x3c59(%rip), %rdi      # 0x730a
leaq 0x3c01(%rip), %rsi      # 0x72b9
leaq 0x3c0c(%rip), %rcx      # 0x72cb
movl $0x12a, %edx            # imm = 0x12A
callq 0x20a0
jmp 0x36d1
jmp 0x36d1
jmp 0x36d1
jmp 0x36d1
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x6b18
movq %rbx, %rdi
callq 0x21e0