Program: 73281
Project: 73281
Buggy source:
/** 
 * Generate fire code. The method generates code that loops through each input [multi-ports] and combines (add or subtract) them.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.MultiplyDivide actor=(ptolemy.actor.lib.MultiplyDivide)getComponent();
  String outputType=getCodeGenerator().codeGenType(actor.output.getType());
  String multiplyType=getCodeGenerator().codeGenType(actor.multiply.getType());
  String divideType=getCodeGenerator().codeGenType(actor.divide.getType());
  boolean divideOnly=!actor.multiply.isOutsideConnected();
  ArrayList<String> args=new ArrayList<String>();
  ArrayList<String> initArgs=new ArrayList<String>();
  if (divideOnly) {
    initArgs.add(divideType);
  }
 else {
    initArgs.add(multiplyType);
    initArgs.add(outputType);
  }
  CodeStream codeStream=getTemplateParser().getCodeStream();
  codeStream.appendCodeBlock(divideOnly ? "String_Node_Str" : "String_Node_Str",initArgs);
  args.add("String_Node_Str");
  args.add(outputType);
  args.add(multiplyType);
  for (int i=1; i < actor.multiply.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  for (int i=divideOnly ? 1 : 0; i < actor.divide.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    args.set(2,divideType);
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  codeStream.appendCodeBlock("String_Node_Str");
  return processCode(codeStream.toString());
}

Fixed version (ground truth):
/** 
 * Generate fire code. The method generates code that loops through each input [multi-ports] and combines (add or subtract) them.
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
protected String _generateFireCode() throws IllegalActionException {
  super._generateFireCode();
  ptolemy.actor.lib.MultiplyDivide actor=(ptolemy.actor.lib.MultiplyDivide)getComponent();
  String outputType=getCodeGenerator().codeGenType(actor.output.getType());
  String multiplyType=getCodeGenerator().codeGenType(actor.multiply.getType());
  String divideType=getCodeGenerator().codeGenType(actor.divide.getType());
  boolean divideOnly=!actor.multiply.isOutsideConnected();
  ArrayList<String> args=new ArrayList<String>();
  ArrayList<String> initArgs=new ArrayList<String>();
  CodeStream codeStream=getTemplateParser().getCodeStream();
  codeStream.appendCodeBlock(divideOnly ? "String_Node_Str" : "String_Node_Str",initArgs);
  args.add("String_Node_Str");
  args.add(outputType);
  args.add(multiplyType);
  for (int i=1; i < actor.multiply.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  for (int i=divideOnly ? 1 : 0; i < actor.divide.getWidth(); i++) {
    args.set(0,Integer.toString(i));
    args.set(2,divideType);
    codeStream.appendCodeBlock("String_Node_Str",args);
  }
  codeStream.appendCodeBlock("String_Node_Str");
  return processCode(codeStream.toString());
}