// File: /workspace/github_cpp_makefile_star2_O2/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 0x2c19e
testq %rsi, %rsi
je 0x2be42
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x2be11
jnp 0x2be42
movq %rdx, %r10
movq %rdi, %rax
xorq $0x20, %rax
movq %rsi, %rdx
xorq $0x20, %rdx
orq %rax, %rdx
jne 0x2be8a
movq %r10, %rdi
movq %rcx, %rsi
movq %r8, %rdx
movq %r9, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2bc4f
xorl %eax, %eax
testq %rdi, %rdi
cmovgq %rdi, %rax
xorpd %xmm0, %xmm0
shlq $0x3, %r9
ucomisd %xmm0, %xmm1
jne 0x2be7f
jp 0x2be7f
subq $0x1, %rax
jb 0x2c19e
andq $0x0, (%r8)
addq %r9, %r8
jmp 0x2be5b
movsd (%r8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%r8)
addq %r9, %r8
subq $0x1, %rax
jae 0x2be6e
jmp 0x2c19e
movabsq $0x2, %r14
movq %rdi, %rax
cqto
idivq %r14
movq %rax, %r11
movabsq $0x8, %rbx
movq %rsi, %rax
cqto
idivq %rbx
movq %rax, %rbx
leaq (,%rax,8), %rdx
movq %rsi, %rax
subq %rdx, %rax
cqto
idivq %r14
movq %r9, %rdx
shlq $0x4, %rdx
xorl %r15d, %r15d
testq %rbx, %rbx
cmovleq %r15, %rbx
testq %rax, %rax
cmovleq %r15, %rax
testq %r11, %r11
cmovleq %r15, %r11
cmpq %r11, %r15
je 0x2c11e
leaq 0x100(%r10), %r12
xorpd %xmm3, %xmm3
movq %rbx, %rbp
movq %rcx, %r13
subq $0x1, %rbp
jb 0x2c036
movsd -0x100(%r12), %xmm7
movsd -0xf8(%r12), %xmm8
movsd -0xf0(%r12), %xmm9
movsd -0xe8(%r12), %xmm6
movhpd (%r12), %xmm7           # xmm7 = xmm7[0],mem[0]
movsd (%r13), %xmm10
movsd 0x8(%r13), %xmm11
movsd 0x10(%r13), %xmm5
movsd 0x18(%r13), %xmm4
unpcklpd %xmm10, %xmm10          # xmm10 = xmm10[0,0]
mulpd %xmm7, %xmm10
movhpd 0x8(%r12), %xmm8        # xmm8 = xmm8[0],mem[0]
addpd %xmm3, %xmm10
unpcklpd %xmm11, %xmm11          # xmm11 = xmm11[0,0]
mulpd %xmm8, %xmm11
addpd %xmm10, %xmm11
movhpd 0x10(%r12), %xmm9       # xmm9 = xmm9[0],mem[0]
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm9, %xmm5
addpd %xmm11, %xmm5
movhpd 0x18(%r12), %xmm6       # xmm6 = xmm6[0],mem[0]
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
mulpd %xmm6, %xmm4
movsd -0xe0(%r12), %xmm3
movhpd 0x20(%r12), %xmm3       # xmm3 = xmm3[0],mem[0]
addpd %xmm5, %xmm4
movsd 0x20(%r13), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm3, %xmm5
addpd %xmm4, %xmm5
movsd -0xd8(%r12), %xmm3
movhpd 0x28(%r12), %xmm3       # xmm3 = xmm3[0],mem[0]
movsd 0x28(%r13), %xmm4
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
mulpd %xmm3, %xmm4
addpd %xmm5, %xmm4
movsd -0xd0(%r12), %xmm3
movhpd 0x30(%r12), %xmm3       # xmm3 = xmm3[0],mem[0]
movsd 0x30(%r13), %xmm5
unpcklpd %xmm5, %xmm5            # xmm5 = xmm5[0,0]
mulpd %xmm3, %xmm5
addpd %xmm4, %xmm5
movsd -0xc8(%r12), %xmm4
movhpd 0x38(%r12), %xmm4       # xmm4 = xmm4[0],mem[0]
movsd 0x38(%r13), %xmm3
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm4, %xmm3
addpd %xmm5, %xmm3
addq $0x40, %r12
addq $0x40, %r13
jmp 0x2bf00
addq $-0x100, %r12
movq %rax, %rbp
subq $0x1, %rbp
jb 0x2c095
movsd (%r12), %xmm4
movsd 0x8(%r12), %xmm5
movhpd 0x100(%r12), %xmm4      # xmm4 = xmm4[0],mem[0]
movsd (%r13), %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
mulpd %xmm4, %xmm6
addpd %xmm3, %xmm6
movsd 0x8(%r13), %xmm3
movhpd 0x108(%r12), %xmm5      # xmm5 = xmm5[0],mem[0]
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd %xmm5, %xmm3
addpd %xmm6, %xmm3
addq $0x10, %r12
addq $0x10, %r13
jmp 0x2c040
testb $0x1, %sil
je 0x2c0bd
movsd (%r12), %xmm4
movhpd 0x100(%r12), %xmm4      # xmm4 = xmm4[0],mem[0]
movsd (%r13), %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 0x2c0d1
jnp 0x2c0fd
movsd (%r8), %xmm5
mulsd %xmm1, %xmm5
addsd %xmm3, %xmm5
movsd %xmm5, (%r8)
mulsd %xmm0, %xmm4
movsd (%r8,%r9,8), %xmm3
mulsd %xmm1, %xmm3
addsd %xmm4, %xmm3
movsd %xmm3, (%r8,%r9,8)
jmp 0x2c10c
movsd %xmm3, (%r8)
mulsd %xmm0, %xmm4
movsd %xmm4, (%r8,%r9,8)
addq $0x200, %r10            # imm = 0x200
addq %rdx, %r8
incq %r15
jmp 0x2bee6
testb $0x1, %dil
je 0x2c19e
movq %rsi, %rax
cqto
idivq %r14
xorl %edx, %edx
testq %rax, %rax
cmovleq %rdx, %rax
xorpd %xmm2, %xmm2
subq $0x1, %rax
jb 0x2c165
movsd (%r10,%rdx), %xmm3
movsd 0x8(%r10,%rdx), %xmm4
mulsd 0x8(%rcx,%rdx), %xmm4
mulsd (%rcx,%rdx), %xmm3
addsd %xmm4, %xmm3
addsd %xmm3, %xmm2
addq $0x10, %rdx
jmp 0x2c139
testb $0x1, %sil
je 0x2c17a
movsd (%r10,%rdx), %xmm3
mulsd (%rcx,%rdx), %xmm3
addsd %xmm3, %xmm2
xorpd %xmm3, %xmm3
mulsd %xmm0, %xmm2
ucomisd %xmm3, %xmm1
jne 0x2c18a
jnp 0x2c195
mulsd (%r8), %xmm1
addsd %xmm2, %xmm1
jmp 0x2c199
movapd %xmm2, %xmm1
movsd %xmm1, (%r8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq