// File: /workspace/github_cpp_makefile_star2_O3/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 0x1fc9b
movq %rcx, %r13
movq %rsi, %rbp
movq %rdi, %r12
movq %r14, 0x8(%rsp)
movq %rax, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
movq 0x70(%rsp), %r14
movq %rdx, 0x10(%rsp)
xorpd %xmm0, %xmm0
jle 0x1fc73
xorl %r15d, %r15d
movq %rdx, %rbx
movsd %xmm0, (%rsp)
movq 0x28(%r12), %rax
movsd (%rax,%r15), %xmm0
movq 0x28(%rbp), %rax
mulsd (%rax,%r15), %xmm0
movq 0x28(%r13), %rax
movsd %xmm0, (%rax,%r15)
movq %r14, %rdi
callq 0x25e30
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x25edc
movsd %xmm0, (%rsp)
movq 0x28(%r12), %rax
movsd 0x8(%rax,%r15), %xmm0
xorpd 0x13579(%rip), %xmm0    # 0x331b0
movq 0x28(%rbp), %rax
mulsd 0x8(%rax,%r15), %xmm0
movq 0x28(%r13), %rax
movsd %xmm0, 0x8(%rax,%r15)
movq %r14, %rdi
callq 0x25e30
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x25edc
addq $0x10, %r15
decq %rbx
jne 0x1fbe1
xorpd %xmm1, %xmm1
movsd %xmm0, (%rsp)
callq 0x25b75
testb %al, %al
je 0x1fcb9
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq %rax, 0x28(%rsp)
movq 0x10(%rsp), %r15
jmp 0x1fcdc
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
callq 0x276c0
movsd %xmm0, (%r14)
movsd %xmm1, 0x8(%r14)
jmp 0x1fe7d
movq 0x10(%rsp), %r15
leaq (%r15,%r15), %rsi
leaq 0x28(%rsp), %rcx
movq %r13, %rdi
movsd (%rsp), %xmm0
movq 0x8(%rsp), %rdx
movq %r14, %r8
callq 0x1f7ca
xorpd %xmm2, %xmm2
testq %r15, %r15
jle 0x1fd73
xorl %ebx, %ebx
movsd %xmm2, (%rsp)
movq 0x28(%r12), %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 0x25e30
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x25edc
movsd %xmm0, (%rsp)
movq 0x28(%r12), %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 0x25e30
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
movq %r14, %rdi
callq 0x25edc
movapd %xmm0, %xmm2
addq $0x10, %rbx
decq %r15
jne 0x1fceb
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm2, (%rsp)
movapd %xmm2, %xmm0
callq 0x25b75
testb %al, %al
je 0x1fda1
movq 0x20(%rsp), %rax
movq $0x0, (%rax)
jmp 0x1fdd0
movq 0x10(%rsp), %rsi
addq %rsi, %rsi
leaq 0x30(%rsp), %rbx
movq %r13, %rdi
movsd (%rsp), %xmm0
movq 0x20(%rsp), %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0x1f7ca
movsd (%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x18(%rsp), %rbx
movsd 0x28(%rsp), %xmm0
xorpd %xmm1, %xmm1
movsd %xmm1, (%rsp)
movsd %xmm0, 0x10(%rsp)
callq 0x25b75
testb %al, %al
je 0x1fe06
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x25b75
testb %al, %al
jne 0x1fe7d
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movq %r14, %rdi
callq 0x25edc
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movq %r14, %rdi
callq 0x25ee1
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movq %r14, %rdi
callq 0x25edc
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
movq %r14, %rdi
callq 0x25e43
addsd 0x13375(%rip), %xmm0    # 0x331e0
movq %r14, %rdi
callq 0x25e48
mulsd (%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