code: def _add_splines(c, b1, d, b2, x):
      """Construct c*b1 + d*b2."""
  
      if S.Zero in (b1, c):
          rv = piecewise_fold(d * b2)
      elif S.Zero in (b2, d):
          rv = piecewise_fold(c * b1)
      else:
          new_args = []
          # Just combining the Piecewise without any fancy optimization
          p1 = piecewise_fold(c * b1)
          p2 = piecewise_fold(d * b2)
  
          # Search all Piecewise arguments except (0, True)
          p2args = list(p2.args[:-1])
  
          # This merging algorithm assumes the conditions in
          # p1 and p2 are sorted
          for arg in p1.args[:-1]:
              expr = arg.expr
              cond = arg.cond
  
              lower = _ivl(cond, x)[0]
  
              # Check p2 for matching conditions that can be merged
              for i, arg2 in enumerate(p2args):
                  expr2 = arg2.expr
                  cond2 = arg2.cond
  
                  lower_2, upper_2 = _ivl(cond2, x)
                  if cond2 == cond:
                      # Conditions match, join expressions
                      expr += expr2
                      # Remove matching element
                      del p2args[i]
                      # No need to check the rest
                      break
                  elif lower_2 < lower and upper_2 <= lower:
                      # Check if arg2 condition smaller than arg1,
                      # add to new_args by itself (no match expected
                      # in p1)
                      new_args.append(arg2)
                      del p2args[i]
                      break
  
              # Checked all, add expr and cond
              new_args.append((expr, cond))
  
          # Add remaining items from p2args
          new_args.extend(p2args)
  
          # Add final (0, True)
          new_args.append((0, True))
  
          rv = Piecewise(*new_args, evaluate=False)
  
      return rv.expand()
  
file_path: sympy/sympy/functions/special/bsplines.py
imports: from sympy.core import S, sympify
  from sympy.core.symbol import Dummy, symbols
  from sympy.functions import Piecewise, piecewise_fold
  from sympy.logic.boolalg import And
  from sympy.sets.sets import Interval
  from functools import lru_cache
label_desc: Use image node_id 2 for calling a global function with example usage: _add_splines(c, b1, d, b2, x) and returns: rv