// File: 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 %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movsd 0x4e217(%rip), %xmm0    # 0x557b8
movsd %xmm0, -0x28(%rbp)
movsd 0x4e222(%rip), %xmm0    # 0x557d0
movsd %xmm0, -0x30(%rbp)
movsd 0x4e20d(%rip), %xmm0    # 0x557c8
movsd %xmm0, -0x38(%rbp)
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c480
testb $0x1, %al
jne 0x75e4
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c480
testb $0x1, %al
jne 0x75e4
jmp 0x7606
movsd 0x4da1c(%rip), %xmm0    # 0x55008
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x79c7
movsd -0x18(%rbp), %xmm0
movsd 0x4d9f5(%rip), %xmm1    # 0x55008
callq 0x3c440
testb $0x1, %al
jne 0x7631
movsd -0x18(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0x7631
jmp 0x766d
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movq -0x20(%rbp), %rdi
callq 0x7240
movaps %xmm0, %xmm1
movsd 0x4d9b9(%rip), %xmm0    # 0x55008
subsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x79c7
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3cd70
movaps %xmm0, %xmm2
movsd -0xc8(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x5530
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd 0x4e0cb(%rip), %xmm1    # 0x557c0
callq 0x3c440
testb $0x1, %al
jne 0x7700
jmp 0x771d
xorps %xmm0, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x79c7
movsd -0x48(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3cdd0
movsd %xmm0, -0x48(%rbp)
movsd 0x4d8d0(%rip), %xmm0    # 0x55008
subsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x18(%rbp), %xmm0
addsd -0x70(%rbp), %xmm0
movsd 0x4d8b4(%rip), %xmm1    # 0x55008
addsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x4d89b(%rip), %xmm0    # 0x55008
movsd %xmm0, -0x90(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0x4d87e(%rip), %xmm0    # 0x55008
addsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x78(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x88(%rbp), %xmm0
divsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x4d842(%rip), %xmm0    # 0x55008
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd 0x4d830(%rip), %xmm0    # 0x55008
addsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd 0x4dbde(%rip), %xmm0    # 0x553c8
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x70(%rbp), %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x88(%rbp), %xmm0
movsd -0x78(%rbp), %xmm2
movsd -0x90(%rbp), %xmm1
mulsd -0x58(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd -0x78(%rbp), %xmm2
movsd -0xa8(%rbp), %xmm1
mulsd -0x58(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c410
testb $0x1, %al
jne 0x7898
jmp 0x78d3
movsd -0x80(%rbp), %xmm0
divsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x40(%rbp), %xmm0
subsd -0x60(%rbp), %xmm0
divsd -0x60(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c820
movsd %xmm0, -0x68(%rbp)
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x78e0
movsd 0x4d72d(%rip), %xmm0    # 0x55008
movsd %xmm0, -0x68(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x80(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c820
movsd -0x30(%rbp), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x793b
jmp 0x798f
movsd -0x90(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x88(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0xa8(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0xa0(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
jmp 0x7991
movsd -0x68(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x77be
movsd -0x40(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)