// File: mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::_ialglib_cmatrixlefttrsm(long, long, alglib_impl::ae_complex*, long, bool, bool, long, alglib_impl::ae_complex*, long)
ae_bool _ialglib_cmatrixlefttrsm(ae_int_t m,
     ae_int_t n,
     ae_complex *_a,
     ae_int_t _a_stride,
     ae_bool isupper,
     ae_bool isunit,
     ae_int_t optype,
     ae_complex *_x,
     ae_int_t _x_stride)
{
    /*
     * local buffers
     */
    double *pdiag, *arow;
    ae_int_t i;
    double _loc_abuf[2*alglib_c_block*alglib_c_block+alglib_simd_alignment];
    double _loc_xbuf[2*alglib_c_block*alglib_c_block+alglib_simd_alignment];
    double _loc_tmpbuf[2*alglib_c_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 (*cmv)(ae_int_t, ae_int_t, const double *, const double *, ae_complex *, double *, ae_int_t, ae_complex, ae_complex) = &_ialglib_cmv;
    
    if( m>alglib_c_block || n>alglib_c_block )
        return ae_false;

    /*
     * Check for SSE2 support
     */
#ifdef AE_HAS_SSE2_INTRINSICS
    if( ae_cpuid() & CPU_SSE2 )
    {
        cmv = &_ialglib_cmv_sse2;
    }    
#endif
    
    /*
     * Prepare
     * Transpose X (so we may use mv, which calculates A*x, but not x*A)
     */
    _ialglib_mcopyblock_complex(m, m, _a, optype, _a_stride, abuf);
    _ialglib_mcopyblock_complex(m, n, _x, 1, _x_stride, xbuf);
    if( isunit )
        for(i=0,pdiag=abuf; i<m; i++,pdiag+=2*(alglib_c_block+1))
        {
            pdiag[0] = 1.0;
            pdiag[1] = 0.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+2*((m-1)*alglib_c_block+(m-1)); i>=0; i--,pdiag-=2*(alglib_c_block+1))
        {
            ae_complex tmp_c;
            ae_complex beta;
            ae_complex alpha;
            tmp_c.x = pdiag[0];
            tmp_c.y = pdiag[1];
            beta = ae_c_d_div(1.0, tmp_c);
            alpha.x = -beta.x;
            alpha.y = -beta.y;
            _ialglib_vcopy_dcomplex(m-1-i, pdiag+2, 1, tmpbuf, 1, "No conj");
            cmv(n, m-1-i, xbuf+2*(i+1), tmpbuf, NULL, xbuf+2*i, alglib_c_block, alpha, beta);
        }
        _ialglib_mcopyunblock_complex(m, n, xbuf, 1, _x, _x_stride);
    }
    else
    {   for(i=0,pdiag=abuf,arow=abuf; i<m; i++,pdiag+=2*(alglib_c_block+1),arow+=2*alglib_c_block)
        {
            ae_complex tmp_c;
            ae_complex beta;
            ae_complex alpha;
            tmp_c.x = pdiag[0];
            tmp_c.y = pdiag[1];
            beta = ae_c_d_div(1.0, tmp_c);
            alpha.x = -beta.x;
            alpha.y = -beta.y;
            _ialglib_vcopy_dcomplex(i, arow, 1, tmpbuf, 1, "No conj");
            cmv(n, i, xbuf, tmpbuf, NULL, xbuf+2*i, alglib_c_block, alpha, beta);
        }
        _ialglib_mcopyunblock_complex(m, n, xbuf, 1, _x, _x_stride);
    }
    return ae_true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c80, %rsp           # imm = 0x4C80
movl %r8d, -0x4c74(%rbp)
movq %rcx, %rax
movl -0x4c74(%rbp), %ecx
movq %rax, -0x4c70(%rbp)
movq %rdx, %rax
movq -0x4c70(%rbp), %rdx
movq %rax, -0x4c68(%rbp)
movq %rsi, %rax
movq -0x4c68(%rbp), %rsi
movq %rax, -0x4c60(%rbp)
movq %rdi, %r8
movq -0x4c60(%rbp), %rdi
movb %r9b, %al
movq 0x20(%rbp), %r9
movq 0x18(%rbp), %r9
movq 0x10(%rbp), %r9
movq %r8, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
andb $0x1, %cl
movb %cl, -0x29(%rbp)
andb $0x1, %al
movb %al, -0x2a(%rbp)
leaq -0x24d0(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4b58(%rbp)
leaq -0x4950(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4b60(%rbp)
leaq -0x4b50(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4b68(%rbp)
leaq -0x24b7(%rip), %rax     # 0x4d780
movq %rax, -0x4b78(%rbp)
cmpq $0x18, -0x10(%rbp)
jg 0x4fc4c
cmpq $0x18, -0x18(%rbp)
jle 0x4fc55
movb $0x0, -0x1(%rbp)
jmp 0x5016b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq 0x10(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x4b58(%rbp), %r9
callq 0x4e410
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x18(%rbp), %rdx
movq 0x20(%rbp), %r8
movq -0x4b60(%rbp), %r9
movl $0x1, %ecx
callq 0x4e410
testb $0x1, -0x2a(%rbp)
je 0x4fcf3
movq $0x0, -0x48(%rbp)
movq -0x4b58(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x4fcf1
movq -0x38(%rbp), %rax
movsd 0x5343(%rip), %xmm0     # 0x55008
movsd %xmm0, (%rax)
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rax)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x38(%rbp)
jmp 0x4fcaf
jmp 0x4fcf3
cmpq $0x0, 0x10(%rbp)
jne 0x4fd07
movb -0x29(%rbp), %al
andb $0x1, %al
movb %al, -0x4b69(%rbp)
jmp 0x4fd14
movb -0x29(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x4b69(%rbp)
testb $0x1, -0x4b69(%rbp)
je 0x4ff5e
movq -0x10(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x4b58(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
imulq $0x18, %rcx, %rcx
movq -0x10(%rbp), %rdx
subq $0x1, %rdx
addq %rdx, %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x48(%rbp)
jl 0x4ff38
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x4b88(%rbp)
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x4b80(%rbp)
movq -0x4b88(%rbp), %rax
movq %rax, -0x4bc8(%rbp)
movq -0x4b80(%rbp), %rax
movq %rax, -0x4bc0(%rbp)
movsd -0x4bc8(%rbp), %xmm1
movsd -0x4bc0(%rbp), %xmm2
movsd 0x524f(%rip), %xmm0     # 0x55008
callq 0x3f980
movsd %xmm0, -0x4bb8(%rbp)
movsd %xmm1, -0x4bb0(%rbp)
movq -0x4bb8(%rbp), %rax
movq %rax, -0x4b98(%rbp)
movq -0x4bb0(%rbp), %rax
movq %rax, -0x4b90(%rbp)
movsd -0x4b98(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x4ba8(%rbp)
movsd -0x4b90(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x4ba0(%rbp)
movq -0x10(%rbp), %rdi
subq $0x1, %rdi
subq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
addq $0x10, %rsi
movq -0x4b68(%rbp), %rcx
movl $0x1, %r8d
leaq 0x86f6(%rip), %r9       # 0x58556
movq %r8, %rdx
callq 0x4dea0
movq -0x4b78(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
subq $0x1, %rsi
subq -0x48(%rbp), %rsi
movq -0x4b60(%rbp), %rdx
movq -0x48(%rbp), %rcx
addq $0x1, %rcx
shlq %rcx
shlq $0x3, %rcx
addq %rcx, %rdx
movq -0x4b68(%rbp), %rcx
movq -0x4b60(%rbp), %r9
movq -0x48(%rbp), %r8
shlq %r8
shlq $0x3, %r8
addq %r8, %r9
movq -0x4ba8(%rbp), %r8
movq %r8, -0x4bd8(%rbp)
movq -0x4ba0(%rbp), %r8
movq %r8, -0x4bd0(%rbp)
movq -0x4b98(%rbp), %r8
movq %r8, -0x4be8(%rbp)
movq -0x4b90(%rbp), %r8
movq %r8, -0x4be0(%rbp)
movsd -0x4bd8(%rbp), %xmm0
movsd -0x4bd0(%rbp), %xmm1
movsd -0x4be8(%rbp), %xmm2
movsd -0x4be0(%rbp), %xmm3
xorl %r8d, %r8d
movq $0x18, (%rsp)
callq *%rax
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $-0x190, %rax           # imm = 0xFE70
movq %rax, -0x38(%rbp)
jmp 0x4fd59
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x4b60(%rbp), %rdx
movq 0x18(%rbp), %r8
movq 0x20(%rbp), %r9
movl $0x1, %ecx
callq 0x4e780
jmp 0x50167
movq $0x0, -0x48(%rbp)
movq -0x4b58(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x4b58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x50146
movq -0x38(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x4bf8(%rbp)
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x4bf0(%rbp)
movq -0x4bf8(%rbp), %rax
movq %rax, -0x4c38(%rbp)
movq -0x4bf0(%rbp), %rax
movq %rax, -0x4c30(%rbp)
movsd -0x4c38(%rbp), %xmm1
movsd -0x4c30(%rbp), %xmm2
movsd 0x5029(%rip), %xmm0     # 0x55008
callq 0x3f980
movsd %xmm0, -0x4c28(%rbp)
movsd %xmm1, -0x4c20(%rbp)
movq -0x4c28(%rbp), %rax
movq %rax, -0x4c08(%rbp)
movq -0x4c20(%rbp), %rax
movq %rax, -0x4c00(%rbp)
movsd -0x4c08(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x4c18(%rbp)
movsd -0x4c00(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x4c10(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x4b68(%rbp), %rcx
movl $0x1, %r8d
leaq 0x84dc(%rip), %r9       # 0x58556
movq %r8, %rdx
callq 0x4dea0
movq -0x4b78(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x4b60(%rbp), %rdx
movq -0x4b68(%rbp), %rcx
movq -0x4b60(%rbp), %r9
movq -0x48(%rbp), %r8
shlq %r8
shlq $0x3, %r8
addq %r8, %r9
movq -0x4c18(%rbp), %r8
movq %r8, -0x4c48(%rbp)
movq -0x4c10(%rbp), %r8
movq %r8, -0x4c40(%rbp)
movq -0x4c08(%rbp), %r8
movq %r8, -0x4c58(%rbp)
movq -0x4c00(%rbp), %r8
movq %r8, -0x4c50(%rbp)
movsd -0x4c48(%rbp), %xmm0
movsd -0x4c40(%rbp), %xmm1
movsd -0x4c58(%rbp), %xmm2
movsd -0x4c50(%rbp), %xmm3
xorl %r8d, %r8d
movq $0x18, (%rsp)
callq *%rax
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $0x190, %rax            # imm = 0x190
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x40(%rbp)
jmp 0x4ff7c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x4b60(%rbp), %rdx
movq 0x18(%rbp), %r8
movq 0x20(%rbp), %r9
movl $0x1, %ecx
callq 0x4e780
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x4c80, %rsp           # imm = 0x4C80
popq %rbp
retq
nopl (%rax)