// File: /workspace/github_cpp_makefile_star2_O3/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::gammafunction(double, alglib_impl::ae_state*)
double gammafunction(double x, ae_state *_state)
{
#ifndef ALGLIB_INTERCEPTS_SPECFUNCS
    double p;
    double pp;
    double q;
    double qq;
    double z;
    ae_int_t i;
    double sgngam;
    double result;


    sgngam = 1;
    q = ae_fabs(x, _state);
    if( ae_fp_greater(q,33.0) )
    {
        if( ae_fp_less(x,0.0) )
        {
            p = ae_ifloor(q, _state);
            i = ae_round(p, _state);
            if( i%2==0 )
            {
                sgngam = -1;
            }
            z = q-p;
            if( ae_fp_greater(z,0.5) )
            {
                p = p+1;
                z = q-p;
            }
            z = q*ae_sin(ae_pi*z, _state);
            z = ae_fabs(z, _state);
            z = ae_pi/(z*gammafunc_gammastirf(q, _state));
        }
        else
        {
            z = gammafunc_gammastirf(x, _state);
        }
        result = sgngam*z;
        return result;
    }
    z = 1;
    while(ae_fp_greater_eq(x,3))
    {
        x = x-1;
        z = z*x;
    }
    while(ae_fp_less(x,0))
    {
        if( ae_fp_greater(x,-0.000000001) )
        {
            result = z/((1+0.5772156649015329*x)*x);
            return result;
        }
        z = z/x;
        x = x+1;
    }
    while(ae_fp_less(x,2))
    {
        if( ae_fp_less(x,0.000000001) )
        {
            result = z/((1+0.5772156649015329*x)*x);
            return result;
        }
        z = z/x;
        x = x+1.0;
    }
    if( ae_fp_eq(x,2) )
    {
        result = z;
        return result;
    }
    x = x-2.0;
    pp = 1.60119522476751861407E-4;
    pp = 1.19135147006586384913E-3+x*pp;
    pp = 1.04213797561761569935E-2+x*pp;
    pp = 4.76367800457137231464E-2+x*pp;
    pp = 2.07448227648435975150E-1+x*pp;
    pp = 4.94214826801497100753E-1+x*pp;
    pp = 9.99999999999999996796E-1+x*pp;
    qq = -2.31581873324120129819E-5;
    qq = 5.39605580493303397842E-4+x*qq;
    qq = -4.45641913851797240494E-3+x*qq;
    qq = 1.18139785222060435552E-2+x*qq;
    qq = 3.58236398605498653373E-2+x*qq;
    qq = -2.34591795718243348568E-1+x*qq;
    qq = 7.14304917030273074085E-2+x*qq;
    qq = 1.00000000000000000320+x*qq;
    result = z*pp/qq;
    return result;
#else
    return _ialglib_i_gammafunction(x);
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movsd %xmm0, 0x8(%rsp)
callq 0x25e30
movsd 0x2e999(%rip), %xmm1    # 0x333f0
movsd %xmm0, 0x10(%rsp)
callq 0x25bf9
testb %al, %al
je 0x4ae2
xorps %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x25bb9
testb %al, %al
je 0x4b3e
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e8e
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x25e79
xorl %r14d, %r14d
testb $0x1, %al
sete %r14b
leaq 0x30170(%rip), %r15     # 0x34c20
movsd 0x10(%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd 0x2e9c4(%rip), %xmm1    # 0x33488
movsd %xmm0, 0x18(%rsp)
callq 0x25bf9
testb %al, %al
jne 0x4d42
movsd 0x18(%rsp), %xmm0
jmp 0x4d5a
movsd 0x2e6fe(%rip), %xmm1    # 0x331e8
movsd 0x8(%rsp), %xmm0
callq 0x25c15
movsd 0x2e6e3(%rip), %xmm1    # 0x331e0
testb %al, %al
je 0x4b59
movsd 0x8(%rsp), %xmm0
addsd 0x2e6f9(%rip), %xmm0    # 0x33208
movsd %xmm0, 0x8(%rsp)
mulsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd 0x2e6c1(%rip), %xmm1    # 0x331e8
callq 0x25c15
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
testb %al, %al
jne 0x4b07
jmp 0x4b5f
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x12cba
movsd 0x2e68c(%rip), %xmm1    # 0x331e0
jmp 0x4db4
movsd 0x8(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
xorpd %xmm1, %xmm1
movsd %xmm0, 0x8(%rsp)
callq 0x25bb9
testb %al, %al
je 0x4bc1
movsd 0x8(%rsp), %xmm0
movsd 0x2e872(%rip), %xmm1    # 0x333f8
callq 0x25bf9
testb %al, %al
jne 0x4c43
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm2
divsd %xmm2, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd 0x2e62f(%rip), %xmm2    # 0x331e0
xorpd %xmm1, %xmm1
movsd %xmm2, 0x8(%rsp)
movapd %xmm2, %xmm0
jmp 0x4b6f
movsd 0x2e837(%rip), %xmm1    # 0x33400
movsd 0x8(%rsp), %xmm0
callq 0x25bb9
testb %al, %al
je 0x4c21
movsd 0x8(%rsp), %xmm0
movsd 0x2e822(%rip), %xmm1    # 0x33408
callq 0x25bb9
testb %al, %al
jne 0x4c43
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd 0x2e5d3(%rip), %xmm1    # 0x331e0
movsd %xmm1, 0x8(%rsp)
movapd %xmm1, %xmm0
movsd 0x2e7e1(%rip), %xmm1    # 0x33400
jmp 0x4bcf
movsd 0x2e7d7(%rip), %xmm1    # 0x33400
movsd 0x8(%rsp), %xmm0
callq 0x25b75
testb %al, %al
je 0x4c74
movsd 0x10(%rsp), %xmm0
jmp 0x4db8
movsd 0x2e835(%rip), %xmm0    # 0x33480
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
addsd 0x2e583(%rip), %xmm0    # 0x331e0
mulsd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x4db8
movsd 0x8(%rsp), %xmm3
addsd 0x2e78e(%rip), %xmm3    # 0x33410
movsd 0x2e78e(%rip), %xmm0    # 0x33418
mulsd %xmm3, %xmm0
addsd 0x2e78a(%rip), %xmm0    # 0x33420
mulsd %xmm3, %xmm0
addsd 0x2e786(%rip), %xmm0    # 0x33428
mulsd %xmm3, %xmm0
addsd 0x2e782(%rip), %xmm0    # 0x33430
mulsd %xmm3, %xmm0
addsd 0x2e77e(%rip), %xmm0    # 0x33438
mulsd %xmm3, %xmm0
addsd 0x2e77a(%rip), %xmm0    # 0x33440
movsd 0x2e77a(%rip), %xmm1    # 0x33448
mulsd %xmm3, %xmm1
addsd 0x2e776(%rip), %xmm1    # 0x33450
mulsd %xmm3, %xmm1
addsd 0x2e772(%rip), %xmm1    # 0x33458
mulsd %xmm3, %xmm1
addsd 0x2e76e(%rip), %xmm1    # 0x33460
mulsd %xmm3, %xmm0
mulsd %xmm3, %xmm1
addsd 0x2e766(%rip), %xmm1    # 0x33468
movsd 0x2e4d6(%rip), %xmm2    # 0x331e0
mulsd %xmm3, %xmm1
addsd 0x2e75a(%rip), %xmm1    # 0x33470
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm1
addsd 0x2e752(%rip), %xmm1    # 0x33478
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
jmp 0x4db8
movsd 0x8(%rsp), %xmm1
addsd 0x2e490(%rip), %xmm1    # 0x331e0
movsd 0x10(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd (%r15,%r14,8), %xmm1
movsd %xmm1, 0x8(%rsp)
mulsd 0x2e722(%rip), %xmm0    # 0x33490
movq %rbx, %rdi
callq 0x25f5f
mulsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x25e30
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x12cba
movsd 0x8(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm0
movsd 0x2e6e4(%rip), %xmm2    # 0x33490
divsd %xmm0, %xmm2
movapd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq