// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]yahs/binomlite.c
// Function: qnorm
double qnorm(double p, double mu, double sigma, int lower_tail, int log_p)
{
    double p_, q, r, val;

    if(sigma == 0)
        return mu;

    p_ = R_DT_qIv(p);/* real lower_tail prob. p */
    q = p_ - 0.5;
/*-- use AS 241 --- */
/* double ppnd16_(double *p, long *ifault)*/
/*      ALGORITHM AS241  APPL. STATIST. (1988) VOL. 37, NO. 3

        Produces the normal deviate Z corresponding to a given lower
        tail area of P; Z is accurate to about 1 part in 10**16.

        (original fortran code used PARAMETER(..) for the coefficients
         and provided hash codes for checking them...)
*/
    if (fabs(q) <= .425) {/* 0.075 <= p <= 0.925 */
        r = .180625 - q * q;
        val =
            q * (((((((r * 2509.0809287301226727 +
                       33430.575583588128105) * r + 67265.770927008700853) * r +
                     45921.953931549871457) * r + 13731.693765509461125) * r +
                   1971.5909503065514427) * r + 133.14166789178437745) * r +
                 3.387132872796366608)
            / (((((((r * 5226.495278852854561 +
                     28729.085735721942674) * r + 39307.89580009271061) * r +
                   21213.794301586595867) * r + 5394.1960214247511077) * r +
                 687.1870074920579083) * r + 42.313330701600911252) * r + 1.);
    } else { /* closer than 0.075 from {0,1} boundary */
        /* r = min(p, 1-p) < 0.075 */
        if (q > 0)
            r = R_DT_CIv(p); /* 1-p */
        else
            r = p_;/* = R_DT_Iv(p) ^=  p */

        r = sqrt(- ((log_p &&
                        ((lower_tail && q <= 0) || (!lower_tail && q > 0))) ?
                    p : /* else */ log(r)));
        /* r = sqrt(-log(r))  <==>  min(p, 1-p) = exp( - r^2 ) */
        if (r <= 5.) { /* <==> min(p,1-p) >= exp(-25) ~= 1.3888e-11 */
            r += -1.6;
            val = (((((((r * 7.7454501427834140764e-4 +
                       .0227238449892691845833) * r + .24178072517745061177) *
                     r + 1.27045825245236838258) * r +
                    3.64784832476320460504) * r + 5.7694972214606914055) *
                  r + 4.6303378461565452959) * r +
                 1.42343711074968357734)
                / (((((((r *
                         1.05075007164441684324e-9 + 5.475938084995344946e-4) *
                        r + .0151986665636164571966) * r +
                       .14810397642748007459) * r + .68976733498510000455) *
                     r + 1.6763848301838038494) * r +
                    2.05319162663775882187) * r + 1.);
        } else { /* very close to  0 or 1 */
            r += -5.;
            val = (((((((r * 2.01033439929228813265e-7 +
                       2.71155556874348757815e-5) * r +
                      .0012426609473880784386) * r + .026532189526576123093) *
                    r + .29656057182850489123) * r +
                   1.7848265399172913358) * r + 5.4637849111641143699) *
                 r + 6.6579046435011037772)
                / (((((((r *
                         2.04426310338993978564e-15 + 1.4215117583164458887e-7)*
                        r + 1.8463183175100546818e-5) * r +
                       7.868691311456132591e-4) * r + .0148753612908506148525)
                     * r + .13692988092273580531) * r +
                    .59983220655588793769) * r + 1.);
        }

        if(q < 0.0)
            val = -val;
        /* return (q >= 0.)? r : -r ;*/
    }

    return mu + sigma * val;
}

// Assembly:
movapd %xmm0, %xmm3
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
jne 0x16dd6
jp 0x16dd6
movaps %xmm1, %xmm0
retq
pushq %rbp
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movl %edi, %ebx
testl %esi, %esi
movsd %xmm2, 0x8(%rsp)
movsd %xmm1, 0x30(%rsp)
movapd %xmm3, 0x20(%rsp)
je 0x16e05
movapd %xmm3, %xmm0
testl %ebx, %ebx
je 0x16e0f
callq 0x2550
jmp 0x16e32
testl %ebx, %ebx
je 0x16e1e
movapd %xmm3, %xmm0
jmp 0x16e32
callq 0x22f0
xorpd 0x8eb4(%rip), %xmm0     # 0x1fcd0
jmp 0x16e32
movsd 0x73ba(%rip), %xmm1     # 0x1e1e0
movapd %xmm1, %xmm0
subsd %xmm3, %xmm0
addsd %xmm1, %xmm0
movsd 0x8946(%rip), %xmm3     # 0x1f780
addsd %xmm0, %xmm3
movapd 0x8e7a(%rip), %xmm1     # 0x1fcc0
andpd %xmm3, %xmm1
movsd 0x8c3e(%rip), %xmm2     # 0x1fa90
ucomisd %xmm1, %xmm2
jae 0x16e9a
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm3
movapd %xmm3, 0x10(%rsp)
jbe 0x16f79
testl %ebp, %ebp
movapd 0x20(%rsp), %xmm0
je 0x16f85
testl %ebx, %ebx
je 0x16fa3
callq 0x22f0
movapd 0x20(%rsp), %xmm2
xorpd 0x8e3b(%rip), %xmm0     # 0x1fcd0
jmp 0x16fae
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1
movsd 0x8bee(%rip), %xmm0     # 0x1fa98
subsd %xmm1, %xmm0
movsd 0x8bea(%rip), %xmm1     # 0x1faa0
mulsd %xmm0, %xmm1
addsd 0x8be6(%rip), %xmm1     # 0x1faa8
mulsd %xmm0, %xmm1
addsd 0x8be2(%rip), %xmm1     # 0x1fab0
mulsd %xmm0, %xmm1
addsd 0x8bde(%rip), %xmm1     # 0x1fab8
mulsd %xmm0, %xmm1
addsd 0x8bda(%rip), %xmm1     # 0x1fac0
mulsd %xmm0, %xmm1
addsd 0x8bd6(%rip), %xmm1     # 0x1fac8
mulsd %xmm0, %xmm1
addsd 0x8bd2(%rip), %xmm1     # 0x1fad0
mulsd %xmm0, %xmm1
addsd 0x8bce(%rip), %xmm1     # 0x1fad8
movsd 0x8bce(%rip), %xmm2     # 0x1fae0
mulsd %xmm0, %xmm2
addsd 0x8bca(%rip), %xmm2     # 0x1fae8
mulsd %xmm0, %xmm2
addsd 0x8bc6(%rip), %xmm2     # 0x1faf0
mulsd %xmm0, %xmm2
addsd 0x8bc2(%rip), %xmm2     # 0x1faf8
mulsd %xmm0, %xmm2
addsd 0x8bbe(%rip), %xmm2     # 0x1fb00
mulsd %xmm0, %xmm2
addsd 0x8bba(%rip), %xmm2     # 0x1fb08
mulsd %xmm3, %xmm1
mulsd %xmm0, %xmm2
addsd 0x8bb2(%rip), %xmm2     # 0x1fb10
mulsd %xmm0, %xmm2
addsd 0x76ae(%rip), %xmm2     # 0x1e618
divsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
jmp 0x17116
testl %ebp, %ebp
movapd 0x20(%rsp), %xmm2
jne 0x16fb4
jmp 0x16fd8
testl %ebx, %ebx
je 0x16fd8
movsd 0x724f(%rip), %xmm2     # 0x1e1e0
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movapd %xmm1, %xmm0
jmp 0x16fd8
callq 0x2550
movapd 0x20(%rsp), %xmm2
movapd 0x10(%rsp), %xmm3
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm3
seta %al
ucomisd %xmm3, %xmm1
setae %dl
testl %ebx, %ebx
setne %sil
sete %cl
testb %dl, %sil
jne 0x16fe7
andb %al, %cl
jne 0x16fe7
callq 0x2240
movapd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm2
movapd 0x8ce1(%rip), %xmm0     # 0x1fcd0
xorpd %xmm2, %xmm0
movsd 0x8b1d(%rip), %xmm1     # 0x1fb18
ucomisd %xmm2, %xmm1
jb 0x17007
sqrtsd %xmm0, %xmm0
jmp 0x17012
callq 0x24f0
movapd 0x10(%rsp), %xmm3
movsd 0x8(%rsp), %xmm2
movsd 0x8b00(%rip), %xmm1     # 0x1fb20
ucomisd %xmm0, %xmm1
jae 0x17090
addsd 0x8b02(%rip), %xmm0     # 0x1fb30
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x8dd6(%rip), %xmm1     # 0x1fe10
mulpd %xmm0, %xmm1
addpd 0x8dda(%rip), %xmm1     # 0x1fe20
mulpd %xmm0, %xmm1
addpd 0x8dde(%rip), %xmm1     # 0x1fe30
mulpd %xmm0, %xmm1
addpd 0x8de2(%rip), %xmm1     # 0x1fe40
mulpd %xmm0, %xmm1
addpd 0x8de6(%rip), %xmm1     # 0x1fe50
mulpd %xmm0, %xmm1
addpd 0x8dea(%rip), %xmm1     # 0x1fe60
mulpd %xmm0, %xmm1
addpd 0x8dee(%rip), %xmm1     # 0x1fe70
mulpd %xmm0, %xmm1
addpd 0x8df2(%rip), %xmm1     # 0x1fe80
jmp 0x170f8
addsd 0x8a90(%rip), %xmm0     # 0x1fb28
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x8cec(%rip), %xmm1     # 0x1fd90
mulpd %xmm0, %xmm1
addpd 0x8cf0(%rip), %xmm1     # 0x1fda0
mulpd %xmm0, %xmm1
addpd 0x8cf4(%rip), %xmm1     # 0x1fdb0
mulpd %xmm0, %xmm1
addpd 0x8cf8(%rip), %xmm1     # 0x1fdc0
mulpd %xmm0, %xmm1
addpd 0x8cfc(%rip), %xmm1     # 0x1fdd0
mulpd %xmm0, %xmm1
addpd 0x8d00(%rip), %xmm1     # 0x1fde0
mulpd %xmm0, %xmm1
addpd 0x8d04(%rip), %xmm1     # 0x1fdf0
mulpd %xmm0, %xmm1
addpd 0x8d08(%rip), %xmm1     # 0x1fe00
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm0
jbe 0x17116
xorpd 0x8bba(%rip), %xmm1     # 0x1fcd0
mulsd %xmm1, %xmm2
addsd 0x30(%rsp), %xmm2
movapd %xmm2, %xmm0
addq $0x38, %rsp
popq %rbx
popq %rbp
retq