// File: mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::incompletebeta(double, double, double, alglib_impl::ae_state*)
double incompletebeta(double a, double b, double x, ae_state *_state)
{
    double t;
    double xc;
    double w;
    double y;
    ae_int_t flag;
    double sg;
    double big;
    double biginv;
    double maxgam;
    double minlog;
    double maxlog;
    double result;


    big = 4.503599627370496e15;
    biginv = 2.22044604925031308085e-16;
    maxgam = 171.624376956302725;
    minlog = ae_log(ae_minrealnumber, _state);
    maxlog = ae_log(ae_maxrealnumber, _state);
    ae_assert(ae_fp_greater(a,0)&&ae_fp_greater(b,0), "Domain error in IncompleteBeta", _state);
    ae_assert(ae_fp_greater_eq(x,0)&&ae_fp_less_eq(x,1), "Domain error in IncompleteBeta", _state);
    if( ae_fp_eq(x,0) )
    {
        result = 0;
        return result;
    }
    if( ae_fp_eq(x,1) )
    {
        result = 1;
        return result;
    }
    flag = 0;
    if( ae_fp_less_eq(b*x,1.0)&&ae_fp_less_eq(x,0.95) )
    {
        result = ibetaf_incompletebetaps(a, b, x, maxgam, _state);
        return result;
    }
    w = 1.0-x;
    if( ae_fp_greater(x,a/(a+b)) )
    {
        flag = 1;
        t = a;
        a = b;
        b = t;
        xc = x;
        x = w;
    }
    else
    {
        xc = w;
    }
    if( (flag==1&&ae_fp_less_eq(b*x,1.0))&&ae_fp_less_eq(x,0.95) )
    {
        t = ibetaf_incompletebetaps(a, b, x, maxgam, _state);
        if( ae_fp_less_eq(t,ae_machineepsilon) )
        {
            result = 1.0-ae_machineepsilon;
        }
        else
        {
            result = 1.0-t;
        }
        return result;
    }
    y = x*(a+b-2.0)-(a-1.0);
    if( ae_fp_less(y,0.0) )
    {
        w = ibetaf_incompletebetafe(a, b, x, big, biginv, _state);
    }
    else
    {
        w = ibetaf_incompletebetafe2(a, b, x, big, biginv, _state)/xc;
    }
    y = a*ae_log(x, _state);
    t = b*ae_log(xc, _state);
    if( (ae_fp_less(a+b,maxgam)&&ae_fp_less(ae_fabs(y, _state),maxlog))&&ae_fp_less(ae_fabs(t, _state),maxlog) )
    {
        t = ae_pow(xc, b, _state);
        t = t*ae_pow(x, a, _state);
        t = t/a;
        t = t*w;
        t = t*(gammafunction(a+b, _state)/(gammafunction(a, _state)*gammafunction(b, _state)));
        if( flag==1 )
        {
            if( ae_fp_less_eq(t,ae_machineepsilon) )
            {
                result = 1.0-ae_machineepsilon;
            }
            else
            {
                result = 1.0-t;
            }
        }
        else
        {
            result = t;
        }
        return result;
    }
    y = y+t+lngamma(a+b, &sg, _state)-lngamma(a, &sg, _state)-lngamma(b, &sg, _state);
    y = y+ae_log(w/a, _state);
    if( ae_fp_less(y,minlog) )
    {
        t = 0.0;
    }
    else
    {
        t = ae_exp(y, _state);
    }
    if( flag==1 )
    {
        if( ae_fp_less_eq(t,ae_machineepsilon) )
        {
            t = 1.0-ae_machineepsilon;
        }
        else
        {
            t = 1.0-t;
        }
    }
    result = t;
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
movq %rdi, -0x28(%rbp)
movsd 0x46c8a(%rip), %xmm0    # 0x557d0
movsd %xmm0, -0x60(%rbp)
movsd 0x46c75(%rip), %xmm0    # 0x557c8
movsd %xmm0, -0x68(%rbp)
movsd 0x478c0(%rip), %xmm0    # 0x56420
movsd %xmm0, -0x70(%rbp)
movq -0x28(%rbp), %rdi
movsd 0x478b7(%rip), %xmm0    # 0x56428
callq 0x3cd70
movsd %xmm0, -0x78(%rbp)
movq -0x28(%rbp), %rdi
movsd 0x46c21(%rip), %xmm0    # 0x557a8
callq 0x3cd70
movsd %xmm0, -0x80(%rbp)
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c4c0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x89(%rbp)
jne 0xebaf
jmp 0xebc2
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c4c0
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
movq -0x28(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x4898a(%rip), %rsi     # 0x57563
callq 0x3b240
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c500
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x8a(%rbp)
jne 0xebfc
jmp 0xec14
movsd -0x20(%rbp), %xmm0
movsd 0x463ff(%rip), %xmm1    # 0x55008
callq 0x3c480
movb %al, -0x8a(%rbp)
movb -0x8a(%rbp), %al
movq -0x28(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x48938(%rip), %rsi     # 0x57563
callq 0x3b240
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c3d0
testb $0x1, %al
jne 0xec43
jmp 0xec60
xorps %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xf24e
movsd -0x20(%rbp), %xmm0
movsd 0x4639b(%rip), %xmm1    # 0x55008
callq 0x3c3d0
testb $0x1, %al
jne 0xec78
jmp 0xec9a
movsd 0x46388(%rip), %xmm0    # 0x55008
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xf24e
movq $0x0, -0x50(%rbp)
movsd -0x18(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
movsd 0x46354(%rip), %xmm1    # 0x55008
callq 0x3c480
testb $0x1, %al
jne 0xecbf
jmp 0xed0e
movsd -0x20(%rbp), %xmm0
movsd 0x47764(%rip), %xmm1    # 0x56430
callq 0x3c480
testb $0x1, %al
jne 0xecd7
jmp 0xed0e
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
movsd -0x70(%rbp), %xmm3
movq -0x28(%rbp), %rdi
callq 0x1c9c0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xf24e
movsd 0x462f2(%rip), %xmm0    # 0x55008
subsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x20(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movsd -0x10(%rbp), %xmm2
addsd -0x18(%rbp), %xmm2
divsd %xmm2, %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0xed43
jmp 0xed7f
movq $0x1, -0x50(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0xed89
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
cmpq $0x1, -0x50(%rbp)
jne 0xee3f
movsd -0x18(%rbp), %xmm0
mulsd -0x20(%rbp), %xmm0
movsd 0x46262(%rip), %xmm1    # 0x55008
callq 0x3c480
testb $0x1, %al
jne 0xedb4
jmp 0xee3f
movsd -0x20(%rbp), %xmm0
movsd 0x4766f(%rip), %xmm1    # 0x56430
callq 0x3c480
testb $0x1, %al
jne 0xedcc
jmp 0xee3f
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
movsd -0x70(%rbp), %xmm3
movq -0x28(%rbp), %rdi
callq 0x1c9c0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0x46b1d(%rip), %xmm1    # 0x55918
callq 0x3c480
testb $0x1, %al
jne 0xee06
jmp 0xee18
movsd 0x4762a(%rip), %xmm0    # 0x56438
movsd %xmm0, -0x88(%rbp)
jmp 0xee2d
movsd 0x461e8(%rip), %xmm0    # 0x55008
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xf24e
movsd -0x20(%rbp), %xmm0
movsd -0x10(%rbp), %xmm2
addsd -0x18(%rbp), %xmm2
movsd 0x46572(%rip), %xmm1    # 0x553c8
subsd %xmm1, %xmm2
movsd -0x10(%rbp), %xmm1
movsd 0x461a1(%rip), %xmm3    # 0x55008
subsd %xmm3, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c440
testb $0x1, %al
jne 0xeea2
jmp 0xeecb
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
movsd -0x60(%rbp), %xmm3
movsd -0x68(%rbp), %xmm4
movq -0x28(%rbp), %rdi
callq 0x1cd30
movsd %xmm0, -0x40(%rbp)
jmp 0xeef7
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
movsd -0x60(%rbp), %xmm3
movsd -0x68(%rbp), %xmm4
movq -0x28(%rbp), %rdi
callq 0x1d210
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x20(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x3cd70
movaps %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x3cd70
movaps %xmm0, %xmm1
movsd -0x98(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x10(%rbp), %xmm0
addsd -0x18(%rbp), %xmm0
movsd -0x70(%rbp), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0xef72
jmp 0xf0fd
movsd -0x48(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x3c820
movsd -0x80(%rbp), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0xef93
jmp 0xf0fd
movsd -0x30(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x3c820
movsd -0x80(%rbp), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0xefb4
jmp 0xf0fd
movsd -0x38(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movq -0x28(%rbp), %rdi
callq 0x3cda0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0x20(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
movq -0x28(%rbp), %rdi
callq 0x3cda0
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x10(%rbp), %xmm0
addsd -0x18(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x4ed0
movsd %xmm0, -0xb0(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x4ed0
movsd %xmm0, -0xb8(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x4ed0
movsd -0xb8(%rbp), %xmm2
movsd -0xb0(%rbp), %xmm1
movaps %xmm0, %xmm3
movsd -0xa8(%rbp), %xmm0
mulsd %xmm3, %xmm2
divsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
cmpq $0x1, -0x50(%rbp)
jne 0xf0de
movsd -0x30(%rbp), %xmm0
movsd 0x4686e(%rip), %xmm1    # 0x55918
callq 0x3c480
testb $0x1, %al
jne 0xf0b5
jmp 0xf0c7
movsd 0x4737b(%rip), %xmm0    # 0x56438
movsd %xmm0, -0x88(%rbp)
jmp 0xf0dc
movsd 0x45f39(%rip), %xmm0    # 0x55008
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
jmp 0xf0eb
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0xf24e
movsd -0x48(%rbp), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0x10(%rbp), %xmm0
addsd -0x18(%rbp), %xmm0
movq -0x28(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x5530
movaps %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x28(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x5530
movaps %xmm0, %xmm1
movsd -0xd8(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x28(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x5530
movaps %xmm0, %xmm1
movsd -0xd0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0x40(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x3cd70
movaps %xmm0, %xmm1
movsd -0xc8(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd -0x78(%rbp), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0xf1d5
jmp 0xf1df
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0xf1f2
movsd -0x48(%rbp), %xmm0
movq -0x28(%rbp), %rdi
callq 0x3cdd0
movsd %xmm0, -0x30(%rbp)
cmpq $0x1, -0x50(%rbp)
jne 0xf234
movsd -0x30(%rbp), %xmm0
movsd 0x46712(%rip), %xmm1    # 0x55918
callq 0x3c480
testb $0x1, %al
jne 0xf211
jmp 0xf220
movsd 0x4721f(%rip), %xmm0    # 0x56438
movsd %xmm0, -0x30(%rbp)
jmp 0xf232
movsd 0x45de0(%rip), %xmm0    # 0x55008
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0xf234
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax)