// File: /workspace/github_cpp_makefile_star2_O2/mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::_ialglib_rmatrixlefttrsm(long, long, double*, long, bool, bool, long, double*, long)
ae_bool _ialglib_rmatrixlefttrsm(ae_int_t m,
     ae_int_t n,
     double *_a,
     ae_int_t _a_stride,
     ae_bool isupper,
     ae_bool isunit,
     ae_int_t optype,
     double *_x,
     ae_int_t _x_stride)
{
    /*
     * local buffers
     */
    double *pdiag, *arow;
    ae_int_t i;
    double _loc_abuf[alglib_r_block*alglib_r_block+alglib_simd_alignment];
    double _loc_xbuf[alglib_r_block*alglib_r_block+alglib_simd_alignment];
    double _loc_tmpbuf[alglib_r_block+alglib_simd_alignment];
    double * const abuf   = (double * const) ae_align(_loc_abuf,  alglib_simd_alignment);
    double * const xbuf   = (double * const) ae_align(_loc_xbuf,  alglib_simd_alignment);
    double * const tmpbuf = (double * const) ae_align(_loc_tmpbuf,alglib_simd_alignment);
    ae_bool uppera;
    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 )
        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
    
    /*
     * Prepare
     * Transpose X (so we may use mv, which calculates A*x, but not x*A)
     */
    mcopyblock(m, m, _a, optype, _a_stride, abuf);
    mcopyblock(m, n, _x, 1, _x_stride, xbuf);
    if( isunit )
        for(i=0,pdiag=abuf; i<m; i++,pdiag+=alglib_r_block+1)
            *pdiag = 1.0;
    if( optype==0 )
        uppera = isupper;
    else
        uppera = !isupper;

    /*
     * Solve A^-1*Y^T=X^T where A is upper or lower triangular
     */
    if( uppera )
    {
        for(i=m-1,pdiag=abuf+(m-1)*alglib_r_block+(m-1); i>=0; i--,pdiag-=alglib_r_block+1)
        {
            double beta = 1.0/(*pdiag);
            double alpha = -beta;
            _ialglib_vcopy(m-1-i, pdiag+1, 1, tmpbuf+i+1, 1);
            rmv(n, m-1-i, xbuf+i+1, tmpbuf+i+1, xbuf+i, alglib_r_block, alpha, beta);
        }
        _ialglib_mcopyunblock(m, n, xbuf, 1, _x, _x_stride);
    }
    else
    {   for(i=0,pdiag=abuf,arow=abuf; i<m; i++,pdiag+=alglib_r_block+1,arow+=alglib_r_block)
        {
            double beta = 1.0/(*pdiag);
            double alpha = -beta;
            _ialglib_vcopy(i, arow, 1, tmpbuf, 1);
            rmv(n, i, xbuf, tmpbuf, xbuf+i, alglib_r_block, alpha, beta);
        }
        _ialglib_mcopyunblock(m, n, xbuf, 1, _x, _x_stride);
    }
    return ae_true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x42c8, %rsp           # imm = 0x42C8
movl %r8d, %ebx
movq %rcx, %r8
cmpq $0x21, %rdi
setl %cl
cmpq $0x21, %rsi
setl %al
andb %cl, %al
cmpb $0x1, %al
jne 0x2d862
movl %r9d, %ebp
movq %rsi, %r15
movq %rdi, %r12
movb %al, 0x7(%rsp)
movq 0x4308(%rsp), %r13
movq 0x4300(%rsp), %rcx
leaq 0x2240(%rsp), %r14
movq %rdi, %rsi
movq %r14, %r9
callq 0x2c4ad
pushq $0x1
popq %rcx
leaq 0x1c0(%rsp), %r9
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x4310(%rsp), %r8
callq 0x2c4ad
testb %bpl, %bpl
je 0x2d6cd
xorl %eax, %eax
testq %r12, %r12
cmovgq %r12, %rax
leaq 0x2240(%rsp), %rcx
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
subq $0x1, %rax
jb 0x2d6cd
movq %rdx, (%rcx)
addq $0x108, %rcx            # imm = 0x108
jmp 0x2d6bb
movq %r15, 0x8(%rsp)
cmpq $0x0, 0x4300(%rsp)
setne %al
xorb %bl, %al
movq %r12, 0x38(%rsp)
je 0x2d79b
leaq -0x1(%r12), %rbx
movq %rbx, %rax
shlq $0x8, %rax
addq %rsp, %rax
addq $0x2240, %rax           # imm = 0x2240
leaq -0x8(%rax,%r12,8), %rbp
movq %r12, %rax
leaq (%rsp,%r12,8), %r12
addq $0x40, %r12
leaq (%rsp,%rax,8), %r14
addq $0x1c0, %r14            # imm = 0x1C0
xorl %r13d, %r13d
testq %rbx, %rbx
js 0x2d834
movsd 0x2ac9(%rip), %xmm0     # 0x301f8
divsd (%rbp), %xmm0
movapd %xmm0, 0x20(%rsp)
xorpd 0x2a6e(%rip), %xmm0     # 0x301b0
movapd %xmm0, 0x10(%rsp)
leaq 0x8(%rbp), %rsi
movq %r13, %rdi
pushq $0x1
popq %rdx
movq %r12, %rcx
movq %rdx, %r8
callq 0x2c32e
leaq -0x8(%r14), %r15
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
pushq $0x20
popq %r9
movaps 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x2bded
decq %rbx
addq $-0x8, %r12
incq %r13
addq $-0x108, %rbp           # imm = 0xFEF8
movq %r15, %r14
jmp 0x2d71e
xorl %r13d, %r13d
testq %r12, %r12
movl $0x0, %ebx
cmovgq %r12, %rbx
leaq 0x1c0(%rsp), %r12
movq %r14, %rbp
cmpq %r13, %rbx
je 0x2d834
movsd 0x2a36(%rip), %xmm0     # 0x301f8
divsd (%r14), %xmm0
movapd %xmm0, 0x20(%rsp)
xorpd 0x29db(%rip), %xmm0     # 0x301b0
movapd %xmm0, 0x10(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rdx
leaq 0x40(%rsp), %r15
movq %r15, %rcx
movq %rdx, %r8
callq 0x2c32e
movq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0x1c0(%rsp), %rdx
movq %r15, %rcx
movq %r12, %r8
pushq $0x20
popq %r9
movaps 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x2bded
incq %r13
addq $0x108, %r14            # imm = 0x108
addq $0x100, %rbp            # imm = 0x100
addq $0x8, %r12
jmp 0x2d7b5
leaq 0x1c0(%rsp), %rdx
pushq $0x1
popq %rcx
movq 0x38(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x4308(%rsp), %r8
movq 0x4310(%rsp), %r9
callq 0x2c58b
movb 0x7(%rsp), %al
addq $0x42c8, %rsp           # imm = 0x42C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq