// File: /workspace/github_cpp_makefile_star2_O3/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 0x11d47
xorps %xmm1, %xmm1
callq 0x25bf9
testb %al, %al
je 0x11d47
movsd 0x214a5(%rip), %xmm1    # 0x331e0
movsd (%rsp), %xmm0
callq 0x25bb9
jmp 0x11d49
xorl %eax, %eax
movzbl %al, %edi
leaq 0x23ced(%rip), %rsi     # 0x35a40
movq %rbx, %rdx
callq 0x2510e
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x224e7(%rip), %xmm1    # 0x34258
movsd (%rsp), %xmm0
callq 0x25bf9
testb %al, %al
je 0x11e5b
movsd 0x2251d(%rip), %xmm1    # 0x342a8
movsd (%rsp), %xmm0
callq 0x25bb9
testb %al, %al
je 0x11e5b
movsd 0x216e3(%rip), %xmm1    # 0x33488
movsd (%rsp), %xmm0
callq 0x25b75
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x11f18
movsd (%rsp), %xmm1
addsd %xmm1, %xmm1
movsd 0x21414(%rip), %xmm0    # 0x331e0
subsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm2
movsd 0x216aa(%rip), %xmm1    # 0x33488
mulsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
movq %rbx, %rdi
callq 0x25e30
movapd %xmm0, %xmm2
movsd 0x2168c(%rip), %xmm0    # 0x33488
movsd 0x10(%rsp), %xmm1
movq %rbx, %rdi
callq 0xb0e5
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x213c4(%rip), %xmm2    # 0x331e0
subsd %xmm0, %xmm2
divsd %xmm2, %xmm1
movapd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x25e48
movapd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
movsd 0x21645(%rip), %xmm1    # 0x33488
callq 0x25bb9
testb %al, %al
jne 0x11f24
movapd 0x10(%rsp), %xmm1
jmp 0x11f18
movsd 0x21625(%rip), %xmm1    # 0x33488
movsd (%rsp), %xmm0
callq 0x25c15
movsd 0x2136b(%rip), %xmm3    # 0x331e0
testb %al, %al
jne 0x11e80
movsd (%rsp), %xmm2
jmp 0x11e8d
movapd %xmm3, %xmm0
subsd (%rsp), %xmm0
movapd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm4
jne 0x11e9d
movsd 0x2136b(%rip), %xmm3    # 0x33208
movapd %xmm3, 0x10(%rsp)
movapd %xmm4, %xmm0
movsd 0x215d9(%rip), %xmm1    # 0x33488
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm2
movq %rbx, %rdi
callq 0xb0e5
movapd %xmm0, %xmm1
movsd 0x21795(%rip), %xmm0    # 0x33660
movsd %xmm1, (%rsp)
mulsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x25bb9
testb %al, %al
je 0x11ef3
movapd 0x10(%rsp), %xmm1
mulsd 0x2176f(%rip), %xmm1    # 0x33660
jmp 0x11f18
movsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
divsd (%rsp), %xmm0
subsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x25e48
movapd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movapd 0x10(%rsp), %xmm1
xorpd 0x2127e(%rip), %xmm1    # 0x331b0
jmp 0x11f18