Program: 75711
Project: 75711
Buggy source:
/** 
 * Generate code for the modes.
 * @return The modes code.
 */
private String _modeCode(Actor modeContainer) throws IllegalActionException {
  String codeString="String_Node_Str";
  int actorFreq=0;
  int actFreq=0;
  int exitFreq=0;
  String outputName, actorName, modeName;
  Parameter period=((GiottoDirector)modeContainer.getDirector()).period;
  double periodValue=((DoubleToken)period.getToken()).doubleValue() * 1000;
  modeName=StringUtilities.sanitizeName(((NamedObj)modeContainer).getName());
  codeString+="String_Node_Str" + modeName + "String_Node_Str"+ (new Double(periodValue)).intValue()+ "String_Node_Str"+ _endLine;
  _outPorts=_container.outputPortList().iterator();
  while (_outPorts.hasNext()) {
    outputName="String_Node_Str";
    TypedIOPort port=(TypedIOPort)_outPorts.next();
    outputName=StringUtilities.sanitizeName(port.getName(_container));
    if (port.insidePortList().size() != 0) {
      Iterator portConnected=port.insidePortList().iterator();
      while (portConnected.hasNext()) {
        TypedIOPort outPort=(TypedIOPort)portConnected.next();
        if (!outPort.isOutput()) {
          continue;
        }
        Nameable actor=outPort.getContainer();
        if (actor instanceof Actor) {
          Parameter actorFreqPara=(Parameter)((NamedObj)actor).getAttribute("String_Node_Str");
          if (actorFreqPara == null) {
            actorFreq=1;
          }
 else {
            actorFreq=((IntToken)actorFreqPara.getToken()).intValue();
          }
        }
        codeString+="String_Node_Str" + actorFreq + "String_Node_Str"+ outputName+ "String_Node_Str"+ outputName+ "String_Node_Str"+ _endLine;
      }
    }
  }
  Iterator actors=_commActors.iterator();
  while (actors.hasNext()) {
    TypedActor actor=(TypedActor)actors.next();
    actorName=StringUtilities.sanitizeName(((NamedObj)actor).getName(_container));
    Parameter actorFreqPara=(Parameter)((NamedObj)actor).getAttribute("String_Node_Str");
    if (actorFreqPara == null) {
      actorFreq=1;
    }
 else {
      actorFreq=((IntToken)actorFreqPara.getToken()).intValue();
    }
    codeString+="String_Node_Str" + actorFreq + "String_Node_Str"+ actorName+ "String_Node_Str"+ "String_Node_Str"+ actorName+ "String_Node_Str"+ _endLine;
  }
  codeString+="String_Node_Str" + _endLine;
  return codeString;
}

Fixed version (ground truth):
/** 
 * Generate code for the modes.
 * @return The modes code.
 */
private String _modeCode() throws IllegalActionException {
  String codeString="String_Node_Str";
  int actorFreq=0;
  int actFreq=0;
  int exitFreq=0;
  String outputName, actorName, modeName;
  modeName=StringUtilities.sanitizeName(((NamedObj)_container).getName());
  int periodValue=((GiottoDirector)((CompositeActor)_container).getDirector()).getIntPeriod();
  codeString+="String_Node_Str" + modeName + "String_Node_Str"+ periodValue+ "String_Node_Str"+ _endLine;
  _outPorts=_container.outputPortList().iterator();
  while (_outPorts.hasNext()) {
    outputName="String_Node_Str";
    TypedIOPort port=(TypedIOPort)_outPorts.next();
    outputName=StringUtilities.sanitizeName(port.getName(_container));
    if (port.insidePortList().size() != 0) {
      Iterator portConnected=port.insidePortList().iterator();
      while (portConnected.hasNext()) {
        TypedIOPort outPort=(TypedIOPort)portConnected.next();
        if (!outPort.isOutput()) {
          continue;
        }
        Nameable actor=outPort.getContainer();
        if (actor instanceof Actor) {
          Parameter actorFreqPara=(Parameter)((NamedObj)actor).getAttribute("String_Node_Str");
          if (actorFreqPara == null) {
            actorFreq=1;
          }
 else {
            actorFreq=((IntToken)actorFreqPara.getToken()).intValue();
          }
        }
        codeString+="String_Node_Str" + actorFreq + "String_Node_Str"+ outputName+ "String_Node_Str"+ outputName+ "String_Node_Str"+ _endLine;
      }
    }
  }
  Iterator actors=_commActors.iterator();
  while (actors.hasNext()) {
    TypedActor actor=(TypedActor)actors.next();
    actorName=StringUtilities.sanitizeName(((NamedObj)actor).getName(_container));
    Parameter actorFreqPara=(Parameter)((NamedObj)actor).getAttribute("String_Node_Str");
    if (actorFreqPara == null) {
      actorFreq=1;
    }
 else {
      actorFreq=((IntToken)actorFreqPara.getToken()).intValue();
    }
    codeString+="String_Node_Str" + actorFreq + "String_Node_Str"+ actorName+ "String_Node_Str"+ "String_Node_Str"+ actorName+ "String_Node_Str"+ _endLine;
  }
  codeString+="String_Node_Str" + _endLine;
  return codeString;
}