Program: 74472
Project: 74472
Buggy source:
/** 
 * Return a StringBuffer that contains the converted .smv format of the system. Note that in this version we use modular approach instead of direct dependency checking detection. Modular approach would generate  a bigger state space. Also the current algorithm enables us to deal with hierarchical systems.
 * @param model The system under analysis.
 * @param pattern The temporal formula used to be attached in the .smv file.
 * @param choice The type of the formula. It may be either a CTL or LTLformula.
 * @param span A constant used to expand the size of the rough domain.
 * @return The converted .smv format of the system.
 * @throws IllegalActionException
 * @throws NameDuplicationException
 */
public static StringBuffer advancedGenerateSMVDescription(CompositeActor model,String pattern,String choice,String span) throws IllegalActionException, NameDuplicationException {
  _globalSignalDistributionInfo=new HashMap<String,ArrayList<String>>();
  _globalSignalRetrivalInfo=new HashMap<String,HashSet<String>>();
  _globalSignalNestedRetrivalInfo=new HashMap<String,HashSet<String>>();
  _variableInfo=new HashMap<String,VariableInfo>();
  StringBuffer returnSMVFormat=new StringBuffer("String_Node_Str");
  _advancedSystemSignalPreScan(model,span);
  for (Iterator actors=(((CompositeActor)model).entityList()).iterator(); actors.hasNext(); ) {
    Entity innerEntity=(Entity)actors.next();
    if (innerEntity instanceof FSMActor) {
      returnSMVFormat.append(_translateSingleFSMActor((FSMActor)innerEntity,span,false,"String_Node_Str","String_Node_Str"));
    }
 else     if (innerEntity instanceof ModalModel) {
      ArrayList<StringBuffer> subSystemDescription=_generateSMVFormatModalModelWithRefinement((ModalModel)innerEntity,span,"String_Node_Str");
      for (int i=0; i < subSystemDescription.size(); i++) {
        returnSMVFormat.append(subSystemDescription.get(i));
      }
    }
  }
  StringBuffer mainModuleDescription=new StringBuffer("String_Node_Str");
  mainModuleDescription.append("String_Node_Str");
  mainModuleDescription.append("String_Node_Str");
  for (Iterator actors=(((CompositeActor)model).entityList()).iterator(); actors.hasNext(); ) {
    Entity innerEntity=(Entity)actors.next();
    if ((innerEntity instanceof FSMActor) || (innerEntity instanceof ModalModel)) {
      mainModuleDescription.append("String_Node_Str" + innerEntity.getName() + "String_Node_Str"+ innerEntity.getName()+ "String_Node_Str");
      ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerEntity.getName());
      if (signalInfo != null) {
        for (int i=0; i < signalInfo.size(); i++) {
          String signalName=signalInfo.get(i);
          boolean contain=false;
          String location="String_Node_Str";
          Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
          while (it.hasNext()) {
            String place=it.next();
            if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
              location=place;
              contain=true;
              break;
            }
          }
          if (contain == true) {
            if (i == signalInfo.size() - 1) {
              mainModuleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
            }
 else {
              mainModuleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
            }
          }
 else {
            if (i == signalInfo.size() - 1) {
              mainModuleDescription.append("String_Node_Str");
            }
 else {
              mainModuleDescription.append("String_Node_Str");
            }
          }
        }
      }
      mainModuleDescription.append("String_Node_Str");
    }
  }
  if (choice.equalsIgnoreCase("String_Node_Str")) {
    mainModuleDescription.append("String_Node_Str");
    mainModuleDescription.append("String_Node_Str" + pattern + "String_Node_Str");
  }
 else   if (choice.equalsIgnoreCase("String_Node_Str")) {
    mainModuleDescription.append("String_Node_Str");
    mainModuleDescription.append("String_Node_Str" + pattern + "String_Node_Str");
  }
  returnSMVFormat.append(mainModuleDescription);
  return returnSMVFormat;
}

