// File: 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 %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x10(%rbp)
movb %al, -0x49(%rbp)
jle 0x19d01
movsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
callq 0x3c4c0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x49(%rbp)
jne 0x19cec
jmp 0x19d01
movsd -0x18(%rbp), %xmm0
movsd 0x3b30f(%rip), %xmm1    # 0x55008
callq 0x3c440
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
movq -0x20(%rbp), %rdx
movzbl %al, %edi
andl $0x1, %edi
leaq 0x3db0b(%rip), %rsi     # 0x57820
callq 0x3b240
cvtsi2sdq -0x10(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x3c6e6(%rip), %xmm1    # 0x56418
callq 0x3c4c0
testb $0x1, %al
jne 0x19d40
jmp 0x19e5d
movsd -0x18(%rbp), %xmm0
movsd 0x3c703(%rip), %xmm1    # 0x56450
callq 0x3c440
testb $0x1, %al
jne 0x19d5b
jmp 0x19e5d
movsd -0x18(%rbp), %xmm0
movsd 0x3b6e8(%rip), %xmm1    # 0x55450
callq 0x3c3d0
testb $0x1, %al
jne 0x19d73
jmp 0x19d8a
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x19f3e
movsd -0x18(%rbp), %xmm1
addsd %xmm1, %xmm1
movsd 0x3b26d(%rip), %xmm0    # 0x55008
subsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x3b6a4(%rip), %xmm0    # 0x55450
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x38(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c820
movsd -0x58(%rbp), %xmm1
movaps %xmm0, %xmm2
movq -0x20(%rbp), %rdi
movsd 0x3b678(%rip), %xmm0    # 0x55450
callq 0xf3a0
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x38(%rbp), %xmm0
movsd 0x3b214(%rip), %xmm1    # 0x55008
subsd -0x38(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c890
movsd %xmm0, -0x28(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x3b638(%rip), %xmm1    # 0x55450
callq 0x3c440
testb $0x1, %al
jne 0x19e23
jmp 0x19e44
movsd -0x28(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x19f3e
movq $-0x1, -0x40(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x3b5de(%rip), %xmm1    # 0x55450
callq 0x3c500
testb $0x1, %al
jne 0x19e7d
jmp 0x19e97
movsd 0x3b183(%rip), %xmm0    # 0x55008
subsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
movq $0x1, -0x40(%rbp)
movsd 0x3b5b1(%rip), %xmm0    # 0x55450
mulsd -0x30(%rbp), %xmm0
movsd 0x3b51c(%rip), %xmm2    # 0x553c8
mulsd -0x18(%rbp), %xmm2
movq -0x20(%rbp), %rdi
movsd 0x3b593(%rip), %xmm1    # 0x55450
callq 0xf3a0
movsd %xmm0, -0x38(%rbp)
movsd 0x3b8d9(%rip), %xmm0    # 0x557a8
mulsd -0x38(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
callq 0x3c440
testb $0x1, %al
jne 0x19ee4
jmp 0x19f07
cvtsi2sdq -0x40(%rbp), %xmm0
movsd 0x3b8b6(%rip), %xmm1    # 0x557a8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x19f3e
movsd -0x30(%rbp), %xmm0
divsd -0x38(%rbp), %xmm0
subsd -0x30(%rbp), %xmm0
movq -0x20(%rbp), %rdi
callq 0x3c890
movsd %xmm0, -0x28(%rbp)
cvtsi2sdq -0x40(%rbp), %xmm0
mulsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)