// File: /workspace/github_c_makefile_star2_O3/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 0x1b544
jp 0x1b544
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 0x1b573
movapd %xmm3, %xmm0
testl %ebx, %ebx
je 0x1b57d
callq 0x2550
jmp 0x1b5a0
testl %ebx, %ebx
je 0x1b58c
movapd %xmm3, %xmm0
jmp 0x1b5a0
callq 0x22f0
xorpd 0x8866(%rip), %xmm0     # 0x23df0
jmp 0x1b5a0
movsd 0x6c84(%rip), %xmm1     # 0x22218
movapd %xmm1, %xmm0
subsd %xmm3, %xmm0
addsd %xmm1, %xmm0
movsd 0x8310(%rip), %xmm3     # 0x238b8
addsd %xmm0, %xmm3
movapd 0x882c(%rip), %xmm1     # 0x23de0
andpd %xmm3, %xmm1
movsd 0x85f0(%rip), %xmm2     # 0x23bb0
ucomisd %xmm1, %xmm2
jae 0x1b608
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm3
movapd %xmm3, 0x10(%rsp)
jbe 0x1b6e7
testl %ebp, %ebp
movapd 0x20(%rsp), %xmm0
je 0x1b6f3
testl %ebx, %ebx
je 0x1b711
callq 0x22f0
movapd 0x20(%rsp), %xmm2
xorpd 0x87ed(%rip), %xmm0     # 0x23df0
jmp 0x1b71c
movapd %xmm3, %xmm1
mulsd %xmm3, %xmm1
movsd 0x85a0(%rip), %xmm0     # 0x23bb8
subsd %xmm1, %xmm0
movsd 0x859c(%rip), %xmm1     # 0x23bc0
mulsd %xmm0, %xmm1
addsd 0x8598(%rip), %xmm1     # 0x23bc8
mulsd %xmm0, %xmm1
addsd 0x8594(%rip), %xmm1     # 0x23bd0
mulsd %xmm0, %xmm1
addsd 0x8590(%rip), %xmm1     # 0x23bd8
mulsd %xmm0, %xmm1
addsd 0x858c(%rip), %xmm1     # 0x23be0
mulsd %xmm0, %xmm1
addsd 0x8588(%rip), %xmm1     # 0x23be8
mulsd %xmm0, %xmm1
addsd 0x8584(%rip), %xmm1     # 0x23bf0
mulsd %xmm0, %xmm1
addsd 0x8580(%rip), %xmm1     # 0x23bf8
movsd 0x8580(%rip), %xmm2     # 0x23c00
mulsd %xmm0, %xmm2
addsd 0x857c(%rip), %xmm2     # 0x23c08
mulsd %xmm0, %xmm2
addsd 0x8578(%rip), %xmm2     # 0x23c10
mulsd %xmm0, %xmm2
addsd 0x8574(%rip), %xmm2     # 0x23c18
mulsd %xmm0, %xmm2
addsd 0x8570(%rip), %xmm2     # 0x23c20
mulsd %xmm0, %xmm2
addsd 0x856c(%rip), %xmm2     # 0x23c28
mulsd %xmm3, %xmm1
mulsd %xmm0, %xmm2
addsd 0x8564(%rip), %xmm2     # 0x23c30
mulsd %xmm0, %xmm2
addsd 0x6f88(%rip), %xmm2     # 0x22660
divsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm2
jmp 0x1b884
testl %ebp, %ebp
movapd 0x20(%rsp), %xmm2
jne 0x1b722
jmp 0x1b746
testl %ebx, %ebx
je 0x1b746
movsd 0x6b19(%rip), %xmm2     # 0x22218
movapd %xmm2, %xmm1
subsd %xmm0, %xmm1
addsd %xmm2, %xmm1
movapd %xmm1, %xmm0
jmp 0x1b746
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 0x1b755
andb %al, %cl
jne 0x1b755
callq 0x2240
movapd 0x10(%rsp), %xmm3
movapd %xmm0, %xmm2
movapd 0x8693(%rip), %xmm0     # 0x23df0
xorpd %xmm2, %xmm0
movsd 0x84cf(%rip), %xmm1     # 0x23c38
ucomisd %xmm2, %xmm1
jb 0x1b775
sqrtsd %xmm0, %xmm0
jmp 0x1b780
callq 0x24f0
movapd 0x10(%rsp), %xmm3
movsd 0x8(%rsp), %xmm2
movsd 0x84b2(%rip), %xmm1     # 0x23c40
ucomisd %xmm0, %xmm1
jae 0x1b7fe
addsd 0x84b4(%rip), %xmm0     # 0x23c50
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x8798(%rip), %xmm1     # 0x23f40
mulpd %xmm0, %xmm1
addpd 0x879c(%rip), %xmm1     # 0x23f50
mulpd %xmm0, %xmm1
addpd 0x87a0(%rip), %xmm1     # 0x23f60
mulpd %xmm0, %xmm1
addpd 0x87a4(%rip), %xmm1     # 0x23f70
mulpd %xmm0, %xmm1
addpd 0x87a8(%rip), %xmm1     # 0x23f80
mulpd %xmm0, %xmm1
addpd 0x87ac(%rip), %xmm1     # 0x23f90
mulpd %xmm0, %xmm1
addpd 0x87b0(%rip), %xmm1     # 0x23fa0
mulpd %xmm0, %xmm1
addpd 0x87b4(%rip), %xmm1     # 0x23fb0
jmp 0x1b866
addsd 0x8442(%rip), %xmm0     # 0x23c48
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd 0x86ae(%rip), %xmm1     # 0x23ec0
mulpd %xmm0, %xmm1
addpd 0x86b2(%rip), %xmm1     # 0x23ed0
mulpd %xmm0, %xmm1
addpd 0x86b6(%rip), %xmm1     # 0x23ee0
mulpd %xmm0, %xmm1
addpd 0x86ba(%rip), %xmm1     # 0x23ef0
mulpd %xmm0, %xmm1
addpd 0x86be(%rip), %xmm1     # 0x23f00
mulpd %xmm0, %xmm1
addpd 0x86c2(%rip), %xmm1     # 0x23f10
mulpd %xmm0, %xmm1
addpd 0x86c6(%rip), %xmm1     # 0x23f20
mulpd %xmm0, %xmm1
addpd 0x86ca(%rip), %xmm1     # 0x23f30
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
divsd %xmm0, %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm3, %xmm0
jbe 0x1b884
xorpd 0x856c(%rip), %xmm1     # 0x23df0
mulsd %xmm1, %xmm2
addsd 0x30(%rsp), %xmm2
movapd %xmm2, %xmm0
addq $0x38, %rsp
popq %rbx
popq %rbp
retq