// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b68, %rsp           # imm = 0x4B68
movl %r8d, %r15d
movq %rcx, %r8
cmpq $0x19, %rdi
setl %cl
cmpq $0x19, %rsi
setl %al
andb %cl, %al
cmpb $0x1, %al
jne 0x3162c
movl %r9d, %ebp
movq %rsi, %rbx
movb %al, 0xf(%rsp)
movq 0x4ba0(%rsp), %r13
leaq 0x26e0(%rsp), %r12
movq %rdi, %rsi
movq %r13, %rcx
movq %r12, %r9
movq %rdi, 0x18(%rsp)
callq 0x30022
movq 0x18(%rsp), %r10
testq %r10, %r10
jle 0x3126d
leaq 0x260(%rsp), %rax
xorl %ecx, %ecx
movq 0x4bb0(%rsp), %rdx
shlq $0x4, %rdx
movq 0x4ba8(%rsp), %rsi
testq %rbx, %rbx
jle 0x3125e
movq %rbx, %rdi
movq %rax, %r8
movq %rsi, %r9
movsd (%r9), %xmm0
movsd %xmm0, (%r8)
movsd 0x8(%r9), %xmm0
movsd %xmm0, 0x8(%r8)
addq $0x180, %r8             # imm = 0x180
addq $0x10, %r9
decq %rdi
jne 0x31238
incq %rcx
addq %rdx, %rsi
addq $0x10, %rax
cmpq %r10, %rcx
jne 0x3122a
testq %r10, %r10
setle %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x312a7
leaq 0x26e0(%rsp), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %r10, %rdx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
addq $0x190, %rax            # imm = 0x190
decq %rdx
jne 0x31291
testq %r13, %r13
setne %al
xorb %r15b, %al
movq %rbx, 0x10(%rsp)
je 0x31485
testq %r10, %r10
jle 0x31411
leaq -0x1(%r10), %rax
imulq $0x190, %rax, %rax      # imm = 0x190
leaq (%rsp,%rax), %r13
addq $0x26e0, %r13           # imm = 0x26E0
movq %r10, %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %r12
addq $0x260, %r12            # imm = 0x260
xorl %r15d, %r15d
movq %r10, %rbx
movsd (%r13), %xmm1
movsd 0x8(%r13), %xmm0
movapd %xmm0, %xmm2
movapd 0x5d96(%rip), %xmm4     # 0x370a0
andpd %xmm4, %xmm2
movapd %xmm1, %xmm3
andpd %xmm4, %xmm3
ucomisd %xmm2, %xmm3
jbe 0x31346
movapd %xmm0, %xmm3
divsd %xmm1, %xmm3
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
movsd 0x2e6c(%rip), %xmm2     # 0x341a0
divsd %xmm0, %xmm2
xorpd 0x2ea0(%rip), %xmm3     # 0x341e0
divsd %xmm0, %xmm3
jmp 0x31366
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
divsd %xmm1, %xmm2
movsd 0x2e6e(%rip), %xmm3     # 0x341d0
divsd %xmm1, %xmm3
movapd %xmm2, 0x20(%rsp)
movapd %xmm3, 0x30(%rsp)
movapd %xmm2, %xmm1
movapd 0x2e62(%rip), %xmm0     # 0x341e0
xorpd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movapd %xmm3, %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
leaq 0x10(%r13), %rsi
movl $0x1, %edx
movl $0x1, %r8d
movq %r15, %rdi
leaq 0x60(%rsp), %r14
movq %r14, %rcx
leaq 0x671b(%rip), %r9       # 0x37ad2
callq 0x2fde2
leaq -0x10(%r12), %rbp
movq $0x18, (%rsp)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movq %rbp, %r9
movaps 0x50(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x20(%rsp), %xmm2
movaps 0x30(%rsp), %xmm3
callq 0x2fb27
incq %r15
addq $-0x190, %r13           # imm = 0xFE70
movq %rbp, %r12
decq %rbx
movq 0x18(%rsp), %r10
jg 0x312f2
testq %r10, %r10
movq 0x10(%rsp), %r8
movb 0xf(%rsp), %al
movq 0x4bb0(%rsp), %r11
movq 0x4ba8(%rsp), %rbx
jle 0x3162c
leaq 0x260(%rsp), %r9
xorl %ecx, %ecx
shlq $0x4, %r11
testq %r8, %r8
jle 0x31471
movq %r8, %rdx
movq %rbx, %rsi
movq %r9, %rdi
movsd (%rdi), %xmm0
movsd %xmm0, (%rsi)
movsd 0x8(%rdi), %xmm0
movsd %xmm0, 0x8(%rsi)
addq $0x10, %rsi
addq $0x180, %rdi            # imm = 0x180
decq %rdx
jne 0x3144f
incq %rcx
addq $0x10, %r9
addq %r11, %rbx
cmpq %r10, %rcx
jne 0x31441
jmp 0x3162c
testq %r10, %r10
jle 0x315c1
leaq 0x260(%rsp), %rbp
xorl %r13d, %r13d
movq %r12, %r15
movsd (%r15), %xmm1
movsd 0x8(%r15), %xmm0
movapd %xmm0, %xmm2
movapd 0x5bed(%rip), %xmm4     # 0x370a0
andpd %xmm4, %xmm2
movapd %xmm1, %xmm3
andpd %xmm4, %xmm3
ucomisd %xmm2, %xmm3
jbe 0x314ef
movapd %xmm0, %xmm3
divsd %xmm1, %xmm3
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
movsd 0x2cc3(%rip), %xmm2     # 0x341a0
divsd %xmm0, %xmm2
xorpd 0x2cf7(%rip), %xmm3     # 0x341e0
divsd %xmm0, %xmm3
jmp 0x3150f
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
divsd %xmm1, %xmm2
movsd 0x2cc5(%rip), %xmm3     # 0x341d0
divsd %xmm1, %xmm3
movapd %xmm2, 0x20(%rsp)
movapd %xmm3, 0x30(%rsp)
movapd %xmm2, %xmm1
movapd 0x2cb9(%rip), %xmm0     # 0x341e0
xorpd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
movapd %xmm3, %xmm1
xorpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
movl $0x1, %edx
movl $0x1, %r8d
movq %r13, %rdi
movq %r12, %rsi
leaq 0x60(%rsp), %rbx
movq %rbx, %rcx
leaq 0x6573(%rip), %r9       # 0x37ad2
callq 0x2fde2
movq $0x18, (%rsp)
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0x260(%rsp), %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
movq %rbp, %r9
movaps 0x50(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x20(%rsp), %xmm2
movaps 0x30(%rsp), %xmm3
callq 0x2fb27
incq %r13
addq $0x190, %r15            # imm = 0x190
addq $0x180, %r12            # imm = 0x180
addq $0x10, %rbp
movq 0x18(%rsp), %r10
cmpq %r13, %r10
jne 0x3149c
testq %r10, %r10
movb 0xf(%rsp), %al
movq 0x4bb0(%rsp), %r9
movq 0x10(%rsp), %r11
movq 0x4ba8(%rsp), %rbx
jle 0x3162c
leaq 0x260(%rsp), %r8
xorl %ecx, %ecx
shlq $0x4, %r9
testq %r11, %r11
jle 0x3161d
movq %r11, %rdx
movq %rbx, %rsi
movq %r8, %rdi
movsd (%rdi), %xmm0
movsd %xmm0, (%rsi)
movsd 0x8(%rdi), %xmm0
movsd %xmm0, 0x8(%rsi)
addq $0x10, %rsi
addq $0x180, %rdi            # imm = 0x180
decq %rdx
jne 0x315fb
incq %rcx
addq $0x10, %r8
addq %r9, %rbx
cmpq %r10, %rcx
jne 0x315ed
addq $0x4b68, %rsp           # imm = 0x4B68
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq