// File: /workspace/github_c_makefile_star2_O1/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 0x706e(%rip), %xmm2     # 0x22b70
ucomisd %xmm6, %xmm2
movapd %xmm5, 0x20(%rsp)
jbe 0x1bb84
movsd 0x5b1a(%rip), %xmm0     # 0x21630
ucomisd %xmm6, %xmm0
jbe 0x1bc43
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x1c72a
movapd 0x20(%rsp), %xmm1
movsd %xmm0, 0x8(%rsp)
movsd 0x702d(%rip), %xmm0     # 0x22b70
ucomisd %xmm1, %xmm0
jbe 0x1bc80
movapd %xmm1, %xmm0
callq 0x1c72a
movsd %xmm0, (%rsp)
movapd 0x20(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
callq 0x1c72a
movsd (%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
jmp 0x1bf21
movapd %xmm6, %xmm0
movapd %xmm5, %xmm1
movapd %xmm6, 0x10(%rsp)
callq 0x1c5ac
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm2
divsd 0x20(%rsp), %xmm2
movsd %xmm2, (%rsp)
addsd 0x6cce(%rip), %xmm0     # 0x22888
xorpd 0x741e(%rip), %xmm0     # 0x22fe0
movapd %xmm0, 0x10(%rsp)
movsd 0x5a60(%rip), %xmm1     # 0x21630
addsd %xmm2, %xmm1
movapd %xmm2, %xmm0
divsd %xmm1, %xmm0
callq 0x2240
mulsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%rsp), %xmm0
callq 0x1ba27
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 0x6c62(%rip), %xmm0     # 0x22888
addsd 0x7172(%rip), %xmm0     # 0x22da0
addsd 0x8(%rsp), %xmm0
jbe 0x1bc73
subsd %xmm2, %xmm0
subsd %xmm1, %xmm0
jmp 0x1bf21
movsd 0x6dbd(%rip), %xmm1     # 0x22a08
ucomisd %xmm6, %xmm1
jbe 0x1bc9a
ucomisd %xmm5, %xmm1
jae 0x1bcff
ucomisd %xmm5, %xmm2
jbe 0x1be55
xorpd %xmm0, %xmm0
movsd %xmm0, (%rsp)
jmp 0x1bdb0
subsd %xmm1, %xmm0
subsd %xmm2, %xmm0
jmp 0x1bf21
movapd 0x10(%rsp), %xmm0
callq 0x1c11f
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
jmp 0x1bd45
movsd 0x69ce(%rip), %xmm1     # 0x22670
ucomisd %xmm5, %xmm1
movsd 0x6ca2(%rip), %xmm1     # 0x22950
addsd %xmm6, %xmm1
cvttsd2si %xmm1, %ebx
jae 0x1bd4e
testl %ebx, %ebx
jle 0x1beb1
movsd 0x5964(%rip), %xmm1     # 0x21630
movsd 0x6c7c(%rip), %xmm2     # 0x22950
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 0x1bcda
jmp 0x1beb9
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x1c72a
movsd %xmm0, 0x8(%rsp)
movapd 0x20(%rsp), %xmm0
callq 0x1c72a
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x1c89b
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x1bf21
testl %ebx, %ebx
jle 0x1bd86
movsd 0x58d6(%rip), %xmm1     # 0x21630
movsd 0x6bee(%rip), %xmm2     # 0x22950
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 0x1bd66
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movapd 0x20(%rsp), %xmm5
ucomisd 0x6dd1(%rip), %xmm5     # 0x22b70
movsd %xmm0, (%rsp)
jae 0x1be80
movapd 0x10(%rsp), %xmm6
movapd %xmm5, %xmm0
addsd 0x6b94(%rip), %xmm0     # 0x22950
cvttsd2si %xmm0, %eax
movsd 0x5868(%rip), %xmm0     # 0x21630
testl %eax, %eax
jle 0x1bdf0
movsd 0x6b7c(%rip), %xmm1     # 0x22950
addsd %xmm1, %xmm5
movapd %xmm6, %xmm2
addsd %xmm5, %xmm2
movapd %xmm5, %xmm3
divsd %xmm2, %xmm3
mulsd %xmm3, %xmm0
decl %eax
jne 0x1bdd4
movapd %xmm5, 0x20(%rsp)
movapd %xmm6, 0x10(%rsp)
callq 0x2240
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movaps 0x10(%rsp), %xmm0
callq 0x1c72a
movsd %xmm0, 0x38(%rsp)
movaps 0x20(%rsp), %xmm0
callq 0x1c72a
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x1c89b
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, %xmm0
addsd 0x38(%rsp), %xmm0
jmp 0x1beaa
movapd %xmm6, %xmm0
movapd %xmm6, 0x10(%rsp)
callq 0x1c72a
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x1c11f
jmp 0x1bf1b
movapd 0x10(%rsp), %xmm0
callq 0x1c72a
movsd (%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x1c11f
addsd (%rsp), %xmm0
jmp 0x1bf21
movsd 0x5777(%rip), %xmm0     # 0x21630
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 0x1c72a
movsd %xmm0, (%rsp)
movapd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
callq 0x1c11f
addsd (%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
addq $0x40, %rsp
popq %rbx
retq