#ifdef __i386__
#include <ieeefp.h>
#endif
#include <stdint.h>
#include "fpmath.h"
#include "math.h"
#include "math_private.h"
static const union IEEEl2bits
pi_hi_u = LD80C(0xc90fdaa200000000, 1, 3.14159265346825122833e+00L),
pi_lo_u = LD80C(0x85a308d313198a2e, -33, 1.21542010130123852029e-10L);
#define pi_hi (pi_hi_u.e)
#define pi_lo (pi_lo_u.e)
#include "k_cospil.h"
#include "k_sinpil.h"
volatile static const double vzero = 0;
long double
sinpil(long double x)
{
long double ax, hi, lo, s;
uint64_t lx, m;
uint32_t j0;
uint16_t hx, ix;
EXTRACT_LDBL80_WORDS(hx, lx, x);
ix = hx & 0x7fff;
INSERT_LDBL80_WORDS(ax, ix, lx);
ENTERI();
if (ix < 0x3fff) {
if (ix < 0x3ffd) {
if (ix < 0x3fdd) {
if (x == 0)
RETURNI(x);
INSERT_LDBL80_WORDS(hi, hx,
lx & 0xffffffff00000000ull);
hi *= 0x1p63L;
lo = x * 0x1p63L - hi;
s = (pi_lo + pi_hi) * lo + pi_lo * hi +
pi_hi * hi;
RETURNI(s * 0x1p-63L);
}
s = __kernel_sinpil(ax);
RETURNI((hx & 0x8000) ? -s : s);
}
if (ix < 0x3ffe)
s = __kernel_cospil(0.5 - ax);
else if (lx < 0xc000000000000000ull)
s = __kernel_cospil(ax - 0.5);
else
s = __kernel_sinpil(1 - ax);
RETURNI((hx & 0x8000) ? -s : s);
}
if (ix < 0x403e) {
FFLOORL80(x, j0, ix, lx);
ax -= x;
EXTRACT_LDBL80_WORDS(ix, lx, ax);
if (ix == 0) {
s = 0;
} else {
if (ix < 0x3ffe) {
if (ix < 0x3ffd)
s = __kernel_sinpil(ax);
else
s = __kernel_cospil(0.5 - ax);
} else {
if (lx < 0xc000000000000000ull)
s = __kernel_cospil(ax - 0.5);
else
s = __kernel_sinpil(1 - ax);
}
if (j0 > 40)
x -= 0x1p40;
if (j0 > 30)
x -= 0x1p30;
j0 = (uint32_t)x;
if (j0 & 1) s = -s;
}
RETURNI((hx & 0x8000) ? -s : s);
}
if (ix >= 0x7fff)
RETURNI(vzero / vzero);
RETURNI(copysignl(0, x));
}