// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/binomlite.c
// Function: psi
static double psi(double x)
{
/* ---------------------------------------------------------------------

 *                 Evaluation of the Digamma function psi(x)

 *                           -----------

 *     Psi(xx) is assigned the value 0 when the digamma function cannot
 *     be computed.

 *     The main computation involves evaluation of rational Chebyshev
 *     approximations published in Math. Comp. 27, 123-127(1973) by
 *     Cody, Strecok and Thacher. */

/* --------------------------------------------------------------------- */
/*     Psi was written at Argonne National Laboratory for the FUNPACK */
/*     package of special function subroutines. Psi was modified by */
/*     A.H. Morris (NSWC). */
/* --------------------------------------------------------------------- */

    static double piov4 = .785398163397448; /* == pi / 4 */
/*     dx0 = zero of psi() to extended precision : */
    static double dx0 = 1.461632144968362341262659542325721325;

/* --------------------------------------------------------------------- */
/*     COEFFICIENTS FOR RATIONAL APPROXIMATION OF */
/*     PSI(X) / (X - X0),  0.5 <= X <= 3. */
    static double p1[7] = { .0089538502298197,4.77762828042627,
        142.441585084029,1186.45200713425,3633.51846806499,
        4138.10161269013,1305.60269827897 };
    static double q1[6] = { 44.8452573429826,520.752771467162,
        2210.0079924783,3641.27349079381,1908.310765963,
        6.91091682714533e-6 };
/* --------------------------------------------------------------------- */


/* --------------------------------------------------------------------- */
/*     COEFFICIENTS FOR RATIONAL APPROXIMATION OF */
/*     PSI(X) - LN(X) + 1 / (2*X),  X > 3. */

    static double p2[4] = { -2.12940445131011,-7.01677227766759,
        -4.48616543918019,-.648157123766197 };
    static double q2[4] = { 32.2703493791143,89.2920700481861,
        54.6117738103215,7.77788548522962 };
/* --------------------------------------------------------------------- */

    int i, m, n, nq;
    double d2;
    double w, z;
    double den, aug, sgn, xmx0, xmax1, upper, xsmall;

/* --------------------------------------------------------------------- */


/*     MACHINE DEPENDENT CONSTANTS ... */

/* --------------------------------------------------------------------- */
/*      XMAX1     = THE SMALLEST POSITIVE FLOATING POINT CONSTANT
           WITH ENTIRELY INT REPRESENTATION.  ALSO USED
           AS NEGATIVE OF LOWER BOUND ON ACCEPTABLE NEGATIVE
           ARGUMENTS AND AS THE POSITIVE ARGUMENT BEYOND WHICH
           PSI MAY BE REPRESENTED AS LOG(X).
 * Originally:  xmax1 = amin1(ipmpar(3), 1./spmpar(1))  */
    xmax1 = (double) INT_MAX;
    d2 = 0.5 / (0.5*DBL_EPSILON); /*= 0.5 / (0.5 * DBL_EPS) = 1/DBL_EPSILON = 2^52 */
    if(xmax1 > d2) xmax1 = d2;

/* --------------------------------------------------------------------- */
/*        XSMALL = ABSOLUTE ARGUMENT BELOW WHICH PI*COTAN(PI*X) */
/*                 MAY BE REPRESENTED BY 1/X. */
    xsmall = 1e-9;
/* --------------------------------------------------------------------- */
    aug = 0.;
    if (x < 0.5) {
/* --------------------------------------------------------------------- */
/*     X < 0.5,  USE REFLECTION FORMULA */
/*     PSI(1-X) = PSI(X) + PI * COTAN(PI*X) */
/* --------------------------------------------------------------------- */
    if (fabs(x) <= xsmall) {

        if (x == 0.) {
        goto L_err;
        }
/* --------------------------------------------------------------------- */
/*     0 < |X| <= XSMALL.  USE 1/X AS A SUBSTITUTE */
/*     FOR  PI*COTAN(PI*X) */
/* --------------------------------------------------------------------- */
        aug = -1. / x;
    } else { /* |x| > xsmall */
/* --------------------------------------------------------------------- */
/*     REDUCTION OF ARGUMENT FOR COTAN */
/* --------------------------------------------------------------------- */
        /* L100: */
        w = -x;
        sgn = piov4;
        if (w <= 0.) {
        w = -w;
        sgn = -sgn;
        }
/* --------------------------------------------------------------------- */
/*     MAKE AN ERROR EXIT IF |X| >= XMAX1 */
/* --------------------------------------------------------------------- */
        if (w >= xmax1) {
        goto L_err;
        }
        nq = (int) w;
        w -= (double) nq;
        nq = (int) (w * 4.);
        w = (w - (double) nq * 0.25) * 4.;
/* --------------------------------------------------------------------- */
/*     W IS NOW RELATED TO THE FRACTIONAL PART OF  4. * X. */
/*     ADJUST ARGUMENT TO CORRESPOND TO VALUES IN FIRST */
/*     QUADRANT AND DETERMINE SIGN */
/* --------------------------------------------------------------------- */
        n = nq / 2;
        if (n + n != nq) {
        w = 1. - w;
        }
        z = piov4 * w;
        m = n / 2;
        if (m + m != n) {
        sgn = -sgn;
        }
/* --------------------------------------------------------------------- */
/*     DETERMINE FINAL VALUE FOR  -PI*COTAN(PI*X) */
/* --------------------------------------------------------------------- */
        n = (nq + 1) / 2;
        m = n / 2;
        m += m;
        if (m == n) {
/* --------------------------------------------------------------------- */
/*     CHECK FOR SINGULARITY */
/* --------------------------------------------------------------------- */
        if (z == 0.) {
            goto L_err;
        }
/* --------------------------------------------------------------------- */
/*     USE COS/SIN AS A SUBSTITUTE FOR COTAN, AND */
/*     SIN/COS AS A SUBSTITUTE FOR TAN */
/* --------------------------------------------------------------------- */
        aug = sgn * (cos(z) / sin(z) * 4.);

        } else { /* L140: */
        aug = sgn * (sin(z) / cos(z) * 4.);
        }
    }

    x = 1. - x;

    }
    /* L200: */
    if (x <= 3.) {
/* --------------------------------------------------------------------- */
/*     0.5 <= X <= 3. */
/* --------------------------------------------------------------------- */
    den = x;
    upper = p1[0] * x;

    for (i = 1; i <= 5; ++i) {
        den = (den + q1[i - 1]) * x;
        upper = (upper + p1[i]) * x;
    }

    den = (upper + p1[6]) / (den + q1[5]);
    xmx0 = x - dx0;
    return den * xmx0 + aug;
    }

/* --------------------------------------------------------------------- */
/*     IF X >= XMAX1, PSI = LN(X) */
/* --------------------------------------------------------------------- */
    if (x < xmax1) {
/* --------------------------------------------------------------------- */
/*     3. < X < XMAX1 */
/* --------------------------------------------------------------------- */
    w = 1. / (x * x);
    den = w;
    upper = p2[0] * w;

    for (i = 1; i <= 3; ++i) {
        den = (den + q2[i - 1]) * w;
        upper = (upper + p2[i]) * w;
    }

    aug = upper / (den + q2[3]) - 0.5 / x + aug;
    }
    return aug + log(x);

/* --------------------------------------------------------------------- */
/*     ERROR RETURN */
/* --------------------------------------------------------------------- */
L_err:
    return 0.;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movsd %xmm0, -0x10(%rbp)
movsd 0xdb00(%rip), %xmm0     # 0x32a58
movsd %xmm0, -0x60(%rbp)
movsd 0xdaeb(%rip), %xmm0     # 0x32a50
movsd %xmm0, -0x28(%rbp)
movsd -0x60(%rbp), %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x24f80
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0xdad8(%rip), %xmm0     # 0x32a60
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd 0xc663(%rip), %xmm0     # 0x31600
ucomisd -0x10(%rbp), %xmm0
jbe 0x2525b
movsd -0x10(%rbp), %xmm1
movaps 0xdb3c(%rip), %xmm0     # 0x32af0
pand %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x24fef
movsd -0x10(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x24fd8
jp 0x24fd8
jmp 0x2543f
movsd 0xd898(%rip), %xmm0     # 0x32878
divsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x25249
movsd -0x10(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x14438(%rip), %xmm0    # 0x39450
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jb 0x25069
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x50(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x30(%rbp), %xmm0
ucomisd -0x60(%rbp), %xmm0
jb 0x2507a
jmp 0x2543f
cvttsd2si -0x30(%rbp), %eax
movl %eax, -0x20(%rbp)
cvtsi2sdl -0x20(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0xd9cb(%rip), %xmm0     # 0x32a68
mulsd -0x30(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x20(%rbp)
movsd -0x30(%rbp), %xmm1
cvtsi2sdl -0x20(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0xd766(%rip), %xmm2     # 0x32838
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0xd986(%rip), %xmm1     # 0x32a68
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movl -0x20(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0x25116
movsd 0xc4ec(%rip), %xmm0     # 0x315f8
subsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x14332(%rip), %xmm0    # 0x39450
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x25162
movsd -0x50(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jne 0x251f2
movsd -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x251a7
jp 0x251a7
jmp 0x2543f
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x2260
movsd %xmm0, -0x80(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x2460
movsd -0x80(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x78(%rbp), %xmm0
divsd %xmm2, %xmm1
movsd 0xd885(%rip), %xmm2     # 0x32a68
mulsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x25247
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x2460
movsd %xmm0, -0x90(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x2260
movsd -0x90(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0x88(%rbp), %xmm0
divsd %xmm2, %xmm1
movsd 0xd82e(%rip), %xmm2     # 0x32a68
mulsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x25249
movsd 0xc3a7(%rip), %xmm0     # 0x315f8
subsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd 0xd52d(%rip), %xmm0     # 0x32790
ucomisd -0x10(%rbp), %xmm0
jb 0x2533b
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x141e0(%rip), %xmm0    # 0x39460
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x1, -0x14(%rbp)
cmpl $0x5, -0x14(%rbp)
jg 0x252e5
movsd -0x40(%rbp), %xmm0
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x141f4(%rip), %rax     # 0x394a0
addsd (%rax,%rcx,8), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x68(%rbp), %xmm0
movslq -0x14(%rbp), %rcx
leaq 0x14195(%rip), %rax     # 0x39460
addsd (%rax,%rcx,8), %xmm0
mulsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x25291
movsd -0x68(%rbp), %xmm0
addsd 0x1419e(%rip), %xmm0    # 0x39490
movsd -0x40(%rbp), %xmm1
addsd 0x141c9(%rip), %xmm1    # 0x394c8
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x10(%rbp), %xmm0
subsd 0x14143(%rip), %xmm0    # 0x39458
movsd %xmm0, -0x58(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
movsd -0x48(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x25447
movsd -0x10(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x25412
movsd -0x10(%rbp), %xmm1
mulsd -0x10(%rbp), %xmm1
movsd 0xc297(%rip), %xmm0     # 0x315f8
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x14154(%rip), %xmm0    # 0x394d0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x1, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jg 0x253e1
movsd -0x40(%rbp), %xmm0
movl -0x14(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rcx
leaq 0x14148(%rip), %rax     # 0x394f0
addsd (%rax,%rcx,8), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x68(%rbp), %xmm0
movslq -0x14(%rbp), %rcx
leaq 0x14109(%rip), %rax     # 0x394d0
addsd (%rax,%rcx,8), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2538d
movsd -0x68(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
addsd 0x14115(%rip), %xmm1    # 0x39508
divsd %xmm1, %xmm0
movsd 0xc201(%rip), %xmm1     # 0x31600
divsd -0x10(%rbp), %xmm1
subsd %xmm1, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x2250
movaps %xmm0, %xmm1
movsd -0x98(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x25447
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)