#include <mpfr.h>
#include "fenv_mpfr.h"
#include <stdint.h>
typedef unsigned __int128 u128;
typedef uint64_t u64;
typedef union {u128 a; u64 b[2]; __float128 f;} b128u128_u;
__float128 ref_atan2q(__float128 x, __float128 y){
b128u128_u xi = {.f = x}, yi = {.f = y};
if((xi.a<<1)<((u128)0xffffull<<112) && (xi.a<<1)>((u128)0x7fffull<<113)){ xi.b[1] |= 1ull<<47;
return xi.f; }
if((yi.a<<1)<((u128)0xffffull<<112) && (yi.a<<1)>((u128)0x7fffull<<113)){ yi.b[1] |= 1ull<<47;
return yi.f; }
mpfr_t xm, ym;
mpfr_init2(xm, 113);
mpfr_init2(ym, 113);
mpfr_set_float128(xm, x, MPFR_RNDN);
mpfr_set_float128(ym, y, MPFR_RNDN);
int inex = mpfr_atan2(xm, xm, ym, rnd2[rnd]);
mpfr_subnormalize(xm, inex, rnd2[rnd]);
__float128 ret = mpfr_get_float128(xm, MPFR_RNDN);
mpfr_clear(xm);
mpfr_clear(ym);
return ret;
}