// File: /workspace/github_c_makefile_star2_O2/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 0x792a(%rip), %xmm2     # 0x1f8b0
ucomisd %xmm6, %xmm2
movapd %xmm5, 0x20(%rsp)
jbe 0x18008
movsd 0x667e(%rip), %xmm1     # 0x1e618
ucomisd %xmm6, %xmm1
jbe 0x180c7
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x18b37
movapd 0x20(%rsp), %xmm1
movsd %xmm0, 0x8(%rsp)
movsd 0x78e9(%rip), %xmm0     # 0x1f8b0
ucomisd %xmm1, %xmm0
jbe 0x18104
movapd %xmm1, %xmm0
callq 0x18b37
movsd %xmm0, (%rsp)
movapd 0x20(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
callq 0x18b37
movsd (%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
jmp 0x1839a
movapd %xmm6, %xmm0
movapd %xmm5, %xmm1
movapd %xmm6, 0x10(%rsp)
callq 0x189ba
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm2
divsd 0x20(%rsp), %xmm2
movsd %xmm2, (%rsp)
addsd 0x7742(%rip), %xmm0     # 0x1f780
xorpd 0x7c8a(%rip), %xmm0     # 0x1fcd0
movapd %xmm0, 0x10(%rsp)
movsd 0x65c4(%rip), %xmm1     # 0x1e618
addsd %xmm2, %xmm1
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x2240
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x17ecb
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 0x76d6(%rip), %xmm0     # 0x1f780
addsd 0x7ab6(%rip), %xmm0     # 0x1fb68
addsd 0x8(%rsp), %xmm0
jbe 0x180f7
subsd %xmm2, %xmm0
subsd %xmm1, %xmm0
jmp 0x1839a
movsd 0x7811(%rip), %xmm0     # 0x1f8e0
ucomisd %xmm6, %xmm0
jbe 0x1811e
ucomisd %xmm5, %xmm0
jae 0x18182
ucomisd %xmm5, %xmm2
jbe 0x1833d
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
jmp 0x18292
subsd %xmm1, %xmm0
subsd %xmm2, %xmm0
jmp 0x1839a
movapd 0x10(%rsp), %xmm0
callq 0x18517
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
jmp 0x181c8
movsd 0x768a(%rip), %xmm0     # 0x1f7b0
addsd %xmm6, %xmm0
cvttsd2si %xmm0, %ebx
xorl %eax, %eax
testl %ebx, %ebx
cmovgl %ebx, %eax
movsd 0x743b(%rip), %xmm0     # 0x1f578
ucomisd %xmm5, %xmm0
jae 0x181d1
movsd 0x64c9(%rip), %xmm1     # 0x1e618
movsd 0x7659(%rip), %xmm2     # 0x1f7b0
movapd %xmm1, %xmm0
subl $0x1, %eax
jb 0x18204
addsd %xmm2, %xmm6
movapd %xmm6, %xmm3
divsd %xmm5, %xmm3
addsd %xmm1, %xmm3
movapd %xmm6, %xmm4
divsd %xmm3, %xmm4
mulsd %xmm4, %xmm0
jmp 0x1815b
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x18b37
movsd %xmm0, 0x8(%rsp)
movapd 0x20(%rsp), %xmm0
callq 0x18b37
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x18ca3
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x1839a
movsd 0x75d7(%rip), %xmm2     # 0x1f7b0
movapd %xmm1, %xmm0
subl $0x1, %eax
jb 0x18268
addsd %xmm2, %xmm6
movapd %xmm6, %xmm3
divsd %xmm5, %xmm3
movapd %xmm3, %xmm4
addsd %xmm1, %xmm4
divsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
jmp 0x181dd
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movsd %xmm0, 0x8(%rsp)
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 0x18b37
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x18517
addsd (%rsp), %xmm0
jmp 0x18363
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movapd 0x20(%rsp), %xmm5
ucomisd 0x762f(%rip), %xmm5     # 0x1f8b0
movsd %xmm0, (%rsp)
jae 0x1836b
movapd 0x10(%rsp), %xmm6
movapd %xmm5, %xmm0
addsd 0x7512(%rip), %xmm0     # 0x1f7b0
cvttsd2si %xmm0, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
movsd 0x6367(%rip), %xmm0     # 0x1e618
movsd 0x74f7(%rip), %xmm1     # 0x1f7b0
subl $0x1, %eax
jb 0x182d8
addsd %xmm1, %xmm5
movapd %xmm6, %xmm2
addsd %xmm5, %xmm2
movapd %xmm5, %xmm3
divsd %xmm2, %xmm3
mulsd %xmm3, %xmm0
jmp 0x182b9
movapd %xmm5, 0x20(%rsp)
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movaps 0x10(%rsp), %xmm0
callq 0x18b37
movsd %xmm0, 0x38(%rsp)
movaps 0x20(%rsp), %xmm0
callq 0x18b37
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x18ca3
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd 0x38(%rsp), %xmm0
jmp 0x18395
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x18b37
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x18517
addsd 0x8(%rsp), %xmm0
jmp 0x1839a
movapd 0x10(%rsp), %xmm0
callq 0x18b37
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x18517
addsd (%rsp), %xmm0
addq $0x40, %rsp
popq %rbx
retq