Program: 73836
Project: 73836
Buggy source:
/** 
 * Generate code for transferring enough tokens to fulfill the output production rate.
 * @param outputPort The port to transfer tokens.
 * @param code The string buffer that the generated code is appended to.
 * @exception IllegalActionException If thrown while transferring tokens.
 */
public void generateTransferOutputsCode(IOPort outputPort,StringBuffer code) throws IllegalActionException {
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str")));
  int rate=DFUtilities.getTokenProductionRate(outputPort);
  CompositeActor container=(CompositeActor)getComponent().getContainer();
  TypedCompositeActor compositeActorAdapter=(TypedCompositeActor)getCodeGenerator().getAdapter(container);
  if ((container instanceof CompiledCompositeActor && ((BooleanToken)getCodeGenerator().generateEmbeddedCode.getToken()).booleanValue()) || (container instanceof CompositeActor)) {
    ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.IOPort portAdapter=(ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.IOPort)getAdapter(outputPort);
    String offset="String_Node_Str";
    for (int i=0; i < outputPort.getWidth(); i++) {
      StringBuffer outputCode=new StringBuffer();
      outputCode.append(NamedProgramCodeGeneratorAdapter.generateName(outputPort));
      if (outputPort.isMultiport()) {
        outputCode.append("String_Node_Str" + Integer.toString(i) + "String_Node_Str");
      }
      int bufferSize=_ports.getBufferSize(outputPort);
      if (bufferSize > 1) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      }
      code.append(portAdapter.generatePutCode(Integer.toString(i),offset,outputCode.toString()));
    }
  }
 else {
    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(CodeStream.indent(compositeActorAdapter.getReference(name + "String_Node_Str" + k)));
          code.append("String_Node_Str" + _eol);
          code.append(CodeStream.indent(compositeActorAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k)));
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  _updatePortOffset(outputPort,code,rate);
}

Fixed version (ground truth):
/** 
 * Generate code for transferring enough tokens to fulfill the output production rate.
 * @param outputPort The port to transfer tokens.
 * @param code The string buffer that the generated code is appended to.
 * @exception IllegalActionException If thrown while transferring tokens.
 */
public void generateTransferOutputsCode(IOPort outputPort,StringBuffer code) throws IllegalActionException {
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str")));
  int rate=DFUtilities.getTokenProductionRate(outputPort);
  CompositeActor container=(CompositeActor)getComponent().getContainer();
  TypedCompositeActor compositeActorAdapter=(TypedCompositeActor)getCodeGenerator().getAdapter(container);
  if ((container instanceof CompiledCompositeActor && ((BooleanToken)getCodeGenerator().generateEmbeddedCode.getToken()).booleanValue()) || (container instanceof CompositeActor)) {
    ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.IOPort portAdapter=(ptolemy.cg.adapter.generic.program.procedural.adapters.ptolemy.actor.IOPort)getAdapter(outputPort);
    String offset="String_Node_Str";
    for (int i=0; i < outputPort.getWidth(); i++) {
      StringBuffer outputCode=new StringBuffer();
      outputCode.append(NamedProgramCodeGeneratorAdapter.generateName(outputPort));
      if (outputPort.isMultiport()) {
        outputCode.append("String_Node_Str" + Integer.toString(i) + "String_Node_Str");
      }
      int bufferSize=_ports.getBufferSize(outputPort);
      if (bufferSize > 1) {
        throw new InternalErrorException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
      }
      code.append(portAdapter.generatePutCode(Integer.toString(i),offset,outputCode.toString()));
    }
  }
 else {
    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(CodeStream.indent(compositeActorAdapter.getReference(name + "String_Node_Str" + k,false)));
          code.append("String_Node_Str" + _eol);
          code.append(CodeStream.indent(compositeActorAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k,false)));
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  _updatePortOffset(outputPort,code,rate);
}