// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
movsd %xmm3, -0x28(%rbp)
movl %edi, -0x2c(%rbp)
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x3d8(%rbp)
movsd -0x20(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x10(%rbp), %xmm0
callq 0x27190
movsd %xmm0, -0x3e0(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x3e8(%rbp)
movsd -0x20(%rbp), %xmm0
divsd -0x18(%rbp), %xmm0
callq 0x27190
movsd -0x3e8(%rbp), %xmm1
movsd -0x3e0(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x3d8(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x2f8(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x225c7
movsd -0x2f8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x300(%rbp)
jmp 0x22615
movsd -0x2f8(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x2560
movsd %xmm0, -0x300(%rbp)
movsd -0x300(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x22613
jp 0x22613
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x22ebe
jmp 0x22615
movsd -0x2f8(%rbp), %xmm0
callq 0x2500
movsd %xmm0, -0x308(%rbp)
movsd -0x308(%rbp), %xmm0
movsd 0x10206(%rip), %xmm1    # 0x32840
divsd %xmm1, %xmm0
movsd 0xefba(%rip), %xmm1     # 0x31600
mulsd %xmm1, %xmm0
movsd %xmm0, -0x310(%rbp)
movsd -0x2f8(%rbp), %xmm0
addsd -0x2f8(%rbp), %xmm0
movsd %xmm0, -0x318(%rbp)
movsd -0x10(%rbp), %xmm1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x22705
movsd -0x10(%rbp), %xmm0
divsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x320(%rbp)
movsd 0xef60(%rip), %xmm1     # 0x315f8
addsd -0x320(%rbp), %xmm1
movsd 0xef50(%rip), %xmm0     # 0x315f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x328(%rbp)
movsd -0x18(%rbp), %xmm0
subsd -0x10(%rbp), %xmm0
divsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
movsd -0x10(%rbp), %xmm0
movsd 0xef20(%rip), %xmm1     # 0x315f8
addsd -0x320(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x2500
movaps %xmm0, %xmm1
movsd 0xef04(%rip), %xmm0     # 0x315f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x338(%rbp)
jmp 0x22787
movsd -0x18(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x320(%rbp)
movsd 0xeed9(%rip), %xmm1     # 0x315f8
addsd -0x320(%rbp), %xmm1
movsd 0xeec9(%rip), %xmm0     # 0x315f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x328(%rbp)
movsd -0x18(%rbp), %xmm0
subsd -0x10(%rbp), %xmm0
divsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x330(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0xee99(%rip), %xmm1     # 0x315f8
addsd -0x320(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x2500
movaps %xmm0, %xmm1
movsd 0xee7d(%rip), %xmm0     # 0x315f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x338(%rbp)
movsd 0x100c9(%rip), %xmm0    # 0x32858
mulsd -0x330(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd 0x100a9(%rip), %xmm0    # 0x32850
mulsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x240(%rbp)
movsd -0x240(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x2f0(%rbp)
movsd -0x308(%rbp), %xmm0
movl $0x1, %edi
callq 0x28630
movaps %xmm0, %xmm1
movsd 0x1004d(%rip), %xmm0    # 0x32848
mulsd %xmm1, %xmm0
movsd %xmm0, -0x340(%rbp)
movsd 0x10031(%rip), %xmm0    # 0x32840
movsd %xmm0, -0x348(%rbp)
movsd -0x340(%rbp), %xmm1
movsd -0x2f0(%rbp), %xmm0
mulsd -0x338(%rbp), %xmm0
movsd -0x348(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x350(%rbp)
movsd 0xeda9(%rip), %xmm0     # 0x315f8
movsd %xmm0, -0x358(%rbp)
movsd -0x320(%rbp), %xmm0
mulsd -0x320(%rbp), %xmm0
movsd %xmm0, -0x360(%rbp)
movsd 0xed81(%rip), %xmm0     # 0x315f8
movsd %xmm0, -0x368(%rbp)
movsd -0x338(%rbp), %xmm0
movsd %xmm0, -0x370(%rbp)
movsd -0x310(%rbp), %xmm0
movsd %xmm0, -0x378(%rbp)
movsd -0x318(%rbp), %xmm0
movsd %xmm0, -0x380(%rbp)
movl $0x2, -0x384(%rbp)
cmpl $0x14, -0x384(%rbp)
jg 0x22dff
movsd -0x360(%rbp), %xmm0
mulsd -0x368(%rbp), %xmm0
movsd %xmm0, -0x368(%rbp)
movsd 0xe8da(%rip), %xmm0     # 0x311c0
mulsd -0x328(%rbp), %xmm0
movsd -0x320(%rbp), %xmm1
movsd -0x368(%rbp), %xmm2
mulsd %xmm2, %xmm1
movsd 0xecee(%rip), %xmm2     # 0x315f8
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x384(%rbp), %xmm1
movsd 0xe89e(%rip), %xmm2     # 0x311c0
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movl -0x384(%rbp), %eax
subl $0x1, %eax
cltq
movsd %xmm0, -0xe0(%rbp,%rax,8)
movl -0x384(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x388(%rbp)
movsd -0x368(%rbp), %xmm0
addsd -0x358(%rbp), %xmm0
movsd %xmm0, -0x358(%rbp)
movsd 0xe853(%rip), %xmm0     # 0x311c0
mulsd -0x330(%rbp), %xmm0
mulsd -0x358(%rbp), %xmm0
cvtsi2sdl -0x384(%rbp), %xmm1
movsd 0xfe03(%rip), %xmm2     # 0x32790
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movl -0x388(%rbp), %eax
subl $0x1, %eax
cltq
movsd %xmm0, -0xe0(%rbp,%rax,8)
movl -0x384(%rbp), %eax
movl %eax, -0x38c(%rbp)
movl -0x38c(%rbp), %eax
cmpl -0x388(%rbp), %eax
jg 0x22c66
cvtsi2sdl -0x38c(%rbp), %xmm0
movsd 0xec21(%rip), %xmm1     # 0x315f8
addsd %xmm1, %xmm0
movsd 0xfe6d(%rip), %xmm1     # 0x32850
mulsd %xmm1, %xmm0
movsd %xmm0, -0x3a0(%rbp)
movsd -0x3a0(%rbp), %xmm0
mulsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x190(%rbp)
movl $0x2, -0x394(%rbp)
movl -0x394(%rbp), %eax
cmpl -0x38c(%rbp), %eax
jg 0x22b4c
xorps %xmm0, %xmm0
movsd %xmm0, -0x3a8(%rbp)
movl $0x1, -0x390(%rbp)
movl -0x390(%rbp), %eax
movl -0x394(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x22aec
movl -0x394(%rbp), %eax
subl -0x390(%rbp), %eax
movl %eax, -0x3ac(%rbp)
cvtsi2sdl -0x390(%rbp), %xmm0
movsd -0x3a0(%rbp), %xmm2
cvtsi2sdl -0x3ac(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl -0x390(%rbp), %eax
subl $0x1, %eax
cltq
mulsd -0xe0(%rbp,%rax,8), %xmm0
movl -0x3ac(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0x190(%rbp,%rax,8), %xmm2
movsd -0x3a8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x3a8(%rbp)
movl -0x390(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x390(%rbp)
jmp 0x22a38
movsd -0x3a0(%rbp), %xmm0
movl -0x394(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0xe0(%rbp,%rax,8), %xmm2
movsd -0x3a8(%rbp), %xmm1
cvtsi2sdl -0x394(%rbp), %xmm3
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movl -0x394(%rbp), %eax
subl $0x1, %eax
cltq
movsd %xmm0, -0x190(%rbp,%rax,8)
movl -0x394(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x394(%rbp)
jmp 0x22a11
movl -0x38c(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0x190(%rbp,%rax,8), %xmm0
cvtsi2sdl -0x38c(%rbp), %xmm1
movsd 0xea88(%rip), %xmm2     # 0x315f8
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movl -0x38c(%rbp), %eax
subl $0x1, %eax
cltq
movsd %xmm0, -0x240(%rbp,%rax,8)
xorps %xmm0, %xmm0
movsd %xmm0, -0x3b8(%rbp)
movl $0x1, -0x390(%rbp)
movl -0x390(%rbp), %eax
movl -0x38c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jg 0x22c0b
movl -0x38c(%rbp), %eax
subl -0x390(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0x2f0(%rbp,%rax,8), %xmm0
movl -0x390(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0x240(%rbp,%rax,8), %xmm2
movsd -0x3b8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x3b8(%rbp)
movl -0x390(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x390(%rbp)
jmp 0x22ba1
movsd -0x3b8(%rbp), %xmm0
movl -0x38c(%rbp), %eax
subl $0x1, %eax
cltq
addsd -0x240(%rbp,%rax,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movl -0x38c(%rbp), %eax
subl $0x1, %eax
cltq
movsd %xmm0, -0x2f0(%rbp,%rax,8)
movl -0x38c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38c(%rbp)
jmp 0x229b5
movsd -0x378(%rbp), %xmm0
cvtsi2sdl -0x384(%rbp), %xmm1
movsd 0xe97a(%rip), %xmm2     # 0x315f8
subsd %xmm2, %xmm1
mulsd -0x340(%rbp), %xmm1
movsd 0xfbae(%rip), %xmm2     # 0x32840
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x340(%rbp)
movsd -0x380(%rbp), %xmm0
cvtsi2sdl -0x384(%rbp), %xmm1
mulsd -0x348(%rbp), %xmm1
movsd 0xfb7e(%rip), %xmm2     # 0x32840
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x348(%rbp)
movsd -0x318(%rbp), %xmm0
mulsd -0x378(%rbp), %xmm0
movsd %xmm0, -0x378(%rbp)
movsd -0x318(%rbp), %xmm0
mulsd -0x380(%rbp), %xmm0
movsd %xmm0, -0x380(%rbp)
movsd -0x338(%rbp), %xmm0
mulsd -0x370(%rbp), %xmm0
movsd %xmm0, -0x370(%rbp)
movl -0x384(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0x2f0(%rbp,%rax,8), %xmm0
mulsd -0x370(%rbp), %xmm0
mulsd -0x340(%rbp), %xmm0
movsd %xmm0, -0x3c0(%rbp)
movsd -0x338(%rbp), %xmm0
mulsd -0x370(%rbp), %xmm0
movsd %xmm0, -0x370(%rbp)
movl -0x388(%rbp), %eax
subl $0x1, %eax
cltq
movsd -0x2f0(%rbp,%rax,8), %xmm0
mulsd -0x370(%rbp), %xmm0
mulsd -0x348(%rbp), %xmm0
movsd %xmm0, -0x3c8(%rbp)
movsd -0x3c0(%rbp), %xmm0
addsd -0x3c8(%rbp), %xmm0
addsd -0x350(%rbp), %xmm0
movsd %xmm0, -0x350(%rbp)
movsd -0x3c0(%rbp), %xmm1
movaps 0xfd37(%rip), %xmm0     # 0x32af0
pand %xmm0, %xmm1
movsd -0x3c8(%rbp), %xmm0
movaps 0xfd24(%rip), %xmm2     # 0x32af0
pand %xmm2, %xmm0
addsd %xmm0, %xmm1
movsd -0x28(%rbp), %xmm0
mulsd -0x350(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x22de9
jmp 0x22dff
jmp 0x22deb
movl -0x384(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x384(%rbp)
jmp 0x228b9
cmpl $0x0, -0x2c(%rbp)
je 0x22e66
movsd 0xfa5b(%rip), %xmm0     # 0x32868
addsd -0x300(%rbp), %xmm0
movsd %xmm0, -0x3f8(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
callq 0x273f0
movaps %xmm0, %xmm1
movsd -0x3f8(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x3f0(%rbp)
movsd -0x350(%rbp), %xmm0
callq 0x2250
movaps %xmm0, %xmm1
movsd -0x3f0(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x22ebe
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
callq 0x273f0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x2560
movsd %xmm0, -0x3d0(%rbp)
movsd 0xf9bf(%rip), %xmm0     # 0x32860
mulsd -0x300(%rbp), %xmm0
mulsd -0x3d0(%rbp), %xmm0
mulsd -0x350(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
nopl (%rax)