// File: /workspace/github_cpp_makefile_star2_O1/mouda[P]LTE_random_access-simulate/specialfunctions.cpp
// Function: alglib_impl::invstudenttdistribution(long, double, alglib_impl::ae_state*)
double invstudenttdistribution(ae_int_t k, double p, ae_state *_state)
{
    double t;
    double rk;
    double z;
    ae_int_t rflg;
    double result;


    ae_assert((k>0&&ae_fp_greater(p,0))&&ae_fp_less(p,1), "Domain error in InvStudentTDistribution", _state);
    rk = k;
    if( ae_fp_greater(p,0.25)&&ae_fp_less(p,0.75) )
    {
        if( ae_fp_eq(p,0.5) )
        {
            result = 0;
            return result;
        }
        z = 1.0-2.0*p;
        z = invincompletebeta(0.5, 0.5*rk, ae_fabs(z, _state), _state);
        t = ae_sqrt(rk*z/(1.0-z), _state);
        if( ae_fp_less(p,0.5) )
        {
            t = -t;
        }
        result = t;
        return result;
    }
    rflg = -1;
    if( ae_fp_greater_eq(p,0.5) )
    {
        p = 1.0-p;
        rflg = 1;
    }
    z = invincompletebeta(0.5*rk, 0.5, 2.0*p, _state);
    if( ae_fp_less(ae_maxrealnumber*z,rk) )
    {
        result = rflg*ae_maxrealnumber;
        return result;
    }
    t = ae_sqrt(rk/z-rk, _state);
    result = rflg*t;
    return result;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
testq %rdi, %rdi
movsd %xmm0, (%rsp)
jle 0x11f1d
xorps %xmm1, %xmm1
callq 0x2633e
testb %al, %al
je 0x11f1d
movsd 0x2228f(%rip), %xmm1    # 0x341a0
movsd (%rsp), %xmm0
callq 0x262fe
jmp 0x11f1f
xorl %eax, %eax
movzbl %al, %edi
leaq 0x24977(%rip), %rsi     # 0x368a0
movq %rbx, %rdx
callq 0x2581c
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x23519(%rip), %xmm1    # 0x35460
movsd (%rsp), %xmm0
callq 0x2633e
testb %al, %al
je 0x12031
movsd 0x23547(%rip), %xmm1    # 0x354a8
movsd (%rsp), %xmm0
callq 0x262fe
testb %al, %al
je 0x12031
movsd 0x224ed(%rip), %xmm1    # 0x34468
movsd (%rsp), %xmm0
callq 0x262ba
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x120ee
movsd (%rsp), %xmm1
addsd %xmm1, %xmm1
movsd 0x221fe(%rip), %xmm0    # 0x341a0
subsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm2
movsd 0x224b4(%rip), %xmm1    # 0x34468
mulsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
movq %rbx, %rdi
callq 0x26575
movapd %xmm0, %xmm2
movsd 0x22496(%rip), %xmm0    # 0x34468
movsd 0x10(%rsp), %xmm1
movq %rbx, %rdi
callq 0xb2f1
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x221ae(%rip), %xmm2    # 0x341a0
subsd %xmm0, %xmm2
divsd %xmm2, %xmm1
movapd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x2658d
movapd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
movsd 0x2244f(%rip), %xmm1    # 0x34468
callq 0x262fe
testb %al, %al
jne 0x120fa
movapd 0x10(%rsp), %xmm1
jmp 0x120ee
movsd 0x2242f(%rip), %xmm1    # 0x34468
movsd (%rsp), %xmm0
callq 0x2635a
movsd 0x22155(%rip), %xmm3    # 0x341a0
testb %al, %al
jne 0x12056
movsd (%rsp), %xmm2
jmp 0x12063
movapd %xmm3, %xmm0
subsd (%rsp), %xmm0
movapd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm4
jne 0x12073
movsd 0x2215d(%rip), %xmm3    # 0x341d0
movapd %xmm3, 0x10(%rsp)
movapd %xmm4, %xmm0
movsd 0x223e3(%rip), %xmm1    # 0x34468
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm2
movq %rbx, %rdi
callq 0xb2f1
movapd %xmm0, %xmm1
movsd 0x22597(%rip), %xmm0    # 0x34638
movsd %xmm1, (%rsp)
mulsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x262fe
testb %al, %al
je 0x120c9
movapd 0x10(%rsp), %xmm1
mulsd 0x22571(%rip), %xmm1    # 0x34638
jmp 0x120ee
movsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
divsd (%rsp), %xmm0
subsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x2658d
movapd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movapd 0x10(%rsp), %xmm1
xorpd 0x220d8(%rip), %xmm1    # 0x341e0
jmp 0x120ee