Program: 74686
Project: 74686
Buggy source:
/** 
 * Generate the expression that represents the offsite in the generated code.
 * @param offsetString The specified offset from the user.
 * @param port The referenced port.
 * @param channel The referenced port channel.
 * @param isWrite Whether to generate the write or read offset.
 * @return The expression that represents the offset in the generated code.
 * @exception IllegalActionException If there is problems getting the portbuffer size or the offset in the channel and offset map.
 */
public String generateOffset(String offsetString,IOPort port,int channel,boolean isWrite) throws IllegalActionException {
  if (!(getBufferSize(port) > 1)) {
    return "String_Node_Str";
  }
  String result=null;
  Object offsetObject;
  if (isWrite) {
    offsetObject=getWriteOffset(port,channel);
  }
 else {
    offsetObject=getReadOffset(port,channel);
  }
  if (!offsetString.equals("String_Node_Str")) {
    String temp;
    if (offsetObject instanceof Integer && _isInteger(offsetString)) {
      int offset=((Integer)offsetObject).intValue() + (Integer.valueOf(offsetString)).intValue();
      offset%=getBufferSize(port,channel);
      temp=Integer.toString(offset);
    }
 else {
      int modulo=getBufferSize(port,channel);
      temp="String_Node_Str" + offsetObject.toString() + "String_Node_Str"+ offsetString+ "String_Node_Str"+ modulo;
    }
    result="String_Node_Str" + temp + "String_Node_Str";
  }
 else {
    if (offsetObject instanceof Integer) {
      int offset=((Integer)offsetObject).intValue();
      offset%=getBufferSize(port,channel);
      result=Integer.toString(offset);
    }
 else {
      int modulo=getBufferSize(port,channel) - 1;
      result=offsetObject + "String_Node_Str" + modulo;
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Generate the expression that represents the offsite in the generated code.
 * @param offsetString The specified offset from the user.
 * @param port The referenced port.
 * @param channel The referenced port channel.
 * @param isWrite Whether to generate the write or read offset.
 * @return The expression that represents the offset in the generated code.
 * @exception IllegalActionException If there is problems getting the portbuffer size or the offset in the channel and offset map.
 */
public String generateOffset(String offsetString,IOPort port,int channel,boolean isWrite) throws IllegalActionException {
  if (!(getBufferSize(port) > 1)) {
    return "String_Node_Str";
  }
  String result=null;
  Object offsetObject;
  if (isWrite) {
    offsetObject=getWriteOffset(port,channel);
  }
 else {
    offsetObject=getReadOffset(port,channel);
  }
  if (!offsetString.equals("String_Node_Str")) {
    String temp;
    if (offsetObject instanceof Integer && _isInteger(offsetString)) {
      int offset=((Integer)offsetObject).intValue() + (Integer.valueOf(offsetString)).intValue();
      offset%=getBufferSize(port,channel);
      temp=Integer.toString(offset);
    }
 else {
      int modulo=getBufferSize(port,channel);
      temp="String_Node_Str" + offsetObject.toString() + "String_Node_Str"+ offsetString+ "String_Node_Str"+ modulo;
    }
    result="String_Node_Str" + temp + "String_Node_Str";
  }
 else {
    if (offsetObject instanceof Integer) {
      int offset=((Integer)offsetObject).intValue();
      offset%=getBufferSize(port,channel);
      result="String_Node_Str" + offset + "String_Node_Str";
    }
 else {
      int modulo=getBufferSize(port,channel) - 1;
      result="String_Node_Str" + offsetObject + "String_Node_Str"+ modulo+ "String_Node_Str";
    }
  }
  return result;
}