// File: /workspace/github_cpp_makefile_star2_O3/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 $0x4b78, %rsp           # imm = 0x4B78
movl %r8d, %r15d
movq %rcx, %r8
cmpq $0x19, %rdi
setl %al
cmpq $0x19, %rsi
setl %cl
andb %al, %cl
movb %cl, 0x17(%rsp)
cmpb $0x1, %cl
jne 0x30940
movl %r9d, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x4bb0(%rsp), %r13
leaq 0x26f0(%rsp), %r12
movq %rdi, %rsi
movq %r13, %rcx
movq %r12, %r9
callq 0x2f376
testq %r14, %r14
jle 0x30940
movq 0x4bc0(%rsp), %r9
movq 0x4bb8(%rsp), %rdx
leaq 0x270(%rsp), %rax
xorl %ecx, %ecx
shlq $0x4, %r9
testq %rbx, %rbx
jle 0x3059d
movq %rbx, %rsi
movq %rax, %rdi
movq %rdx, %r8
movups (%r8), %xmm0
movups %xmm0, (%rdi)
addq $0x180, %rdi            # imm = 0x180
addq $0x10, %r8
decq %rsi
jne 0x30586
incq %rcx
addq %r9, %rdx
addq $0x10, %rax
cmpq %r14, %rcx
jne 0x30578
testq %r14, %r14
setle %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x305dc
leaq 0x26f0(%rsp), %rax
movsd 0x2c15(%rip), %xmm0     # 0x331e0
movq %r14, %rcx
movups %xmm0, (%rax)
addq $0x190, %rax            # imm = 0x190
decq %rcx
jne 0x305ce
testq %r13, %r13
setne %al
xorb %r15b, %al
movq %r9, 0x28(%rsp)
je 0x307ae
testq %r14, %r14
jle 0x30940
movq %rbx, 0x20(%rsp)
leaq -0x1(%r14), %rax
imulq $0x190, %rax, %rax      # imm = 0x190
leaq (%rsp,%rax), %r13
addq $0x26f0, %r13           # imm = 0x26F0
movq %r14, %rax
shlq $0x4, %rax
leaq (%rsp,%rax), %r12
addq $0x270, %r12            # imm = 0x270
xorl %r15d, %r15d
movq %r14, 0x18(%rsp)
movdqu (%r13), %xmm0
movdqa %xmm0, %xmm1
pand 0x5be0(%rip), %xmm1     # 0x36220
pshufd $0xee, %xmm1, %xmm2     # xmm2 = xmm1[2,3,2,3]
ucomisd %xmm2, %xmm1
movdqa %xmm0, %xmm1
punpckhqdq %xmm0, %xmm1    # xmm1 = xmm1[1],xmm0[1]
jbe 0x30681
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
xorpd 0x2b45(%rip), %xmm2     # 0x331b0
movapd 0x469d(%rip), %xmm3     # 0x34d10
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divpd %xmm1, %xmm3
jmp 0x306a2
movdqa %xmm0, %xmm3
divsd %xmm1, %xmm3
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
shufpd $0x2, 0x5ba6(%rip), %xmm3 # xmm3 = xmm3[0],mem[1]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm3
movapd %xmm3, 0x30(%rsp)
movapd %xmm3, %xmm1
movapd 0x2afc(%rip), %xmm0     # 0x331b0
xorpd %xmm0, %xmm1
movapd %xmm1, 0x60(%rsp)
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
movapd %xmm1, 0x50(%rsp)
xorpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
leaq 0x10(%r13), %rsi
movl $0x1, %edx
movl $0x1, %r8d
movq %r15, %rdi
leaq 0x70(%rsp), %rbx
movq %rbx, %rcx
leaq 0x65b7(%rip), %r9       # 0x36cae
callq 0x2f136
leaq -0x10(%r12), %rbp
movq $0x18, (%rsp)
movq 0x20(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
movq %rbp, %r9
movaps 0x60(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x30(%rsp), %xmm2
movaps 0x50(%rsp), %xmm3
callq 0x2eebd
incq %r15
addq $-0x190, %r13           # imm = 0xFE70
movq %rbp, %r12
decq %r14
movq 0x28(%rsp), %r9
jg 0x3062e
movq 0x18(%rsp), %r8
testq %r8, %r8
movq 0x4bb8(%rsp), %r10
movq 0x20(%rsp), %r11
jle 0x30940
leaq 0x270(%rsp), %rax
xorl %ecx, %ecx
testq %r11, %r11
jle 0x3079a
movq %r11, %rdx
movq %r10, %rsi
movq %rax, %rdi
movups (%rdi), %xmm0
movups %xmm0, (%rsi)
addq $0x10, %rsi
addq $0x180, %rdi            # imm = 0x180
decq %rdx
jne 0x30784
incq %rcx
addq $0x10, %rax
addq %r9, %r10
cmpq %r8, %rcx
jne 0x30776
jmp 0x30940
testq %r14, %r14
jle 0x30940
leaq 0x270(%rsp), %rbp
xorl %r13d, %r13d
movq %r12, %r15
movq %r14, 0x18(%rsp)
movdqu (%r15), %xmm0
movdqa %xmm0, %xmm1
pand 0x5a45(%rip), %xmm1     # 0x36220
pshufd $0xee, %xmm1, %xmm2     # xmm2 = xmm1[2,3,2,3]
ucomisd %xmm2, %xmm1
movdqa %xmm0, %xmm1
punpckhqdq %xmm0, %xmm1    # xmm1 = xmm1[1],xmm0[1]
jbe 0x3081c
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
xorpd 0x29aa(%rip), %xmm2     # 0x331b0
movapd 0x4502(%rip), %xmm3     # 0x34d10
unpcklpd %xmm2, %xmm3            # xmm3 = xmm3[0],xmm2[0]
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
divpd %xmm1, %xmm3
jmp 0x3083d
movdqa %xmm0, %xmm3
divsd %xmm1, %xmm3
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
shufpd $0x2, 0x5a0b(%rip), %xmm3 # xmm3 = xmm3[0],mem[1]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm3
movapd %xmm3, 0x30(%rsp)
movapd %xmm3, %xmm1
movapd 0x2961(%rip), %xmm0     # 0x331b0
xorpd %xmm0, %xmm1
movapd %xmm1, 0x60(%rsp)
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
movapd %xmm1, 0x50(%rsp)
xorpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
movl $0x1, %edx
movl $0x1, %r8d
movq %r13, %rdi
movq %r12, %rsi
leaq 0x70(%rsp), %r14
movq %r14, %rcx
leaq 0x641d(%rip), %r9       # 0x36cae
callq 0x2f136
movq $0x18, (%rsp)
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x270(%rsp), %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movq %rbp, %r9
movaps 0x60(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movaps 0x30(%rsp), %xmm2
movaps 0x50(%rsp), %xmm3
callq 0x2eebd
incq %r13
addq $0x190, %r15            # imm = 0x190
addq $0x180, %r12            # imm = 0x180
addq $0x10, %rbp
movq 0x18(%rsp), %r10
cmpq %r13, %r10
movq 0x28(%rsp), %r8
jne 0x307ca
testq %r10, %r10
movq 0x4bb8(%rsp), %r9
jle 0x30940
leaq 0x270(%rsp), %rax
xorl %ecx, %ecx
testq %rbx, %rbx
jle 0x30931
movq %rbx, %rdx
movq %r9, %rsi
movq %rax, %rdi
movups (%rdi), %xmm0
movups %xmm0, (%rsi)
addq $0x10, %rsi
addq $0x180, %rdi            # imm = 0x180
decq %rdx
jne 0x3091b
incq %rcx
addq $0x10, %rax
addq %r8, %r9
cmpq %r10, %rcx
jne 0x3090d
movb 0x17(%rsp), %al
addq $0x4b78, %rsp           # imm = 0x4B78
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq