Program: 74420
Project: 74420
Buggy source:
public void fire() throws IllegalActionException {
  if (!_isInController()) {
    ERGModalModel modalModel=(ERGModalModel)getContainer();
    List<?> ergControllers=modalModel.entityList(ERGController.class);
    for (    Object controllerObject : ergControllers) {
      ((ERGController)controllerObject).readInputs();
    }
  }
  ERGController controller=getController();
  boolean hasInput=controller.hasInput();
  boolean synchronize=controller.synchronizeToRealtime();
  Time modelTime=getModelTime();
  boolean fired=false;
  if (hasInput && !_inputQueue.isEmpty()) {
    Iterator<TimedEvent> iterator=_inputQueue.iterator();
    while (!fired && iterator.hasNext()) {
      TimedEvent timedEvent=iterator.next();
      if (timedEvent.contents instanceof Event) {
        iterator.remove();
        _eventQueue.remove(timedEvent);
        _fire(timedEvent);
        fired=true;
      }
    }
  }
  if (hasInput && !fired && !_inputQueue.isEmpty()) {
    TimedEvent timedEvent=_inputQueue.poll();
    _eventQueue.remove(timedEvent);
    _fire(timedEvent);
    fired=true;
  }
  if (!fired && !_eventQueue.isEmpty()) {
    TimedEvent timedEvent=_eventQueue.peek();
    Time nextEventTime=timedEvent.timeStamp;
    if (nextEventTime.compareTo(modelTime) <= 0) {
      _eventQueue.poll();
      Object contents=timedEvent.contents;
      if (contents instanceof Actor) {
        _inputQueue.remove(timedEvent);
      }
 else       if (timedEvent.contents instanceof Event && ((Event)contents).fireOnInput()) {
        _inputQueue.remove(timedEvent);
      }
      if (synchronize) {
        if (!_synchronizeToRealtime(nextEventTime)) {
          return;
        }
        synchronize=false;
      }
      _fire(timedEvent);
      fired=true;
    }
  }
}

Fixed version (ground truth):
public void fire() throws IllegalActionException {
  if (!_isInController()) {
    ERGModalModel modalModel=(ERGModalModel)getContainer();
    List<?> ergControllers=modalModel.entityList(ERGController.class);
    for (    Object controllerObject : ergControllers) {
      ((ERGController)controllerObject).readInputs();
    }
  }
  ERGController controller=getController();
  boolean hasInput=controller.hasInput();
  boolean synchronize=controller.synchronizeToRealtime();
  Time modelTime=getModelTime();
  boolean fired=false;
  if (hasInput && !_inputQueue.isEmpty()) {
    Iterator<TimedEvent> iterator=_inputQueue.iterator();
    while (!fired && iterator.hasNext()) {
      TimedEvent timedEvent=iterator.next();
      if (timedEvent.contents instanceof Event) {
        if (_fire(timedEvent)) {
          fired=true;
        }
      }
    }
  }
  if (hasInput && !fired && !_inputQueue.isEmpty()) {
    TimedEvent timedEvent=_inputQueue.peek();
    if (_fire(timedEvent)) {
      fired=true;
    }
  }
  if (!fired && !_eventQueue.isEmpty()) {
    TimedEvent timedEvent=_eventQueue.peek();
    Time nextEventTime=timedEvent.timeStamp;
    if (nextEventTime.compareTo(modelTime) <= 0) {
      _eventQueue.peek();
      if (synchronize) {
        if (!_synchronizeToRealtime(nextEventTime)) {
          return;
        }
        synchronize=false;
      }
      if (_fire(timedEvent)) {
        fired=true;
      }
    }
  }
}