code: def real_stirling_series(x, prec):
      """
      Sums the rational part of Stirling's expansion,
  
      log(sqrt(2*pi)) - z + 1/(12*z) - 1/(360*z^3) + ...
  
      """
      t = (MPZ_ONE << (prec + prec)) // x  # t = 1/x
      u = (t * t) >> prec  # u = 1/x**2
      s = ln_sqrt2pi_fixed(prec) - x
      # Add initial terms of Stirling's series
      s += t // 12
      t = (t * u) >> prec
      s -= t // 360
      t = (t * u) >> prec
      s += t // 1260
      t = (t * u) >> prec
      s -= t // 1680
      t = (t * u) >> prec
      if not t:
          return s
      s += t // 1188
      t = (t * u) >> prec
      s -= 691 * t // 360360
      t = (t * u) >> prec
      s += t // 156
      t = (t * u) >> prec
      if not t:
          return s
      s -= 3617 * t // 122400
      t = (t * u) >> prec
      s += 43867 * t // 244188
      t = (t * u) >> prec
      s -= 174611 * t // 125400
      t = (t * u) >> prec
      if not t:
          return s
      k = 22
      # From here on, the coefficients are growing, so we
      # have to keep t at a roughly constant size
      usize = bitcount(abs(u))
      tsize = bitcount(abs(t))
      texp = 0
      while 1:
          p, q, pb, qb = stirling_coefficient(k)
          term_mag = tsize + pb + texp
          shift = -texp
          m = pb - term_mag
          if m > 0 and shift < m:
              p >>= m
              shift -= m
          m = tsize - term_mag
          if m > 0 and shift < m:
              w = t >> m
              shift -= m
          else:
              w = t
          term = (t * p // q) >> shift
          if not term:
              break
          s += term
          t = (t * u) >> usize
          texp -= prec - usize
          k += 2
      return s
  
imports: import math
  import sys
  from .backend import xrange
  from .backend import MPZ, MPZ_ZERO, MPZ_ONE, MPZ_THREE, gmpy
  from .libintmath import list_primes, ifac, ifac2, moebius
  from .libmpf import round_floor, round_ceiling, round_down, round_up, round_nearest, round_fast, lshift, sqrt_fixed, isqrt_fast, fzero, fone, fnone, fhalf, ftwo, finf, fninf, fnan, from_int, to_int, to_fixed, from_man_exp, from_rational, mpf_pos, mpf_neg, mpf_abs, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_sqrt, mpf_pow_int, mpf_rdiv_int, mpf_perturb, mpf_le, mpf_lt, mpf_gt, mpf_shift, negative_rnd, reciprocal_rnd, bitcount, to_float, mpf_floor, mpf_sign, ComplexResult
  from .libelefun import constant_memo, def_mpf_constant, mpf_pi, pi_fixed, ln2_fixed, log_int_fixed, mpf_ln2, mpf_exp, mpf_log, mpf_pow, mpf_cosh, mpf_cos_sin, mpf_cosh_sinh, mpf_cos_sin_pi, mpf_cos_pi, mpf_sin_pi, ln_sqrt2pi_fixed, mpf_ln_sqrt2pi, sqrtpi_fixed, mpf_sqrtpi, cos_sin_fixed, exp_fixed
  from .libmpc import mpc_zero, mpc_one, mpc_half, mpc_two, mpc_abs, mpc_shift, mpc_pos, mpc_neg, mpc_add, mpc_sub, mpc_mul, mpc_div, mpc_add_mpf, mpc_mul_mpf, mpc_div_mpf, mpc_mpf_div, mpc_mul_int, mpc_pow_int, mpc_log, mpc_exp, mpc_pow, mpc_cos_pi, mpc_sin_pi, mpc_reciprocal, mpc_square, mpc_sub_mpf
label_desc: Use image node_id 32 for calling a global function with example usage: real_stirling_series(x, prec) and returns: s, s, s, s