// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]yahs/binomlite.c
// Function: betaln
static double betaln(double a0, double b0)
{
/* -----------------------------------------------------------------------
 *     Evaluation of the logarithm of the beta function  ln(beta(a0,b0))
 * ----------------------------------------------------------------------- */

    static double e = .918938533204673;/* e == 0.5*LN(2*PI) */

    double
    a = fmin2(a0 ,b0),
    b = fmax2(a0, b0);

    if (a < 8.) {
    if (a < 1.) {
/* ----------------------------------------------------------------------- */
//                            A < 1
/* ----------------------------------------------------------------------- */
        if (b < 8.)
        return gamln(a) + (gamln(b) - gamln(a+b));
        else
        return gamln(a) + algdiv(a, b);
    }
    /* else */
/* ----------------------------------------------------------------------- */
//                1 <= A < 8
/* ----------------------------------------------------------------------- */
    double w;
    if (a < 2.) {
        if (b <= 2.) {
        return gamln(a) + gamln(b) - gsumln(a, b);
        }
        /* else */

        if (b < 8.) {
        w = 0.;
        goto L40;
        }
        return gamln(a) + algdiv(a, b);
    }
    // else L30:    REDUCTION OF A WHEN B <= 1000

    if (b <= 1e3) {
        int n = (int)(a - 1.);
        w = 1.;
        int i;
        for (i = 1; i <= n; ++i) {
        a += -1.;
        double h = a / b;
        w *= h / (h + 1.);
        }
        w = log(w);

        if (b >= 8.)
        return w + gamln(a) + algdiv(a, b);

        // else
    L40:
        //     1 < A <= B < 8 :  reduction of B
        n = (int)(b - 1.);
        double z = 1.;
        for (i = 1; i <= n; ++i) {
        b += -1.;
        z *= b / (a + b);
        }
        return w + log(z) + (gamln(a) + (gamln(b) - gsumln(a, b)));
    }
    else { // L50:    reduction of A when  B > 1000
        int i, n = (int)(a - 1.);
        w = 1.;
        for (i = 1; i <= n; ++i) {
        a += -1.;
        w *= a / (a / b + 1.);
        }
        return log(w) - n * log(b) + (gamln(a) + algdiv(a, b));
    }

    } else {
/* ----------------------------------------------------------------------- */
    // L60:            A >= 8
/* ----------------------------------------------------------------------- */

    double
        w = bcorr(a, b),
        h = a / b,
        u = -(a - 0.5) * log(h / (h + 1.)),
        v = b * alnrel(h);
    if (u > v)
        return log(b) * -0.5 + e + w - v - u;
    else
        return log(b) * -0.5 + e + w - u - v;
    }

}

