// File: /workspace/github_cpp_makefile_star2_O2/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 0x111ae
xorps %xmm1, %xmm1
callq 0x24279
testb %al, %al
je 0x111ae
movsd 0x1f056(%rip), %xmm1    # 0x301f8
movsd (%rsp), %xmm0
callq 0x24239
jmp 0x111b0
xorl %eax, %eax
movzbl %al, %edi
leaq 0x21876(%rip), %rsi     # 0x32a30
movq %rbx, %rdx
callq 0x238ca
cvtsi2sd %r14, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x20083(%rip), %xmm1    # 0x31258
movsd (%rsp), %xmm0
callq 0x24279
testb %al, %al
je 0x112bf
movsd 0x200b9(%rip), %xmm1    # 0x312a8
movsd (%rsp), %xmm0
callq 0x24239
testb %al, %al
je 0x112bf
movsd 0x1f27f(%rip), %xmm1    # 0x30488
movsd (%rsp), %xmm0
callq 0x241f5
xorpd %xmm1, %xmm1
testb %al, %al
jne 0x1137c
movsd (%rsp), %xmm1
addsd %xmm1, %xmm1
movsd 0x1efc8(%rip), %xmm0    # 0x301f8
subsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm2
movsd 0x1f246(%rip), %xmm1    # 0x30488
mulsd %xmm1, %xmm2
movsd %xmm2, 0x10(%rsp)
movq %rbx, %rdi
callq 0x2440c
movapd %xmm0, %xmm2
movsd 0x1f228(%rip), %xmm0    # 0x30488
movsd 0x10(%rsp), %xmm1
movq %rbx, %rdi
callq 0xa961
movsd 0x8(%rsp), %xmm1
mulsd %xmm0, %xmm1
movsd 0x1ef78(%rip), %xmm2    # 0x301f8
subsd %xmm0, %xmm2
divsd %xmm2, %xmm1
movapd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x24424
movapd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
movsd 0x1f1e1(%rip), %xmm1    # 0x30488
callq 0x24239
testb %al, %al
jne 0x11388
movapd 0x10(%rsp), %xmm1
jmp 0x1137c
movsd 0x1f1c1(%rip), %xmm1    # 0x30488
movsd (%rsp), %xmm0
callq 0x24295
movsd 0x1ef1f(%rip), %xmm3    # 0x301f8
testb %al, %al
jne 0x112e4
movsd (%rsp), %xmm2
jmp 0x112f1
movapd %xmm3, %xmm0
subsd (%rsp), %xmm0
movapd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm4
jne 0x11301
movsd 0x1eeff(%rip), %xmm3    # 0x30200
movapd %xmm3, 0x10(%rsp)
movapd %xmm4, %xmm0
movsd 0x1f175(%rip), %xmm1    # 0x30488
mulsd %xmm1, %xmm0
addsd %xmm2, %xmm2
movq %rbx, %rdi
callq 0xa961
movapd %xmm0, %xmm1
movsd 0x1f331(%rip), %xmm0    # 0x30660
movsd %xmm1, (%rsp)
mulsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x24239
testb %al, %al
je 0x11357
movapd 0x10(%rsp), %xmm1
mulsd 0x1f30b(%rip), %xmm1    # 0x30660
jmp 0x1137c
movsd 0x8(%rsp), %xmm1
movapd %xmm1, %xmm0
divsd (%rsp), %xmm0
subsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x24424
movapd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movapd 0x10(%rsp), %xmm1
xorpd 0x1ee1a(%rip), %xmm1    # 0x301b0
jmp 0x1137c