// File: /workspace/github_cpp_makefile_star2_O2/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 0x24259
movsd 0x2a7ca(%rip), %xmm1    # 0x301f8
testb %al, %al
jne 0x5a93
xorpd %xmm1, %xmm1
movsd (%rsp), %xmm0
callq 0x24259
movsd 0x2a7b0(%rip), %xmm1    # 0x301f8
testb %al, %al
jne 0x5a93
movsd 0x2a7a4(%rip), %xmm1    # 0x301f8
movaps 0x20(%rsp), %xmm0
callq 0x24239
testb %al, %al
jne 0x5a75
movaps 0x20(%rsp), %xmm0
movsd (%rsp), %xmm1
callq 0x24239
testb %al, %al
je 0x5aa0
movsd (%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
movq %rbx, %rdi
callq 0x579e
movsd 0x2a769(%rip), %xmm1    # 0x301f8
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x80, %rsp
popq %rbx
retq
movapd 0x20(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2455f
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 0x48dc
movsd 0x10(%rsp), %xmm2
subsd %xmm0, %xmm2
movsd 0x2ac3a(%rip), %xmm1    # 0x30720
movsd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
callq 0x24239
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x5a93
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24569
movsd %xmm0, 0x50(%rsp)
movsd 0x2a6df(%rip), %xmm2    # 0x301f8
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 0x2c1b2(%rip), %xmm4    # 0x31d10
unpcklpd %xmm6, %xmm4            # xmm4 = xmm4[0],xmm6[0]
unpcklpd %xmm0, %xmm3            # xmm3 = xmm3[0],xmm0[0]
xorpd %xmm1, %xmm1
addsd %xmm2, %xmm1
addpd 0x2c1aa(%rip), %xmm3    # 0x31d20
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 0x24217
testb %al, %al
je 0x5c01
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 0x2440c
movsd %xmm0, 0x30(%rsp)
movaps 0x60(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
jmp 0x5c0f
movsd 0x2a5ef(%rip), %xmm0    # 0x301f8
movsd %xmm0, 0x30(%rsp)
movaps (%rsp), %xmm0
movq %rbx, %rdi
callq 0x2440c
movsd 0x2ab0d(%rip), %xmm1    # 0x30730
callq 0x24279
testb %al, %al
jne 0x5c34
movapd 0x10(%rsp), %xmm3
jmp 0x5c54
movapd 0x10(%rsp), %xmm3
movapd 0x2c0ee(%rip), %xmm1    # 0x31d30
mulpd %xmm1, %xmm3
movapd (%rsp), %xmm2
mulpd %xmm1, %xmm2
movapd %xmm2, (%rsp)
movsd 0x30(%rsp), %xmm0
movapd %xmm3, 0x10(%rsp)
movsd 0x2aac0(%rip), %xmm1    # 0x30728
callq 0x24279
movapd 0x10(%rsp), %xmm4
movapd (%rsp), %xmm5
testb %al, %al
movsd 0x2a576(%rip), %xmm2    # 0x301f8
movapd 0x20(%rsp), %xmm3
movsd 0x58(%rsp), %xmm1
jne 0x5b6a
movsd 0x50(%rsp), %xmm1
mulsd 0x40(%rsp), %xmm1
jmp 0x5a93