// File: /workspace/github_cpp_makefile_star2_O3/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::incompletegammac(double, double, alglib_impl::ae_state*)
double incompletegammac(double a, double x, ae_state *_state)
{
    double igammaepsilon;
    double igammabignumber;
    double igammabignumberinv;
    double ans;
    double ax;
    double c;
    double yc;
    double r;
    double t;
    double y;
    double z;
    double pk;
    double pkm1;
    double pkm2;
    double qk;
    double qkm1;
    double qkm2;
    double tmp;
    double result;


    igammaepsilon = 0.000000000000001;
    igammabignumber = 4503599627370496.0;
    igammabignumberinv = 2.22044604925031308085*0.0000000000000001;
    if( ae_fp_less_eq(x,0)||ae_fp_less_eq(a,0) )
    {
        result = 1;
        return result;
    }
    if( ae_fp_less(x,1)||ae_fp_less(x,a) )
    {
        result = 1-incompletegamma(a, x, _state);
        return result;
    }
    ax = a*ae_log(x, _state)-x-lngamma(a, &tmp, _state);
    if( ae_fp_less(ax,-709.78271289338399) )
    {
        result = 0;
        return result;
    }
    ax = ae_exp(ax, _state);
    y = 1-a;
    z = x+y+1;
    c = 0;
    pkm2 = 1;
    qkm2 = x;
    pkm1 = x+1;
    qkm1 = z*x;
    ans = pkm1/qkm1;
    do
    {
        c = c+1;
        y = y+1;
        z = z+2;
        yc = y*c;
        pk = pkm1*z-pkm2*yc;
        qk = qkm1*z-qkm2*yc;
        if( ae_fp_neq(qk,0) )
        {
            r = pk/qk;
            t = ae_fabs((ans-r)/r, _state);
            ans = r;
        }
        else
        {
            t = 1;
        }
        pkm2 = pkm1;
        pkm1 = pk;
        qkm2 = qkm1;
        qkm1 = qk;
        if( ae_fp_greater(ae_fabs(pk, _state),igammabignumber) )
        {
            pkm2 = pkm2*igammabignumberinv;
            pkm1 = pkm1*igammabignumberinv;
            qkm2 = qkm2*igammabignumberinv;
            qkm1 = qkm1*igammabignumberinv;
        }
    }
    while(ae_fp_greater(t,igammaepsilon));
    result = ans*ax;
    return result;
}

// Assembly:
pushq %rbx
subq $0x80, %rsp
movq %rdi, %rbx
movapd %xmm1, %xmm2
movsd %xmm0, (%rsp)
xorpd %xmm1, %xmm1
movapd %xmm2, 0x20(%rsp)
movapd %xmm2, %xmm0
callq 0x25bd9
movsd 0x2d141(%rip), %xmm1    # 0x331e0
testb %al, %al
jne 0x6104
xorpd %xmm1, %xmm1
movsd (%rsp), %xmm0
callq 0x25bd9
movsd 0x2d127(%rip), %xmm1    # 0x331e0
testb %al, %al
jne 0x6104
movsd 0x2d11b(%rip), %xmm1    # 0x331e0
movaps 0x20(%rsp), %xmm0
callq 0x25bb9
testb %al, %al
jne 0x60e6
movaps 0x20(%rsp), %xmm0
movsd (%rsp), %xmm1
callq 0x25bb9
testb %al, %al
je 0x6111
movsd (%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
movq %rbx, %rdi
callq 0x5e0d
movsd 0x2d0e0(%rip), %xmm1    # 0x331e0
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x80, %rsp
popq %rbx
retq
movapd 0x20(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f91
movapd %xmm0, %xmm1
movsd (%rsp), %xmm0
mulsd %xmm0, %xmm1
subsd 0x20(%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x4e80
movsd 0x10(%rsp), %xmm2
subsd %xmm0, %xmm2
movsd 0x2d5c9(%rip), %xmm1    # 0x33720
movsd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
callq 0x25bb9
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x6104
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25f9b
movsd %xmm0, 0x50(%rsp)
movsd 0x2d056(%rip), %xmm2    # 0x331e0
movapd %xmm2, %xmm0
subsd (%rsp), %xmm0
movapd %xmm0, %xmm3
movapd 0x20(%rsp), %xmm6
addsd %xmm6, %xmm3
addsd %xmm2, %xmm3
movapd %xmm6, %xmm5
addsd %xmm2, %xmm5
movapd %xmm3, %xmm1
mulsd %xmm6, %xmm1
movapd %xmm5, %xmm4
divsd %xmm1, %xmm4
movapd %xmm4, 0x40(%rsp)
unpcklpd %xmm1, %xmm5            # xmm5 = xmm5[0],xmm1[0]
movapd 0x2eb41(%rip), %xmm4    # 0x34d10
unpcklpd %xmm6, %xmm4            # xmm4 = xmm4[0],xmm6[0]
unpcklpd %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
xorpd %xmm1, %xmm1
addsd %xmm2, %xmm1
addpd 0x2eb39(%rip), %xmm3    # 0x34d20
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
movsd %xmm1, 0x58(%rsp)
mulsd %xmm1, %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm4, %xmm0
movapd %xmm3, 0x20(%rsp)
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
movapd %xmm5, 0x10(%rsp)
mulpd %xmm5, %xmm3
subpd %xmm0, %xmm3
movapd %xmm3, (%rsp)
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
xorpd %xmm1, %xmm1
movapd %xmm0, 0x30(%rsp)
callq 0x25b97
testb %al, %al
je 0x6272
movapd (%rsp), %xmm1
divsd 0x30(%rsp), %xmm1
movapd %xmm1, 0x60(%rsp)
movapd 0x40(%rsp), %xmm0
subsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x25e30
movsd %xmm0, 0x30(%rsp)
movaps 0x60(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
jmp 0x6280
movsd 0x2cf66(%rip), %xmm0    # 0x331e0
movsd %xmm0, 0x30(%rsp)
movaps (%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e30
movsd 0x2d49c(%rip), %xmm1    # 0x33730
callq 0x25bf9
testb %al, %al
jne 0x62a5
movapd 0x10(%rsp), %xmm3
jmp 0x62c5
movapd 0x10(%rsp), %xmm3
movapd 0x2ea7d(%rip), %xmm1    # 0x34d30
mulpd %xmm1, %xmm3
movapd (%rsp), %xmm2
mulpd %xmm1, %xmm2
movapd %xmm2, (%rsp)
movsd 0x30(%rsp), %xmm0
movapd %xmm3, 0x10(%rsp)
movsd 0x2d44f(%rip), %xmm1    # 0x33728
callq 0x25bf9
movapd 0x10(%rsp), %xmm4
movapd (%rsp), %xmm5
testb %al, %al
movsd 0x2ceed(%rip), %xmm2    # 0x331e0
movapd 0x20(%rsp), %xmm3
movsd 0x58(%rsp), %xmm1
jne 0x61db
movsd 0x50(%rsp), %xmm1
mulsd 0x40(%rsp), %xmm1
jmp 0x6104