// File: mouda[P]LTE_random_access-simulate/ap.cpp
// Function: alglib_impl::_ialglib_rmatrixsyrk(long, long, double, double*, long, long, double, double*, long, bool)
ae_bool _ialglib_rmatrixsyrk(ae_int_t n,
     ae_int_t k,
     double alpha,
     double *_a,
     ae_int_t _a_stride,
     ae_int_t optypea,
     double beta,
     double *_c,
     ae_int_t _c_stride,
     ae_bool isupper)
{
    /*
     * local buffers
     */
    double *arow, *crow;
    ae_int_t i;
    double _loc_abuf[alglib_r_block*alglib_r_block+alglib_simd_alignment];
    double _loc_cbuf[alglib_r_block*alglib_r_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);

    if( n>alglib_r_block || k>alglib_r_block )
        return ae_false;
    if( n==0 )
        return ae_true;

    /*
     * copy A and C, task is transformed to "A*A^T"-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)
     */
    if( alpha==0 )
        k = 0;
    if( k>0 )
    {
        if( optypea==0 )
            _ialglib_mcopyblock(n, k, _a, 0, _a_stride, abuf);
        else
            _ialglib_mcopyblock(k, n, _a, 1, _a_stride, abuf);
    }
    _ialglib_mcopyblock(n, n, _c, 0, _c_stride, cbuf);
    if( beta==0 )
    {
        for(i=0,crow=cbuf; i<n; i++,crow+=alglib_r_block)
            if( isupper )
                _ialglib_vzero(n-i, crow+i, 1);
            else
                _ialglib_vzero(i+1, crow, 1);
    }


    /*
     * update C
     */
    if( isupper )
    {
        for(i=0,arow=abuf,crow=cbuf; i<n; i++,arow+=alglib_r_block,crow+=alglib_r_block)
        {
            _ialglib_rmv(n-i, k, arow, arow, crow+i, 1, alpha, beta);
        }
    }
    else
    {
        for(i=0,arow=abuf,crow=cbuf; i<n; i++,arow+=alglib_r_block,crow+=alglib_r_block)
        {
            _ialglib_rmv(i+1, k, abuf, arow, crow, 1, alpha, beta);
        }
    }

    /*
     * copy back
     */
    _ialglib_mcopyunblock(n, n, cbuf, 0, _c, _c_stride);

    return ae_true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4180, %rsp           # imm = 0x4180
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 -0x20f0(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4178(%rbp)
leaq -0x4170(%rbp), %rdi
movl $0x10, %esi
callq 0x3aab0
movq %rax, -0x4180(%rbp)
cmpq $0x20, -0x10(%rbp)
jg 0x50ac7
cmpq $0x20, -0x18(%rbp)
jle 0x50ad0
movb $0x0, -0x1(%rbp)
jmp 0x50d38
cmpq $0x0, -0x10(%rbp)
jne 0x50ae0
movb $0x1, -0x1(%rbp)
jmp 0x50d38
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x50af8
jp 0x50af8
movq $0x0, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jle 0x50b4b
cmpq $0x0, -0x38(%rbp)
jne 0x50b28
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %r8
movq -0x4178(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
callq 0x4dfd0
jmp 0x50b49
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %r8
movq -0x4178(%rbp), %r9
movl $0x1, %ecx
callq 0x4dfd0
jmp 0x50b4b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x10(%rbp), %r8
movq -0x4180(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
callq 0x4dfd0
movsd -0x40(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x50bf7
jp 0x50bf7
movq $0x0, -0x68(%rbp)
movq -0x4180(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x50bf5
testb $0x1, -0x49(%rbp)
je 0x50bc1
movq -0x10(%rbp), %rdi
subq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movl $0x1, %edx
callq 0x4db20
jmp 0x50bd7
movq -0x68(%rbp), %rdi
addq $0x1, %rdi
movq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0x4db20
jmp 0x50bd9
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x60(%rbp)
jmp 0x50b8e
jmp 0x50bf7
testb $0x1, -0x49(%rbp)
je 0x50c90
movq $0x0, -0x68(%rbp)
movq -0x4178(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x4180(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x50c8b
movq -0x10(%rbp), %rdi
subq -0x68(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
movq -0x68(%rbp), %rax
shlq $0x3, %rax
addq %rax, %r8
movsd -0x20(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movl $0x1, %r9d
callq 0x4cee0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x60(%rbp)
jmp 0x50c1f
jmp 0x50d14
movq $0x0, -0x68(%rbp)
movq -0x4178(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x4180(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x50d12
movq -0x68(%rbp), %rdi
addq $0x1, %rdi
movq -0x18(%rbp), %rsi
movq -0x4178(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %r8
movsd -0x20(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
movl $0x1, %r9d
callq 0x4cee0
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x60(%rbp)
jmp 0x50cae
jmp 0x50d14
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x4180(%rbp), %rdx
movq -0x48(%rbp), %r8
movq 0x10(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
callq 0x4e1f0
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x4180, %rsp           # imm = 0x4180
popq %rbp
retq
nopw %cs:(%rax,%rax)