#include <mpfr.h>
#include "fenv_mpfr.h"
#include <stdint.h>
typedef union {_Float16 f; int16_t u;} b16u16;
_Float16
ref_hypot (_Float16 x, _Float16 y)
{
mpfr_t xm, ym, zm;
b16u16 xi = {.f = x}, yi = {.f = y};
if((xi.u & 0x7fff)<(0x7e<<8) && (xi.u & 0x7fff)>(0x7c<<8)) return x + y; if((yi.u & 0x7fff)<(0x7e<<8) && (yi.u & 0x7fff)>(0x7c<<8)) return x + y; if((xi.u & 0x7fff) == 0){ yi.u = (yi.u & 0x7fff);
return yi.f;
}
if((yi.u & 0x7fff) == 0){ xi.u = (xi.u & 0x7fff);
return xi.f;
}
mpfr_init2 (xm, 11);
mpfr_init2 (ym, 11);
mpfr_init2 (zm, 11);
mpfr_set_flt (xm, (float) x, MPFR_RNDN);
mpfr_set_flt (ym, (float) y, MPFR_RNDN);
int inex = mpfr_hypot (zm, xm, ym, rnd2[rnd]);
mpfr_subnormalize (zm, inex, rnd2[rnd]);
_Float16 ret = (_Float16) mpfr_get_flt (zm, MPFR_RNDN);
mpfr_clear (xm);
mpfr_clear (ym);
mpfr_clear (zm);
return ret;
}