// File: /workspace/github_cpp_makefile_star2_O3/mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::_ialglib_rmv(long, long, double const*, double const*, double*, long, double, double)
void _ialglib_rmv(ae_int_t m, ae_int_t n, const double *a, const double *x, double *y, ae_int_t stride, double alpha, double beta)
{
    /*
     * Handle special cases:
     * - alpha is zero or n is zero
     * - m is zero
     */
    if( m==0 )
        return;
    if( alpha==0.0 || n==0 )
    {
        ae_int_t i;
        if( beta==0.0 )
        {
            for(i=0; i<m; i++)
            {
                *y = 0.0;
                y += stride;
            }
        }
        else
        {
            for(i=0; i<m; i++)
            {
                *y *= beta;
                y += stride;
            }
        }
        return;
    }
    
    /*
     * Handle general case: nonzero alpha, n and m
     *
     */
    if( m==32 && n==32 )
    {
        /*
         * 32x32, may be we have something better than general implementation
         */
        _ialglib_mv_32(a, x, y, stride, alpha, beta);
    }
    else
    {
        ae_int_t i, k, m2, n8, n2, ntrail2;
        const double *pa0, *pa1, *pb;

        /*
         * First M/2 rows of A are processed in pairs.
         * optimized code is used.
         */
        m2 = m/2;
        n8 = n/8;
        ntrail2 = (n-8*n8)/2;
        for(i=0; i<m2; i++)
        {
            double v0 = 0, v1 = 0;

            /*
             * 'a' points to the part of the matrix which
             * is not processed yet
             */
            pb = x;
            pa0 = a;
            pa1 = a+alglib_r_block;
            a += alglib_twice_r_block;

            /*
             * 8 elements per iteration
             */
            for(k=0; k<n8; k++)
            {
                v0 += pa0[0]*pb[0];
                v1 += pa1[0]*pb[0];
                v0 += pa0[1]*pb[1];
                v1 += pa1[1]*pb[1];
                v0 += pa0[2]*pb[2];
                v1 += pa1[2]*pb[2];
                v0 += pa0[3]*pb[3];
                v1 += pa1[3]*pb[3];
                v0 += pa0[4]*pb[4];
                v1 += pa1[4]*pb[4];
                v0 += pa0[5]*pb[5];
                v1 += pa1[5]*pb[5];
                v0 += pa0[6]*pb[6];
                v1 += pa1[6]*pb[6];
                v0 += pa0[7]*pb[7];
                v1 += pa1[7]*pb[7];
                pa0 += 8;
                pa1 += 8;
                pb  += 8;
            }

            /*
             * 2 elements per iteration
             */
            for(k=0; k<ntrail2; k++)
            {
                v0 += pa0[0]*pb[0];
                v1 += pa1[0]*pb[0];
                v0 += pa0[1]*pb[1];
                v1 += pa1[1]*pb[1];
                pa0 += 2;
                pa1 += 2;
                pb  += 2;
            }

            /*
             * last element, if needed
             */
            if( n%2!=0 )
            {
                v0 += pa0[0]*pb[0];
                v1 += pa1[0]*pb[0];
            }

            /*
             * final update
             */
            if( beta!=0 )
            {
                y[0] = beta*y[0]+alpha*v0;
                y[stride] = beta*y[stride]+alpha*v1;
            }
            else
            {
                y[0] = alpha*v0;
                y[stride] = alpha*v1;
            }
            
            /*
             * move to the next pair of elements
             */
            y+=2*stride;
        }


        /*
         * Last (odd) row is processed with less optimized code.
         */
        if( m%2!=0 )
        {
            double v0 = 0;

            /*
             * 'a' points to the part of the matrix which
             * is not processed yet
             */
            pb = x;
            pa0 = a;

            /*
             * 2 elements per iteration
             */
            n2 = n/2;
            for(k=0; k<n2; k++)
            {
                v0 += pa0[0]*pb[0]+pa0[1]*pb[1];
                pa0 += 2;
                pb  += 2;
            }

            /*
             * last element, if needed
             */
            if( n%2!=0 )
                v0 += pa0[0]*pb[0];

            /*
             * final update
             */
            if( beta!=0 )
                y[0] = beta*y[0]+alpha*v0;
            else
                y[0] = alpha*v0;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x2eeb2
movq %r9, %r13
movq %rsi, %rbx
testq %rsi, %rsi
je 0x2eaaf
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x2ea81
jnp 0x2eaaf
movq %rdi, %rax
xorq $0x20, %rax
movq %rbx, %rsi
xorq $0x20, %rsi
orq %rax, %rsi
jne 0x2eae4
movq %rdx, %rdi
movq %rcx, %rsi
movq %r8, %rdx
movq %r13, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2e8c5
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x2edf0
jp 0x2edf0
testq %rdi, %rdi
jle 0x2eeb2
shlq $0x3, %r13
movq $0x0, (%r8)
addq %r13, %r8
decq %rdi
jne 0x2ead0
jmp 0x2eeb2
leaq 0x7(%rbx), %rax
testq %rbx, %rbx
cmovnsq %rbx, %rax
cmpq $0x2, %rdi
jl 0x2ee18
movq %rdi, %rsi
shrq $0x3f, %rsi
addq %rdi, %rsi
sarq %rsi
movq %rsi, -0x8(%rsp)
movq %rax, %rsi
sarq $0x3, %rsi
andq $-0x8, %rax
movq %rbx, %r9
subq %rax, %r9
movq %r9, %rax
shrq $0x3f, %rax
movq %r9, -0x10(%rsp)
addq %r9, %rax
sarq %rax
movq %r13, %r9
shlq $0x4, %r9
movq %r9, -0x18(%rsp)
movq %rsi, -0x30(%rsp)
shlq $0x6, %rsi
addq %rcx, %rsi
movq %rsi, -0x40(%rsp)
movq %rax, -0x38(%rsp)
shlq $0x4, %rax
movq %rax, -0x48(%rsp)
movl $0x138, %ebp            # imm = 0x138
movq $-0x100, %r11
xorl %r12d, %r12d
movq %rdx, %rsi
xorl %r14d, %r14d
movq %r13, -0x20(%rsp)
movq %rdx, -0x28(%rsp)
cmpq $0x8, %rbx
jl 0x2ecc4
xorpd %xmm3, %xmm3
movq -0x30(%rsp), %r15
movq %rdx, %rax
movq %rcx, %r10
movsd -0x138(%rax,%rbp), %xmm6
movsd -0x130(%rax,%rbp), %xmm7
movsd -0x128(%rax,%rbp), %xmm8
movsd -0x120(%rax,%rbp), %xmm5
movhpd -0x38(%rax,%rbp), %xmm6 # xmm6 = xmm6[0],mem[0]
movsd (%r10), %xmm9
movsd 0x8(%r10), %xmm10
movsd 0x10(%r10), %xmm11
movsd 0x18(%r10), %xmm4
unpcklpd %xmm9, %xmm9            # xmm9 = xmm9[0,0]
mulpd %xmm6, %xmm9
addpd %xmm3, %xmm9
movhpd -0x30(%rax,%rbp), %xmm7 # xmm7 = xmm7[0],mem[0]
unpcklpd %xmm10, %xmm10          # xmm10 = xmm10[0,0]
mulpd %xmm7, %xmm10
movhpd -0x28(%rax,%rbp), %xmm8 # xmm8 = xmm8[0],mem[0]
addpd %xmm9, %xmm10
unpcklpd %xmm11, %xmm11          # xmm11 = xmm11[0,0]
mulpd %xmm8, %xmm11
addpd %xmm10, %xmm11
movhpd -0x20(%rax,%rbp), %xmm5 # xmm5 = xmm5[0],mem[0]
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
mulpd %xmm5, %xmm4
addpd %xmm11, %xmm4
movsd -0x118(%rax,%rbp), %xmm3
movhpd -0x18(%rax,%rbp), %xmm3 # xmm3 = xmm3[0],mem[0]
movsd 0x20(%r10), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm3, %xmm5
addpd %xmm4, %xmm5
movsd -0x110(%rax,%rbp), %xmm3
movhpd -0x10(%rax,%rbp), %xmm3 # xmm3 = xmm3[0],mem[0]
movsd 0x28(%r10), %xmm4
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
mulpd %xmm3, %xmm4
addpd %xmm5, %xmm4
movsd -0x108(%rax,%rbp), %xmm3
movhpd -0x8(%rax,%rbp), %xmm3  # xmm3 = xmm3[0],mem[0]
movsd 0x30(%r10), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm3, %xmm5
movsd -0x100(%rax,%rbp), %xmm6
movhpd (%rax,%rbp), %xmm6      # xmm6 = xmm6[0],mem[0]
addpd %xmm4, %xmm5
movsd 0x38(%r10), %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm6, %xmm3
addpd %xmm5, %xmm3
addq $0x40, %r10
addq $0x40, %rax
decq %r15
jne 0x2eb91
movq %rax, %r15
subq %r11, %r15
subq %r12, %rax
movq -0x40(%rsp), %r10
jmp 0x2ecd5
leaq 0x100(%rsi), %r15
xorpd %xmm3, %xmm3
movq %rsi, %rax
movq %rcx, %r10
cmpq $0x2, -0x10(%rsp)
jl 0x2ed4f
movq %rbx, %rdx
movq -0x48(%rsp), %r9
addq %r15, %r9
movq -0x38(%rsp), %r13
xorl %ebx, %ebx
movsd (%rax,%rbx), %xmm4
movsd 0x8(%rax,%rbx), %xmm5
movhpd (%r15,%rbx), %xmm4      # xmm4 = xmm4[0],mem[0]
movsd (%r10,%rbx), %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
mulpd %xmm4, %xmm6
addpd %xmm3, %xmm6
movsd 0x8(%r10,%rbx), %xmm3
movhpd 0x8(%r15,%rbx), %xmm5   # xmm5 = xmm5[0],mem[0]
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm5, %xmm3
addpd %xmm6, %xmm3
addq $0x10, %rbx
decq %r13
jne 0x2ecef
movq -0x48(%rsp), %rbx
addq %rbx, %rax
addq %rbx, %r10
movq %rdx, %rbx
movq -0x20(%rsp), %r13
movq -0x28(%rsp), %rdx
jmp 0x2ed52
movq %r15, %r9
testb $0x1, %bl
je 0x2ed71
movsd (%rax), %xmm4
movhpd (%r9), %xmm4            # xmm4 = xmm4[0],mem[0]
movsd (%r10), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm4, %xmm5
addpd %xmm5, %xmm3
ucomisd %xmm2, %xmm1
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
mulsd %xmm0, %xmm3
jne 0x2ed85
jnp 0x2edb1
movsd (%r8), %xmm5
mulsd %xmm1, %xmm5
addsd %xmm3, %xmm5
movsd %xmm5, (%r8)
mulsd %xmm0, %xmm4
movsd (%r8,%r13,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, (%r8,%r13,8)
jmp 0x2edc0
movsd %xmm3, (%r8)
mulsd %xmm0, %xmm4
movsd %xmm4, (%r8,%r13,8)
addq $0x200, %rsi            # imm = 0x200
addq -0x18(%rsp), %r8
incq %r14
addq $0x200, %rbp            # imm = 0x200
movq $-0x200, %rax           # imm = 0xFE00
addq %rax, %r11
addq %rax, %r12
cmpq -0x8(%rsp), %r14
jne 0x2eb78
jmp 0x2ee1b
testq %rdi, %rdi
jle 0x2eeb2
shlq $0x3, %r13
movsd (%r8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%r8)
addq %r13, %r8
decq %rdi
jne 0x2edfd
jmp 0x2eeb2
movq %rdx, %rsi
testb $0x1, %dil
je 0x2eeb2
xorpd %xmm2, %xmm2
cmpq $0x2, %rbx
jl 0x2ee7a
movq %rbx, %r10
shrq $0x3f, %r10
addq %rbx, %r10
sarq %r10
movq %r10, %rdi
shlq $0x4, %rdi
leaq (%rsi,%rdi), %rax
xorl %r9d, %r9d
movsd (%rsi,%r9), %xmm3
movsd 0x8(%rsi,%r9), %xmm4
mulsd 0x8(%rcx,%r9), %xmm4
mulsd (%rcx,%r9), %xmm3
addsd %xmm4, %xmm3
addsd %xmm3, %xmm2
addq $0x10, %r9
decq %r10
jne 0x2ee4a
addq %rdi, %rcx
jmp 0x2ee7d
movq %rsi, %rax
testb $0x1, %bl
je 0x2ee8e
movsd (%rax), %xmm3
mulsd (%rcx), %xmm3
addsd %xmm3, %xmm2
xorpd %xmm3, %xmm3
mulsd %xmm0, %xmm2
ucomisd %xmm3, %xmm1
jne 0x2ee9e
jnp 0x2eea9
mulsd (%r8), %xmm1
addsd %xmm2, %xmm1
jmp 0x2eead
movapd %xmm2, %xmm1
movsd %xmm1, (%r8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq