// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]yahs/binomlite.c
// Function: brcmp1
static double brcmp1(int mu, double a, double b, double x, double y, int give_log)
{
/* -----------------------------------------------------------------------
 *          Evaluation of    exp(mu) * x^a * y^b / beta(a,b)
 * ----------------------------------------------------------------------- */

    static double const__ = .398942280401433; /* == 1/sqrt(2*pi); */
    /* R has  M_1_SQRT_2PI */

    /* Local variables */
    double c, t, u, v, z, a0, b0, apb;

    a0 = fmin2(a,b);
    if (a0 < 8.) {
    double lnx, lny;
    if (x <= .375) {
        lnx = log(x);
        lny = alnrel(-x);
    } else if (y > .375) {
        // L11:
        lnx = log(x);
        lny = log(y);
    } else {
        lnx = alnrel(-y);
        lny = log(y);
    }

    // L20:
    z = a * lnx + b * lny;
    if (a0 >= 1.) {
        z -= betaln(a, b);
        return esum(mu, z, give_log);
    }
    // else :
    /* ----------------------------------------------------------------------- */
    /*              PROCEDURE FOR A < 1 OR B < 1 */
    /* ----------------------------------------------------------------------- */
    // L30:
    b0 = fmax2(a,b);
    if (b0 >= 8.) {
    /* L80:                  ALGORITHM FOR b0 >= 8 */
        u = gamln1(a0) + algdiv(a0, b0);
        return give_log
        ? log(a0) + esum(mu, z - u, 1)
        :     a0  * esum(mu, z - u, 0);

    } else if (b0 <= 1.) {
        //                   a0 < 1, b0 <= 1
        double ans = esum(mu, z, give_log);
        if (ans == (give_log ? ML_NEGINF : 0.))
        return ans;

        apb = a + b;
        if (apb > 1.) {
        // L40:
        u = a + b - 1.;
        z = (gam1(u) + 1.) / apb;
        } else {
        z = gam1(apb) + 1.;
        }
        // L50:
        c = give_log
        ? log1p(gam1(a)) + log1p(gam1(b)) - log(z)
        : (gam1(a) + 1.) * (gam1(b) + 1.) / z;
        return give_log
        ? ans + log(a0) + c - log1p(a0 / b0)
        : ans * (a0 * c) / (a0 / b0 + 1.);
    }
    // else:               algorithm for    a0 < 1 < b0 < 8
    // L60:
    u = gamln1(a0);
    int i, n = (int)(b0 - 1.);
    if (n >= 1) {
        c = 1.;
        for (i = 1; i <= n; ++i) {
        b0 += -1.;
        c *= b0 / (a0 + b0);
        /* L61: */
        }
        u += log(c); // TODO?: log(c) = log( prod(...) ) =  sum( log(...) )
    }
    // L70:
    z -= u;
    b0 += -1.;
    apb = a0 + b0;
    if (apb > 1.) {
        // L71:
        t = (gam1(apb - 1.) + 1.) / apb;
    } else {
        t = gam1(apb) + 1.;
    }
    // L72:
    return give_log
        ? log(a0)+ esum(mu, z, 1) + log1p(gam1(b0)) - log(t) // TODO? log(t) = log1p(..)
        :     a0 * esum(mu, z, 0) * (gam1(b0) + 1.) / t;

    } else {

/* ----------------------------------------------------------------------- */
/*              PROCEDURE FOR A >= 8 AND B >= 8 */
/* ----------------------------------------------------------------------- */
    // L100:
    double h, x0, y0, lambda;
    if (a > b) {
        // L101:
        h = b / a;
        x0 = 1. / (h + 1.);// => lx0 := log(x0) = 0 - log1p(h)
        y0 = h / (h + 1.);
        lambda = (a + b) * y - b;
    } else {
        h = a / b;
        x0 = h / (h + 1.);  // => lx0 := log(x0) = - log1p(1/h)
        y0 = 1. / (h + 1.);
        lambda = a - (a + b) * x;
    }
    double lx0 = -log1p(b/a); // in both cases

    // L110:
    double e = -lambda / a;
    if (fabs(e) > 0.6) {
        // L111:
        u = e - log(x / x0);
    } else {
        u = rlog1(e);
    }

    // L120:
    e = lambda / b;
    if (fabs(e) > 0.6) {
        // L121:
        v = e - log(y / y0);
    } else {
        v = rlog1(e);
    }

    // L130:
    z = esum(mu, -(a * u + b * v), give_log);
    return give_log
        ? log(const__)+ (log(b) + lx0)/2. + z      - bcorr(a, b)
        :     const__ * sqrt(b * x0)      * z * exp(-bcorr(a, b));
    }

}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebx
movapd %xmm0, %xmm4
movl %edi, %ebp
movapd %xmm0, %xmm5
cmplesd %xmm1, %xmm5
movapd %xmm5, %xmm0
andpd %xmm4, %xmm0
andnpd %xmm1, %xmm5
orpd %xmm0, %xmm5
movsd 0x786d(%rip), %xmm0     # 0x22b70
ucomisd %xmm5, %xmm0
movapd %xmm1, 0x10(%rsp)
movapd %xmm4, 0x20(%rsp)
jbe 0x1b34b
movsd 0x76cb(%rip), %xmm0     # 0x229e8
ucomisd %xmm2, %xmm0
movapd %xmm5, 0x30(%rsp)
jae 0x1b3a7
ucomisd 0x76b7(%rip), %xmm3     # 0x229e8
movapd %xmm3, 0x40(%rsp)
jbe 0x1b57e
movapd %xmm2, %xmm0
callq 0x2240
jmp 0x1b58f
ucomisd %xmm1, %xmm4
movapd %xmm4, %xmm6
addsd %xmm1, %xmm6
movapd %xmm1, %xmm0
divsd %xmm4, %xmm0
movapd %xmm3, 0x40(%rsp)
movapd %xmm2, 0x50(%rsp)
jbe 0x1b3d3
movsd 0x62bb(%rip), %xmm5     # 0x21630
movapd %xmm0, %xmm2
addsd %xmm5, %xmm2
divsd %xmm2, %xmm5
movapd %xmm5, 0x60(%rsp)
movapd %xmm0, %xmm5
divsd %xmm2, %xmm5
movapd %xmm5, 0x80(%rsp)
mulsd %xmm3, %xmm6
subsd %xmm1, %xmm6
movapd %xmm6, (%rsp)
jmp 0x1b413
movapd %xmm2, %xmm0
movapd %xmm2, 0x50(%rsp)
callq 0x2240
movsd %xmm0, (%rsp)
movapd 0x50(%rsp), %xmm0
xorpd 0x7c17(%rip), %xmm0     # 0x22fe0
callq 0x1ba27
jmp 0x1b59f
movapd %xmm4, %xmm3
divsd %xmm1, %xmm3
movsd 0x624d(%rip), %xmm5     # 0x21630
movapd %xmm3, %xmm1
addsd %xmm5, %xmm1
divsd %xmm1, %xmm3
movapd %xmm3, 0x60(%rsp)
divsd %xmm1, %xmm5
movapd %xmm5, 0x80(%rsp)
mulsd %xmm2, %xmm6
movapd %xmm4, %xmm1
subsd %xmm6, %xmm1
movapd %xmm1, (%rsp)
callq 0x2220
movsd %xmm0, 0x78(%rsp)
movapd 0x7bba(%rip), %xmm1     # 0x22fe0
xorpd (%rsp), %xmm1
divsd 0x20(%rsp), %xmm1
movapd 0x7b97(%rip), %xmm0     # 0x22fd0
andpd %xmm1, %xmm0
ucomisd 0x7743(%rip), %xmm0     # 0x22b88
jbe 0x1b470
movapd 0x50(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
movapd %xmm1, 0x30(%rsp)
callq 0x2240
movapd 0x30(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
jmp 0x1b47f
movapd %xmm1, %xmm0
callq 0x1c47b
movapd %xmm0, 0x30(%rsp)
movapd (%rsp), %xmm1
divsd 0x10(%rsp), %xmm1
movapd 0x7b3e(%rip), %xmm0     # 0x22fd0
andpd %xmm1, %xmm0
ucomisd 0x76ea(%rip), %xmm0     # 0x22b88
movapd 0x40(%rsp), %xmm0
jbe 0x1b4c4
divsd 0x80(%rsp), %xmm0
movapd %xmm1, (%rsp)
callq 0x2240
movapd (%rsp), %xmm1
subsd %xmm0, %xmm1
jmp 0x1b4d1
movapd %xmm1, %xmm0
callq 0x1c47b
movapd %xmm0, %xmm1
mulsd 0x10(%rsp), %xmm1
movapd 0x30(%rsp), %xmm0
mulsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
xorpd 0x7af1(%rip), %xmm0     # 0x22fe0
movl %ebp, %edi
movl %ebx, %esi
callq 0x1bf27
movapd %xmm0, %xmm3
testl %ebx, %ebx
je 0x1b553
movapd 0x10(%rsp), %xmm0
movsd %xmm3, (%rsp)
callq 0x2240
subsd 0x78(%rsp), %xmm0
mulsd 0x5cda(%rip), %xmm0     # 0x211f8
addsd 0x7842(%rip), %xmm0     # 0x22d68
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd 0x20(%rsp), %xmm0
movapd 0x10(%rsp), %xmm1
callq 0x1c5ac
movsd (%rsp), %xmm2
subsd %xmm0, %xmm2
jmp 0x1b7b3
movapd 0x60(%rsp), %xmm0
movapd 0x10(%rsp), %xmm2
mulsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1b768
movapd %xmm2, %xmm1
sqrtsd %xmm0, %xmm0
jmp 0x1b77d
movapd 0x7a5a(%rip), %xmm0     # 0x22fe0
xorpd %xmm3, %xmm0
callq 0x1ba27
movsd %xmm0, (%rsp)
movapd 0x40(%rsp), %xmm0
callq 0x2240
movapd 0x10(%rsp), %xmm1
mulsd %xmm1, %xmm0
movapd 0x20(%rsp), %xmm3
movsd (%rsp), %xmm5
mulsd %xmm3, %xmm5
addsd %xmm0, %xmm5
movapd 0x30(%rsp), %xmm0
ucomisd 0x6066(%rip), %xmm0     # 0x21630
jae 0x1b6dc
movapd %xmm1, %xmm4
cmplesd %xmm3, %xmm4
movapd %xmm4, %xmm2
andpd %xmm3, %xmm2
andnpd %xmm1, %xmm4
orpd %xmm2, %xmm4
ucomisd 0x757f(%rip), %xmm4     # 0x22b70
movapd %xmm4, 0x40(%rsp)
jae 0x1b709
movsd 0x602b(%rip), %xmm1     # 0x21630
ucomisd %xmm4, %xmm1
jae 0x1b7c1
movsd %xmm5, (%rsp)
callq 0x1bfbb
movsd %xmm0, 0x10(%rsp)
movsd 0x7329(%rip), %xmm0     # 0x22950
movapd 0x40(%rsp), %xmm4
addsd %xmm4, %xmm0
cvttsd2si %xmm0, %eax
testl %eax, %eax
jle 0x1b68c
movsd 0x730f(%rip), %xmm5     # 0x22950
movapd 0x30(%rsp), %xmm3
movsd 0x5fe1(%rip), %xmm0     # 0x21630
addsd %xmm5, %xmm4
movapd %xmm3, %xmm1
addsd %xmm4, %xmm1
movapd %xmm4, %xmm2
divsd %xmm1, %xmm2
mulsd %xmm2, %xmm0
decl %eax
jne 0x1b64f
movapd %xmm4, 0x40(%rsp)
callq 0x2240
movapd 0x40(%rsp), %xmm4
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
addsd 0x72bc(%rip), %xmm4     # 0x22950
movapd 0x30(%rsp), %xmm1
movapd %xmm4, 0x40(%rsp)
addsd %xmm4, %xmm1
ucomisd 0x5f84(%rip), %xmm1     # 0x21630
jbe 0x1b858
movsd 0x7296(%rip), %xmm0     # 0x22950
addsd %xmm1, %xmm0
movsd %xmm1, 0x20(%rsp)
callq 0x1c2db
addsd 0x5f5f(%rip), %xmm0     # 0x21630
divsd 0x20(%rsp), %xmm0
jmp 0x1b869
movapd %xmm3, %xmm0
movsd %xmm5, (%rsp)
callq 0x1bac7
movsd (%rsp), %xmm1
subsd %xmm0, %xmm1
movl %ebp, %edi
movapd %xmm1, %xmm0
movl %ebx, %esi
addq $0x98, %rsp
popq %rbx
popq %rbp
jmp 0x1bf27
movsd %xmm5, (%rsp)
callq 0x1bfbb
movsd %xmm0, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
callq 0x1c11f
movapd %xmm0, %xmm1
addsd 0x10(%rsp), %xmm1
testl %ebx, %ebx
je 0x1b837
movapd 0x30(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
callq 0x2240
movsd (%rsp), %xmm1
subsd 0x10(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
addsd %xmm1, %xmm2
addsd %xmm0, %xmm2
jmp 0x1b7b3
movsd %xmm3, (%rsp)
callq 0x24f0
movsd (%rsp), %xmm3
movapd 0x10(%rsp), %xmm1
movapd 0x20(%rsp), %xmm2
mulsd 0x740d(%rip), %xmm0     # 0x22b98
mulsd %xmm0, %xmm3
movsd %xmm3, (%rsp)
movapd %xmm2, %xmm0
callq 0x1c5ac
xorpd 0x783b(%rip), %xmm0     # 0x22fe0
callq 0x2550
movapd %xmm0, %xmm2
mulsd (%rsp), %xmm2
movapd %xmm2, %xmm0
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
movl %ebp, %edi
movapd %xmm5, %xmm0
movl %ebx, %esi
callq 0x1bf27
movapd %xmm0, %xmm2
xorpd %xmm0, %xmm0
testl %ebx, %ebx
je 0x1b7e2
movsd 0x709e(%rip), %xmm0     # 0x22880
ucomisd %xmm0, %xmm2
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
jne 0x1b7f6
jnp 0x1b7b3
movsd %xmm2, (%rsp)
addsd %xmm0, %xmm1
ucomisd 0x5e29(%rip), %xmm1     # 0x21630
jbe 0x1b91a
movsd 0x713b(%rip), %xmm0     # 0x22950
addsd %xmm1, %xmm0
movapd %xmm1, 0x50(%rsp)
callq 0x1c2db
addsd 0x5e04(%rip), %xmm0     # 0x21630
divsd 0x50(%rsp), %xmm0
jmp 0x1b92b
movsd (%rsp), %xmm0
subsd %xmm1, %xmm0
movl %ebp, %edi
xorl %esi, %esi
callq 0x1bf27
movapd 0x30(%rsp), %xmm2
mulsd %xmm0, %xmm2
jmp 0x1b7b3
movapd %xmm1, %xmm0
callq 0x1c2db
addsd 0x5dc7(%rip), %xmm0     # 0x21630
movsd %xmm0, 0x20(%rsp)
movsd (%rsp), %xmm2
subsd 0x10(%rsp), %xmm2
testl %ebx, %ebx
movapd 0x30(%rsp), %xmm1
je 0x1b8d5
movapd %xmm1, %xmm0
movsd %xmm2, (%rsp)
callq 0x2240
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
movsd (%rsp), %xmm2
addsd %xmm1, %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
movapd 0x40(%rsp), %xmm0
callq 0x1c2db
callq 0x2220
addsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movsd 0x20(%rsp), %xmm0
callq 0x2240
jmp 0x1b545
movl %ebp, %edi
movapd %xmm2, %xmm0
xorl %esi, %esi
callq 0x1bf27
movapd 0x30(%rsp), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
movapd 0x40(%rsp), %xmm0
callq 0x1c2db
movapd %xmm0, %xmm2
addsd 0x5d27(%rip), %xmm2     # 0x21630
mulsd 0x30(%rsp), %xmm2
divsd 0x20(%rsp), %xmm2
jmp 0x1b7b3
movapd %xmm1, %xmm0
callq 0x1c2db
addsd 0x5d05(%rip), %xmm0     # 0x21630
movsd %xmm0, 0x50(%rsp)
movaps 0x20(%rsp), %xmm0
callq 0x1c2db
movsd %xmm0, 0x20(%rsp)
movapd 0x10(%rsp), %xmm0
callq 0x1c2db
movapd %xmm0, %xmm1
testl %ebx, %ebx
je 0x1b999
movsd 0x20(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
callq 0x2220
movsd %xmm0, 0x20(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x2220
addsd 0x20(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x50(%rsp), %xmm0
callq 0x2240
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
jmp 0x1b9b9
movsd 0x5c8f(%rip), %xmm0     # 0x21630
movsd 0x20(%rsp), %xmm2
addsd %xmm0, %xmm2
addsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
divsd 0x50(%rsp), %xmm1
movapd 0x30(%rsp), %xmm0
testl %ebx, %ebx
je 0x1ba03
movsd %xmm1, 0x10(%rsp)
callq 0x2240
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movapd 0x30(%rsp), %xmm0
divsd 0x40(%rsp), %xmm0
callq 0x2220
movsd 0x10(%rsp), %xmm2
jmp 0x1b54a
mulsd %xmm0, %xmm1
movsd (%rsp), %xmm2
mulsd %xmm1, %xmm2
divsd 0x40(%rsp), %xmm0
addsd 0x5c12(%rip), %xmm0     # 0x21630
divsd %xmm0, %xmm2
jmp 0x1b7b3