Program: 10568
Project: 10568
Buggy source:
public LookAheadDfa createAfa(AtnState atnStartState){
  LookAheadDfa ret=new LookAheadDfa();
  Deque<DfaState> work=new ArrayDeque<DfaState>();
  DfaState D0=new DfaState();
  for (int alt=0; alt < atnStartState.getTransitionCount(); alt++) {
    ret.addDummyFinalState(alt);
  }
  List<Pair<Object,AtnState>> transitions=atnStartState.getTransitionsAsPairs();
  for (int i=0; i < transitions.size(); i++) {
    AtnState pa_i=transitions.get(i).getRight();
    Predicate pi=null;
    Object first_t=pa_i.getTransitions().entrySet().iterator().next().getKey();
    if (first_t instanceof Predicate)     pi=(Predicate)first_t;
    D0.addAllConfs(closure(D0,new AtnConfig(pa_i,extractAltFromAltState(pa_i),new CallStack(),pi)));
    D0.releaseBusy();
  }
  work.push(D0);
  ret.addState(D0);
  while (!work.isEmpty()) {
    DfaState state=work.pop();
    Set<TokenType> newTrans=new HashSet<TokenType>();
    int newWorkCount=0;
    Set<DfaState> newStates=new HashSet<DfaState>();
    moving:     for (    TokenType a : state.getAllTerminalEdgesOfContainingAtnStates()) {
      DfaState newState=new DfaState();
      for (      AtnConfig conf : state.move(a)) {
        newState.addAllConfs(closure(state,conf));
        state.releaseBusy();
        resolveOverflow(state);
        checkIfFinalAndReplace(state,ret);
        if (state.isStopTransit())         break moving;
      }
      if (!ret.containState(newState)) {
        resolveConflicts(newState);
        if (!checkIfFinalAndReplace(newState,ret)) {
          work.push(newState);
          newWorkCount++;
        }
        ret.addState(newState);
        newStates.add(newState);
        state.addTransition(a,newState);
        newTrans.add(a);
      }
 else {
        state.addTransition(a,ret.getSameState(newState));
        newTrans.add(a);
      }
    }
    if (state.isStopTransit()) {
      ret.removeStates(newStates);
      state.removeTransitions(newTrans);
      for (int i=0; i < newWorkCount; i++) {
        work.pop();
      }
    }
    Set<Pair<Predicate,DfaState>> predTrans=new HashSet<Pair<Predicate,DfaState>>();
    for (    AtnConfig conf : state.getResolvedConfs()) {
      predTrans.add(new Pair<Predicate,DfaState>(conf.getPred(),ret.getFinalStateOfAlt(conf.getAlt())));
    }
    for (    Pair<Predicate,DfaState> p : predTrans) {
      state.addTransition(p.getLeft(),p.getRight());
    }
  }
  return ret;
}

Fixed version (ground truth):
public LookAheadDfa createAfa(AtnState atnStartState){
  LookAheadDfa ret=new LookAheadDfa();
  Deque<DfaState> work=new ArrayDeque<DfaState>();
  DfaState D0=new DfaState();
  for (int alt=0; alt < atnStartState.getTransitionCount(); alt++) {
    ret.addDummyFinalState(alt);
  }
  List<Pair<Object,AtnState>> transitions=atnStartState.getTransitionsAsPairs();
  for (int i=0; i < transitions.size(); i++) {
    AtnState pa_i=transitions.get(i).getRight();
    Predicate pi=null;
    Object first_t=pa_i.getTransitions().entrySet().iterator().next().getKey();
    if (first_t instanceof Predicate)     pi=(Predicate)first_t;
    D0.addAllConfs(closure(D0,new AtnConfig(pa_i,extractAltFromAltState(pa_i),new CallStack(),pi)));
    D0.releaseBusy();
  }
  work.push(D0);
  ret.addState(D0);
  while (!work.isEmpty()) {
    DfaState state=work.pop();
    Set<TokenType> newTrans=new HashSet<TokenType>();
    int newWorkCount=0;
    Set<DfaState> newStates=new HashSet<DfaState>();
    Map<Integer,DfaState> finalsBack=new HashMap<Integer,DfaState>();
    moving:     for (    TokenType a : state.getAllTerminalEdgesOfContainingAtnStates()) {
      DfaState newState=new DfaState();
      for (      AtnConfig conf : state.move(a)) {
        newState.addAllConfs(closure(state,conf));
        state.releaseBusy();
        resolveOverflow(state);
        checkIfFinalAndReplace(state,ret,finalsBack,false);
        if (state.isStopTransit())         break moving;
      }
      if (!ret.containState(newState)) {
        resolveConflicts(newState);
        if (!checkIfFinalAndReplace(newState,ret,finalsBack,true)) {
          work.push(newState);
          newWorkCount++;
        }
        ret.addState(newState);
        newStates.add(newState);
        state.addTransition(a,newState);
        newTrans.add(a);
      }
 else {
        state.addTransition(a,ret.getSameState(newState));
        newTrans.add(a);
      }
    }
    if (state.isStopTransit()) {
      ret.removeStates(newStates);
      state.removeTransitions(newTrans);
      for (      Map.Entry<Integer,DfaState> e : finalsBack.entrySet()) {
        DfaState s=e.getValue();
        ret.addState(s);
        ret.overrideFinalState(e.getKey(),s);
      }
      for (int i=0; i < newWorkCount; i++) {
        work.pop();
      }
    }
    Set<Pair<Predicate,DfaState>> predTrans=new HashSet<Pair<Predicate,DfaState>>();
    for (    AtnConfig conf : state.getResolvedConfs()) {
      predTrans.add(new Pair<Predicate,DfaState>(conf.getPred(),ret.getFinalStateOfAlt(conf.getAlt())));
    }
    for (    Pair<Predicate,DfaState> p : predTrans) {
      state.addTransition(p.getLeft(),p.getRight());
    }
  }
  return ret;
}