// File: mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::_ialglib_rmatrixgemm(long, long, long, double, double*, long, long, double*, long, long, double, double*, long)
ae_bool _ialglib_rmatrixgemm(ae_int_t m,
     ae_int_t n,
     ae_int_t k,
     double alpha,
     double *_a,
     ae_int_t _a_stride,
     ae_int_t optypea,
     double *_b,
     ae_int_t _b_stride,
     ae_int_t optypeb,
     double beta,
     double *_c,
     ae_int_t _c_stride)
{
    int i;
    double *crow;
    double __abuf[alglib_r_block+alglib_simd_alignment];
    double __b[alglib_r_block*alglib_r_block+alglib_simd_alignment];
    double * const abuf = (double * const) ae_align(__abuf,alglib_simd_alignment);
    double * const b    = (double * const) ae_align(__b,   alglib_simd_alignment);
    void (*rmv)(ae_int_t, ae_int_t, const double *, const double *, double *, ae_int_t, double, double) = &_ialglib_rmv;
    void (*mcopyblock)(ae_int_t, ae_int_t, const double *, ae_int_t, ae_int_t, double *) = &_ialglib_mcopyblock;
    
    if( m>alglib_r_block || n>alglib_r_block || k>alglib_r_block || m<=0 || n<=0 || k<=0 || alpha==0.0 )
        return ae_false;

    /*
     * Check for SSE2 support
     */
#ifdef AE_HAS_SSE2_INTRINSICS
    if( ae_cpuid() & CPU_SSE2 )
    {
        rmv = &_ialglib_rmv_sse2;
        mcopyblock = &_ialglib_mcopyblock_sse2;
    }
#endif
    
    /*
     * copy b
     */
    if( optypeb==0 )
        mcopyblock(k, n, _b, 1, _b_stride, b);
    else
        mcopyblock(n, k, _b, 0, _b_stride, b);

    /*
     * multiply B by A (from the right, by rows)
     * and store result in C
     */
    crow  = _c;
    if( optypea==0 )
    {
        const double *arow = _a;
        for(i=0; i<m; i++)
        {
            _ialglib_vcopy(k, arow, 1, abuf, 1);
            if( beta==0 )
                _ialglib_vzero(n, crow, 1);
            rmv(n, k, b, abuf, crow, 1, alpha, beta);
            crow += _c_stride;
            arow += _a_stride;
        }
    }
    else
    {
        const double *acol = _a;
        for(i=0; i<m; i++)
        {
            _ialglib_vcopy(k, acol, _a_stride, abuf, 1);
            if( beta==0 )
                _ialglib_vzero(n, crow, 1);
            rmv(n, k, b, abuf, crow, 1, alpha, beta);
            crow += _c_stride;
            acol++;
        }
    }
    return ae_true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2290, %rsp           # imm = 0x2290
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movsd %xmm1, -0x48(%rbp)
leaq -0x1e0(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x2268(%rbp)
leaq -0x2260(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x2270(%rbp)
leaq -0x1c88(%rip), %rax     # 0x4cee0
movq %rax, -0x2278(%rbp)
leaq -0xba6(%rip), %rax      # 0x4dfd0
movq %rax, -0x2280(%rbp)
cmpq $0x20, -0x10(%rbp)
jg 0x4ebb7
cmpq $0x20, -0x18(%rbp)
jg 0x4ebb7
cmpq $0x20, -0x20(%rbp)
jg 0x4ebb7
cmpq $0x0, -0x10(%rbp)
jle 0x4ebb7
cmpq $0x0, -0x18(%rbp)
jle 0x4ebb7
cmpq $0x0, -0x20(%rbp)
jle 0x4ebb7
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4ebc0
jp 0x4ebc0
movb $0x0, -0x1(%rbp)
jmp 0x4edbd
cmpq $0x0, 0x20(%rbp)
jne 0x4ebee
movq -0x2280(%rbp), %rax
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %r8
movq -0x2270(%rbp), %r9
movl $0x1, %ecx
callq *%rax
jmp 0x4ec10
movq -0x2280(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %r8
movq -0x2270(%rbp), %r9
xorl %ecx, %ecx
callq *%rax
movq 0x28(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x4ecf1
movq -0x30(%rbp), %rax
movq %rax, -0x2288(%rbp)
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x4ecec
movq -0x20(%rbp), %rdi
movq -0x2288(%rbp), %rsi
movq -0x2268(%rbp), %rcx
movl $0x1, %r8d
movq %r8, %rdx
callq 0x4dc60
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4ec85
jp 0x4ec85
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0x4db20
movq -0x2278(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x2270(%rbp), %rdx
movq -0x2268(%rbp), %rcx
movq -0x58(%rbp), %r8
movsd -0x28(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movl $0x1, %r9d
callq *%rax
movq 0x30(%rbp), %rax
shlq $0x3, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rax
shlq $0x3, %rax
addq -0x2288(%rbp), %rax
movq %rax, -0x2288(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4ec35
jmp 0x4edb9
movq -0x30(%rbp), %rax
movq %rax, -0x2290(%rbp)
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x4edb7
movq -0x20(%rbp), %rdi
movq -0x2290(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x2268(%rbp), %rcx
movl $0x1, %r8d
callq 0x4dc60
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4ed54
jp 0x4ed54
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0x4db20
movq -0x2278(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x2270(%rbp), %rdx
movq -0x2268(%rbp), %rcx
movq -0x58(%rbp), %r8
movsd -0x28(%rbp), %xmm0
movsd -0x48(%rbp), %xmm1
movl $0x1, %r9d
callq *%rax
movq 0x30(%rbp), %rax
shlq $0x3, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x2290(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x2290(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x4ed03
jmp 0x4edb9
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x2290, %rsp           # imm = 0x2290
popq %rbp
retq
nopl (%rax,%rax)