// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/binomlite.c
// Function: grat_r
static double grat_r(double a, double x, double log_r, double eps)
{
/* -----------------------------------------------------------------------
 *        Scaled complement of incomplete gamma ratio function
 *                   grat_r(a,x,r) :=  Q(a,x) / r
 * where
 *               Q(a,x) = pgamma(x,a, lower.tail=0)
 *     and            r = e^(-x)* x^a / Gamma(a) ==  exp(log_r)
 *
 *     It is assumed that a <= 1.  eps is the tolerance to be used.
 * ----------------------------------------------------------------------- */

    if (a * x == 0.) { /* L130: */
    if (x <= a) {
        /* L100: */ return exp(-log_r);
    } else {
        /* L110:*/  return 0.;
    }
    }
    else if (a == 0.5) { // e.g. when called from pt()
    /* L120: */
    if (x < 0.25) {
        double p = erf__(sqrt(x));
        return (0.5 - p + 0.5)*exp(-log_r);

        } else { // 2013-02-27: improvement for "large" x: direct computation of q/r:
        double sx = sqrt(x),
        q_r = erfc1(1, sx)/sx * M_SQRT_PI;
        return q_r;
    }

    } else if (x < 1.1) { /* L10:  Taylor series for  P(a,x)/x^a */

    double an = 3.,
        c = x,
        sum = x / (a + 3.),
        tol = eps * 0.1 / (a + 1.), t;
    do {
        an += 1.;
        c *= -(x / an);
        t = c / (a + an);
        sum += t;
    } while (fabs(t) > tol);

    double j = a * x * ((sum/6. - 0.5/(a + 2.)) * x + 1./(a + 1.)),
        z = a * log(x),
        h = gam1(a),
        g = h + 1.;

    if ((x >= 0.25 && (a < x / 2.59)) || (z > -0.13394)) {
        // L40:
        double l = rexpm1(z),
        q = ((l + 0.5 + 0.5) * j - l) * g - h;
        if (q <= 0.) {
        /* L110:*/ return 0.;
        } else {
        return q * exp(-log_r);
        }

    } else {
        double p = exp(z) * g * (0.5 - j + 0.5);
        return /* q/r = */ (0.5 - p + 0.5) * exp(-log_r);
    }

    } else {
    /* L50: ----  (x >= 1.1)  ---- Continued Fraction Expansion */

    double a2n_1 = 1.,
        a2n = 1.,
        b2n_1 = x,
        b2n = x + (1. - a),
        c = 1., am0, an0;

    do {
        a2n_1 = x * a2n + c * a2n_1;
        b2n_1 = x * b2n + c * b2n_1;
        am0 = a2n_1 / b2n_1;
        c += 1.;
        double c_a = c - a;
        a2n = a2n_1 + c_a * a2n;
        b2n = b2n_1 + c_a * b2n;
        an0 = a2n / b2n;
    } while (fabs(an0 - am0) >= eps * an0);

    return /* q/r = (r * an0)/r = */ an0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
movsd %xmm3, -0x28(%rbp)
movsd -0x10(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x27aac
jp 0x27aac
movsd -0x18(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x27a9f
movsd -0x20(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x2560
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
movsd -0x10(%rbp), %xmm0
movsd 0x9b47(%rip), %xmm1     # 0x31600
ucomisd %xmm1, %xmm0
jne 0x27b8a
jp 0x27b8a
movsd 0xad67(%rip), %xmm0     # 0x32838
ucomisd -0x18(%rbp), %xmm0
jbe 0x27b47
movsd -0x18(%rbp), %xmm0
callq 0x2500
callq 0x28130
movsd %xmm0, -0x30(%rbp)
movsd 0x9b0c(%rip), %xmm0     # 0x31600
subsd -0x30(%rbp), %xmm0
movsd 0x9aff(%rip), %xmm1     # 0x31600
addsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x20(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x2560
movaps %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
movsd -0x18(%rbp), %xmm0
callq 0x2500
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movl $0x1, %edi
callq 0x28630
divsd -0x38(%rbp), %xmm0
movsd 0xaf5e(%rip), %xmm1     # 0x32ad0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
movsd 0xac8e(%rip), %xmm0     # 0x32820
ucomisd -0x18(%rbp), %xmm0
jbe 0x27ef0
movsd 0xabeb(%rip), %xmm0     # 0x32790
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0xabcf(%rip), %xmm1     # 0x32790
addsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd 0x9a31(%rip), %xmm0     # 0x31608
mulsd -0x28(%rbp), %xmm0
movsd 0x9a14(%rip), %xmm1     # 0x315f8
addsd -0x10(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x99fe(%rip), %xmm0     # 0x315f8
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movsd -0x10(%rbp), %xmm1
addsd -0x48(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x68(%rbp), %xmm0
movaps 0xae8e(%rip), %xmm1     # 0x32af0
pand %xmm1, %xmm0
ucomisd -0x60(%rbp), %xmm0
ja 0x27bf2
movsd -0x10(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
movsd 0xada4(%rip), %xmm2     # 0x32a28
divsd %xmm2, %xmm1
movsd 0x9530(%rip), %xmm3     # 0x311c0
addsd -0x10(%rbp), %xmm3
movsd 0x9963(%rip), %xmm2     # 0x31600
divsd %xmm3, %xmm2
subsd %xmm2, %xmm1
movsd -0x18(%rbp), %xmm3
movsd 0x9946(%rip), %xmm4     # 0x315f8
addsd -0x10(%rbp), %xmm4
movsd 0x9939(%rip), %xmm2     # 0x315f8
divsd %xmm4, %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x2250
movaps %xmm0, %xmm1
movsd -0xf0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x26e70
movsd %xmm0, -0x80(%rbp)
movsd 0x98e2(%rip), %xmm0     # 0x315f8
addsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0xab08(%rip), %xmm1     # 0x32838
ucomisd %xmm1, %xmm0
jb 0x27d52
movsd -0x10(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
movsd 0xad78(%rip), %xmm2     # 0x32ac0
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x27d69
movsd -0x78(%rbp), %xmm0
movsd 0xad69(%rip), %xmm1     # 0x32ac8
ucomisd %xmm1, %xmm0
jbe 0x27e5b
movsd -0x78(%rbp), %xmm0
callq 0x216d0
movsd %xmm0, -0x90(%rbp)
movsd 0x987d(%rip), %xmm0     # 0x31600
addsd -0x90(%rbp), %xmm0
movsd 0x986d(%rip), %xmm1     # 0x31600
addsd %xmm1, %xmm0
movsd -0x70(%rbp), %xmm2
movsd -0x90(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd -0x88(%rbp), %xmm2
movsd -0x80(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x98(%rbp), %xmm0
jb 0x27e11
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x20(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x2560
movaps %xmm0, %xmm1
movsd -0xf8(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
movsd -0x78(%rbp), %xmm0
callq 0x2560
mulsd -0x88(%rbp), %xmm0
movsd 0x978b(%rip), %xmm1     # 0x31600
subsd -0x70(%rbp), %xmm1
movsd 0x977e(%rip), %xmm2     # 0x31600
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd 0x9766(%rip), %xmm0     # 0x31600
subsd -0xa0(%rbp), %xmm0
movsd 0x9756(%rip), %xmm1     # 0x31600
addsd %xmm1, %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x20(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x2560
movaps %xmm0, %xmm1
movsd -0x100(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x28091
movsd 0x9700(%rip), %xmm0     # 0x315f8
movsd %xmm0, -0xa8(%rbp)
movsd 0x96f0(%rip), %xmm0     # 0x315f8
movsd %xmm0, -0xb0(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x96ce(%rip), %xmm1     # 0x315f8
subsd -0x10(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd 0x96b5(%rip), %xmm0     # 0x315f8
movsd %xmm0, -0xc8(%rbp)
movsd -0x18(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm2
movsd -0xc8(%rbp), %xmm1
mulsd -0xa8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x18(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm2
movsd -0xc8(%rbp), %xmm1
mulsd -0xb8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xa8(%rbp), %xmm0
divsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movsd 0x9633(%rip), %xmm0     # 0x315f8
addsd -0xc8(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xc8(%rbp), %xmm0
subsd -0x10(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xa8(%rbp), %xmm1
movsd -0xe0(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb8(%rbp), %xmm1
movsd -0xe0(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0xb0(%rbp), %xmm0
divsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0xd8(%rbp), %xmm0
subsd -0xd0(%rbp), %xmm0
movaps 0xaa87(%rip), %xmm1     # 0x32af0
pand %xmm1, %xmm0
movsd -0x28(%rbp), %xmm1
mulsd -0xd8(%rbp), %xmm1
ucomisd %xmm1, %xmm0
jae 0x27f4b
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nop