Program: 135925
Project: 135925
Buggy source:
/** 
 */
private void GenAssign(AST.Assign ast,Changed c,String context,String prefix,int col) throws PcalTLAGenException {
  Changed cThis=new Changed(c);
  StringBuffer sb=new StringBuffer();
  Vector vlines=new Vector();
  ast.ass=SortSass(ast.ass);
  int i=0;
  int numAssigns=0;
  while (i < ast.ass.size()) {
    int iFirst=i;
    AST.SingleAssign sF=(AST.SingleAssign)ast.ass.elementAt(i);
    int iLast=i;
    AST.SingleAssign sL=(AST.SingleAssign)ast.ass.elementAt(i);
    while (iLast < ast.ass.size() && sF.lhs.var.equals(sL.lhs.var)) {
      iLast=iLast + 1;
      if (iLast < ast.ass.size())       sL=(AST.SingleAssign)ast.ass.elementAt(iLast);
    }
    iLast=iLast - 1;
    if (cThis.Set(sF.lhs.var) > 1 || (iLast - iFirst > 0 && EmptyExpr(sF.lhs.sub)))     throw new PcalTLAGenException("String_Node_Str" + sF.lhs.var,ast);
    numAssigns=numAssigns + 1;
    Vector lines=new Vector();
    if (iFirst == iLast) {
      AST.SingleAssign sass=sF;
      TLAExpr sub=AddSubscriptsToExpr(sass.lhs.sub,SubExpr(Self(context)),c);
      TLAExpr rhs=AddSubscriptsToExpr(sass.rhs,SubExpr(Self(context)),c);
      if (mp && (sass.lhs.var.equals("String_Node_Str") || IsProcedureVar(sass.lhs.var) || IsProcessSetVar(sass.lhs.var)|| sass.lhs.var.equals("String_Node_Str"))) {
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        int wrapCol=sb.length() + 2;
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        if (sb.length() + prefix.length() > ssWrapColumn) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(wrapCol));
        }
        sb.append("String_Node_Str");
        sb.append(self);
        sb.append("String_Node_Str");
        int here=sb.length();
        Vector sv=sub.toStringVector();
        if (sv.size() > 0) {
          sb.append((String)sv.elementAt(0));
          for (int v=1; v < sv.size(); v++) {
            lines.addElement(sb.toString());
            sb=new StringBuffer(NSpaces(here));
            sb.append((String)sv.elementAt(v));
          }
        }
        sb.append("String_Node_Str");
        here=sb.length();
        sv=rhs.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append("String_Node_Str");
        lines.addElement(sb.toString());
        sb=new StringBuffer();
      }
 else       if (!EmptyExpr(sass.lhs.sub)) {
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        int here=sb.length();
        Vector sv=sub.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append("String_Node_Str");
        here=sb.length();
        sv=rhs.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append("String_Node_Str");
        lines.addElement(sb.toString());
        sb=new StringBuffer();
      }
 else {
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        int here=sb.length();
        Vector sv=Parenthesize(rhs.toStringVector());
        for (int v=0; v < sv.size(); v++) {
          sb.append((String)sv.elementAt(v));
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
        }
        sb=new StringBuffer();
      }
    }
 else {
      AST.SingleAssign sass=sF;
      sb.append(sass.lhs.var);
      sb.append("String_Node_Str");
      sb.append(sass.lhs.var);
      sb.append("String_Node_Str");
      int cc=sb.length();
      boolean subscript=(mp && (IsProcedureVar(sass.lhs.var) || IsProcessSetVar(sass.lhs.var)));
      while (iFirst <= iLast) {
        sass=(AST.SingleAssign)ast.ass.elementAt(iFirst);
        TLAExpr sub=AddSubscriptsToExpr(sass.lhs.sub,SubExpr(Self(context)),c);
        TLAExpr rhs=AddSubscriptsToExpr(sass.rhs,SubExpr(Self(context)),c);
        sb.append("String_Node_Str");
        int here=sb.length();
        if (subscript)         sb.append("String_Node_Str" + Self(context) + "String_Node_Str");
        Vector sv=sub.toStringVector();
        if (sv.size() > 0) {
          sb.append((String)sv.elementAt(0));
          for (int v=1; v < sv.size(); v++) {
            lines.addElement(sb.toString());
            sb=new StringBuffer(NSpaces(here));
            sb.append((String)sv.elementAt(v));
          }
        }
        sb.append("String_Node_Str");
        here=sb.length();
        sv=rhs.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append(((iFirst == iLast) ? "String_Node_Str" : "String_Node_Str"));
        lines.addElement(sb.toString());
        sb=new StringBuffer();
        if (iFirst < iLast)         AddSpaces(sb,cc);
        iFirst=iFirst + 1;
      }
    }
    vlines.addElement(lines);
    i=iLast + 1;
  }
  c.Merge(cThis);
  sb=new StringBuffer(prefix);
  col=sb.length();
  if (numAssigns > 1)   sb.append("String_Node_Str");
  if (vlines.size() > 0) {
    for (int v1=0; v1 < vlines.size(); v1++) {
      Vector vl=(Vector)vlines.elementAt(v1);
      for (int v2=0; v2 < vl.size(); v2++) {
        sb.append((String)vl.elementAt(v2));
        tlacode.addElement(sb.toString());
        sb=new StringBuffer(NSpaces(col));
        if ((v1 > 0 || numAssigns > 1) && (v2 != vl.size() - 1))         sb.append("String_Node_Str");
      }
      sb.append("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * @param ast
 * @param c
 * @param context
 * @param prefix
 * @param col
 * @throws PcalTLAGenException
 */
private void GenAssign(AST.Assign ast,Changed c,String context,String prefix,int col) throws PcalTLAGenException {
  Changed cThis=new Changed(c);
  StringBuffer sb=new StringBuffer();
  Vector vlines=new Vector();
  ast.ass=SortSass(ast.ass);
  int i=0;
  int numAssigns=0;
  while (i < ast.ass.size()) {
    int iFirst=i;
    AST.SingleAssign sF=(AST.SingleAssign)ast.ass.elementAt(i);
    int iLast=i;
    AST.SingleAssign sL=(AST.SingleAssign)ast.ass.elementAt(i);
    while (iLast < ast.ass.size() && sF.lhs.var.equals(sL.lhs.var)) {
      iLast=iLast + 1;
      if (iLast < ast.ass.size())       sL=(AST.SingleAssign)ast.ass.elementAt(iLast);
    }
    iLast=iLast - 1;
    if (cThis.Set(sF.lhs.var) > 1 || (iLast - iFirst > 0 && EmptyExpr(sF.lhs.sub)))     throw new PcalTLAGenException("String_Node_Str" + sF.lhs.var,ast);
    numAssigns=numAssigns + 1;
    Vector lines=new Vector();
    if (iFirst == iLast) {
      AST.SingleAssign sass=sF;
      TLAExpr sub=AddSubscriptsToExpr(sass.lhs.sub,SubExpr(Self(context)),c);
      TLAExpr rhs=AddSubscriptsToExpr(sass.rhs,SubExpr(Self(context)),c);
      if (mp && (sass.lhs.var.equals("String_Node_Str") || IsProcedureVar(sass.lhs.var) || IsProcessSetVar(sass.lhs.var)|| sass.lhs.var.equals("String_Node_Str"))) {
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        int wrapCol=sb.length() + 2;
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        if (sb.length() + prefix.length() > ssWrapColumn) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(wrapCol));
        }
        sb.append("String_Node_Str");
        sb.append(self);
        sb.append("String_Node_Str");
        int here=sb.length();
        Vector sv=sub.toStringVector();
        if (sv.size() > 0) {
          sb.append((String)sv.elementAt(0));
          for (int v=1; v < sv.size(); v++) {
            lines.addElement(sb.toString());
            sb=new StringBuffer(NSpaces(here));
            sb.append((String)sv.elementAt(v));
          }
        }
        sb.append("String_Node_Str");
        here=sb.length();
        sv=rhs.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append("String_Node_Str");
        lines.addElement(sb.toString());
        sb=new StringBuffer();
      }
 else       if (!EmptyExpr(sass.lhs.sub)) {
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        int here=sb.length();
        Vector sv=sub.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append("String_Node_Str");
        here=sb.length();
        sv=rhs.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append("String_Node_Str");
        lines.addElement(sb.toString());
        sb=new StringBuffer();
      }
 else {
        sb.append(sass.lhs.var);
        sb.append("String_Node_Str");
        int here=sb.length();
        Vector sv=Parenthesize(rhs.toStringVector());
        for (int v=0; v < sv.size(); v++) {
          sb.append((String)sv.elementAt(v));
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
        }
        sb=new StringBuffer();
      }
    }
 else {
      AST.SingleAssign sass=sF;
      sb.append(sass.lhs.var);
      sb.append("String_Node_Str");
      sb.append(sass.lhs.var);
      sb.append("String_Node_Str");
      int cc=sb.length();
      boolean subscript=(mp && (IsProcedureVar(sass.lhs.var) || IsProcessSetVar(sass.lhs.var)));
      while (iFirst <= iLast) {
        sass=(AST.SingleAssign)ast.ass.elementAt(iFirst);
        TLAExpr sub=AddSubscriptsToExpr(sass.lhs.sub,SubExpr(Self(context)),c);
        TLAExpr rhs=AddSubscriptsToExpr(sass.rhs,SubExpr(Self(context)),c);
        sb.append("String_Node_Str");
        if (subscript) {
          sb.append("String_Node_Str" + Self(context) + "String_Node_Str");
        }
        int here=sb.length();
        Vector sv=sub.toStringVector();
        if (sv.size() > 0) {
          sb.append((String)sv.elementAt(0));
          for (int v=1; v < sv.size(); v++) {
            lines.addElement(sb.toString());
            sb=new StringBuffer(NSpaces(here));
            sb.append((String)sv.elementAt(v));
          }
        }
        sb.append("String_Node_Str");
        here=sb.length();
        sv=rhs.toStringVector();
        sb.append((String)sv.elementAt(0));
        for (int v=1; v < sv.size(); v++) {
          lines.addElement(sb.toString());
          sb=new StringBuffer(NSpaces(here));
          sb.append((String)sv.elementAt(v));
        }
        sb.append(((iFirst == iLast) ? "String_Node_Str" : "String_Node_Str"));
        lines.addElement(sb.toString());
        sb=new StringBuffer();
        if (iFirst < iLast)         AddSpaces(sb,cc);
        iFirst=iFirst + 1;
      }
    }
    vlines.addElement(lines);
    i=iLast + 1;
  }
  c.Merge(cThis);
  sb=new StringBuffer(prefix);
  col=sb.length();
  if (numAssigns > 1)   sb.append("String_Node_Str");
  if (vlines.size() > 0) {
    for (int v1=0; v1 < vlines.size(); v1++) {
      Vector vl=(Vector)vlines.elementAt(v1);
      for (int v2=0; v2 < vl.size(); v2++) {
        sb.append((String)vl.elementAt(v2));
        tlacode.addElement(sb.toString());
        sb=new StringBuffer(NSpaces(col));
        if ((v1 > 0 || numAssigns > 1) && (v2 != vl.size() - 1))         sb.append("String_Node_Str");
      }
      sb.append("String_Node_Str");
    }
  }
}