Program: 73846
Project: 73846
Buggy source:
/** 
 * Generate code for transferring enough tokens to complete an internal iteration.
 * @param inputPort 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 generateTransferInputsCode(IOPort inputPort,StringBuffer code) throws IllegalActionException {
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str")));
  int rate=DFUtilities.getTokenConsumptionRate(inputPort);
  CompositeActor container=(CompositeActor)getComponent().getContainer();
  TypedCompositeActor compositeActorAdapter=(TypedCompositeActor)getCodeGenerator().getAdapter(container);
  if (container instanceof CompiledCompositeActor && ((BooleanToken)getCodeGenerator().generateEmbeddedCode.getToken()).booleanValue()) {
    if (!(inputPort instanceof TypedIOPort)) {
      throw new InternalErrorException(inputPort,null,"String_Node_Str");
    }
    Type type=((TypedIOPort)inputPort).getType();
    String portName=inputPort.getName();
    for (int i=0; i < inputPort.getWidth(); i++) {
      if (i < inputPort.getWidthInside()) {
        String tokensFromOneChannel="String_Node_Str" + portName + i;
        if (type == BaseType.INT) {
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ portName+ "String_Node_Str"+ String.valueOf(i)+ "String_Node_Str"+ _eol);
        }
 else         if (type == BaseType.DOUBLE) {
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ portName+ "String_Node_Str"+ String.valueOf(i)+ "String_Node_Str"+ _eol);
        }
 else         if (type == BaseType.BOOLEAN) {
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ portName+ "String_Node_Str"+ String.valueOf(i)+ "String_Node_Str"+ _eol);
        }
 else {
        }
        String portNameWithChannelNumber=portName;
        if (inputPort.isMultiport()) {
          portNameWithChannelNumber=portName + '#' + i;
        }
        for (int k=0; k < rate; k++) {
          code.append(compositeActorAdapter.getReference("String_Node_Str" + portNameWithChannelNumber + "String_Node_Str"+ k));
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ k+ "String_Node_Str"+ _eol);
        }
      }
    }
  }
 else {
    for (int i=0; i < inputPort.getWidth(); i++) {
      if (i < inputPort.getWidthInside()) {
        String name=inputPort.getName();
        if (inputPort.isMultiport()) {
          name=name + '#' + i;
        }
        for (int k=0; k < rate; k++) {
          code.append(compositeActorAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k));
          code.append("String_Node_Str" + _eol);
          code.append(compositeActorAdapter.getReference(name + "String_Node_Str" + k));
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  code.append(compositeActorAdapter.generateTypeConvertFireCode(true));
  _updateConnectedPortsOffset(inputPort,code,rate);
}

Fixed version (ground truth):
/** 
 * Generate code for transferring enough tokens to complete an internal iteration.
 * @param inputPort 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 generateTransferInputsCode(IOPort inputPort,StringBuffer code) throws IllegalActionException {
  code.append(CodeStream.indent(getCodeGenerator().comment("String_Node_Str" + "String_Node_Str")));
  int rate=DFUtilities.getTokenConsumptionRate(inputPort);
  CompositeActor container=(CompositeActor)getComponent().getContainer();
  TypedCompositeActor compositeActorAdapter=(TypedCompositeActor)getCodeGenerator().getAdapter(container);
  if (container instanceof CompiledCompositeActor && ((BooleanToken)getCodeGenerator().generateEmbeddedCode.getToken()).booleanValue()) {
    if (!(inputPort instanceof TypedIOPort)) {
      throw new InternalErrorException(inputPort,null,"String_Node_Str");
    }
    Type type=((TypedIOPort)inputPort).getType();
    String portName=inputPort.getName();
    for (int i=0; i < inputPort.getWidth(); i++) {
      if (i < inputPort.getWidthInside()) {
        String tokensFromOneChannel="String_Node_Str" + portName + i;
        if (type == BaseType.INT) {
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ portName+ "String_Node_Str"+ String.valueOf(i)+ "String_Node_Str"+ _eol);
        }
 else         if (type == BaseType.DOUBLE) {
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ portName+ "String_Node_Str"+ String.valueOf(i)+ "String_Node_Str"+ _eol);
        }
 else         if (type == BaseType.BOOLEAN) {
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ portName+ "String_Node_Str"+ String.valueOf(i)+ "String_Node_Str"+ _eol);
        }
 else {
        }
        String portNameWithChannelNumber=portName;
        if (inputPort.isMultiport()) {
          portNameWithChannelNumber=portName + '#' + i;
        }
        for (int k=0; k < rate; k++) {
          code.append(compositeActorAdapter.getReference("String_Node_Str" + portNameWithChannelNumber + "String_Node_Str"+ k,false));
          code.append("String_Node_Str" + tokensFromOneChannel + "String_Node_Str"+ k+ "String_Node_Str"+ _eol);
        }
      }
    }
  }
 else {
    for (int i=0; i < inputPort.getWidth(); i++) {
      if (i < inputPort.getWidthInside()) {
        String name=inputPort.getName();
        if (inputPort.isMultiport()) {
          name=name + '#' + i;
        }
        for (int k=0; k < rate; k++) {
          code.append(compositeActorAdapter.getReference("String_Node_Str" + name + "String_Node_Str"+ k,false));
          code.append("String_Node_Str" + _eol);
          code.append(compositeActorAdapter.getReference(name + "String_Node_Str" + k,false));
          code.append("String_Node_Str" + _eol);
        }
      }
    }
  }
  code.append(compositeActorAdapter.generateTypeConvertFireCode(true));
  _updateConnectedPortsOffset(inputPort,code,rate);
}