Program: 76156
Project: 76156
Buggy source:
/** 
 * Add branches corresponding to the channels of the port argument. The port must be contained by the same actor that contains this controller. If branches corresponding to the port have already been added to this controller, then an IllegalActionException will be thrown. If the input/output polarity of this port does not match that of ports for whom branches have been previously added to this controller, then throw an IllegalActionException.
 * @param port The port for which branches will be added to thiscontroller.
 * @exception IllegalActionException If branches for theport have been previously added to this controller or if the port input/output polarity does not match that of ports for whom branches were previously add to this controller.
 */
public void addBranches(IOPort port) throws IllegalActionException {
  if (port.getContainer() != getParent()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (_ports == null) {
    _ports=new LinkedList();
  }
  if (_ports.contains(port)) {
    throw new IllegalActionException(port,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (_hasInputPorts() && !port.isInput()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (_hasOutputPorts() && !port.isOutput()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  _ports.add(port);
  Branch branch=null;
  BoundaryReceiver prodRcvr=null;
  BoundaryReceiver consRcvr=null;
  Receiver[][] prodRcvrs=null;
  Receiver[][] consRcvrs=null;
  for (int i=0; i < port.getWidth(); i++) {
    if (port.isInput()) {
      prodRcvrs=port.getReceivers();
      consRcvrs=port.deepGetReceivers();
    }
 else     if (port.isOutput()) {
      prodRcvrs=port.getReceivers();
      consRcvrs=port.getRemoteReceivers();
    }
 else {
      throw new IllegalActionException("String_Node_Str");
    }
    prodRcvr=(BoundaryReceiver)prodRcvrs[i][0];
    consRcvr=(BoundaryReceiver)consRcvrs[i][0];
    branch=new Branch(prodRcvr,consRcvr,this);
    _branches.add(branch);
  }
}

Fixed version (ground truth):
/** 
 * Add branches corresponding to the channels of the port argument. The port must be contained by the same actor that contains this controller. If branches corresponding to the port have already been added to this controller, then an IllegalActionException will be thrown. If the input/output polarity of this port does not match that of ports for whom branches have been previously added to this controller, then throw an IllegalActionException.
 * @param port The port for which branches will be added to thiscontroller.
 * @exception IllegalActionException If branches for theport have been previously added to this controller or if the port input/output polarity does not match that of ports for whom branches were previously add to this controller.
 */
public void addBranches(IOPort port) throws IllegalActionException {
  if (port.getContainer() != getParent()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (_ports == null) {
    _ports=new LinkedList();
  }
  if (_ports.contains(port)) {
    throw new IllegalActionException(port,"String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (_hasInputPorts() && !port.isInput()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  if (_hasOutputPorts() && !port.isOutput()) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  }
  _ports.add(port);
  Branch branch=null;
  BoundaryReceiver prodRcvr=null;
  BoundaryReceiver consRcvr=null;
  Receiver[][] prodRcvrs=null;
  Receiver[][] consRcvrs=null;
  for (int i=0; i < port.getWidth(); i++) {
    if (port.isInput()) {
      prodRcvrs=port.getReceivers();
      consRcvrs=port.deepGetReceivers();
    }
 else     if (port.isOutput()) {
      prodRcvrs=port.getInsideReceivers();
      consRcvrs=port.getRemoteReceivers();
    }
 else {
      throw new IllegalActionException("String_Node_Str");
    }
    prodRcvr=(BoundaryReceiver)prodRcvrs[i][0];
    consRcvr=(BoundaryReceiver)consRcvrs[i][0];
    branch=new Branch(prodRcvr,consRcvr,this);
    _branches.add(branch);
  }
}