// File: /workspace/github_c_makefile_star2_O3/c-zhou[P]yahs/binomlite.c
// Function: bup
static double bup(double a, double b, double x, double y, int n, double eps, int give_log)
{
/* ----------------------------------------------------------------------- */
/*     EVALUATION OF I_x(A,B) - I_x(A+N,B) WHERE N IS A POSITIVE INT. */
/*     EPS IS THE TOLERANCE USED. */
/* ----------------------------------------------------------------------- */

    double ret_val;
    int i, k, mu;
    double d, l;

// Obtain the scaling factor exp(-mu) and exp(mu)*(x^a * y^b / beta(a,b))/a

    double apb = a + b,
    ap1 = a + 1.;
    if (n > 1 && a >= 1. && apb >= ap1 * 1.1) {
        mu = (int)fabs(exparg(1));
        k = (int) exparg(0);
        if (mu > k)
            mu = k;
         d = exp(-(double) mu);
    } else {
        mu = 0;
        d = 1.;
    }

    /* L10: */
    ret_val = give_log? brcmp1(mu, a, b, x, y, 1) - log(a)
        : brcmp1(mu, a, b, x, y, 0)  / a;
    if (n == 1 ||
            (give_log && ret_val == ML_NEGINF) || (!give_log && ret_val == 0.))
        return ret_val;

    int nm1 = n - 1;
    double w = d;

/*          LET K BE THE INDEX OF THE MAXIMUM TERM */

    k = 0;
    if (b > 1.) {
        if (y > 1e-4) {
            double r = (b - 1.) * x / y - a;
            if (r >= 1.)
                k = (r < nm1) ? (int) r : nm1;
        } else {
            k = nm1;
        }

//          ADD THE INCREASING TERMS OF THE SERIES - if k > 0
/* L30: */
        for (i = 0; i < k; ++i) {
            l = (double) i;
            d *= (apb + l) / (ap1 + l) * x;
            w += d;
        }
    }

// L40:     ADD THE REMAINING TERMS OF THE SERIES

    for (i = k; i < nm1; ++i) {
        l = (double) i;
        d *= (apb + l) / (ap1 + l) * x;
        w += d;
        if (d <= eps * w) /* relativ convergence (eps) */
            break;
    }

    // L50: TERMINATE THE PROCEDURE
    if(give_log) {
        ret_val += log(w);
    } else {
        ret_val *= w;
    }
    return ret_val;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebx
movl %edi, %r14d
movapd %xmm0, %xmm4
addsd %xmm1, %xmm4
movsd 0x92be(%rip), %xmm7     # 0x22660
movapd %xmm0, %xmm5
addsd %xmm7, %xmm5
cmpl $0x2, %edi
setl %al
movsd 0xa61f(%rip), %xmm8     # 0x239d8
mulsd %xmm5, %xmm8
cmpnlepd %xmm4, %xmm8
movapd %xmm7, %xmm6
movapd %xmm0, 0x10(%rsp)
cmpnlepd %xmm0, %xmm6
orpd %xmm8, %xmm6
movd %xmm6, %ecx
orb %al, %cl
xorl %eax, %eax
movl $0x2c4, %edi            # imm = 0x2C4
testb $0x1, %cl
cmovnel %eax, %edi
jne 0x193f5
movsd 0xa5eb(%rip), %xmm7     # 0x239e0
movapd %xmm5, 0x40(%rsp)
movapd %xmm4, 0x50(%rsp)
movapd %xmm7, 0x60(%rsp)
testl %ebx, %ebx
movsd %xmm2, 0x28(%rsp)
movsd %xmm1, 0x38(%rsp)
movsd %xmm3, 0x30(%rsp)
je 0x1944b
movaps 0x10(%rsp), %xmm0
movl $0x1, %esi
callq 0x1c0fb
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
callq 0x2240
movsd 0x8(%rsp), %xmm9
subsd %xmm0, %xmm9
jmp 0x19464
movapd 0x10(%rsp), %xmm0
xorl %esi, %esi
callq 0x1c0fb
movapd %xmm0, %xmm9
divsd 0x10(%rsp), %xmm9
testl %ebx, %ebx
setne %al
movsd 0xa43f(%rip), %xmm0     # 0x238b0
ucomisd %xmm9, %xmm0
setae %cl
cmpl $0x1, %r14d
je 0x195f2
andb %cl, %al
jne 0x195f2
testl %ebx, %ebx
jne 0x194a0
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm9
jne 0x194a0
jnp 0x195f2
leal -0x1(%r14), %eax
xorl %ecx, %ecx
movsd 0x38(%rsp), %xmm2
ucomisd 0x91ac(%rip), %xmm2     # 0x22660
jbe 0x19519
movsd 0x30(%rsp), %xmm1
ucomisd 0xa524(%rip), %xmm1     # 0x239e8
movl %eax, %edx
movapd 0x60(%rsp), %xmm0
movsd 0x28(%rsp), %xmm6
movapd 0x50(%rsp), %xmm7
movapd 0x40(%rsp), %xmm8
jbe 0x19538
addsd 0xa47f(%rip), %xmm2     # 0x23968
mulsd %xmm6, %xmm2
divsd %xmm1, %xmm2
subsd 0x10(%rsp), %xmm2
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
ucomisd %xmm2, %xmm1
cvttsd2si %xmm2, %edx
cmovbel %eax, %edx
ucomisd 0x914f(%rip), %xmm2     # 0x22660
jae 0x19538
movapd %xmm0, %xmm5
jmp 0x1957f
movapd 0x60(%rsp), %xmm0
movapd %xmm0, %xmm5
movsd 0x28(%rsp), %xmm6
movapd 0x50(%rsp), %xmm7
movapd 0x40(%rsp), %xmm8
jmp 0x1957f
testl %edx, %edx
jle 0x19579
xorpd %xmm1, %xmm1
movsd 0x9118(%rip), %xmm2     # 0x22660
movl %edx, %ecx
movapd %xmm0, %xmm5
movapd %xmm7, %xmm3
addsd %xmm1, %xmm3
movapd %xmm8, %xmm4
addsd %xmm1, %xmm4
divsd %xmm4, %xmm3
mulsd %xmm6, %xmm3
mulsd %xmm3, %xmm5
addsd %xmm5, %xmm0
addsd %xmm2, %xmm1
decl %ecx
jne 0x1954e
jmp 0x1957d
movapd %xmm0, %xmm5
movl %edx, %ecx
cmpl %eax, %ecx
jge 0x195cf
addl $-0x2, %r14d
movsd 0xa341(%rip), %xmm1     # 0x238d0
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
movapd %xmm5, %xmm3
movapd %xmm7, %xmm5
addsd %xmm2, %xmm5
addsd %xmm8, %xmm2
divsd %xmm2, %xmm5
mulsd %xmm6, %xmm5
mulsd %xmm3, %xmm5
addsd %xmm5, %xmm0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
ucomisd %xmm5, %xmm2
jae 0x195cf
leal 0x1(%rcx), %eax
cmpl %ecx, %r14d
movl %eax, %ecx
jne 0x1958f
testl %ebx, %ebx
je 0x195ed
movsd %xmm9, 0x8(%rsp)
callq 0x2240
movsd 0x8(%rsp), %xmm9
addsd %xmm0, %xmm9
jmp 0x195f2
mulsd %xmm0, %xmm9
movapd %xmm9, %xmm0
addq $0x78, %rsp
popq %rbx
popq %r14
retq