// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/alglibinternal.cpp
// Function: alglib_impl::xcdot(alglib_impl::ae_vector*, alglib_impl::ae_vector*, long, alglib_impl::ae_vector*, alglib_impl::ae_complex*, double*, alglib_impl::ae_state*)
void xcdot(/* Complex */ ae_vector* a,
     /* Complex */ ae_vector* b,
     ae_int_t n,
     /* Real    */ ae_vector* temp,
     ae_complex* r,
     double* rerr,
     ae_state *_state)
{
    ae_int_t i;
    double mx;
    double v;
    double rerrx;
    double rerry;

    r->x = 0;
    r->y = 0;
    *rerr = 0;

    
    /*
     * special cases:
     * * N=0
     */
    if( n==0 )
    {
        *r = ae_complex_from_d(0);
        *rerr = 0;
        return;
    }
    
    /*
     * calculate real part
     */
    mx = 0;
    for(i=0; i<=n-1; i++)
    {
        v = a->ptr.p_complex[i].x*b->ptr.p_complex[i].x;
        temp->ptr.p_double[2*i+0] = v;
        mx = ae_maxreal(mx, ae_fabs(v, _state), _state);
        v = -a->ptr.p_complex[i].y*b->ptr.p_complex[i].y;
        temp->ptr.p_double[2*i+1] = v;
        mx = ae_maxreal(mx, ae_fabs(v, _state), _state);
    }
    if( ae_fp_eq(mx,0) )
    {
        r->x = 0;
        rerrx = 0;
    }
    else
    {
        xblas_xsum(temp, mx, 2*n, &r->x, &rerrx, _state);
    }
    
    /*
     * calculate imaginary part
     */
    mx = 0;
    for(i=0; i<=n-1; i++)
    {
        v = a->ptr.p_complex[i].x*b->ptr.p_complex[i].y;
        temp->ptr.p_double[2*i+0] = v;
        mx = ae_maxreal(mx, ae_fabs(v, _state), _state);
        v = a->ptr.p_complex[i].y*b->ptr.p_complex[i].x;
        temp->ptr.p_double[2*i+1] = v;
        mx = ae_maxreal(mx, ae_fabs(v, _state), _state);
    }
    if( ae_fp_eq(mx,0) )
    {
        r->y = 0;
        rerry = 0;
    }
    else
    {
        xblas_xsum(temp, mx, 2*n, &r->y, &rerry, _state);
    }
    
    /*
     * total error
     */
    if( ae_fp_eq(rerrx,0)&&ae_fp_eq(rerry,0) )
    {
        *rerr = 0;
    }
    else
    {
        *rerr = ae_maxreal(rerrx, rerry, _state)*ae_sqrt(1+ae_sqr(ae_minreal(rerrx, rerry, _state)/ae_maxreal(rerrx, rerry, _state), _state), _state);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movq %r8, %r14
leaq 0x8(%r8), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, (%r8)
movq $0x0, (%r9)
testq %rdx, %rdx
je 0x202c3
movq %rcx, %r13
movq %rsi, %rbp
movq %rdi, %r15
movq %r14, 0x28(%rsp)
movq %rax, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movq 0x70(%rsp), %r14
movq %rdx, 0x8(%rsp)
xorpd %xmm0, %xmm0
jle 0x2029b
xorl %r12d, %r12d
movq %rdx, %rbx
movsd %xmm0, (%rsp)
movq 0x28(%r15), %rax
movsd (%rax,%r12), %xmm0
movq 0x28(%rbp), %rax
mulsd (%rax,%r12), %xmm0
movq 0x28(%r13), %rax
movsd %xmm0, (%rax,%r12)
movq %r14, %rdi
callq 0x26575
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x26621
movsd %xmm0, (%rsp)
movq 0x28(%r15), %rax
movsd 0x8(%rax,%r12), %xmm0
xorpd 0x13f81(%rip), %xmm0    # 0x341e0
movq 0x28(%rbp), %rax
mulsd 0x8(%rax,%r12), %xmm0
movq 0x28(%r13), %rax
movsd %xmm0, 0x8(%rax,%r12)
movq %r14, %rdi
callq 0x26575
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x26621
addq $0x10, %r12
decq %rbx
jne 0x2020b
xorpd %xmm1, %xmm1
movsd %xmm0, (%rsp)
callq 0x262ba
testb %al, %al
je 0x202e1
xorl %eax, %eax
movq 0x28(%rsp), %rcx
movq %rax, (%rcx)
movq %rax, 0x30(%rsp)
movq 0x8(%rsp), %r12
jmp 0x20304
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
callq 0x27e6b
movsd %xmm0, (%r14)
movsd %xmm1, 0x8(%r14)
jmp 0x20488
movq 0x8(%rsp), %r12
leaq (%r12,%r12), %rsi
leaq 0x30(%rsp), %rcx
movq %r13, %rdi
movsd (%rsp), %xmm0
movq 0x28(%rsp), %rdx
movq %r14, %r8
callq 0x1fe0f
xorpd %xmm0, %xmm0
testq %r12, %r12
jle 0x20391
xorl %ebx, %ebx
movsd %xmm0, (%rsp)
movq 0x28(%r15), %rax
movsd (%rax,%rbx), %xmm0
movq 0x28(%rbp), %rax
mulsd 0x8(%rax,%rbx), %xmm0
movq 0x28(%r13), %rax
movsd %xmm0, (%rax,%rbx)
movq %r14, %rdi
callq 0x26575
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x26621
movsd %xmm0, (%rsp)
movq 0x28(%r15), %rax
movsd 0x8(%rax,%rbx), %xmm0
movq 0x28(%rbp), %rax
mulsd (%rax,%rbx), %xmm0
movq 0x28(%r13), %rax
movsd %xmm0, 0x8(%rax,%rbx)
movq %r14, %rdi
callq 0x26575
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x26621
addq $0x10, %rbx
decq %r12
jne 0x20313
xorpd %xmm1, %xmm1
movsd %xmm0, (%rsp)
callq 0x262ba
testb %al, %al
je 0x203b4
xorl %eax, %eax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %rax, 0x20(%rsp)
jmp 0x203d6
movq 0x8(%rsp), %rsi
addq %rsi, %rsi
leaq 0x20(%rsp), %rcx
movq %r13, %rdi
movsd (%rsp), %xmm0
movq 0x10(%rsp), %rdx
movq %r14, %r8
callq 0x1fe0f
movq 0x18(%rsp), %rbx
movsd 0x30(%rsp), %xmm0
xorpd %xmm1, %xmm1
movsd %xmm1, (%rsp)
movsd %xmm0, 0x8(%rsp)
callq 0x262ba
testb %al, %al
je 0x2040c
movsd 0x20(%rsp), %xmm0
xorpd %xmm1, %xmm1
callq 0x262ba
testb %al, %al
jne 0x20488
movsd 0x20(%rsp), %xmm1
movsd %xmm1, (%rsp)
movsd 0x8(%rsp), %xmm0
movq %r14, %rdi
callq 0x26621
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movq %r14, %rdi
callq 0x26626
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movq %r14, %rdi
callq 0x26621
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq %r14, %rdi
callq 0x26588
addsd 0x13d2b(%rip), %xmm0    # 0x341a0
movq %r14, %rdi
callq 0x2658d
mulsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm0
movsd %xmm0, (%rbx)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq