// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]yahs/binomlite.c
// Function: basym
static double basym(double a, double b, double lambda, double eps, int log_p)
{
/* ----------------------------------------------------------------------- */
/*     ASYMPTOTIC EXPANSION FOR I_x(A,B) FOR LARGE A AND B. */
/*     LAMBDA = (A + B)*Y - B  AND EPS IS THE TOLERANCE USED. */
/*     IT IS ASSUMED THAT LAMBDA IS NONNEGATIVE AND THAT */
/*     A AND B ARE GREATER THAN OR EQUAL TO 15. */
/* ----------------------------------------------------------------------- */


/* ------------------------ */
/*     ****** NUM IS THE MAXIMUM VALUE THAT N CAN TAKE IN THE DO LOOP */
/*            ENDING AT STATEMENT 50. IT IS REQUIRED THAT NUM BE EVEN. */
#define num_IT 20
/*            THE ARRAYS A0, B0, C, D HAVE DIMENSION NUM + 1. */

    static double const e0 = 1.12837916709551;/* e0 == 2/sqrt(pi) */
    static double const e1 = .353553390593274;/* e1 == 2^(-3/2)   */
    static double const ln_e0 = 0.120782237635245; /* == ln(e0) */

    double a0[num_IT + 1], b0[num_IT + 1], c[num_IT + 1], d[num_IT + 1];

    double f = a * rlog1(-lambda/a) + b * rlog1(lambda/b), t;
    if(log_p)
    t = -f;
    else {
    t = exp(-f);
    if (t == 0.) {
        return 0; /* once underflow, always underflow .. */
    }
    }
    double z0 = sqrt(f),
    z = z0 / e1 * 0.5,
    z2 = f + f,
    h, r0, r1, w0;

    if (a < b) {
    h = a / b;
    r0 = 1. / (h + 1.);
    r1 = (b - a) / b;
    w0 = 1. / sqrt(a * (h + 1.));
    } else {
    h = b / a;
    r0 = 1. / (h + 1.);
    r1 = (b - a) / a;
    w0 = 1. / sqrt(b * (h + 1.));
    }

    a0[0] = r1 * .66666666666666663;
    c[0] = a0[0] * -0.5;
    d[0] = -c[0];
    double j0 = 0.5 / e0 * erfc1(1, z0),
    j1 = e1,
    sum = j0 + d[0] * w0 * j1;

    double s = 1.,
    h2 = h * h,
    hn = 1.,
    w = w0,
    znm1 = z,
    zn = z2;
    int n;
    for (n = 2; n <= num_IT; n += 2) {
    hn *= h2;
    a0[n - 1] = r0 * 2. * (h * hn + 1.) / (n + 2.);
    int np1 = n + 1;
    s += hn;
    a0[np1 - 1] = r1 * 2. * s / (n + 3.);
    
    int i, j, m;
    for (i = n; i <= np1; ++i) {
        double r = (i + 1.) * -0.5;
        b0[0] = r * a0[0];
        for (m = 2; m <= i; ++m) {
        double bsum = 0.;
        for (j = 1; j <= m-1; ++j) {
            int mmj = m - j;
            bsum += (j * r - mmj) * a0[j - 1] * b0[mmj - 1];
        }
        b0[m - 1] = r * a0[m - 1] + bsum / m;
        }
        c[i - 1] = b0[i - 1] / (i + 1.);

        double dsum = 0.;
        for (j = 1; j <= i-1; ++j) {
        dsum += d[i - j - 1] * c[j - 1];
        }
        d[i - 1] = -(dsum + c[i - 1]);
    }

    j0 = e1 * znm1 + (n - 1.) * j0;
    j1 = e1 * zn + n * j1;
    znm1 = z2 * znm1;
    zn = z2 * zn;
    w *= w0;
    double t0 = d[n - 1] * w * j0;
    w *= w0;
    double t1 = d[np1 - 1] * w * j1;
    sum += t0 + t1;
    if (fabs(t0) + fabs(t1) <= eps * sum) {
        break;
    }
    }

    if(log_p)
    return ln_e0 + t - bcorr(a, b) + log(sum);
    else {
    double u = exp(-bcorr(a, b));
    return e0 * t * u * sum;
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
movl %edi, %ebx
movapd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movapd %xmm0, %xmm1
movsd %xmm0, 0x28(%rsp)
movapd %xmm2, %xmm0
xorpd 0x9d78(%rip), %xmm0     # 0x22fe0
divsd %xmm1, %xmm0
callq 0x1c47b
movapd %xmm0, 0x40(%rsp)
movapd 0x10(%rsp), %xmm0
divsd 0x8(%rsp), %xmm0
callq 0x1c47b
movapd 0x40(%rsp), %xmm1
mulsd 0x8(%rsp), %xmm0
mulsd 0x28(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd 0x9d3a(%rip), %xmm0     # 0x22fe0
xorpd %xmm1, %xmm0
testl %ebx, %ebx
movapd %xmm1, 0x40(%rsp)
je 0x197b3
xorpd %xmm8, %xmm8
ucomisd %xmm8, %xmm1
movapd %xmm0, 0x60(%rsp)
jb 0x192d0
sqrtsd %xmm1, %xmm7
jmp 0x192e2
movapd %xmm1, %xmm0
callq 0x24f0
xorpd %xmm8, %xmm8
movapd %xmm0, %xmm7
movapd %xmm7, %xmm6
divsd 0x9852(%rip), %xmm6     # 0x22b40
movsd 0x8(%rsp), %xmm2
movapd %xmm2, %xmm4
movsd 0x28(%rsp), %xmm3
subsd %xmm3, %xmm4
movapd %xmm2, %xmm0
divsd %xmm3, %xmm0
movapd %xmm3, %xmm1
divsd %xmm2, %xmm1
movapd %xmm3, %xmm5
cmpltsd %xmm2, %xmm5
andpd %xmm5, %xmm1
andnpd %xmm0, %xmm5
orpd %xmm1, %xmm5
movapd %xmm2, %xmm0
maxsd %xmm3, %xmm0
divsd %xmm0, %xmm4
movsd %xmm4, 0x30(%rsp)
movapd %xmm3, %xmm0
movapd %xmm5, 0x90(%rsp)
addsd 0x82e2(%rip), %xmm5     # 0x21630
minsd %xmm2, %xmm0
mulsd %xmm5, %xmm0
ucomisd %xmm8, %xmm0
movl %ebx, 0x5c(%rsp)
jb 0x19367
sqrtsd %xmm0, %xmm0
jmp 0x19396
movsd %xmm6, 0x38(%rsp)
movsd %xmm7, 0x10(%rsp)
movapd %xmm5, 0x80(%rsp)
callq 0x24f0
movapd 0x80(%rsp), %xmm5
movsd 0x10(%rsp), %xmm7
movsd 0x38(%rsp), %xmm6
movapd 0x40(%rsp), %xmm1
mulsd 0x7e54(%rip), %xmm6     # 0x211f8
movsd %xmm6, 0x38(%rsp)
addsd %xmm1, %xmm1
movapd %xmm1, 0x40(%rsp)
movsd 0x8274(%rip), %xmm2     # 0x21630
movapd %xmm2, %xmm1
divsd %xmm5, %xmm1
movsd %xmm1, 0x50(%rsp)
divsd %xmm0, %xmm2
movsd %xmm2, 0x78(%rsp)
movsd 0x976c(%rip), %xmm1     # 0x22b48
mulsd 0x30(%rsp), %xmm1
movsd %xmm1, 0xa0(%rsp)
mulsd 0x9495(%rip), %xmm1     # 0x22888
movapd %xmm1, 0x10(%rsp)
leaq 0x2b0(%rsp), %r14
movsd %xmm1, (%r14)
movapd 0x9bd2(%rip), %xmm0     # 0x22fe0
xorpd %xmm1, %xmm0
movlpd %xmm0, 0x150(%rsp)
movapd %xmm7, %xmm0
callq 0x1c93b
mulsd 0x9724(%rip), %xmm0     # 0x22b50
movsd 0x78(%rsp), %xmm10
movapd 0x10(%rsp), %xmm1
mulsd %xmm10, %xmm1
movsd 0x96fa(%rip), %xmm7     # 0x22b40
mulsd %xmm7, %xmm1
movapd %xmm1, %xmm2
movapd %xmm0, %xmm1
subsd %xmm2, %xmm1
movsd %xmm1, 0x10(%rsp)
movapd 0x90(%rsp), %xmm2
mulsd %xmm2, %xmm2
movsd 0x50(%rsp), %xmm1
addsd %xmm1, %xmm1
movsd %xmm1, 0x50(%rsp)
movsd 0x30(%rsp), %xmm1
addsd %xmm1, %xmm1
movsd %xmm1, 0x30(%rsp)
movl $0x3, %eax
movl $0x2, %esi
movl $0x4, %ecx
xorl %edx, %edx
movsd 0x93e6(%rip), %xmm3     # 0x22888
movapd 0x9b36(%rip), %xmm4     # 0x22fe0
movsd 0x817d(%rip), %xmm9     # 0x21630
movapd %xmm9, %xmm8
movapd 0x40(%rsp), %xmm11
movapd %xmm11, %xmm1
cmpq $0x14, %rsi
ja 0x19760
mulsd %xmm2, %xmm9
movapd 0x90(%rsp), %xmm12
mulsd %xmm9, %xmm12
addsd 0x8145(%rip), %xmm12    # 0x21630
leaq 0x2(%rsi), %rdi
xorps %xmm13, %xmm13
cvtsi2sd %edi, %xmm13
mulsd 0x50(%rsp), %xmm12
divsd %xmm13, %xmm12
leaq -0x1(%rsi), %r8
movq %r8, 0x80(%rsp)
movsd %xmm12, 0x98(%rsp,%rsi,8)
addsd %xmm9, %xmm8
movsd 0x30(%rsp), %xmm12
mulsd %xmm8, %xmm12
leal 0x3(%rsi), %r9d
xorps %xmm13, %xmm13
cvtsi2sd %r9d, %xmm13
divsd %xmm13, %xmm12
movsd %xmm12, 0xa0(%rsp,%rsi,8)
movsd 0xa0(%rsp), %xmm12
movq %rdx, %r9
movq %rsi, %r11
movq %rax, %r10
leaq 0x1(%r11), %r15
movl %r15d, %ebx
xorps %xmm13, %xmm13
cvtsi2sd %rbx, %xmm13
movapd %xmm13, %xmm14
mulsd %xmm3, %xmm14
movapd %xmm14, %xmm15
mulsd %xmm12, %xmm15
movsd %xmm15, 0x200(%rsp)
movl $0x2, %r12d
movl $0x1, %r13d
xorpd %xmm15, %xmm15
xorl %ebx, %ebx
movq %r13, %rbp
leaq 0x1(%rbx), %r8
xorps %xmm6, %xmm6
cvtsi2sd %r8d, %xmm6
xorps %xmm5, %xmm5
cvtsi2sd %ebp, %xmm5
mulsd %xmm14, %xmm6
subsd %xmm5, %xmm6
mulsd 0xa0(%rsp,%rbx,8), %xmm6
mulsd 0x1f8(%rsp,%rbp,8), %xmm6
addsd %xmm6, %xmm15
movq %r8, %rbx
decq %rbp
jne 0x1959e
xorps %xmm5, %xmm5
cvtsi2sd %r12d, %xmm5
divsd %xmm5, %xmm15
movsd 0x98(%rsp,%r12,8), %xmm5
mulsd %xmm14, %xmm5
addsd %xmm15, %xmm5
movsd %xmm5, 0x1f8(%rsp,%r12,8)
incq %r12
incq %r13
cmpq %r10, %r12
jne 0x19594
movsd 0x1f8(%rsp,%r11,8), %xmm14
divsd %xmm13, %xmm14
movsd %xmm14, 0x2a8(%rsp,%r11,8)
xorpd %xmm13, %xmm13
movq %r14, %rbx
movq %r9, %r12
movsd 0x150(%rsp,%r12,8), %xmm5
mulsd (%rbx), %xmm5
addsd %xmm5, %xmm13
addq $0x8, %rbx
addq $-0x1, %r12
jb 0x19633
addsd %xmm13, %xmm14
xorpd %xmm4, %xmm14
movlpd %xmm14, 0x148(%rsp,%r11,8)
incq %r10
incq %r9
movq %r15, %r11
cmpq %rcx, %r15
jne 0x1955a
xorps %xmm5, %xmm5
cvtsi2sd %esi, %xmm5
xorps %xmm6, %xmm6
cvtsi2sdl 0x80(%rsp), %xmm6
mulsd %xmm5, %xmm7
mulsd %xmm6, %xmm0
movapd %xmm1, %xmm13
movapd %xmm1, %xmm12
movsd 0x38(%rsp), %xmm5
mulsd %xmm5, %xmm12
movsd 0x9492(%rip), %xmm6     # 0x22b40
mulsd %xmm6, %xmm5
addsd %xmm5, %xmm0
mulsd %xmm11, %xmm13
mulsd %xmm6, %xmm11
addsd %xmm11, %xmm7
movsd 0x78(%rsp), %xmm11
mulsd %xmm11, %xmm10
mulsd %xmm10, %xmm11
mulsd 0x148(%rsp,%rsi,8), %xmm10
mulsd %xmm0, %xmm10
movsd 0x150(%rsp,%rsi,8), %xmm5
mulsd %xmm11, %xmm5
mulsd %xmm7, %xmm5
movapd %xmm10, %xmm6
addsd %xmm5, %xmm6
movsd 0x10(%rsp), %xmm14
addsd %xmm6, %xmm14
movapd 0x98bc(%rip), %xmm6     # 0x22fd0
andpd %xmm6, %xmm10
andpd %xmm6, %xmm5
addsd %xmm10, %xmm5
movsd %xmm14, 0x10(%rsp)
movapd %xmm14, %xmm6
mulsd 0x9422(%rip), %xmm6     # 0x22b58
addq $0x2, %rax
addq $0x2, %rcx
addq $0x2, %rdx
ucomisd %xmm5, %xmm6
movq %rdi, %rsi
movapd %xmm11, %xmm10
movsd %xmm12, 0x38(%rsp)
movapd %xmm13, %xmm11
jb 0x194c4
cmpl $0x0, 0x5c(%rsp)
je 0x197cf
movapd 0x60(%rsp), %xmm0
addsd 0x93eb(%rip), %xmm0     # 0x22b60
movapd %xmm0, 0x60(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x1c5ac
movapd 0x60(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, 0x60(%rsp)
movsd 0x10(%rsp), %xmm0
callq 0x2240
movapd %xmm0, %xmm2
addsd 0x60(%rsp), %xmm2
jmp 0x19809
callq 0x2550
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jne 0x197c4
jnp 0x19809
movapd 0x40(%rsp), %xmm1
jmp 0x192b8
movsd 0x28(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
callq 0x1c5ac
xorpd 0x97f8(%rip), %xmm0     # 0x22fe0
callq 0x2550
movapd 0x60(%rsp), %xmm1
mulsd 0x936d(%rip), %xmm1     # 0x22b68
mulsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm2
mulsd %xmm1, %xmm2
movapd %xmm2, %xmm0
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq