// File: /workspace/github_cpp_makefile_star2_O3/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::incompleteellipticintegrale(double, double, alglib_impl::ae_state*)
double incompleteellipticintegrale(double phi, double m, ae_state *_state)
{
    double pio2;
    double a;
    double b;
    double c;
    double e;
    double temp;
    double lphi;
    double t;
    double ebig;
    ae_int_t d;
    ae_int_t md;
    ae_int_t npio2;
    ae_int_t s;
    double result;


    pio2 = 1.57079632679489661923;
    if( ae_fp_eq(m,0) )
    {
        result = phi;
        return result;
    }
    lphi = phi;
    npio2 = ae_ifloor(lphi/pio2, _state);
    if( npio2%2!=0 )
    {
        npio2 = npio2+1;
    }
    lphi = lphi-npio2*pio2;
    if( ae_fp_less(lphi,0) )
    {
        lphi = -lphi;
        s = -1;
    }
    else
    {
        s = 1;
    }
    a = 1.0-m;
    ebig = ellipticintegrale(m, _state);
    if( ae_fp_eq(a,0) )
    {
        temp = ae_sin(lphi, _state);
        if( s<0 )
        {
            temp = -temp;
        }
        result = temp+npio2*ebig;
        return result;
    }
    t = ae_tan(lphi, _state);
    b = ae_sqrt(a, _state);
    
    /*
     * Thanks to Brian Fitzgerald <fitzgb@mml0.meche.rpi.edu>
     * for pointing out an instability near odd multiples of pi/2
     */
    if( ae_fp_greater(ae_fabs(t, _state),10) )
    {
        
        /*
         * Transform the amplitude
         */
        e = 1.0/(b*t);
        
        /*
         * ... but avoid multiple recursions.
         */
        if( ae_fp_less(ae_fabs(e, _state),10) )
        {
            e = ae_atan(e, _state);
            temp = ebig+m*ae_sin(lphi, _state)*ae_sin(e, _state)-incompleteellipticintegrale(e, m, _state);
            if( s<0 )
            {
                temp = -temp;
            }
            result = temp+npio2*ebig;
            return result;
        }
    }
    c = ae_sqrt(m, _state);
    a = 1.0;
    d = 1;
    e = 0.0;
    md = 0;
    while(ae_fp_greater(ae_fabs(c/a, _state),ae_machineepsilon))
    {
        temp = b/a;
        lphi = lphi+ae_atan(t*temp, _state)+md*ae_pi;
        md = ae_trunc((lphi+pio2)/ae_pi, _state);
        t = t*(1.0+temp)/(1.0-temp*t*t);
        c = 0.5*(a-b);
        temp = ae_sqrt(a*b, _state);
        a = 0.5*(a+b);
        b = temp;
        d = d+d;
        e = e+c*ae_sin(lphi, _state);
    }
    temp = ebig/ellipticintegralk(m, _state);
    temp = temp*((ae_atan(t, _state)+md*ae_pi)/(d*a));
    temp = temp+e;
    if( s<0 )
    {
        temp = -temp;
    }
    result = temp+npio2*ebig;
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movapd %xmm1, %xmm2
movaps %xmm0, (%rsp)
xorpd %xmm1, %xmm1
movsd %xmm2, 0x30(%rsp)
movapd %xmm2, %xmm0
callq 0x25b75
testb %al, %al
je 0xe2b9
movapd (%rsp), %xmm0
jmp 0xe6fa
movapd (%rsp), %xmm0
divsd 0x2627a(%rip), %xmm0    # 0x34540
movq %rbx, %rdi
callq 0x25e8e
movl %eax, %ecx
andl $0x1, %ecx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
movsd %xmm0, 0x20(%rsp)
movapd %xmm0, %xmm1
mulsd 0x26250(%rip), %xmm1    # 0x34540
movapd (%rsp), %xmm0
subsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
movapd %xmm0, (%rsp)
callq 0x25bb9
movl %eax, %ebp
testb %al, %al
je 0xe31f
movapd (%rsp), %xmm0
xorpd 0x24e96(%rip), %xmm0    # 0x331b0
movapd %xmm0, (%rsp)
movsd 0x24eb9(%rip), %xmm1    # 0x331e0
movsd 0x30(%rsp), %xmm0
subsd %xmm0, %xmm1
movsd %xmm1, 0x40(%rsp)
movq %rbx, %rdi
callq 0xe01b
movapd %xmm0, 0x50(%rsp)
xorpd %xmm1, %xmm1
movsd 0x40(%rsp), %xmm0
callq 0x25b75
testb %al, %al
je 0xe38f
movapd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f5f
testb %bpl, %bpl
je 0xe372
xorpd 0x24e3e(%rip), %xmm0    # 0x331b0
movsd 0x20(%rsp), %xmm1
movapd 0x50(%rsp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0xe6fa
movaps (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f69
movsd %xmm0, 0x10(%rsp)
movsd 0x40(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e48
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e30
movsd 0x251a5(%rip), %xmm1    # 0x33570
callq 0x25bf9
testb %al, %al
je 0xe49c
movsd 0x10(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm1
movsd 0x24df4(%rip), %xmm0    # 0x331e0
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbx, %rdi
callq 0x25e30
movsd 0x2516a(%rip), %xmm1    # 0x33570
callq 0x25bb9
testb %al, %al
je 0xe49c
movsd 0x28(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f87
movsd %xmm0, 0x10(%rsp)
movapd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f5f
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f5f
mulsd (%rsp), %xmm0
addsd 0x50(%rsp), %xmm0
movapd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
movq %rbx, %rdi
callq 0xe283
movapd (%rsp), %xmm1
subsd %xmm0, %xmm1
testb %bpl, %bpl
je 0xe487
xorpd 0x24d29(%rip), %xmm1    # 0x331b0
movsd 0x20(%rsp), %xmm0
mulsd 0x50(%rsp), %xmm0
addsd %xmm1, %xmm0
jmp 0xe6fa
movsd 0x30(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e48
movq %rbx, %rdi
callq 0x25e30
movsd 0x25336(%rip), %xmm1    # 0x337f0
callq 0x25bf9
testb %al, %al
je 0xe64d
movsd 0x24d11(%rip), %xmm0    # 0x331e0
xorps %xmm1, %xmm1
movsd %xmm1, 0x28(%rsp)
movl $0x1, %r15d
xorl %r14d, %r14d
movaps %xmm0, 0x30(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
divsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
movq %rbx, %rdi
callq 0x25f87
addsd (%rsp), %xmm0
xorps %xmm2, %xmm2
cvtsi2sd %r14, %xmm2
movsd 0x24f69(%rip), %xmm1    # 0x33490
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, (%rsp)
movapd %xmm2, %xmm0
addsd 0x26000(%rip), %xmm0    # 0x34540
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x25e9b
movq %rax, %r14
movsd 0x24c89(%rip), %xmm0    # 0x331e0
movsd 0x48(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm3
mulsd %xmm3, %xmm1
movsd 0x60(%rsp), %xmm2
mulsd %xmm3, %xmm2
subsd %xmm2, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movapd 0x30(%rsp), %xmm1
movapd %xmm1, %xmm3
movsd 0x18(%rsp), %xmm2
subsd %xmm2, %xmm3
movsd 0x24ee9(%rip), %xmm0    # 0x33488
mulsd %xmm0, %xmm3
movsd %xmm3, 0x48(%rsp)
movapd %xmm1, %xmm0
mulsd %xmm2, %xmm0
movq %rbx, %rdi
callq 0x25e48
movsd %xmm0, 0x60(%rsp)
movapd 0x30(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
mulsd 0x24eb5(%rip), %xmm0    # 0x33488
movapd %xmm0, 0x30(%rsp)
addq %r15, %r15
movapd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f5f
movsd 0x48(%rsp), %xmm2
mulsd %xmm2, %xmm0
movsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
divsd 0x30(%rsp), %xmm2
movapd %xmm2, %xmm0
movq %rbx, %rdi
callq 0x25e30
movsd 0x251d3(%rip), %xmm1    # 0x337f0
callq 0x25bf9
movsd 0x60(%rsp), %xmm0
testb %al, %al
jne 0xe4ec
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movapd %xmm0, (%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
movsd %xmm0, 0x18(%rsp)
jmp 0xe673
xorps %xmm0, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x24b82(%rip), %xmm0    # 0x331e0
movapd %xmm0, 0x30(%rsp)
movsd %xmm0, 0x18(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rsp)
movsd 0x40(%rsp), %xmm0
movq %rbx, %rdi
callq 0xd8e7
movaps %xmm0, 0x60(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f87
movapd (%rsp), %xmm2
mulsd 0x24def(%rip), %xmm2    # 0x33490
addsd %xmm0, %xmm2
movapd 0x30(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
movapd 0x50(%rsp), %xmm3
movapd %xmm3, %xmm1
unpcklpd %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
movapd 0x60(%rsp), %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
divpd %xmm2, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
mulsd %xmm1, %xmm2
addsd 0x28(%rsp), %xmm2
testb %bpl, %bpl
je 0xe6ec
xorpd 0x24ac4(%rip), %xmm2    # 0x331b0
movsd 0x20(%rsp), %xmm0
mulsd %xmm3, %xmm0
addsd %xmm2, %xmm0
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq