code: def mpf_atan(x, prec, rnd=round_fast):
      sign, man, exp, bc = x
      if not man:
          if x == fzero:
              return fzero
          if x == finf:
              return atan_inf(0, prec, rnd)
          if x == fninf:
              return atan_inf(1, prec, rnd)
          return fnan
      mag = exp + bc
      # Essentially infinity
      if mag > prec + 20:
          return atan_inf(sign, prec, rnd)
      # Essentially ~ x
      if -mag > prec + 20:
          return mpf_perturb(x, 1 - sign, prec, rnd)
      wp = prec + 30 + abs(mag)
      # For large x, use atan(x) = pi/2 - atan(1/x)
      if mag >= 2:
          x = mpf_rdiv_int(1, x, wp)
          reciprocal = True
      else:
          reciprocal = False
      t = to_fixed(x, wp)
      if sign:
          t = -t
      if wp < ATAN_TAYLOR_PREC:
          a = atan_taylor(t, wp)
      else:
          a = atan_newton(t, wp)
      if reciprocal:
          a = ((pi_fixed(wp) >> 1) + 1) - a
      if sign:
          a = -a
      return from_man_exp(a, -wp, prec, rnd)
  
imports: import math
  from bisect import bisect
  from .backend import xrange
  from .backend import MPZ, MPZ_ZERO, MPZ_ONE, MPZ_TWO, MPZ_FIVE, BACKEND
  from .libmpf import round_floor, round_ceiling, round_down, round_up, round_nearest, round_fast, ComplexResult, bitcount, bctable, lshift, rshift, giant_steps, sqrt_fixed, from_int, to_int, from_man_exp, to_fixed, to_float, from_float, from_rational, normalize, fzero, fone, fnone, fhalf, finf, fninf, fnan, mpf_cmp, mpf_sign, mpf_abs, mpf_pos, mpf_neg, mpf_add, mpf_sub, mpf_mul, mpf_div, mpf_shift, mpf_rdiv_int, mpf_pow_int, mpf_sqrt, reciprocal_rnd, negative_rnd, mpf_perturb, isqrt_fast
  from .libintmath import ifib
label_desc: Use image node_id 32 for calling a global function with example usage: mpf_atan(x, prec, rnd) and returns: from_man_exp, fnan, atan_inf, mpf_perturb, fzero, atan_inf, atan_inf