// File: /workspace/github_cpp_makefile_star2_O2/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 0x1dd9b(%rip), %xmm4    # 0x301f8
movapd %xmm4, %xmm3
divsd %xmm0, %xmm3
movapd %xmm4, %xmm5
movsd %xmm1, 0x28(%rsp)
subsd %xmm1, %xmm5
movsd %xmm2, 0x38(%rsp)
mulsd %xmm2, %xmm5
movsd %xmm0, 0x20(%rsp)
addsd %xmm4, %xmm0
movsd %xmm5, 0x10(%rsp)
divsd %xmm0, %xmm5
movsd 0x1e357(%rip), %xmm0    # 0x307f0
movsd %xmm3, 0x18(%rsp)
mulsd %xmm3, %xmm0
movsd %xmm0, 0x48(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x1df3d(%rip), %xmm0    # 0x303f8
movsd %xmm0, 0x30(%rsp)
movsd %xmm5, 0x40(%rsp)
movapd %xmm5, %xmm0
movq %rbx, %rdi
callq 0x2440c
movsd 0x48(%rsp), %xmm1
callq 0x24279
testb %al, %al
je 0x1253e
movsd 0x30(%rsp), %xmm3
movapd %xmm3, %xmm0
subsd 0x28(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
divsd %xmm3, %xmm0
movsd 0x10(%rsp), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm3, %xmm1
addsd 0x20(%rsp), %xmm1
movsd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
addsd 0x1dcc2(%rip), %xmm3    # 0x301f8
movsd %xmm3, 0x30(%rsp)
jmp 0x124cb
movsd 0x40(%rsp), %xmm1
addsd 0x8(%rsp), %xmm1
movsd 0x18(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x38(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2455f
movsd 0x20(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
addsd 0x28(%rsp), %xmm0
movsd 0x1ecde(%rip), %xmm1    # 0x31268
movsd %xmm0, 0x10(%rsp)
callq 0x24239
testb %al, %al
je 0x12648
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2440c
movsd %xmm0, 0x30(%rsp)
movsd 0x1e0a7(%rip), %xmm0    # 0x30660
movq %rbx, %rdi
callq 0x2455f
movaps %xmm0, %xmm1
movsd 0x30(%rsp), %xmm0
callq 0x24239
testb %al, %al
je 0x12648
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
movsd %xmm0, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
movq %rbx, %rdi
callq 0x44b6
mulsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x18(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x38(%rsp), %xmm0
movsd 0x20(%rsp), %xmm1
movq %rbx, %rdi
callq 0x24564
mulsd 0x18(%rsp), %xmm0
jmp 0x126f0
leaq 0x50(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x48dc
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x48dc
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x48dc
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 0x2455f
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x1eb9e(%rip), %xmm0    # 0x31270
movq %rbx, %rdi
callq 0x2455f
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x24239
xorpd %xmm0, %xmm0
testb %al, %al
je 0x126f8
addq $0x58, %rsp
popq %rbx
popq %r14
retq
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r14
jmp 0x24569