// File: /workspace/github_cpp_makefile_star2_O1/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 0x2fb1c
movq %rsi, %rbx
testq %rsi, %rsi
je 0x2f71d
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x2f6ec
jnp 0x2f71d
movq %rcx, %r13
movq %rdi, %rax
xorq $0x20, %rax
movq %rbx, %rcx
xorq $0x20, %rcx
orq %rax, %rcx
jne 0x2f752
movq %rdx, %rdi
movq %r13, %rsi
movq %r8, %rdx
movq %r9, %rcx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2f53f
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jne 0x2fa57
jp 0x2fa57
testq %rdi, %rdi
jle 0x2fb1c
shlq $0x3, %r9
movq $0x0, (%r8)
addq %r9, %r8
decq %rdi
jne 0x2f73e
jmp 0x2fb1c
leaq 0x7(%rbx), %rax
testq %rbx, %rbx
cmovnsq %rbx, %rax
cmpq $0x2, %rdi
jl 0x2fa7f
movq %rdi, %rcx
shrq $0x3f, %rcx
addq %rdi, %rcx
sarq %rcx
movq %rcx, -0x8(%rsp)
movq %rax, %rcx
sarq $0x3, %rcx
andq $-0x8, %rax
movq %rbx, %rsi
subq %rax, %rsi
movq %rsi, %rax
shrq $0x3f, %rax
movq %rsi, -0x10(%rsp)
addq %rsi, %rax
sarq %rax
movq %r9, %rsi
shlq $0x4, %rsi
movq %rsi, -0x18(%rsp)
movq %rcx, -0x30(%rsp)
shlq $0x6, %rcx
addq %r13, %rcx
movq %rcx, -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 %r9, -0x20(%rsp)
movq %rdx, -0x28(%rsp)
cmpq $0x8, %rbx
jl 0x2f92a
xorpd %xmm3, %xmm3
movq -0x30(%rsp), %r15
movq %rdx, %rax
xorpd %xmm4, %xmm4
movq %r13, %r10
movsd (%r10), %xmm5
movsd 0x8(%r10), %xmm6
movsd -0x138(%rax,%rbp), %xmm7
mulsd %xmm5, %xmm7
addsd %xmm4, %xmm7
mulsd -0x38(%rax,%rbp), %xmm5
addsd %xmm3, %xmm5
movsd -0x130(%rax,%rbp), %xmm3
mulsd %xmm6, %xmm3
addsd %xmm7, %xmm3
mulsd -0x30(%rax,%rbp), %xmm6
addsd %xmm5, %xmm6
movsd 0x10(%r10), %xmm4
movsd -0x128(%rax,%rbp), %xmm5
mulsd %xmm4, %xmm5
mulsd -0x28(%rax,%rbp), %xmm4
addsd %xmm3, %xmm5
addsd %xmm6, %xmm4
movsd 0x18(%r10), %xmm3
movsd -0x120(%rax,%rbp), %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
mulsd -0x20(%rax,%rbp), %xmm3
addsd %xmm4, %xmm3
movsd 0x20(%r10), %xmm4
movsd -0x118(%rax,%rbp), %xmm5
mulsd %xmm4, %xmm5
addsd %xmm6, %xmm5
mulsd -0x18(%rax,%rbp), %xmm4
addsd %xmm3, %xmm4
movsd 0x28(%r10), %xmm3
movsd -0x110(%rax,%rbp), %xmm6
mulsd %xmm3, %xmm6
addsd %xmm5, %xmm6
mulsd -0x10(%rax,%rbp), %xmm3
addsd %xmm4, %xmm3
movsd 0x30(%r10), %xmm5
movsd -0x108(%rax,%rbp), %xmm7
mulsd %xmm5, %xmm7
mulsd -0x8(%rax,%rbp), %xmm5
addsd %xmm6, %xmm7
addsd %xmm3, %xmm5
movsd 0x38(%r10), %xmm3
movsd -0x100(%rax,%rbp), %xmm4
mulsd %xmm3, %xmm4
addsd %xmm7, %xmm4
mulsd (%rax,%rbp), %xmm3
addsd %xmm5, %xmm3
addq $0x40, %r10
addq $0x40, %rax
decq %r15
jne 0x2f803
movq %rax, %r15
subq %r11, %r15
subq %r12, %rax
movq -0x40(%rsp), %r10
jmp 0x2f93f
leaq 0x100(%rsi), %r15
movq %rsi, %rax
movq %r13, %r10
xorpd %xmm4, %xmm4
xorpd %xmm3, %xmm3
cmpq $0x2, -0x10(%rsp)
jl 0x2f9bf
movq %rbx, %rdx
movq %r13, %r9
movq -0x48(%rsp), %rcx
addq %r15, %rcx
movq -0x38(%rsp), %r13
xorl %ebx, %ebx
movsd (%r10,%rbx), %xmm5
movsd (%rax,%rbx), %xmm6
mulsd %xmm5, %xmm6
mulsd (%r15,%rbx), %xmm5
addsd %xmm3, %xmm5
movsd 0x8(%r10,%rbx), %xmm3
addsd %xmm4, %xmm6
movsd 0x8(%rax,%rbx), %xmm4
mulsd %xmm3, %xmm4
addsd %xmm6, %xmm4
mulsd 0x8(%r15,%rbx), %xmm3
addsd %xmm5, %xmm3
addq $0x10, %rbx
decq %r13
jne 0x2f95c
movq -0x48(%rsp), %rbx
addq %rbx, %rax
addq %rbx, %r10
movq %r9, %r13
movq %rdx, %rbx
movq -0x20(%rsp), %r9
movq -0x28(%rsp), %rdx
jmp 0x2f9c2
movq %r15, %rcx
testb $0x1, %bl
je 0x2f9e0
movsd (%r10), %xmm5
movsd (%rax), %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm4
mulsd (%rcx), %xmm5
addsd %xmm5, %xmm3
ucomisd %xmm2, %xmm1
mulsd %xmm0, %xmm4
jne 0x2f9ec
jnp 0x2fa18
movsd (%r8), %xmm5
mulsd %xmm1, %xmm5
addsd %xmm4, %xmm5
movsd %xmm5, (%r8)
mulsd %xmm0, %xmm3
movsd (%r8,%r9,8), %xmm4
mulsd %xmm1, %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, (%r8,%r9,8)
jmp 0x2fa27
movsd %xmm4, (%r8)
mulsd %xmm0, %xmm3
movsd %xmm3, (%r8,%r9,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 0x2f7e6
jmp 0x2fa82
testq %rdi, %rdi
jle 0x2fb1c
shlq $0x3, %r9
movsd (%r8), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, (%r8)
addq %r9, %r8
decq %rdi
jne 0x2fa64
jmp 0x2fb1c
movq %rdx, %rsi
testb $0x1, %dil
je 0x2fb1c
xorpd %xmm2, %xmm2
cmpq $0x2, %rbx
jl 0x2fae2
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(%r13,%r9), %xmm4
mulsd (%r13,%r9), %xmm3
addsd %xmm4, %xmm3
addsd %xmm3, %xmm2
addq $0x10, %r9
decq %r10
jne 0x2fab1
addq %rdi, %r13
jmp 0x2fae5
movq %rsi, %rax
testb $0x1, %bl
je 0x2faf8
movsd (%rax), %xmm3
mulsd (%r13), %xmm3
addsd %xmm3, %xmm2
xorpd %xmm3, %xmm3
mulsd %xmm0, %xmm2
ucomisd %xmm3, %xmm1
jne 0x2fb08
jnp 0x2fb13
mulsd (%r8), %xmm1
addsd %xmm2, %xmm1
jmp 0x2fb17
movapd %xmm2, %xmm1
movsd %xmm1, (%r8)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq