// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %rbx
subq $0x78, %rsp
movl %esi, %ebx
movl %edi, %ebp
movapd %xmm0, %xmm7
addsd %xmm1, %xmm7
movsd 0x8abe(%rip), %xmm5     # 0x1e618
movapd %xmm0, %xmm4
addsd %xmm5, %xmm4
cmpl $0x2, %edi
setl %al
movsd 0x9db7(%rip), %xmm8     # 0x1f928
mulsd %xmm4, %xmm8
cmpnlepd %xmm7, %xmm8
movapd %xmm5, %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 0x15bad
movsd 0x9d83(%rip), %xmm5     # 0x1f930
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 0x15c01
pushq $0x1
popq %rsi
movaps 0x10(%rsp), %xmm0
callq 0x1776d
movsd %xmm0, 0x8(%rsp)
movapd 0x10(%rsp), %xmm0
callq 0x2240
movsd 0x8(%rsp), %xmm9
subsd %xmm0, %xmm9
jmp 0x15c1a
movapd 0x10(%rsp), %xmm0
xorl %esi, %esi
callq 0x1776d
movapd %xmm0, %xmm9
divsd 0x10(%rsp), %xmm9
testl %ebx, %ebx
setne %al
movsd 0x9b51(%rip), %xmm0     # 0x1f778
ucomisd %xmm9, %xmm0
setae %cl
cmpl $0x1, %ebp
je 0x15d8f
andb %cl, %al
jne 0x15d8f
testl %ebx, %ebx
jne 0x15c55
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm9
jne 0x15c55
jnp 0x15d8f
decl %ebp
xorl %eax, %eax
movsd 0x38(%rsp), %xmm1
ucomisd 0x89b1(%rip), %xmm1     # 0x1e618
jbe 0x15d0f
movsd 0x30(%rsp), %xmm0
ucomisd 0x9cbd(%rip), %xmm0     # 0x1f938
movl %ebp, %eax
movsd 0x28(%rsp), %xmm5
movapd 0x60(%rsp), %xmm6
movapd 0x50(%rsp), %xmm7
movapd 0x40(%rsp), %xmm8
jbe 0x15cca
addsd 0x9b10(%rip), %xmm1     # 0x1f7b0
mulsd %xmm5, %xmm1
divsd %xmm0, %xmm1
subsd 0x10(%rsp), %xmm1
cvtsi2sd %ebp, %xmm0
ucomisd %xmm1, %xmm0
cvttsd2si %xmm1, %ecx
cmovbel %ebp, %ecx
xorl %eax, %eax
ucomisd 0x8951(%rip), %xmm1     # 0x1e618
cmovael %ecx, %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovgl %eax, %ecx
xorpd %xmm1, %xmm1
movsd 0x893b(%rip), %xmm2     # 0x1e618
movapd %xmm8, %xmm0
subl $0x1, %ecx
jb 0x15d2d
movapd %xmm6, %xmm3
addsd %xmm1, %xmm3
movapd %xmm7, %xmm4
addsd %xmm1, %xmm4
divsd %xmm4, %xmm3
mulsd %xmm5, %xmm3
mulsd %xmm3, %xmm8
addsd %xmm8, %xmm0
addsd %xmm2, %xmm1
jmp 0x15ce2
movapd 0x40(%rsp), %xmm8
movapd %xmm8, %xmm0
movsd 0x28(%rsp), %xmm5
movapd 0x60(%rsp), %xmm6
movapd 0x50(%rsp), %xmm7
movsd 0x9a63(%rip), %xmm1     # 0x1f798
cmpl %ebp, %eax
jge 0x15d6c
cvtsi2sd %eax, %xmm2
movapd %xmm6, %xmm3
addsd %xmm2, %xmm3
addsd %xmm7, %xmm2
divsd %xmm2, %xmm3
mulsd %xmm5, %xmm3
mulsd %xmm3, %xmm8
addsd %xmm8, %xmm0
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
incl %eax
ucomisd %xmm8, %xmm2
jb 0x15d35
testl %ebx, %ebx
je 0x15d8a
movsd %xmm9, 0x8(%rsp)
callq 0x2240
movsd 0x8(%rsp), %xmm9
addsd %xmm0, %xmm9
jmp 0x15d8f
mulsd %xmm0, %xmm9
movapd %xmm9, %xmm0
addq $0x78, %rsp
popq %rbx
popq %rbp
retq