def lcs_analysis(Nb,Ne,Mb,Me,lcs,identical,equivalent,different):
  """This routine is derived from lcs_to_diff. Instead of writing out the
     diff based on the snake list it analyses the snake list and establishes
     whether the reference file and the data file are identical, equivalent,
     or different. 

     In this case the three results mean:
     - identical: there are no differences between the two files at all.
     - equivalent: there are only tolerated differences.
     - different : there are some non-tolerated differences.

     The values for the results are taken from the argument list.
     """
  analysis = identical
  xi1 = Mb-1
  yj1 = Nb-1
  mxtype = 0
  Nsnake = len(lcs)
  Isnake = 0
  itype  = 0
  if Nsnake == 0:
    if Nb <= Ne:
      analysis = different
    else:
      if Mb <= Me:
        analysis = different
      else:
        pass
  else:
    while (Isnake < Nsnake):
      (xi2,yj2,xi3,yj3,itype) = lcs[Isnake]
      Isnake = Isnake + 1
      if itype > mxtype:
        mxtype = itype
    if mxtype == 1:
      # there are only exact matches so identical still is the best possible
      pass
    elif mxtype == 2:
      # there are tolerated differences so equivalent is the best possible
      analysis = equivalent
    elif mxtype == 3:
      # there are non-tolerated differences so different is the best possible
      analysis = different
      return analysis
    Isnake = -1
    while (Isnake < Nsnake):
      Isnake = Isnake + 1
      if (Isnake < Nsnake):
        (xi2,yj2,xi3,yj3,itype) = lcs[Isnake]
      else:
        xi2 = Me+1
        yj2 = Ne+1
        xi3 = Me+1
        yj3 = Ne+1
      if xi1+1 <= xi2 and yj1+1 <= yj2:
        if xi1+1 == xi2:
          if yj1+1 == yj2:
            #
            # This is a continuation of the previous snake (of a different type)
            #
            pass
          else:
            analysis = different
        else:
          analysis = different
      xi1 = xi3
      yj1 = yj3
  return analysis