// File: /workspace/github_cpp_makefile_star2_O3/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 $0x42a8, %rsp           # imm = 0x42A8
cmpq $0x21, %rdi
setl %al
cmpq $0x21, %rsi
setl %bpl
andb %al, %bpl
cmpb $0x1, %bpl
jne 0x30d86
movl %r9d, %r15d
movl %r8d, %r12d
movq %rcx, %r8
movq %rsi, %rbx
movq %rdi, %r14
movq 0x42e0(%rsp), %rcx
leaq 0x2220(%rsp), %r13
movq %rdi, %rsi
movq %r13, %r9
callq 0x2f1b2
testq %r14, %r14
jle 0x30d86
movq 0x42f0(%rsp), %r9
movq 0x42e8(%rsp), %rdx
movq %rbx, %rax
shrq $0x3f, %rax
addq %rbx, %rax
sarq %rax
movq %rax, 0x10(%rsp)
leaq 0x1a0(%rsp), %rax
xorl %ecx, %ecx
movq %rdx, %rdi
movq %rax, %rsi
cmpq $0x2, %rbx
jl 0x30a1e
movq 0x10(%rsp), %r8
movq %rax, %rsi
movq %rdx, %rdi
movsd (%rdi), %xmm0
movsd %xmm0, (%rsi)
movq 0x8(%rdi), %xmm0
movq %xmm0, 0x100(%rsi)
addq $0x200, %rsi            # imm = 0x200
addq $0x10, %rdi
decq %r8
jne 0x309f9
testb $0x1, %bl
je 0x30a2b
movq (%rdi), %xmm0
movq %xmm0, (%rsi)
incq %rcx
leaq (%rdx,%r9,8), %rdx
addq $0x8, %rax
cmpq %r14, %rcx
jne 0x309e2
testq %r14, %r14
setle %al
xorb $0x1, %r15b
orb %al, %r15b
jne 0x30af5
leaq 0x1(%r14), %rax
andq $-0x2, %rax
leaq -0x1(%r14), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x2220(%rsp), %rcx
xorl %edx, %edx
movdqa 0x57da(%rip), %xmm1     # 0x36250
movdqa 0x57e2(%rip), %xmm2     # 0x36260
pxor %xmm2, %xmm0
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
pcmpeqd %xmm3, %xmm3
movq %rdx, %xmm4
pshufd $0x44, %xmm4, %xmm4     # xmm4 = xmm4[0,1,0,1]
por %xmm1, %xmm4
pxor %xmm2, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm0, %xmm5
pcmpeqd %xmm0, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %edi
notl %edi
testb $0x1, %dil
je 0x30acf
movq %rsi, (%rcx)
pxor %xmm3, %xmm4
pextrw $0x4, %xmm4, %edi
testb $0x1, %dil
je 0x30ae5
movq %rsi, 0x108(%rcx)
addq $0x2, %rdx
addq $0x210, %rcx            # imm = 0x210
cmpq %rdx, %rax
jne 0x30a90
cmpq $0x0, 0x42e0(%rsp)
setne %al
xorb %r12b, %al
je 0x30c4e
testq %r14, %r14
jle 0x30d86
leaq -0x1(%r14), %r12
movq %r12, %rax
shlq $0x8, %rax
addq %rsp, %rax
addq $0x2220, %rax           # imm = 0x2220
leaq (%rax,%r12,8), %r13
movq %r12, %r15
movq %r12, %rsi
subq %r15, %rsi
leaq 0x8(%r13), %rax
leaq 0x28(%rsp), %rcx
leaq (%rcx,%r15,8), %rcx
cmpq $0x2, %rsi
jae 0x30b4c
movq %rcx, %rdx
jmp 0x30b6a
movq %rsi, %rdi
shrq %rdi
movq %rcx, %rdx
movdqu (%rax), %xmm0
movdqu %xmm0, (%rdx)
addq $0x10, %rax
addq $0x10, %rdx
decq %rdi
jne 0x30b55
testb $0x1, %sil
je 0x30b78
movq (%rax), %xmm0
movq %xmm0, (%rdx)
movsd 0x2660(%rip), %xmm1     # 0x331e0
divsd (%r13), %xmm1
movapd %xmm1, %xmm0
xorpd 0x261e(%rip), %xmm0     # 0x331b0
leaq (%rsp,%r15,8), %r8
addq $0x1a0, %r8             # imm = 0x1A0
leaq (%rsp,%r15,8), %rdx
addq $0x1a8, %rdx            # imm = 0x1A8
movl $0x20, %r9d
movq %rbx, %rdi
callq 0x2ea57
leaq -0x1(%r15), %rax
addq $-0x108, %r13           # imm = 0xFEF8
testq %r15, %r15
movq %rax, %r15
movq 0x42f0(%rsp), %r8
jg 0x30b2e
testq %r14, %r14
movq 0x42e8(%rsp), %r9
jle 0x30d86
leaq 0x1a0(%rsp), %rax
xorl %ecx, %ecx
movq %rax, %rsi
movq %r9, %rdx
cmpq $0x2, %rbx
jl 0x30c2c
movq 0x10(%rsp), %rdi
movq %r9, %rdx
movq %rax, %rsi
movsd (%rsi), %xmm0
movsd %xmm0, (%rdx)
movq 0x100(%rsi), %xmm0
movq %xmm0, 0x8(%rdx)
addq $0x10, %rdx
addq $0x200, %rsi            # imm = 0x200
decq %rdi
jne 0x30c07
testb $0x1, %bl
je 0x30c39
movq (%rsi), %xmm0
movq %xmm0, (%rdx)
incq %rcx
addq $0x8, %rax
leaq (%r9,%r8,8), %r9
cmpq %r14, %rcx
jne 0x30bf0
jmp 0x30d86
testq %r14, %r14
jle 0x30d86
movq %rbx, 0x18(%rsp)
movb %bpl, 0xf(%rsp)
xorl %esi, %esi
leaq 0x20(%rsp), %rbx
leaq 0x1a0(%rsp), %r12
movq %r13, %r15
movq %rbx, %rax
movq %r13, %r8
cmpq $0x2, %rsi
jb 0x30ca1
movq %rsi, %rdx
shrq %rdx
movq %r13, %r8
movq %rbx, %rax
movdqu (%r8), %xmm0
movdqu %xmm0, (%rax)
addq $0x10, %r8
addq $0x10, %rax
decq %rdx
jne 0x30c8b
movq %r14, %rbp
testb $0x1, %sil
movq 0x18(%rsp), %rdi
je 0x30cb8
movq (%r8), %xmm0
movq %xmm0, (%rax)
movsd 0x2520(%rip), %xmm1     # 0x331e0
divsd (%r15), %xmm1
movapd %xmm1, %xmm0
xorpd 0x24df(%rip), %xmm0     # 0x331b0
leaq 0x1(%rsi), %r14
leaq 0x1a0(%rsp,%rsi,8), %r8
movl $0x20, %r9d
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2ea57
addq $0x108, %r15            # imm = 0x108
addq $0x100, %r13            # imm = 0x100
movq %r14, %rsi
cmpq %rbp, %r14
movq %rbp, %r14
movq 0x42f0(%rsp), %rdi
jne 0x30c73
testq %r14, %r14
movb 0xf(%rsp), %bpl
movq 0x42e8(%rsp), %r8
movq 0x18(%rsp), %r9
jle 0x30d86
xorl %eax, %eax
movq %r12, %rdx
movq %r8, %rcx
cmpq $0x2, %r9
jl 0x30d68
movq 0x10(%rsp), %rsi
movq %r8, %rcx
movq %r12, %rdx
movsd (%rdx), %xmm0
movsd %xmm0, (%rcx)
movq 0x100(%rdx), %xmm0
movq %xmm0, 0x8(%rcx)
addq $0x10, %rcx
addq $0x200, %rdx            # imm = 0x200
decq %rsi
jne 0x30d43
testb $0x1, %r9b
je 0x30d76
movq (%rdx), %xmm0
movq %xmm0, (%rcx)
incq %rax
addq $0x8, %r12
leaq (%r8,%rdi,8), %r8
cmpq %r14, %rax
jne 0x30d2c
movl %ebp, %eax
addq $0x42a8, %rsp           # imm = 0x42A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq