// File: mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::incompletegamma(double, double, alglib_impl::ae_state*)
double incompletegamma(double a, double x, ae_state *_state)
{
    double igammaepsilon;
    double ans;
    double ax;
    double c;
    double r;
    double tmp;
    double result;


    igammaepsilon = 0.000000000000001;
    if( ae_fp_less_eq(x,0)||ae_fp_less_eq(a,0) )
    {
        result = 0;
        return result;
    }
    if( ae_fp_greater(x,1)&&ae_fp_greater(x,a) )
    {
        result = 1-incompletegammac(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);
    r = a;
    c = 1;
    ans = 1;
    do
    {
        r = r+1;
        c = c*x/r;
        ans = ans+c;
    }
    while(ae_fp_greater(c/ans,igammaepsilon));
    result = ans*ax/a;
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movsd 0x4e55a(%rip), %xmm0    # 0x557b8
movsd %xmm0, -0x28(%rbp)
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c480
testb $0x1, %al
jne 0x7287
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c480
testb $0x1, %al
jne 0x7287
jmp 0x729e
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x743e
movsd -0x18(%rbp), %xmm0
movsd 0x4dd5d(%rip), %xmm1    # 0x55008
callq 0x3c4c0
testb $0x1, %al
jne 0x72b6
jmp 0x7301
movsd -0x18(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x72cb
jmp 0x7301
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
movq -0x20(%rbp), %rdi
callq 0x7580
movaps %xmm0, %xmm1
movsd 0x4dd1f(%rip), %xmm0    # 0x55008
subsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x743e
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3cd70
movaps %xmm0, %xmm2
movsd -0x68(%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, -0x60(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x20(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x5530
movaps %xmm0, %xmm1
movsd -0x60(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movsd 0x4e446(%rip), %xmm1    # 0x557c0
callq 0x3c440
testb $0x1, %al
jne 0x7385
jmp 0x739c
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x743e
movsd -0x38(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3cdd0
movsd %xmm0, -0x38(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0x4dc47(%rip), %xmm0    # 0x55008
movsd %xmm0, -0x40(%rbp)
movsd 0x4dc3a(%rip), %xmm0    # 0x55008
movsd %xmm0, -0x30(%rbp)
movsd 0x4dc2d(%rip), %xmm0    # 0x55008
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x40(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x30(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x40(%rbp), %xmm0
divsd -0x30(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
callq 0x3c4c0
testb $0x1, %al
jne 0x73d3
movsd -0x30(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)