Fixed version (ground truth):
/** 
 * Return a StringBuffer that contains the converted .smv format of the system. Note that in this version we use modular approach instead of direct dependency checking detection. Modular approach would generate  a bigger state space. Also the current algorithm enables us to deal with hierarchical systems.
 * @param model The system under analysis.
 * @param pattern The temporal formula used to be attached in the .smv file.
 * @param choice The type of the formula. It may be either a CTL or LTLformula.
 * @param span A constant used to expand the size of the rough domain.
 * @return The converted .smv format of the system.
 * @throws IllegalActionException
 * @throws NameDuplicationException
 */
public static StringBuffer advancedGenerateSMVDescription(CompositeActor model,String pattern,String choice,String span) throws IllegalActionException, NameDuplicationException {
  _globalSignalDistributionInfo=new HashMap<String,ArrayList<String>>();
  _globalSignalRetrivalInfo=new HashMap<String,HashSet<String>>();
  _globalSignalNestedRetrivalInfo=new HashMap<String,HashSet<String>>();
  _variableInfo=new HashMap<String,VariableInfo>();
  StringBuffer returnSMVFormat=new StringBuffer("String_Node_Str");
  _advancedSystemSignalPreScan(model,span);
  for (Iterator actors=(((CompositeActor)model).entityList()).iterator(); actors.hasNext(); ) {
    Entity innerEntity=(Entity)actors.next();
    if (innerEntity instanceof FSMActor) {
      returnSMVFormat.append(_translateSingleFSMActor((FSMActor)innerEntity,span,false,"String_Node_Str","String_Node_Str"));
    }
 else     if (innerEntity instanceof ModalModel) {
      ArrayList<StringBuffer> subSystemDescription=_generateSMVFormatModalModelWithRefinement((ModalModel)innerEntity,span,"String_Node_Str");
      for (int i=0; i < subSystemDescription.size(); i++) {
        returnSMVFormat.append(subSystemDescription.get(i));
      }
    }
  }
  StringBuffer mainModuleDescription=new StringBuffer("String_Node_Str");
  mainModuleDescription.append("String_Node_Str");
  mainModuleDescription.append("String_Node_Str");
  for (Iterator actors=(((CompositeActor)model).entityList()).iterator(); actors.hasNext(); ) {
    Entity innerEntity=(Entity)actors.next();
    if ((innerEntity instanceof FSMActor) || (innerEntity instanceof ModalModel)) {
      mainModuleDescription.append("String_Node_Str" + innerEntity.getName() + "String_Node_Str"+ innerEntity.getName()+ "String_Node_Str");
      ArrayList<String> signalInfo=_globalSignalDistributionInfo.get(innerEntity.getName());
      if (signalInfo != null) {
        for (int i=0; i < signalInfo.size(); i++) {
          String signalName=signalInfo.get(i);
          boolean contain=false;
          String location="String_Node_Str";
          Iterator<String> it=_globalSignalRetrivalInfo.keySet().iterator();
          while (it.hasNext()) {
            String place=it.next();
            if (_globalSignalRetrivalInfo.get(place) != null) {
              if (_globalSignalRetrivalInfo.get(place).contains(signalName)) {
                location=place;
                contain=true;
                break;
              }
            }
          }
          if (contain == true) {
            if (i == signalInfo.size() - 1) {
              mainModuleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
            }
 else {
              mainModuleDescription.append(location.trim() + "String_Node_Str" + signalName+ "String_Node_Str");
            }
          }
 else {
            if (i == signalInfo.size() - 1) {
              mainModuleDescription.append("String_Node_Str");
            }
 else {
              mainModuleDescription.append("String_Node_Str");
            }
          }
        }
      }
      mainModuleDescription.append("String_Node_Str");
    }
  }
  if (choice.equalsIgnoreCase("String_Node_Str")) {
    mainModuleDescription.append("String_Node_Str");
    mainModuleDescription.append("String_Node_Str" + pattern + "String_Node_Str");
  }
 else   if (choice.equalsIgnoreCase("String_Node_Str")) {
    mainModuleDescription.append("String_Node_Str");
    mainModuleDescription.append("String_Node_Str" + pattern + "String_Node_Str");
  }
  returnSMVFormat.append(mainModuleDescription);
  return returnSMVFormat;
}