Program: 73839
Project: 73839
Buggy source:
/** 
 * Generate the initialize code for the associated SDF director.
 * @return The generated initialize code.
 * @exception IllegalActionException If the adapter associated withan actor throws it while generating initialize code for the actor.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generateInitializeCode());
  ptolemy.actor.CompositeActor container=(ptolemy.actor.CompositeActor)getComponent().getContainer();
  NamedProgramCodeGeneratorAdapter containerAdapter=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(container);
  Iterator<?> actors=container.deepEntityList().iterator();
  while (actors.hasNext()) {
    NamedObj actor=(NamedObj)actors.next();
    ProgramCodeGeneratorAdapter actorAdapter=(ProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(actor);
    StringBuffer resetCode=new StringBuffer();
    Iterator<?> inputPorts=((Actor)actorAdapter.getComponent()).inputPortList().iterator();
    while (inputPorts.hasNext()) {
      IOPort port=(IOPort)inputPorts.next();
      resetCode.append(_ports.initializeOffsets(port));
    }
    if (resetCode.length() > 0) {
      resetCode.append(_eol + getCodeGenerator().comment(1,actor.getName() + "String_Node_Str"));
      code.append(resetCode);
    }
  }
  String resetCode=_resetOutputPortsOffset();
  if (resetCode.length() > 0) {
    code.append(_eol + getCodeGenerator().comment(getComponent().getName() + "String_Node_Str"));
    code.append(resetCode);
  }
  Iterator<?> outputPorts=container.outputPortList().iterator();
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    int rate=DFUtilities.getTokenInitProduction(outputPort);
    if (rate > 0) {
      for (int i=0; i < outputPort.getWidthInside(); i++) {
        if (i < outputPort.getWidth()) {
          String name=outputPort.getName();
          if (outputPort.isMultiport()) {
            name=name + '#' + i;
          }
          for (int k=0; k < rate; k++) {
            code.append(containerAdapter.getReference(name + "String_Node_Str" + k));
            code.append("String_Node_Str");
            code.append(containerAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k));
            code.append("String_Node_Str" + _eol);
          }
        }
      }
      _updatePortOffset(outputPort,code,rate);
    }
  }
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate the initialize code for the associated SDF director.
 * @return The generated initialize code.
 * @exception IllegalActionException If the adapter associated withan actor throws it while generating initialize code for the actor.
 */
public String generateInitializeCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generateInitializeCode());
  ptolemy.actor.CompositeActor container=(ptolemy.actor.CompositeActor)getComponent().getContainer();
  NamedProgramCodeGeneratorAdapter containerAdapter=(NamedProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(container);
  Iterator<?> actors=container.deepEntityList().iterator();
  while (actors.hasNext()) {
    NamedObj actor=(NamedObj)actors.next();
    ProgramCodeGeneratorAdapter actorAdapter=(ProgramCodeGeneratorAdapter)getCodeGenerator().getAdapter(actor);
    StringBuffer resetCode=new StringBuffer();
    Iterator<?> inputPorts=((Actor)actorAdapter.getComponent()).inputPortList().iterator();
    while (inputPorts.hasNext()) {
      IOPort port=(IOPort)inputPorts.next();
      resetCode.append(_ports.initializeOffsets(port));
    }
    if (resetCode.length() > 0) {
      resetCode.append(_eol + getCodeGenerator().comment(1,actor.getName() + "String_Node_Str"));
      code.append(resetCode);
    }
  }
  String resetCode=_resetOutputPortsOffset();
  if (resetCode.length() > 0) {
    code.append(_eol + getCodeGenerator().comment(getComponent().getName() + "String_Node_Str"));
    code.append(resetCode);
  }
  Iterator<?> outputPorts=container.outputPortList().iterator();
  while (outputPorts.hasNext()) {
    IOPort outputPort=(IOPort)outputPorts.next();
    int rate=DFUtilities.getTokenInitProduction(outputPort);
    if (rate > 0) {
      for (int i=0; i < outputPort.getWidthInside(); i++) {
        if (i < outputPort.getWidth()) {
          String name=outputPort.getName();
          if (outputPort.isMultiport()) {
            name=name + '#' + i;
          }
          for (int k=0; k < rate; k++) {
            code.append(containerAdapter.getReference(name + "String_Node_Str" + k,true));
            code.append("String_Node_Str");
            code.append(containerAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k,false));
            code.append("String_Node_Str" + _eol);
          }
        }
      }
      _updatePortOffset(outputPort,code,rate);
    }
  }
  return code.toString();
}