Program: 135899
Project: 135899
Buggy source:
private static Vector ExplodeWhile(AST.LabeledStmt ast,String next) throws PcalTranslateException {
  Vector result=new Vector();
  AST.While w=(AST.While)ast.stmts.elementAt(0);
  AST.LabeledStmt newast=new AST.LabeledStmt();
  PCalLocation newastBeginLoc=ast.getOrigin().getBegin();
  PCalLocation whileBeginLoc=w.getOrigin().getBegin();
  PCalLocation whileBeginUnlabDoLoc=(w.unlabDo.size() != 0) ? ((AST)w.unlabDo.elementAt(0)).getOrigin().getBegin() : w.test.getOrigin().getEnd();
  PCalLocation whileEndUnlabDoLoc=(w.unlabDo.size() != 0) ? ((AST)w.unlabDo.elementAt(w.unlabDo.size() - 1)).getOrigin().getEnd() : w.test.getOrigin().getEnd();
  PCalLocation whileEndLoc=(w.labDo.size() != 0) ? w.getOrigin().getEnd() : whileEndUnlabDoLoc;
  newast.setOrigin(new Region(newastBeginLoc,whileEndLoc));
  newast.col=ast.col;
  newast.line=ast.line;
  newast.label=ast.label;
  newast.stmts=new Vector();
  if (!ParseAlgorithm.omitPC) {
    newast.stmts.addElement(CheckPC(ast.label));
  }
  AST.LabeledStmt firstLS=(w.labDo.size() == 0) ? null : (AST.LabeledStmt)w.labDo.elementAt(0);
  String unlabDoNext=(firstLS == null) ? ast.label : firstLS.label;
  Vector pair1=CopyAndExplodeLastStmtWithGoto((Vector)w.unlabDo.clone(),unlabDoNext);
  Vector rest=(Vector)ast.stmts.clone();
  rest.remove(0);
  Vector pair2=CopyAndExplodeLastStmtWithGoto(rest,next);
  if (IsTRUE(w.test))   newast.stmts.addAll((Vector)pair1.elementAt(0));
 else {
    AST.If ifS=new AST.If();
    ifS.test=w.test;
    ifS.Then=(Vector)pair1.elementAt(0);
    ifS.Else=(Vector)pair2.elementAt(0);
    ifS.setOrigin(new Region(whileBeginLoc,whileEndLoc));
    newast.stmts.addElement(ifS);
  }
  result.addElement(newast);
  for (int i=0; i < w.labDo.size(); i++) {
    AST.LabeledStmt nextLS=(w.labDo.size() > i + 1) ? (AST.LabeledStmt)w.labDo.elementAt(i + 1) : null;
    String nextLSL=(nextLS == null) ? ast.label : nextLS.label;
    result.addAll(ExplodeLabeledStmt(firstLS,nextLSL));
    firstLS=nextLS;
  }
  result.addAll((Vector)pair1.elementAt(1));
  if (!IsTRUE(w.test))   result.addAll((Vector)pair2.elementAt(1));
  return result;
}

Fixed version (ground truth):
private static Vector ExplodeWhile(AST.LabeledStmt ast,String next) throws PcalTranslateException {
  Vector result=new Vector();
  AST.While w=(AST.While)ast.stmts.elementAt(0);
  AST.LabeledStmt newast=new AST.LabeledStmt();
  PCalLocation newastBeginLoc=ast.getOrigin().getBegin();
  PCalLocation whileBeginLoc=w.getOrigin().getBegin();
  PCalLocation whileBeginUnlabDoLoc=(w.unlabDo.size() != 0) ? ((AST)w.unlabDo.elementAt(0)).getOrigin().getBegin() : w.test.getOrigin().getEnd();
  PCalLocation whileEndUnlabDoLoc=(w.unlabDo.size() != 0) ? ((AST)w.unlabDo.elementAt(w.unlabDo.size() - 1)).getOrigin().getEnd() : w.test.getOrigin().getEnd();
  PCalLocation whileEndLoc=(ast.stmts.size() != 1) ? ast.getOrigin().getEnd() : whileEndUnlabDoLoc;
  newast.setOrigin(new Region(newastBeginLoc,whileEndLoc));
  newast.col=ast.col;
  newast.line=ast.line;
  newast.label=ast.label;
  newast.stmts=new Vector();
  if (!ParseAlgorithm.omitPC) {
    newast.stmts.addElement(CheckPC(ast.label));
  }
  AST.LabeledStmt firstLS=(w.labDo.size() == 0) ? null : (AST.LabeledStmt)w.labDo.elementAt(0);
  String unlabDoNext=(firstLS == null) ? ast.label : firstLS.label;
  Vector pair1=CopyAndExplodeLastStmtWithGoto((Vector)w.unlabDo.clone(),unlabDoNext);
  Vector rest=(Vector)ast.stmts.clone();
  rest.remove(0);
  Vector pair2=CopyAndExplodeLastStmtWithGoto(rest,next);
  if (IsTRUE(w.test))   newast.stmts.addAll((Vector)pair1.elementAt(0));
 else {
    AST.If ifS=new AST.If();
    ifS.test=w.test;
    ifS.Then=(Vector)pair1.elementAt(0);
    ifS.Else=(Vector)pair2.elementAt(0);
    ifS.setOrigin(new Region(whileBeginLoc,whileEndLoc));
    newast.stmts.addElement(ifS);
  }
  result.addElement(newast);
  for (int i=0; i < w.labDo.size(); i++) {
    AST.LabeledStmt nextLS=(w.labDo.size() > i + 1) ? (AST.LabeledStmt)w.labDo.elementAt(i + 1) : null;
    String nextLSL=(nextLS == null) ? ast.label : nextLS.label;
    result.addAll(ExplodeLabeledStmt(firstLS,nextLSL));
    firstLS=nextLS;
  }
  result.addAll((Vector)pair1.elementAt(1));
  if (!IsTRUE(w.test))   result.addAll((Vector)pair2.elementAt(1));
  return result;
}