#pragma weak __powl = powl
#include "libm.h"
#include "xpg6.h"
#define _C99SUSv3_pow _C99SUSv3_pow_treats_Inf_as_an_even_int
#if defined(__sparc)
#define i0 0
#define i1 1
#define i2 2
#define i3 3
static const long double zero = 0.0L, one = 1.0L, two = 2.0L;
extern const long double _TBL_logl_hi[], _TBL_logl_lo[];
static const long double
two113 = 10384593717069655257060992658440192.0L,
ln2hi = 6.931471805599453094172319547495844850203e-0001L,
ln2lo = 1.667085920830552208890449330400379754169e-0025L,
A2 = 6.666666666666666666666666666666091393804e-0001L,
A3 = 4.000000000000000000000000407167070220671e-0001L,
A4 = 2.857142857142857142730077490612903681164e-0001L,
A5 = 2.222222222222242577702836920812882605099e-0001L,
A6 = 1.818181816435493395985912667105885828356e-0001L,
A7 = 1.538537835211839751112067512805496931725e-0001L,
B1 = 6.666666666666666666666666666666666667787e-0001L,
B2 = 3.999999999999999999999999999999848524411e-0001L,
B3 = 2.857142857142857142857142865084581075070e-0001L,
B4 = 2.222222222222222222222010781800643808497e-0001L,
B5 = 1.818181818181818185051442171337036403674e-0001L,
B6 = 1.538461538461508363540720286292008207673e-0001L,
B7 = 1.333333333506731842033180638329317108428e-0001L,
B8 = 1.176469984587418890634302788283946761670e-0001L,
B9 = 1.053794891561452331722969901564862497132e-0001L;
static long double
logl_x(long double x, long double *w) {
long double f, f1, v, s, z, qn, h, t;
int *px = (int *) &x;
int *pz = (int *) &z;
int i, j, ix, n;
n = 0;
ix = px[i0];
if (ix > 0x3ffef03f && ix < 0x3fff0820) {
f = x - one;
z = f * f;
if (((ix - 0x3fff0000) | px[i1] | px[i2] | px[i3]) == 0) {
*w = zero;
return (zero);
}
qn = one / (two + f);
s = f * qn;
v = s * s;
h = (long double) (2.0 * (double) s);
f1 = (long double) ((double) f);
t = ((two * (f - h) - h * f1) - h * (f - f1)) * qn +
s * (v * (B1 + v * (B2 + v * (B3 + v * (B4 +
v * (B5 + v * (B6 + v * (B7 + v * (B8 + v * B9)))))))));
s = (long double) ((double) (h + t));
*w = t - (s - h);
return (s);
}
if (ix < 0x00010000) {
x *= two113;
n = -113;
ix = px[i0];
}
n += ((ix + 0x200) >> 16) - 0x3fff;
ix = (ix & 0x0000ffff) | 0x3fff0000;
px[i0] = ix;
i = ix + 0x200;
pz[i0] = i & 0xfffffc00;
pz[i1] = pz[i2] = pz[i3] = 0;
qn = one / (x + z);
f = x - z;
s = f * qn;
f1 = (long double) ((double) f);
h = (long double) (2.0 * (double) s);
t = qn * ((two * (f - z * h) - h * f1) - h * (f - f1));
j = (i >> 10) & 0x3f;
v = s * s;
qn = (long double) n;
t += qn * ln2lo + _TBL_logl_lo[j];
t += s * (v * (A2 + v * (A3 + v * (A4 + v * (A5 + v * (A6 +
v * A7))))));
v = qn * ln2hi + _TBL_logl_hi[j];
s = h + v;
t += (h - (s - v));
z = (long double) ((double) (s + t));
*w = t - (z - s);
return (z);
}
extern const long double _TBL_expl_hi[], _TBL_expl_lo[];
static const long double
invln2_32 = 4.616624130844682903551758979206054839765e+1L,
ln2_32hi = 2.166084939249829091928849858592451515688e-2L,
ln2_32lo = 5.209643502595475652782654157501186731779e-27L,
ln2_64 = 1.083042469624914545964425189778400898568e-2L;
long double
powl(long double x, long double y) {
long double z, ax;
long double y1, y2, w1, w2;
int sbx, sby, j, k, yisint, m;
int hx, lx, hy, ly, ahx, ahy;
int *pz = (int *) &z;
int *px = (int *) &x;
int *py = (int *) &y;
hx = px[i0];
lx = px[i1] | px[i2] | px[i3];
hy = py[i0];
ly = py[i1] | py[i2] | py[i3];
ahx = hx & ~0x80000000;
ahy = hy & ~0x80000000;
if ((ahy | ly) == 0)
return (one);
else if (hx == 0x3fff0000 && lx == 0 &&
(__xpg6 & _C99SUSv3_pow) != 0)
return (one);
else if (ahx > 0x7fff0000 || (ahx == 0x7fff0000 && lx != 0) ||
ahy > 0x7fff0000 || (ahy == 0x7fff0000 && ly != 0))
return (x + y);
sbx = (unsigned) hx >> 31;
sby = (unsigned) hy >> 31;
ax = fabsl(x);
yisint = 0;
if (sbx) {
if (ahy >= 0x40700000)
yisint = 2;
else if (ahy >= 0x3fff0000) {
k = (ahy >> 16) - 0x3fff;
if (k > 80) {
j = ((unsigned) py[i3]) >> (112 - k);
if ((j << (112 - k)) == py[i3])
yisint = 2 - (j & 1);
} else if (k > 48) {
j = ((unsigned) py[i2]) >> (80 - k);
if ((j << (80 - k)) == py[i2])
yisint = 2 - (j & 1);
} else if (k > 16) {
j = ((unsigned) py[i1]) >> (48 - k);
if ((j << (48 - k)) == py[i1])
yisint = 2 - (j & 1);
} else if (ly == 0) {
j = ahy >> (16 - k);
if ((j << (16 - k)) == ahy)
yisint = 2 - (j & 1);
}
}
}
if (ly == 0) {
if (ahy == 0x7fff0000) {
if (((ahx - 0x3fff0000) | lx) == 0) {
if ((__xpg6 & _C99SUSv3_pow) != 0)
return (one);
else
return (y - y);
} else if (ahx >= 0x3fff0000)
return (sby == 0 ? y : zero);
else
return (sby != 0 ? -y : zero);
} else if (ahy == 0x3fff0000) {
if (sby != 0)
return (one / x);
else
return (x);
} else if (hy == 0x40000000)
return (x * x);
else if (hy == 0x3ffe0000) {
if (!((ahx | lx) == 0 || ((ahx - 0x7fff0000) | lx) ==
0))
return (sqrtl(x));
}
}
if (lx == 0) {
if (ahx == 0x7fff0000 || ahx == 0 || ahx == 0x3fff0000) {
z = ax;
if (sby == 1)
z = one / z;
if (sbx == 1) {
if (ahx == 0x3fff0000 && yisint == 0)
z = zero / zero;
else if (yisint == 1)
z = -z;
}
return (z);
}
}
if (sbx == 1 && yisint == 0)
return (zero / zero);
w1 = logl_x(ax, &w2);
if (ly == 0 || ahy >= 0x43fe0000) {
y1 = y * w1;
y2 = y * w2;
} else {
y1 = (long double) ((double) y);
y2 = (y - y1) * w1 + y * w2;
y1 *= w1;
}
z = y1 + y2;
j = pz[i0];
if ((unsigned) j >= 0xffff0000) {
if (sbx == 1 && yisint == 1)
return (one / z);
else
return (-one / z);
} else if ((j & ~0x80000000) < 0x3fc30000) {
if (sbx == 1 && yisint == 1)
return (-one - z);
else
return (one + z);
} else if (j > 0) {
if (j > 0x400d0000) {
if (sbx == 1 && yisint == 1)
return (scalbnl(-one, 20000));
else
return (scalbnl(one, 20000));
}
k = (int) (invln2_32 * (z + ln2_64));
} else {
if ((unsigned) j > 0xc00d0000) {
if (sbx == 1 && yisint == 1)
return (scalbnl(-one, -20000));
else
return (scalbnl(one, -20000));
}
k = (int) (invln2_32 * (z - ln2_64));
}
j = k & 0x1f;
m = k >> 5;
{
long double
t1 = 1.666666666666666666666666666660876387437e-1L,
t2 = -2.777777777777777777777707812093173478756e-3L,
t3 = 6.613756613756613482074280932874221202424e-5L,
t4 = -1.653439153392139954169609822742235851120e-6L,
t5 = 4.175314851769539751387852116610973796053e-8L;
long double t = (long double) k;
w1 = (y2 - (t * ln2_32hi - y1)) - t * ln2_32lo;
t = w1 * w1;
w2 = (w1 - t * (t1 + t * (t2 + t * (t3 + t * (t4 + t * t5))))) -
two;
z = _TBL_expl_hi[j] - ((_TBL_expl_hi[j] * (w1 + w1)) / w2 -
_TBL_expl_lo[j]);
}
j = m + (pz[i0] >> 16);
if (j && (unsigned) j < 0x7fff)
pz[i0] += m << 16;
else
z = scalbnl(z, m);
if (sbx == 1 && yisint == 1)
z = -z;
return (z);
}
#else
#error Unsupported Architecture
#endif