// File: 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
movq %rsp, %rbp
subq $0x4bf0, %rsp           # imm = 0x4BF0
movb 0x18(%rbp), %al
movq 0x10(%rbp), %r10
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movsd %xmm1, -0x40(%rbp)
movq %r9, -0x48(%rbp)
andb $0x1, %al
movb %al, -0x49(%rbp)
leaq -0x2510(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4b98(%rbp)
leaq -0x4990(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4ba0(%rbp)
leaq -0x4b90(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4ba8(%rbp)
cmpq $0x18, -0x10(%rbp)
jg 0x5066f
cmpq $0x18, -0x18(%rbp)
jle 0x50678
movb $0x0, -0x1(%rbp)
jmp 0x50a40
cmpq $0x0, -0x10(%rbp)
jne 0x50688
movb $0x1, -0x1(%rbp)
jmp 0x50a40
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x506c4
jp 0x506c4
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jle 0x50718
cmpq $0x0, -0x38(%rbp)
jne 0x506f5
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %r8
movq -0x4b98(%rbp), %r9
movl $0x3, %ecx
callq 0x4e410
jmp 0x50716
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %r8
movq -0x4b98(%rbp), %r9
movl $0x1, %ecx
callq 0x4e410
jmp 0x50718
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x10(%rbp), %r8
movq -0x4ba0(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
callq 0x4e410
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x507ed
jp 0x507ed
movq $0x0, -0x88(%rbp)
movq -0x4ba0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x507eb
testb $0x1, -0x49(%rbp)
je 0x507a8
movq -0x10(%rbp), %rdi
subq -0x88(%rbp), %rdi
shlq %rdi
movq -0x60(%rbp), %rsi
movq -0x88(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %rsi
movl $0x1, %edx
callq 0x4db20
jmp 0x507c4
movq -0x88(%rbp), %rdi
addq $0x1, %rdi
shlq %rdi
movq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0x4db20
jmp 0x507c6
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x60(%rbp)
jmp 0x50766
jmp 0x507ed
testb $0x1, -0x49(%rbp)
je 0x50912
movq $0x0, -0x88(%rbp)
movq -0x4b98(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x4ba0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x5090d
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x4ba8(%rbp), %rcx
movl $0x1, %r8d
leaq 0x74ed(%rip), %r9       # 0x57d32
movq %r8, %rdx
callq 0x4dea0
movq -0x10(%rbp), %rdi
subq -0x88(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x4ba8(%rbp), %rcx
movq -0x60(%rbp), %r9
movq -0x88(%rbp), %rax
shlq %rax
shlq $0x3, %rax
addq %rax, %r9
movq -0x70(%rbp), %rax
movq %rax, -0x4bb8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x4bb0(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x4bc8(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x4bc0(%rbp)
movsd -0x4bb8(%rbp), %xmm0
movsd -0x4bb0(%rbp), %xmm1
movsd -0x4bc8(%rbp), %xmm2
movsd -0x4bc0(%rbp), %xmm3
xorl %eax, %eax
movl %eax, %r8d
movq $0x1, (%rsp)
callq 0x4d780
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x60(%rbp)
jmp 0x50818
jmp 0x50a1c
movq $0x0, -0x88(%rbp)
movq -0x4b98(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x4ba0(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x50a1a
movq -0x18(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x4ba8(%rbp), %rcx
movl $0x1, %r8d
leaq 0x73d2(%rip), %r9       # 0x57d32
movq %r8, %rdx
callq 0x4dea0
movq -0x88(%rbp), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rsi
movq -0x4b98(%rbp), %rdx
movq -0x4ba8(%rbp), %rcx
movq -0x60(%rbp), %r9
movq -0x70(%rbp), %rax
movq %rax, -0x4bd8(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x4bd0(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x4be8(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x4be0(%rbp)
movsd -0x4bd8(%rbp), %xmm0
movsd -0x4bd0(%rbp), %xmm1
movsd -0x4be8(%rbp), %xmm2
movsd -0x4be0(%rbp), %xmm3
xorl %eax, %eax
movl %eax, %r8d
movq $0x1, (%rsp)
callq 0x4d780
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x180, %rax            # imm = 0x180
movq %rax, -0x60(%rbp)
jmp 0x50933
jmp 0x50a1c
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x4ba0(%rbp), %rdx
movq -0x48(%rbp), %r8
movq 0x10(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
callq 0x4e780
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x4bf0, %rsp           # imm = 0x4BF0
popq %rbp
retq
nop