// File: /workspace/github_cpp_makefile_star2_O1/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 $0x60, %rsp
movq %rdi, %rbx
movapd %xmm1, %xmm2
movsd %xmm0, 0x8(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm2, (%rsp)
movapd %xmm2, %xmm0
callq 0x2631e
movsd 0x2e083(%rip), %xmm1    # 0x341a0
testb %al, %al
jne 0x6185
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x2631e
movsd 0x2e068(%rip), %xmm1    # 0x341a0
testb %al, %al
jne 0x6185
movsd 0x2e05c(%rip), %xmm1    # 0x341a0
movsd (%rsp), %xmm0
callq 0x262fe
testb %al, %al
jne 0x6166
movsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x262fe
testb %al, %al
je 0x618f
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movq %rbx, %rdi
callq 0x5e8e
movsd 0x2e01f(%rip), %xmm1    # 0x341a0
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x60, %rsp
popq %rbx
retq
movsd (%rsp), %xmm0
movq %rbx, %rdi
callq 0x266d6
movapd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm1
subsd (%rsp), %xmm1
movsd %xmm1, 0x10(%rsp)
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x4e78
movsd 0x10(%rsp), %xmm2
subsd %xmm0, %xmm2
movsd 0x2e604(%rip), %xmm1    # 0x347d8
movsd %xmm2, 0x10(%rsp)
movapd %xmm2, %xmm0
callq 0x262fe
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x6185
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x266e0
movsd %xmm0, 0x30(%rsp)
movsd 0x2df99(%rip), %xmm1    # 0x341a0
movapd %xmm1, %xmm3
subsd 0x8(%rsp), %xmm3
movapd %xmm3, %xmm4
movsd (%rsp), %xmm2
addsd %xmm2, %xmm4
addsd %xmm1, %xmm4
movapd %xmm2, %xmm5
addsd %xmm1, %xmm5
movapd %xmm4, %xmm8
mulsd %xmm2, %xmm8
movapd %xmm5, %xmm0
divsd %xmm8, %xmm0
movsd %xmm0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm1, %xmm9
movapd %xmm5, %xmm6
movapd %xmm8, %xmm7
movsd %xmm8, 0x18(%rsp)
movsd %xmm5, (%rsp)
addsd %xmm1, %xmm0
addsd %xmm1, %xmm3
addsd 0x2e16f(%rip), %xmm4    # 0x343e0
movsd %xmm0, 0x40(%rsp)
movsd %xmm3, 0x50(%rsp)
mulsd %xmm3, %xmm0
mulsd %xmm0, %xmm9
mulsd %xmm4, %xmm6
subsd %xmm9, %xmm6
movsd %xmm6, 0x8(%rsp)
mulsd %xmm2, %xmm0
movsd %xmm4, 0x48(%rsp)
mulsd %xmm4, %xmm7
subsd %xmm0, %xmm7
movsd %xmm7, 0x10(%rsp)
xorpd %xmm1, %xmm1
movapd %xmm7, %xmm0
callq 0x262dc
testb %al, %al
je 0x62fa
movsd 0x8(%rsp), %xmm1
divsd 0x10(%rsp), %xmm1
movsd %xmm1, 0x38(%rsp)
movsd 0x20(%rsp), %xmm0
subsd %xmm1, %xmm0
divsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x26575
movsd %xmm0, 0x28(%rsp)
movsd 0x38(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
jmp 0x6308
movsd 0x2de9e(%rip), %xmm0    # 0x341a0
movsd %xmm0, 0x28(%rsp)
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x26575
movsd 0x2e4ca(%rip), %xmm1    # 0x347e8
callq 0x2633e
testb %al, %al
je 0x6364
movsd 0x2e4c1(%rip), %xmm0    # 0x347f0
movsd (%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
movsd %xmm2, 0x8(%rsp)
movsd 0x18(%rsp), %xmm2
mulsd %xmm0, %xmm2
movsd 0x10(%rsp), %xmm3
mulsd %xmm0, %xmm3
movsd %xmm3, 0x10(%rsp)
jmp 0x636f
movsd (%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x28(%rsp), %xmm0
movsd %xmm2, (%rsp)
movsd %xmm1, 0x18(%rsp)
movsd 0x2e458(%rip), %xmm1    # 0x347e0
callq 0x2633e
movsd 0x18(%rsp), %xmm9
movsd (%rsp), %xmm2
movsd 0x8(%rsp), %xmm6
movapd %xmm6, %xmm5
movsd 0x10(%rsp), %xmm7
movapd %xmm7, %xmm8
testb %al, %al
movsd 0x2dde8(%rip), %xmm1    # 0x341a0
movsd 0x50(%rsp), %xmm3
movsd 0x48(%rsp), %xmm4
movsd 0x40(%rsp), %xmm0
jne 0x6255
movsd 0x30(%rsp), %xmm1
mulsd 0x20(%rsp), %xmm1
jmp 0x6185