code: def mpi_cos_sin(x, prec):
      a, b = x
      if a == b == fzero:
          return (fone, fone), (fzero, fzero)
      # Guaranteed to contain both -1 and 1
      if (finf in x) or (fninf in x):
          return (fnone, fone), (fnone, fone)
      wp = prec + 20
      ca, sa, na = cos_sin_quadrant(a, wp)
      cb, sb, nb = cos_sin_quadrant(b, wp)
      ca, cb = mpf_min_max([ca, cb])
      sa, sb = mpf_min_max([sa, sb])
      # Both functions are monotonic within one quadrant
      if na == nb:
          pass
      # Guaranteed to contain both -1 and 1
      elif nb - na >= 4:
          return (fnone, fone), (fnone, fone)
      else:
          # cos has maximum between a and b
          if na // 4 != nb // 4:
              cb = fone
          # cos has minimum
          if (na - 2) // 4 != (nb - 2) // 4:
              ca = fnone
          # sin has maximum
          if (na - 1) // 4 != (nb - 1) // 4:
              sb = fone
          # sin has minimum
          if (na - 3) // 4 != (nb - 3) // 4:
              sa = fnone
      # Perturb to force interval rounding
      more = from_man_exp((MPZ_ONE << wp) + (MPZ_ONE << 10), -wp)
      less = from_man_exp((MPZ_ONE << wp) - (MPZ_ONE << 10), -wp)
  
      def finalize(v, rounding):
          if bool(v[0]) == (rounding == round_floor):
              p = more
          else:
              p = less
          v = mpf_mul(v, p, prec, rounding)
          sign, man, exp, bc = v
          if exp + bc >= 1:
              if sign:
                  return fnone
              return fone
          return v
  
      ca = finalize(ca, round_floor)
      cb = finalize(cb, round_ceiling)
      sa = finalize(sa, round_floor)
      sb = finalize(sb, round_ceiling)
      return (ca, cb), (sa, sb)
  
imports: from .backend import xrange
  from .libmpf import ComplexResult, round_down, round_up, round_floor, round_ceiling, round_nearest, prec_to_dps, repr_dps, dps_to_prec, bitcount, from_float, fnan, finf, fninf, fzero, fhalf, fone, fnone, mpf_sign, mpf_lt, mpf_le, mpf_gt, mpf_ge, mpf_eq, mpf_cmp, mpf_min_max, mpf_floor, from_int, to_int, to_str, from_str, mpf_abs, mpf_neg, mpf_pos, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_shift, mpf_pow_int, from_man_exp, MPZ_ONE
  from .libelefun import mpf_log, mpf_exp, mpf_sqrt, mpf_atan, mpf_atan2, mpf_pi, mod_pi2, mpf_cos_sin
  from .gammazeta import mpf_gamma, mpf_rgamma, mpf_loggamma, mpc_loggamma
label_desc: Use image node_id 30 for calling a global function with example usage: mpi_cos_sin(x, prec) and returns: ca,  cb,  sa,  sb, fone,  fone,  fzero,  fzero, fnone,  fone,  fnone,  fone, v, fnone,  fone,  fnone,  fone, fone, fnone