// Assembly:
pushq %rbx
subq $0x40, %rsp
movapd %xmm0, %xmm6
cmplesd %xmm1, %xmm6
movapd %xmm6, %xmm2
andpd %xmm0, %xmm2
andnpd %xmm1, %xmm6
orpd %xmm2, %xmm6
movapd %xmm1, %xmm5
cmplesd %xmm0, %xmm5
andpd %xmm5, %xmm0
andnpd %xmm1, %xmm5
orpd %xmm0, %xmm5
movsd 0x725d(%rip), %xmm2     # 0x23b78
ucomisd %xmm6, %xmm2
movapd %xmm5, 0x20(%rsp)
jbe 0x1c99d
movsd 0x5d31(%rip), %xmm0     # 0x22660
ucomisd %xmm6, %xmm0
jbe 0x1ca5c
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x1d4dd
movapd 0x20(%rsp), %xmm1
movsd %xmm0, 0x8(%rsp)
movsd 0x721c(%rip), %xmm0     # 0x23b78
ucomisd %xmm1, %xmm0
jbe 0x1ca99
movapd %xmm1, %xmm0
callq 0x1d4dd
movsd %xmm0, (%rsp)
movapd 0x20(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
callq 0x1d4dd
movsd (%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
jmp 0x1cd3a
movapd %xmm6, %xmm0
movapd %xmm5, %xmm1
movapd %xmm6, 0x10(%rsp)
callq 0x1d360
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm2
divsd 0x20(%rsp), %xmm2
movsd %xmm2, (%rsp)
addsd 0x6ee5(%rip), %xmm0     # 0x238b8
xorpd 0x7415(%rip), %xmm0     # 0x23df0
movapd %xmm0, 0x10(%rsp)
movsd 0x5c77(%rip), %xmm1     # 0x22660
addsd %xmm2, %xmm1
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x2240
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x1c860
movapd %xmm0, %xmm1
movapd 0x20(%rsp), %xmm0
mulsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
callq 0x2240
movsd (%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
ucomisd %xmm2, %xmm1
mulsd 0x6e79(%rip), %xmm0     # 0x238b8
addsd 0x7241(%rip), %xmm0     # 0x23c88
addsd 0x8(%rsp), %xmm0
jbe 0x1ca8c
subsd %xmm2, %xmm0
subsd %xmm1, %xmm0
jmp 0x1cd3a
movsd 0x6fac(%rip), %xmm1     # 0x23a10
ucomisd %xmm6, %xmm1
jbe 0x1cab3
ucomisd %xmm5, %xmm1
jae 0x1cb18
ucomisd %xmm5, %xmm2
jbe 0x1cc6e
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
jmp 0x1cbc9
subsd %xmm1, %xmm0
subsd %xmm2, %xmm0
jmp 0x1cd3a
movapd 0x10(%rsp), %xmm0
callq 0x1cebd
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
jmp 0x1cb5e
movsd 0x6bf5(%rip), %xmm1     # 0x236b0
ucomisd %xmm5, %xmm1
movsd 0x6ea1(%rip), %xmm1     # 0x23968
addsd %xmm6, %xmm1
cvttsd2si %xmm1, %ebx
jae 0x1cb67
testl %ebx, %ebx
jle 0x1ccca
movsd 0x5b7b(%rip), %xmm1     # 0x22660
movsd 0x6e7b(%rip), %xmm2     # 0x23968
movl %ebx, %eax
movapd %xmm1, %xmm0
addsd %xmm2, %xmm6
movapd %xmm6, %xmm3
divsd %xmm5, %xmm3
addsd %xmm1, %xmm3
movapd %xmm6, %xmm4
divsd %xmm3, %xmm4
mulsd %xmm4, %xmm0
decl %eax
jne 0x1caf3
jmp 0x1ccd2
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x1d4dd
movsd %xmm0, 0x8(%rsp)
movapd 0x20(%rsp), %xmm0
callq 0x1d4dd
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x1d64e
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x1cd3a
testl %ebx, %ebx
jle 0x1cb9f
movsd 0x5aed(%rip), %xmm1     # 0x22660
movsd 0x6ded(%rip), %xmm2     # 0x23968
movapd %xmm1, %xmm0
addsd %xmm2, %xmm6
movapd %xmm6, %xmm3
divsd %xmm5, %xmm3
movapd %xmm3, %xmm4
addsd %xmm1, %xmm4
divsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
decl %ebx
jne 0x1cb7f
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movapd 0x20(%rsp), %xmm5
ucomisd 0x6fc0(%rip), %xmm5     # 0x23b78
movsd %xmm0, (%rsp)
jae 0x1cc99
movapd 0x10(%rsp), %xmm6
movapd %xmm5, %xmm0
addsd 0x6d93(%rip), %xmm0     # 0x23968
cvttsd2si %xmm0, %eax
movsd 0x5a7f(%rip), %xmm0     # 0x22660
testl %eax, %eax
jle 0x1cc09
movsd 0x6d7b(%rip), %xmm1     # 0x23968
addsd %xmm1, %xmm5
movapd %xmm6, %xmm2
addsd %xmm5, %xmm2
movapd %xmm5, %xmm3
divsd %xmm2, %xmm3
mulsd %xmm3, %xmm0
decl %eax
jne 0x1cbed
movapd %xmm5, 0x20(%rsp)
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movaps 0x10(%rsp), %xmm0
callq 0x1d4dd
movsd %xmm0, 0x38(%rsp)
movaps 0x20(%rsp), %xmm0
callq 0x1d4dd
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x1d64e
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd 0x38(%rsp), %xmm0
jmp 0x1ccc3
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x1d4dd
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x1cebd
jmp 0x1cd34
movapd 0x10(%rsp), %xmm0
callq 0x1d4dd
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x1cebd
addsd (%rsp), %xmm0
jmp 0x1cd3a
movsd 0x598e(%rip), %xmm0     # 0x22660
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebx, %xmm0
movsd %xmm0, (%rsp)
movapd 0x20(%rsp), %xmm0
callq 0x2240
mulsd (%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movaps 0x10(%rsp), %xmm0
callq 0x1d4dd
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x1cebd
addsd (%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
addq $0x40, %rsp
popq %rbx
retq