// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::_ialglib_cmatrixsyrk(long, long, double, alglib_impl::ae_complex*, long, long, double, alglib_impl::ae_complex*, long, bool)
ae_bool _ialglib_cmatrixsyrk(ae_int_t n,
     ae_int_t k,
     double alpha,
     ae_complex *_a,
     ae_int_t _a_stride,
     ae_int_t optypea,
     double beta,
     ae_complex *_c,
     ae_int_t _c_stride,
     ae_bool isupper)
{
    /*
     * local buffers
     */
    double *arow, *crow;
    ae_complex c_alpha, c_beta;
    ae_int_t i;
    double _loc_abuf[2*alglib_c_block*alglib_c_block+alglib_simd_alignment];
    double _loc_cbuf[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 cbuf   = (double * const) ae_align(_loc_cbuf,  alglib_simd_alignment);
    double * const tmpbuf = (double * const) ae_align(_loc_tmpbuf,alglib_simd_alignment);

    if( n>alglib_c_block || k>alglib_c_block )
        return ae_false;
    if( n==0 )
        return ae_true;

    /*
     * copy A and C, task is transformed to "A*A^H"-form.
     * if beta==0, then C is filled by zeros (and not referenced)
     *
     * alpha==0 or k==0 are correctly processed (A is not referenced)
     */
    c_alpha.x = alpha;
    c_alpha.y = 0;
    c_beta.x = beta;
    c_beta.y = 0;
    if( alpha==0 )
        k = 0;
    if( k>0 )
    {
        if( optypea==0 )
            _ialglib_mcopyblock_complex(n, k, _a, 3, _a_stride, abuf);
        else
            _ialglib_mcopyblock_complex(k, n, _a, 1, _a_stride, abuf);
    }
    _ialglib_mcopyblock_complex(n, n, _c, 0, _c_stride, cbuf);
    if( beta==0 )
    {
        for(i=0,crow=cbuf; i<n; i++,crow+=2*alglib_c_block)
            if( isupper )
                _ialglib_vzero(2*(n-i), crow+2*i, 1);
            else
                _ialglib_vzero(2*(i+1), crow, 1);
    }


    /*
     * update C
     */
    if( isupper )
    {
        for(i=0,arow=abuf,crow=cbuf; i<n; i++,arow+=2*alglib_c_block,crow+=2*alglib_c_block)
        {
            _ialglib_vcopy_dcomplex(k, arow, 1, tmpbuf, 1, "Conj");
            _ialglib_cmv(n-i, k, arow, tmpbuf, NULL, crow+2*i, 1, c_alpha, c_beta);
        }
    }
    else
    {
        for(i=0,arow=abuf,crow=cbuf; i<n; i++,arow+=2*alglib_c_block,crow+=2*alglib_c_block)
        {
            _ialglib_vcopy_dcomplex(k, arow, 1, tmpbuf, 1, "Conj");
            _ialglib_cmv(i+1, k, abuf, tmpbuf, NULL, crow, 1, c_alpha, c_beta);
        }
    }

    /*
     * copy back
     */
    _ialglib_mcopyunblock_complex(n, n, cbuf, 0, _c, _c_stride);

    return ae_true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4b48, %rsp           # imm = 0x4B48
movq %r9, %rbx
cmpq $0x19, %rdi
setl %r9b
cmpq $0x19, %rsi
setl %al
andb %r9b, %al
movl %eax, %r10d
xorb $0x1, %r10b
testq %rdi, %rdi
sete %r9b
orb %r10b, %r9b
jne 0x31ddb
xorl %r14d, %r14d
movapd %xmm0, %xmm2
xorpd %xmm0, %xmm0
movsd %xmm2, 0x30(%rsp)
ucomisd %xmm0, %xmm2
cmovneq %rsi, %r14
cmovpq %rsi, %r14
testq %r14, %r14
jle 0x31b2a
testq %r8, %r8
je 0x31ad0
leaq 0x26c0(%rsp), %r11
xorl %esi, %esi
shlq $0x4, %rcx
testq %rdi, %rdi
jle 0x31abf
movq %rdi, %r10
movq %r11, %r8
movq %rdx, %r9
movsd (%r9), %xmm0
movsd %xmm0, (%r8)
movsd 0x8(%r9), %xmm0
movsd %xmm0, 0x8(%r8)
addq $0x180, %r8             # imm = 0x180
addq $0x10, %r9
decq %r10
jne 0x31a99
incq %rsi
addq %rcx, %rdx
addq $0x10, %r11
cmpq %r14, %rsi
jne 0x31a8b
jmp 0x31b2a
testq %rdi, %rdi
jle 0x31b2a
shlq $0x4, %rcx
leaq 0x26c0(%rsp), %r10
xorl %esi, %esi
movapd 0x26f5(%rip), %xmm0     # 0x341e0
movq %r14, %r9
xorl %r8d, %r8d
movsd (%rdx,%r8), %xmm2
movsd %xmm2, (%r10,%r8)
movsd 0x8(%rdx,%r8), %xmm2
xorpd %xmm0, %xmm2
movlpd %xmm2, 0x8(%r10,%r8)
addq $0x10, %r8
decq %r9
jne 0x31af1
incq %rsi
addq $0x180, %r10            # imm = 0x180
addq %rcx, %rdx
cmpq %rdi, %rsi
jne 0x31aeb
movq 0x4b80(%rsp), %r10
testq %rdi, %rdi
jle 0x31b83
shlq $0x4, %r10
leaq 0x240(%rsp), %rcx
xorl %edx, %edx
movq %rbx, %rsi
movq %rdi, %r9
xorl %r8d, %r8d
movsd (%rsi,%r8), %xmm0
movsd %xmm0, (%rcx,%r8)
movsd 0x8(%rsi,%r8), %xmm0
movsd %xmm0, 0x8(%rcx,%r8)
addq $0x10, %r8
decq %r9
jne 0x31b4e
incq %rdx
addq $0x180, %rcx            # imm = 0x180
addq %r10, %rsi
cmpq %rdi, %rdx
jne 0x31b48
movq %r14, 0x28(%rsp)
movb %al, 0x17(%rsp)
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
setp %al
setne %cl
orb %al, %cl
movq %rdi, 0x18(%rsp)
testq %rdi, %rdi
setle %al
orb %cl, %al
movsd %xmm1, 0x38(%rsp)
jne 0x31c2e
movq 0x18(%rsp), %r12
movq %r12, %rax
shlq $0x4, %rax
leaq 0x240(%rsp), %r15
movl $0x10, %ebp
movl $0x2, %r14d
movq %r15, %r13
cmpb $0x0, 0x4b88(%rsp)
je 0x31bf3
testq %r12, %r12
jle 0x31c0f
movq %r15, %rdi
xorl %esi, %esi
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdx
jmp 0x31c05
testq %r14, %r14
jle 0x31c0f
movq %r13, %rdi
xorl %esi, %esi
movq %rax, 0x20(%rsp)
movq %rbp, %rdx
callq 0x3170
movq 0x20(%rsp), %rax
addq $0x180, %r13            # imm = 0x180
addq $0x190, %r15            # imm = 0x190
addq $-0x10, %rax
addq $0x10, %rbp
addq $0x2, %r14
decq %r12
jne 0x31bd3
cmpb $0x0, 0x4b88(%rsp)
je 0x31cd1
cmpq $0x0, 0x18(%rsp)
movq 0x28(%rsp), %r14
jle 0x31d7f
leaq 0x26c0(%rsp), %r12
leaq 0x240(%rsp), %r13
leaq 0x40(%rsp), %rbp
movq 0x18(%rsp), %r15
movl $0x1, %edx
movl $0x1, %r8d
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rcx
leaq 0x51dc(%rip), %r9       # 0x36e5e
callq 0x2fde2
movq $0x1, (%rsp)
xorpd %xmm1, %xmm1
xorps %xmm3, %xmm3
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
movq %r13, %r9
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
callq 0x2fb27
addq $0x180, %r12            # imm = 0x180
addq $0x190, %r13            # imm = 0x190
decq %r15
jne 0x31c67
jmp 0x31d7f
cmpq $0x0, 0x18(%rsp)
movq 0x28(%rsp), %r13
jle 0x31d7f
movq 0x18(%rsp), %rax
negq %rax
movq %rax, 0x20(%rsp)
leaq 0x240(%rsp), %r12
leaq 0x26c0(%rsp), %r15
movl $0x1, %ebp
movl $0x1, %edx
movl $0x1, %r8d
movq %r13, %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %r14
movq %r14, %rcx
leaq 0x513a(%rip), %r9       # 0x36e5e
callq 0x2fde2
movq $0x1, (%rsp)
xorpd %xmm1, %xmm1
xorps %xmm3, %xmm3
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x26c0(%rsp), %rdx
movq %r14, %rcx
xorl %r8d, %r8d
movq %r12, %r9
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm2
callq 0x2fb27
movl $0x180, %eax            # imm = 0x180
addq %rax, %r15
addq %rax, %r12
movq 0x20(%rsp), %rax
addq %rbp, %rax
incq %rax
incq %rbp
cmpq $0x1, %rax
jne 0x31d04
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
movb 0x17(%rsp), %al
movq 0x4b80(%rsp), %r9
jle 0x31ddb
shlq $0x4, %r9
leaq 0x240(%rsp), %r8
xorl %ecx, %ecx
movq %rdi, %rdx
xorl %esi, %esi
movsd (%r8,%rsi), %xmm0
movsd %xmm0, (%rbx,%rsi)
movsd 0x8(%r8,%rsi), %xmm0
movsd %xmm0, 0x8(%rbx,%rsi)
addq $0x10, %rsi
decq %rdx
jne 0x31da8
incq %rcx
addq $0x180, %r8             # imm = 0x180
addq %r9, %rbx
cmpq %rdi, %rcx
jne 0x31da3
addq $0x4b48, %rsp           # imm = 0x4B48
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq