code: def discrete_log(n, a, b, order=None, prime_order=None):
      """
      Compute the discrete logarithm of ``a`` to the base ``b`` modulo ``n``.
  
      This is a recursive function to reduce the discrete logarithm problem in
      cyclic groups of composite order to the problem in cyclic groups of prime
      order.
  
      It employs different algorithms depending on the problem (subgroup order
      size, prime order or not):
  
          * Trial multiplication
          * Baby-step giant-step
          * Pollard's Rho
          * Pohlig-Hellman
  
      Examples
      ========
  
      >>> from sympy.ntheory import discrete_log
      >>> discrete_log(41, 15, 7)
      3
  
      References
      ==========
  
      .. [1] https://mathworld.wolfram.com/DiscreteLogarithm.html
      .. [2] "Handbook of applied cryptography", Menezes, A. J., Van, O. P. C., &
          Vanstone, S. A. (1997).
  
      """
      n, a, b = as_int(n), as_int(a), as_int(b)
      if order is None:
          order = n_order(b, n)
  
      if prime_order is None:
          prime_order = isprime(order)
  
      if order < 1000:
          return _discrete_log_trial_mul(n, a, b, order)
      elif prime_order:
          if order < 1000000000000:
              return _discrete_log_shanks_steps(n, a, b, order)
          return _discrete_log_pollard_rho(n, a, b, order)
  
      return _discrete_log_pohlig_hellman(n, a, b, order)
  
imports: from __future__ import annotations
  from sympy.external.gmpy import gcd, lcm, invert, sqrt, legendre, jacobi, kronecker, bit_scan1, remove
  from sympy.polys import Poly
  from sympy.polys.domains import ZZ
  from sympy.polys.galoistools import gf_crt1, gf_crt2, linear_congruence, gf_csolve
  from .primetest import isprime
  from .factor_ import factorint, _perfect_power
  from .modular import crt
  from sympy.utilities.decorator import deprecated
  from sympy.utilities.memoization import recurrence_memo
  from sympy.utilities.misc import as_int
  from sympy.utilities.iterables import iproduct
  from sympy.core.random import _randint, randint
  from itertools import product
label_desc: Use image node_id 27 for calling a global function with example usage: discrete_log(n, a, b, order, prime_order) and returns: _discrete_log_pohlig_hellman, _discrete_log_trial_mul, _discrete_log_pollard_rho, _discrete_log_shanks_steps