Program: 158108
Project: 158108
Buggy source:
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    ArrayList<Permanent> destroyedPermanents=new ArrayList<>();
    for (    UUID targetId : getTargetPointer().getTargets(game,source)) {
      Permanent target=game.getPermanent(targetId);
      if (target != null) {
        if (target.destroy(source.getSourceId(),game,false)) {
          destroyedPermanents.add(target);
        }
      }
    }
    HashMap<Player,Cards> cardsToReveal=new HashMap<>();
    for (    Permanent permanent : destroyedPermanents) {
      Player controllerOfDestroyedCreature=game.getPlayer(permanent.getControllerId());
      if (controllerOfDestroyedCreature != null) {
        Library library=controllerOfDestroyedCreature.getLibrary();
        if (library.hasCards()) {
          Cards cards=new CardsImpl();
          Cards revealCards;
          if (cardsToReveal.containsKey(controllerOfDestroyedCreature)) {
            revealCards=cardsToReveal.get(controllerOfDestroyedCreature);
          }
 else {
            revealCards=new CardsImpl();
            cardsToReveal.put(controllerOfDestroyedCreature,revealCards);
          }
          Card card=library.removeFromTop(game);
          cards.add(card);
          while (!card.isCreature() && !card.isArtifact() && library.hasCards()) {
            card=library.removeFromTop(game);
            cards.add(card);
          }
          if (card.isCreature() || card.isArtifact()) {
            controllerOfDestroyedCreature.moveCards(card,Zone.BATTLEFIELD,source,game);
          }
          if (!cards.isEmpty()) {
            revealCards.addAll(cards);
            Set<Card> cardsToShuffle=cards.getCards(game);
            cardsToShuffle.remove(card);
            library.addAll(cardsToShuffle,game);
          }
          controllerOfDestroyedCreature.shuffleLibrary(source,game);
        }
      }
    }
    for (    Player player : cardsToReveal.keySet()) {
      player.revealCards(sourceObject.getIdName(),cardsToReveal.get(player),game);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  Player controller=game.getPlayer(source.getControllerId());
  MageObject sourceObject=source.getSourceObject(game);
  if (controller != null && sourceObject != null) {
    ArrayList<Permanent> destroyedPermanents=new ArrayList<>();
    for (    UUID targetId : getTargetPointer().getTargets(game,source)) {
      Permanent target=game.getPermanent(targetId);
      if (target != null) {
        if (target.destroy(source.getSourceId(),game,false)) {
          destroyedPermanents.add(target);
        }
      }
    }
    HashMap<Player,Cards> cardsToReveal=new HashMap<>();
    for (    Permanent permanent : destroyedPermanents) {
      Player controllerOfDestroyedCreature=game.getPlayer(permanent.getControllerId());
      if (controllerOfDestroyedCreature != null) {
        Library library=controllerOfDestroyedCreature.getLibrary();
        if (library.hasCards()) {
          Cards cards=new CardsImpl();
          Cards revealCards;
          if (cardsToReveal.containsKey(controllerOfDestroyedCreature)) {
            revealCards=cardsToReveal.get(controllerOfDestroyedCreature);
          }
 else {
            revealCards=new CardsImpl();
            cardsToReveal.put(controllerOfDestroyedCreature,revealCards);
          }
          Card card=library.removeFromTop(game);
          cards.add(card);
          while (!card.isCreature() && !card.isArtifact() && library.hasCards()) {
            card=library.removeFromTop(game);
            cards.add(card);
          }
          if (!cards.isEmpty()) {
            revealCards.addAll(cards);
            if (card.isCreature() || card.isArtifact()) {
              controllerOfDestroyedCreature.moveCards(card,Zone.EXILED,source,game);
              controllerOfDestroyedCreature.moveCards(card,Zone.BATTLEFIELD,source,game);
            }
            Set<Card> cardsToShuffle=cards.getCards(game);
            cardsToShuffle.remove(card);
            library.addAll(cardsToShuffle,game);
          }
          controllerOfDestroyedCreature.shuffleLibrary(source,game);
        }
      }
    }
    for (    Player player : cardsToReveal.keySet()) {
      player.revealCards(sourceObject.getIdName(),cardsToReveal.get(player),game);
    }
    return true;
  }
  return false;
}