// File: /workspace/github_cpp_makefile_star2_O2/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 0x2440c
movsd 0x2bf1b(%rip), %xmm1    # 0x303f0
movsd %xmm0, 0x10(%rsp)
callq 0x24279
testb %al, %al
je 0x455e
xorpd %xmm1, %xmm1
movsd 0x8(%rsp), %xmm0
callq 0x24239
testb %al, %al
je 0x4691
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x24468
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x24453
xorl %r14d, %r14d
testb $0x1, %al
sete %r14b
leaq 0x2d6f4(%rip), %r15     # 0x31c20
movsd 0x10(%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd 0x2bf48(%rip), %xmm1    # 0x30488
movsd %xmm0, 0x18(%rsp)
callq 0x24279
testb %al, %al
jne 0x46cf
movsd 0x18(%rsp), %xmm0
jmp 0x46e7
movsd 0x2bc92(%rip), %xmm0    # 0x301f8
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x2bc60(%rip), %xmm1    # 0x301e0
callq 0x24295
testb %al, %al
je 0x45ad
movsd 0x8(%rsp), %xmm1
addsd 0x2bc69(%rip), %xmm1    # 0x30200
movsd 0x10(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movapd %xmm1, %xmm0
jmp 0x4572
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm1, %xmm1
callq 0x24239
testb %al, %al
je 0x4604
movsd 0x8(%rsp), %xmm0
movsd 0x2bead(%rip), %xmm1    # 0x30480
callq 0x24279
testb %al, %al
jne 0x4660
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd 0x2bbfa(%rip), %xmm1    # 0x301f8
movapd %xmm1, %xmm0
jmp 0x45b3
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x2bde0(%rip), %xmm1    # 0x303f8
callq 0x24239
testb %al, %al
je 0x46ac
movsd 0x8(%rsp), %xmm0
movsd 0x2be3d(%rip), %xmm1    # 0x30470
callq 0x24239
testb %al, %al
jne 0x4660
movsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
addsd 0x2bb9e(%rip), %xmm1    # 0x301f8
movapd %xmm1, %xmm0
jmp 0x460a
movsd 0x2be10(%rip), %xmm0    # 0x30478
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
addsd 0x2bb7e(%rip), %xmm0    # 0x301f8
mulsd %xmm1, %xmm0
movsd 0x10(%rsp), %xmm1
divsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x4745
movsd 0x8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x12114
movsd 0x2bb51(%rip), %xmm1    # 0x301f8
jmp 0x4741
movsd 0x2bd44(%rip), %xmm1    # 0x303f8
movsd 0x8(%rsp), %xmm0
callq 0x241f5
testb %al, %al
je 0x474f
movsd 0x10(%rsp), %xmm0
jmp 0x4745
movsd 0x8(%rsp), %xmm1
addsd 0x2bb1b(%rip), %xmm1    # 0x301f8
movsd 0x10(%rsp), %xmm0
subsd %xmm1, %xmm0
movsd (%r15,%r14,8), %xmm1
movsd %xmm1, 0x8(%rsp)
mulsd 0x2bd95(%rip), %xmm0    # 0x30490
movq %rbx, %rdi
callq 0x2452d
mulsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2440c
movsd %xmm0, 0x18(%rsp)
movsd 0x10(%rsp), %xmm0
movq %rbx, %rdi
callq 0x12114
movsd 0x8(%rsp), %xmm1
mulsd 0x18(%rsp), %xmm0
movsd 0x2bd57(%rip), %xmm2    # 0x30490
divsd %xmm0, %xmm2
movapd %xmm2, %xmm0
mulsd %xmm1, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movsd 0x8(%rsp), %xmm3
addsd 0x2bca3(%rip), %xmm3    # 0x30400
movsd 0x2bca3(%rip), %xmm0    # 0x30408
mulsd %xmm3, %xmm0
addsd 0x2bc9f(%rip), %xmm0    # 0x30410
mulsd %xmm3, %xmm0
addsd 0x2bc9b(%rip), %xmm0    # 0x30418
mulsd %xmm3, %xmm0
addsd 0x2bc97(%rip), %xmm0    # 0x30420
mulsd %xmm3, %xmm0
addsd 0x2bc93(%rip), %xmm0    # 0x30428
mulsd %xmm3, %xmm0
addsd 0x2bc8f(%rip), %xmm0    # 0x30430
movsd 0x2bc8f(%rip), %xmm1    # 0x30438
mulsd %xmm3, %xmm1
addsd 0x2bc8b(%rip), %xmm1    # 0x30440
mulsd %xmm3, %xmm1
addsd 0x2bc87(%rip), %xmm1    # 0x30448
mulsd %xmm3, %xmm1
addsd 0x2bc83(%rip), %xmm1    # 0x30450
mulsd %xmm3, %xmm1
addsd 0x2bc7f(%rip), %xmm1    # 0x30458
mulsd %xmm3, %xmm0
mulsd %xmm3, %xmm1
addsd 0x2bc77(%rip), %xmm1    # 0x30460
movsd 0x2ba07(%rip), %xmm2    # 0x301f8
addsd %xmm2, %xmm0
mulsd %xmm3, %xmm1
addsd 0x2bc67(%rip), %xmm1    # 0x30468
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movsd 0x10(%rsp), %xmm2
mulsd %xmm0, %xmm2
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
jmp 0x4745