code: def mpf_ei(x, prec, rnd=round_fast, e1=False):
      if e1:
          x = mpf_neg(x)
      sign, man, exp, bc = x
      if e1 and not sign:
          if x == fzero:
              return finf
          raise ComplexResult("E1(x) for x < 0")
      if man:
          xabs = 0, man, exp, bc
          xmag = exp + bc
          wp = prec + 20
          can_use_asymp = xmag > wp
          if not can_use_asymp:
              if exp >= 0:
                  xabsint = man << exp
              else:
                  xabsint = man >> (-exp)
              can_use_asymp = xabsint > int(wp * 0.693) + 10
          if can_use_asymp:
              if xmag > wp:
                  v = fone
              else:
                  v = from_man_exp(
                      ei_asymptotic(to_fixed(x, wp), wp), -wp
                  )
              v = mpf_mul(v, mpf_exp(x, wp), wp)
              v = mpf_div(v, x, prec, rnd)
          else:
              wp += 2 * int(to_int(xabs))
              u = to_fixed(x, wp)
              v = ei_taylor(u, wp) + euler_fixed(wp)
              t1 = from_man_exp(v, -wp)
              t2 = mpf_log(xabs, wp)
              v = mpf_add(t1, t2, prec, rnd)
      else:
          if x == fzero:
              v = fninf
          elif x == finf:
              v = finf
          elif x == fninf:
              v = fzero
          else:
              v = fnan
      if e1:
          v = mpf_neg(v)
      return v
  
imports: import operator
  import math
  from .backend import MPZ_ZERO, MPZ_ONE, BACKEND, xrange, exec_
  from .libintmath import gcd
  from .libmpf import ComplexResult, round_fast, round_nearest, negative_rnd, bitcount, to_fixed, from_man_exp, from_int, to_int, from_rational, fzero, fone, fnone, ftwo, finf, fninf, fnan, mpf_sign, mpf_add, mpf_abs, mpf_pos, mpf_cmp, mpf_lt, mpf_le, mpf_gt, mpf_min_max, mpf_perturb, mpf_neg, mpf_shift, mpf_sub, mpf_mul, mpf_div, sqrt_fixed, mpf_sqrt, mpf_rdiv_int, mpf_pow_int, to_rational
  from .libelefun import mpf_pi, mpf_exp, mpf_log, pi_fixed, mpf_cos_sin, mpf_cos, mpf_sin, mpf_sqrt, agm_fixed
  from .libmpc import mpc_one, mpc_sub, mpc_mul_mpf, mpc_mul, mpc_neg, complex_int_pow, mpc_div, mpc_add_mpf, mpc_sub_mpf, mpc_log, mpc_add, mpc_pos, mpc_shift, mpc_is_infnan, mpc_zero, mpc_sqrt, mpc_abs, mpc_mpf_div, mpc_square, mpc_exp
  from .libintmath import ifac
  from .gammazeta import mpf_gamma_int, mpf_euler, euler_fixed
label_desc: Use image node_id 9 for calling a global function with example usage: mpf_ei(x, prec, rnd, e1) and returns: v, finf