Program: 22605
Project: 22605
Buggy source:
@Override protected Iterator<BindingHDTId> makeNextStage(final BindingHDTId input){
  numSearches++;
  if (var[0] != null) {
    HDTId id=input.get(var[0]);
    if (id != null) {
      patternID.setSubject(NodeDictionary.translate(dictionary,id,TripleComponentRole.SUBJECT));
    }
  }
  if (var[1] != null) {
    HDTId id=input.get(var[1]);
    if (id != null) {
      patternID.setPredicate(NodeDictionary.translate(dictionary,id,TripleComponentRole.PREDICATE));
    }
  }
  if (var[2] != null) {
    HDTId id=input.get(var[2]);
    if (id != null) {
      patternID.setObject(NodeDictionary.translate(dictionary,id,TripleComponentRole.OBJECT));
    }
  }
  if (patternID.getSubject() == -1 || patternID.getPredicate() == -1 || patternID.getObject() == -1) {
    return Iter.nullIter();
  }
  IteratorTripleID iterTripleIDSearch=triples.search(patternID);
  Iter<TripleID> it=Iter.iter(iterTripleIDSearch);
  if (varIsSO[0] || varIsSO[2]) {
    it=it.filter(new Predicate<TripleID>(){
      @Override public boolean test(      TripleID t){
        if (varIsSO[0] && t.getSubject() > numSharedSO) {
          return false;
        }
        if (varIsSO[2] && t.getObject() > numSharedSO) {
          return false;
        }
        return true;
      }
    }
);
  }
  Function<TripleID,BindingHDTId> binder=new Function<TripleID,BindingHDTId>(){
    @Override public BindingHDTId apply(    TripleID triple){
      BindingHDTId output=new BindingHDTId(input);
      if (var[0] != null && !insert(var[0],new HDTId(triple.getSubject(),TripleComponentRole.SUBJECT,dictionary),output)) {
        return null;
      }
      if (var[1] != null && !insert(var[1],new HDTId(triple.getPredicate(),TripleComponentRole.PREDICATE,dictionary),output)) {
        return null;
      }
      if (var[2] != null && !insert(var[2],new HDTId(triple.getObject(),TripleComponentRole.OBJECT,dictionary),output)) {
        return null;
      }
      return output;
    }
  }
;
  return it.map(binder).removeNulls();
}

Fixed version (ground truth):
@Override protected Iterator<BindingHDTId> makeNextStage(final BindingHDTId input){
  numSearches++;
  if (var[0] != null) {
    HDTId id=input.get(var[0]);
    if (id != null) {
      patternID.setSubject(NodeDictionary.translate(dictionary,id,TripleComponentRole.SUBJECT));
    }
  }
  if (var[1] != null) {
    HDTId id=input.get(var[1]);
    if (id != null) {
      patternID.setPredicate(NodeDictionary.translate(dictionary,id,TripleComponentRole.PREDICATE));
    }
  }
  if (var[2] != null) {
    HDTId id=input.get(var[2]);
    if (id != null) {
      patternID.setObject(NodeDictionary.translate(dictionary,id,TripleComponentRole.OBJECT));
    }
  }
  if (patternID.isNoMatch()) {
    return Iter.nullIter();
  }
  IteratorTripleID iterTripleIDSearch=triples.search(patternID);
  Iter<TripleID> it=Iter.iter(iterTripleIDSearch);
  if (varIsSO[0] || varIsSO[2]) {
    it=it.filter(new Predicate<TripleID>(){
      @Override public boolean test(      TripleID t){
        if (varIsSO[0] && t.getSubject() > numSharedSO) {
          return false;
        }
        if (varIsSO[2] && t.getObject() > numSharedSO) {
          return false;
        }
        return true;
      }
    }
);
  }
  Function<TripleID,BindingHDTId> binder=new Function<TripleID,BindingHDTId>(){
    @Override public BindingHDTId apply(    TripleID triple){
      BindingHDTId output=new BindingHDTId(input);
      if (var[0] != null && !insert(var[0],new HDTId(triple.getSubject(),TripleComponentRole.SUBJECT,dictionary),output)) {
        return null;
      }
      if (var[1] != null && !insert(var[1],new HDTId(triple.getPredicate(),TripleComponentRole.PREDICATE,dictionary),output)) {
        return null;
      }
      if (var[2] != null && !insert(var[2],new HDTId(triple.getObject(),TripleComponentRole.OBJECT,dictionary),output)) {
        return null;
      }
      return output;
    }
  }
;
  return it.map(binder).removeNulls();
}