// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::ibetaf_incompletebetaps(double, double, double, double, alglib_impl::ae_state*)
static double ibetaf_incompletebetaps(double a,
     double b,
     double x,
     double maxgam,
     ae_state *_state)
{
    double s;
    double t;
    double u;
    double v;
    double n;
    double t1;
    double z;
    double ai;
    double sg;
    double result;


    ai = 1.0/a;
    u = (1.0-b)*x;
    v = u/(a+1.0);
    t1 = v;
    t = u;
    n = 2.0;
    s = 0.0;
    z = ae_machineepsilon*ai;
    while(ae_fp_greater(ae_fabs(v, _state),z))
    {
        u = (n-b)*x/n;
        t = t*u;
        v = t/(a+n);
        s = s+v;
        n = n+1.0;
    }
    s = s+t1;
    s = s+ai;
    u = a*ae_log(x, _state);
    if( ae_fp_less(a+b,maxgam)&&ae_fp_less(ae_fabs(u, _state),ae_log(ae_maxrealnumber, _state)) )
    {
        t = gammafunction(a+b, _state)/(gammafunction(a, _state)*gammafunction(b, _state));
        s = s*t*ae_pow(x, a, _state);
    }
    else
    {
        t = lngamma(a+b, &sg, _state)-lngamma(a, &sg, _state)-lngamma(b, &sg, _state)+u+ae_log(s, _state);
        if( ae_fp_less(t,ae_log(ae_minrealnumber, _state)) )
        {
            s = 0.0;
        }
        else
        {
            s = ae_exp(t, _state);
        }
    }
    result = s;
    return result;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movsd 0x20bdc(%rip), %xmm4    # 0x341a0
movapd %xmm4, %xmm3
divsd %xmm0, %xmm3
movapd %xmm4, %xmm5
movsd %xmm1, 0x28(%rsp)
subsd %xmm1, %xmm5
movsd %xmm2, 0x30(%rsp)
mulsd %xmm2, %xmm5
movsd %xmm0, 0x20(%rsp)
addsd %xmm4, %xmm0
movsd %xmm5, 0x8(%rsp)
divsd %xmm0, %xmm5
movsd 0x21320(%rip), %xmm0    # 0x34920
movsd %xmm3, 0x18(%rsp)
mulsd %xmm3, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd %xmm5, 0x48(%rsp)
movapd %xmm5, %xmm0
callq 0x26575
movsd 0x40(%rsp), %xmm1
callq 0x2633e
xorpd %xmm3, %xmm3
testb %al, %al
je 0x136ab
movsd 0x20da6(%rip), %xmm4    # 0x343e0
movapd %xmm4, %xmm0
subsd 0x28(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
divsd %xmm4, %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm4, %xmm1
addsd 0x20(%rsp), %xmm1
movsd %xmm2, 0x8(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
addsd %xmm0, %xmm3
movsd %xmm3, 0x10(%rsp)
addsd 0x20b1e(%rip), %xmm4    # 0x341a0
movsd %xmm4, 0x38(%rsp)
movq %rbx, %rdi
callq 0x26575
movsd 0x40(%rsp), %xmm1
callq 0x2633e
movsd 0x38(%rsp), %xmm4
movsd 0x10(%rsp), %xmm3
testb %al, %al
jne 0x1363a
movsd 0x48(%rsp), %xmm1
addsd %xmm3, %xmm1
movsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x30(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266d6
movsd 0x20(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
addsd 0x28(%rsp), %xmm0
movsd 0x21d7b(%rip), %xmm1    # 0x35470
movsd %xmm0, 0x10(%rsp)
callq 0x262fe
testb %al, %al
je 0x137b3
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x26575
movsd %xmm0, 0x38(%rsp)
movsd 0x20f14(%rip), %xmm0    # 0x34638
movq %rbx, %rdi
callq 0x266d6
movaps %xmm0, %xmm1
movsd 0x38(%rsp), %xmm0
callq 0x262fe
testb %al, %al
je 0x137b3
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
movsd %xmm0, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a30
mulsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movq %rbx, %rdi
callq 0x266db
mulsd 0x18(%rsp), %xmm0
jmp 0x1385b
leaq 0x50(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e78
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e78
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e78
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x18(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266d6
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x21c3b(%rip), %xmm0    # 0x35478
movq %rbx, %rdi
callq 0x266d6
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x262fe
xorpd %xmm0, %xmm0
testb %al, %al
je 0x13863
addq $0x58, %rsp
popq %rbx
popq %r14
retq
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r14
jmp 0x266e0