// File: /workspace/github_cpp_makefile_star2_O3/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 0x201dd(%rip), %xmm4    # 0x331e0
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 0x207b1(%rip), %xmm0    # 0x337f0
movsd %xmm3, 0x18(%rsp)
mulsd %xmm3, %xmm0
movsd %xmm0, 0x40(%rsp)
movsd %xmm5, 0x48(%rsp)
movapd %xmm5, %xmm0
callq 0x25e30
movsd 0x40(%rsp), %xmm1
callq 0x25bf9
xorpd %xmm3, %xmm3
testb %al, %al
je 0x130ea
movsd 0x20387(%rip), %xmm4    # 0x33400
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 0x2011f(%rip), %xmm4    # 0x331e0
movsd %xmm4, 0x38(%rsp)
movq %rbx, %rdi
callq 0x25e30
movsd 0x40(%rsp), %xmm1
callq 0x25bf9
movsd 0x38(%rsp), %xmm4
movsd 0x10(%rsp), %xmm3
testb %al, %al
jne 0x13079
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 0x25f91
movsd 0x20(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movapd %xmm1, %xmm0
addsd 0x28(%rsp), %xmm0
movsd 0x21134(%rip), %xmm1    # 0x34268
movsd %xmm0, 0x10(%rsp)
callq 0x25bb9
testb %al, %al
je 0x131f2
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e30
movsd %xmm0, 0x38(%rsp)
movsd 0x204fd(%rip), %xmm0    # 0x33660
movq %rbx, %rdi
callq 0x25f91
movaps %xmm0, %xmm1
movsd 0x38(%rsp), %xmm0
callq 0x25bb9
testb %al, %al
je 0x131f2
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
movsd %xmm0, 0x8(%rsp)
movsd 0x20(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
movsd %xmm0, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
movq %rbx, %rdi
callq 0x4a38
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 0x25f96
mulsd 0x18(%rsp), %xmm0
jmp 0x1329a
leaq 0x50(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e80
movsd %xmm0, 0x10(%rsp)
movsd 0x20(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e80
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x28(%rsp), %xmm0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4e80
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 0x25f91
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x20ff4(%rip), %xmm0    # 0x34270
movq %rbx, %rdi
callq 0x25f91
movaps %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x25bb9
xorpd %xmm0, %xmm0
testb %al, %al
je 0x132a2
addq $0x58, %rsp
popq %rbx
popq %r14
retq
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r14
jmp 0x25f9b