Program: 79867
Project: 79867
Buggy source:
@Override public List<EncounterSet> getEncounters(boolean useTimeOfDay){
  List<EncounterSet> encounters=new ArrayList<EncounterSet>();
  Pokemon ghostMarowak=pokes[Gen1Constants.marowakIndex];
  if (canChangeStaticPokemon()) {
    ghostMarowak=pokes[pokeRBYToNumTable[rom[romEntry.ghostMarowakOffsets[0]] & 0xFF]];
  }
  List<Integer> usedOffsets=new ArrayList<Integer>();
  int tableOffset=romEntry.getValue("String_Node_Str");
  int tableBank=bankOf(tableOffset);
  int mapID=-1;
  while (readWord(tableOffset) != Gen1Constants.encounterTableEnd) {
    mapID++;
    int offset=calculateOffset(tableBank,readWord(tableOffset));
    int rootOffset=offset;
    if (!usedOffsets.contains(offset)) {
      usedOffsets.add(offset);
      for (int a=0; a < 2; a++) {
        int rate=rom[offset++] & 0xFF;
        if (rate > 0) {
          EncounterSet thisSet=new EncounterSet();
          thisSet.rate=rate;
          thisSet.offset=rootOffset;
          thisSet.displayName=(a == 1 ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + mapNames[mapID];
          if (mapID >= Gen1Constants.towerMapsStartIndex && mapID <= Gen1Constants.towerMapsEndIndex) {
            thisSet.bannedPokemon.add(ghostMarowak);
          }
          for (int slot=0; slot < Gen1Constants.encounterTableSize; slot++) {
            Encounter enc=new Encounter();
            enc.level=rom[offset] & 0xFF;
            enc.pokemon=pokes[pokeRBYToNumTable[rom[offset + 1] & 0xFF]];
            thisSet.encounters.add(enc);
            offset+=2;
          }
          encounters.add(thisSet);
        }
      }
    }
 else {
      for (      EncounterSet es : encounters) {
        if (es.offset == offset) {
          es.displayName+="String_Node_Str" + mapNames[mapID];
        }
      }
    }
    tableOffset+=2;
  }
  int oldRodOffset=romEntry.getValue("String_Node_Str");
  EncounterSet oldRodSet=new EncounterSet();
  oldRodSet.displayName="String_Node_Str";
  Encounter oldRodEnc=new Encounter();
  oldRodEnc.level=rom[oldRodOffset + 2] & 0xFF;
  oldRodEnc.pokemon=pokes[pokeRBYToNumTable[rom[oldRodOffset + 1] & 0xFF]];
  oldRodSet.encounters.add(oldRodEnc);
  encounters.add(oldRodSet);
  int goodRodOffset=romEntry.getValue("String_Node_Str");
  EncounterSet goodRodSet=new EncounterSet();
  goodRodSet.displayName="String_Node_Str";
  for (int grSlot=0; grSlot < 2; grSlot++) {
    Encounter enc=new Encounter();
    enc.level=rom[goodRodOffset + grSlot * 2] & 0xFF;
    enc.pokemon=pokes[pokeRBYToNumTable[rom[goodRodOffset + grSlot * 2 + 1] & 0xFF]];
    goodRodSet.encounters.add(enc);
  }
  encounters.add(goodRodSet);
  if (romEntry.isYellow) {
    int superRodOffset=romEntry.getValue("String_Node_Str");
    while ((rom[superRodOffset] & 0xFF) != 0xFF) {
      int map=rom[superRodOffset++] & 0xFF;
      EncounterSet thisSet=new EncounterSet();
      thisSet.displayName="String_Node_Str" + mapNames[map];
      for (int encN=0; encN < Gen1Constants.yellowSuperRodTableSize; encN++) {
        Encounter enc=new Encounter();
        enc.level=rom[superRodOffset + 1] & 0xFF;
        enc.pokemon=pokes[pokeRBYToNumTable[rom[superRodOffset] & 0xFF]];
        thisSet.encounters.add(enc);
        superRodOffset+=2;
      }
      encounters.add(thisSet);
    }
  }
 else {
    int superRodOffset=romEntry.getValue("String_Node_Str");
    int superRodBank=bankOf(superRodOffset);
    List<Integer> usedSROffsets=new ArrayList<Integer>();
    while ((rom[superRodOffset] & 0xFF) != 0xFF) {
      int map=rom[superRodOffset++] & 0xFF;
      int setOffset=calculateOffset(superRodBank,readWord(superRodOffset));
      superRodOffset+=2;
      if (!usedSROffsets.contains(setOffset)) {
        usedSROffsets.add(setOffset);
        EncounterSet thisSet=new EncounterSet();
        thisSet.displayName="String_Node_Str" + mapNames[map];
        thisSet.offset=setOffset;
        int pokesInSet=rom[setOffset++] & 0xFF;
        for (int encN=0; encN < pokesInSet; encN++) {
          Encounter enc=new Encounter();
          enc.level=rom[setOffset] & 0xFF;
          enc.pokemon=pokes[pokeRBYToNumTable[rom[setOffset + 1] & 0xFF]];
          thisSet.encounters.add(enc);
          setOffset+=2;
        }
        encounters.add(thisSet);
      }
 else {
        for (        EncounterSet es : encounters) {
          if (es.offset == setOffset) {
            es.displayName+="String_Node_Str" + mapNames[map];
          }
        }
      }
    }
  }
  return encounters;
}

Fixed version (ground truth):
@Override public List<EncounterSet> getEncounters(boolean useTimeOfDay){
  List<EncounterSet> encounters=new ArrayList<EncounterSet>();
  Pokemon ghostMarowak=pokes[Gen1Constants.marowakIndex];
  if (canChangeStaticPokemon()) {
    ghostMarowak=pokes[pokeRBYToNumTable[rom[romEntry.ghostMarowakOffsets[0]] & 0xFF]];
  }
  List<Integer> usedOffsets=new ArrayList<Integer>();
  int tableOffset=romEntry.getValue("String_Node_Str");
  int tableBank=bankOf(tableOffset);
  int mapID=-1;
  while (readWord(tableOffset) != Gen1Constants.encounterTableEnd) {
    mapID++;
    int offset=calculateOffset(tableBank,readWord(tableOffset));
    int rootOffset=offset;
    if (!usedOffsets.contains(offset)) {
      usedOffsets.add(offset);
      for (int a=0; a < 2; a++) {
        int rate=rom[offset++] & 0xFF;
        if (rate > 0) {
          EncounterSet thisSet=new EncounterSet();
          thisSet.rate=rate;
          thisSet.offset=rootOffset;
          thisSet.displayName=(a == 1 ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + mapNames[mapID];
          if (mapID >= Gen1Constants.towerMapsStartIndex && mapID <= Gen1Constants.towerMapsEndIndex) {
            thisSet.bannedPokemon.add(ghostMarowak);
          }
          for (int slot=0; slot < Gen1Constants.encounterTableSize; slot++) {
            Encounter enc=new Encounter();
            enc.level=rom[offset] & 0xFF;
            enc.pokemon=pokes[pokeRBYToNumTable[rom[offset + 1] & 0xFF]];
            thisSet.encounters.add(enc);
            offset+=2;
          }
          encounters.add(thisSet);
        }
      }
    }
 else {
      for (      EncounterSet es : encounters) {
        if (es.offset == offset) {
          es.displayName+="String_Node_Str" + mapNames[mapID];
        }
      }
    }
    tableOffset+=2;
  }
  int oldRodOffset=romEntry.getValue("String_Node_Str");
  EncounterSet oldRodSet=new EncounterSet();
  oldRodSet.displayName="String_Node_Str";
  Encounter oldRodEnc=new Encounter();
  oldRodEnc.level=rom[oldRodOffset + 2] & 0xFF;
  oldRodEnc.pokemon=pokes[pokeRBYToNumTable[rom[oldRodOffset + 1] & 0xFF]];
  oldRodSet.encounters.add(oldRodEnc);
  oldRodSet.bannedPokemon.add(ghostMarowak);
  encounters.add(oldRodSet);
  int goodRodOffset=romEntry.getValue("String_Node_Str");
  EncounterSet goodRodSet=new EncounterSet();
  goodRodSet.displayName="String_Node_Str";
  for (int grSlot=0; grSlot < 2; grSlot++) {
    Encounter enc=new Encounter();
    enc.level=rom[goodRodOffset + grSlot * 2] & 0xFF;
    enc.pokemon=pokes[pokeRBYToNumTable[rom[goodRodOffset + grSlot * 2 + 1] & 0xFF]];
    goodRodSet.encounters.add(enc);
  }
  goodRodSet.bannedPokemon.add(ghostMarowak);
  encounters.add(goodRodSet);
  if (romEntry.isYellow) {
    int superRodOffset=romEntry.getValue("String_Node_Str");
    while ((rom[superRodOffset] & 0xFF) != 0xFF) {
      int map=rom[superRodOffset++] & 0xFF;
      EncounterSet thisSet=new EncounterSet();
      thisSet.displayName="String_Node_Str" + mapNames[map];
      for (int encN=0; encN < Gen1Constants.yellowSuperRodTableSize; encN++) {
        Encounter enc=new Encounter();
        enc.level=rom[superRodOffset + 1] & 0xFF;
        enc.pokemon=pokes[pokeRBYToNumTable[rom[superRodOffset] & 0xFF]];
        thisSet.encounters.add(enc);
        superRodOffset+=2;
      }
      thisSet.bannedPokemon.add(ghostMarowak);
      encounters.add(thisSet);
    }
  }
 else {
    int superRodOffset=romEntry.getValue("String_Node_Str");
    int superRodBank=bankOf(superRodOffset);
    List<Integer> usedSROffsets=new ArrayList<Integer>();
    while ((rom[superRodOffset] & 0xFF) != 0xFF) {
      int map=rom[superRodOffset++] & 0xFF;
      int setOffset=calculateOffset(superRodBank,readWord(superRodOffset));
      superRodOffset+=2;
      if (!usedSROffsets.contains(setOffset)) {
        usedSROffsets.add(setOffset);
        EncounterSet thisSet=new EncounterSet();
        thisSet.displayName="String_Node_Str" + mapNames[map];
        thisSet.offset=setOffset;
        int pokesInSet=rom[setOffset++] & 0xFF;
        for (int encN=0; encN < pokesInSet; encN++) {
          Encounter enc=new Encounter();
          enc.level=rom[setOffset] & 0xFF;
          enc.pokemon=pokes[pokeRBYToNumTable[rom[setOffset + 1] & 0xFF]];
          thisSet.encounters.add(enc);
          setOffset+=2;
        }
        thisSet.bannedPokemon.add(ghostMarowak);
        encounters.add(thisSet);
      }
 else {
        for (        EncounterSet es : encounters) {
          if (es.offset == setOffset) {
            es.displayName+="String_Node_Str" + mapNames[map];
          }
        }
      }
    }
  }
  return encounters;
}