// File: /workspace/github_c_makefile_star2_O1/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 0x9121(%rip), %xmm7     # 0x21630
movapd %xmm0, %xmm5
addsd %xmm7, %xmm5
cmpl $0x2, %edi
setl %al
movsd 0xa4aa(%rip), %xmm8     # 0x229d0
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 0x18562
movsd 0xa476(%rip), %xmm7     # 0x229d8
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 0x185b8
movaps 0x10(%rsp), %xmm0
movl $0x1, %esi
callq 0x1b2d1
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
callq 0x2240
movsd 0x8(%rsp), %xmm9
subsd %xmm0, %xmm9
jmp 0x185d1
movapd 0x10(%rsp), %xmm0
xorl %esi, %esi
callq 0x1b2d1
movapd %xmm0, %xmm9
divsd 0x10(%rsp), %xmm9
testl %ebx, %ebx
setne %al
movsd 0xa2a2(%rip), %xmm0     # 0x22880
ucomisd %xmm9, %xmm0
setae %cl
cmpl $0x1, %r14d
je 0x1875e
andb %cl, %al
jne 0x1875e
testl %ebx, %ebx
jne 0x1860d
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm9
jne 0x1860d
jnp 0x1875e
leal -0x1(%r14), %ecx
xorl %eax, %eax
movsd 0x38(%rsp), %xmm2
ucomisd 0x900f(%rip), %xmm2     # 0x21630
jbe 0x186c8
movsd 0x30(%rsp), %xmm1
ucomisd 0xa3ab(%rip), %xmm1     # 0x229e0
movl %ecx, %eax
movapd 0x60(%rsp), %xmm0
movsd 0x28(%rsp), %xmm6
movapd 0x50(%rsp), %xmm7
movapd 0x40(%rsp), %xmm8
jbe 0x18687
addsd 0xa2f6(%rip), %xmm2     # 0x22950
mulsd %xmm6, %xmm2
divsd %xmm1, %xmm2
subsd 0x10(%rsp), %xmm2
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
ucomisd %xmm2, %xmm1
cvttsd2si %xmm2, %edx
cmovbel %ecx, %edx
xorl %eax, %eax
ucomisd 0x8fac(%rip), %xmm2     # 0x21630
cmovael %edx, %eax
testl %eax, %eax
jle 0x186e7
xorpd %xmm1, %xmm1
movsd 0x8f99(%rip), %xmm2     # 0x21630
movl %eax, %edx
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 %edx
jne 0x1869d
jmp 0x186eb
movapd 0x60(%rsp), %xmm0
movapd %xmm0, %xmm5
movsd 0x28(%rsp), %xmm6
movapd 0x50(%rsp), %xmm7
movapd 0x40(%rsp), %xmm8
jmp 0x186eb
movapd %xmm0, %xmm5
cmpl %ecx, %eax
jge 0x1873b
addl $-0x2, %r14d
movsd 0xa1a5(%rip), %xmm1     # 0x228a0
xorps %xmm2, %xmm2
cvtsi2sd %eax, %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 0x1873b
leal 0x1(%rax), %ecx
cmpl %eax, %r14d
movl %ecx, %eax
jne 0x186fb
testl %ebx, %ebx
je 0x18759
movsd %xmm9, 0x8(%rsp)
callq 0x2240
movsd 0x8(%rsp), %xmm9
addsd %xmm0, %xmm9
jmp 0x1875e
mulsd %xmm0, %xmm9
movapd %xmm9, %xmm0
addq $0x78, %rsp
popq %rbx
popq %r14
retq