Program: 158419
Project: 158419
Buggy source:
@Override public boolean apply(Game game,Ability source){
  UUID targetId;
  if (getTargetPointer() instanceof FixedTarget) {
    targetId=((FixedTarget)getTargetPointer()).getTarget();
  }
 else {
    targetId=getTargetPointer().getFirst(game,source);
  }
  Permanent permanent=game.getPermanentOrLKIBattlefield(targetId);
  Card copyFrom;
  ApplyToPermanent applier=new EmptyApplyToPermanent();
  if (permanent != null) {
    Permanent copyFromPermanent=permanent;
    for (    Effect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
      if (effect instanceof CopyEffect) {
        CopyEffect copyEffect=(CopyEffect)effect;
        if (copyEffect.getSourceId().equals(permanent.getId())) {
          MageObject object=((CopyEffect)effect).getTarget();
          if (object instanceof Permanent) {
            copyFromPermanent=(Permanent)object;
            if (copyEffect.getApplier() != null) {
              applier=copyEffect.getApplier();
            }
          }
        }
      }
    }
    copyFrom=copyFromPermanent;
  }
 else {
    copyFrom=game.getCard(getTargetPointer().getFirst(game,source));
  }
  if (permanent == null && copyFrom == null) {
    return false;
  }
  EmptyToken token=new EmptyToken();
  CardUtil.copyTo(token).from(copyFrom);
  applier.apply(game,token);
  if (additionalCardType != null && !token.getCardType().contains(additionalCardType)) {
    token.getCardType().add(additionalCardType);
  }
  if (gainsHaste) {
    token.addAbility(HasteAbility.getInstance());
  }
  if (gainsFlying) {
    token.addAbility(FlyingAbility.getInstance());
  }
  if (tokenPower != Integer.MIN_VALUE) {
    token.setPower(tokenPower);
  }
  if (tokenToughness != Integer.MIN_VALUE) {
    token.setToughness(tokenToughness);
  }
  if (additionalSubType != null && !token.getSubtype(game).contains(additionalSubType)) {
    token.getSubtype(game).add(additionalSubType);
  }
  token.putOntoBattlefield(number,game,source.getSourceId(),playerId == null ? source.getControllerId() : playerId,tapped,attacking,attackedPlayer);
  for (  UUID tokenId : token.getLastAddedTokenIds()) {
    Permanent tokenPermanent=game.getPermanent(tokenId);
    if (tokenPermanent != null) {
      addedTokenPermanents.add(tokenPermanent);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean apply(Game game,Ability source){
  UUID targetId;
  if (getTargetPointer() instanceof FixedTarget) {
    targetId=((FixedTarget)getTargetPointer()).getTarget();
  }
 else {
    targetId=getTargetPointer().getFirst(game,source);
  }
  Permanent permanent=game.getPermanentOrLKIBattlefield(targetId);
  Card copyFrom;
  ApplyToPermanent applier=new EmptyApplyToPermanent();
  if (permanent != null) {
    Permanent copyFromPermanent=permanent;
    for (    Effect effect : game.getState().getContinuousEffects().getLayeredEffects(game)) {
      if (effect instanceof CopyEffect) {
        CopyEffect copyEffect=(CopyEffect)effect;
        if (copyEffect.getSourceId().equals(permanent.getId())) {
          MageObject object=((CopyEffect)effect).getTarget();
          if (object instanceof Permanent) {
            copyFromPermanent=(Permanent)object;
            if (copyEffect.getApplier() != null) {
              applier=copyEffect.getApplier();
            }
          }
        }
      }
    }
    copyFrom=copyFromPermanent;
  }
 else {
    copyFrom=game.getCard(getTargetPointer().getFirst(game,source));
  }
  if (permanent == null && copyFrom == null) {
    return false;
  }
  EmptyToken token=new EmptyToken();
  CardUtil.copyTo(token).from(copyFrom);
  applier.apply(game,token);
  if (additionalCardType != null && !token.getCardType().contains(additionalCardType)) {
    token.getCardType().add(additionalCardType);
  }
  if (gainsHaste) {
    token.addAbility(HasteAbility.getInstance());
  }
  if (gainsFlying) {
    token.addAbility(FlyingAbility.getInstance());
  }
  if (tokenPower != Integer.MIN_VALUE) {
    token.getPower().modifyBaseValue(tokenPower);
  }
  if (tokenToughness != Integer.MIN_VALUE) {
    token.getToughness().modifyBaseValue(tokenToughness);
  }
  if (additionalSubType != null && !token.getSubtype(game).contains(additionalSubType)) {
    token.getSubtype(game).add(additionalSubType);
  }
  token.putOntoBattlefield(number,game,source.getSourceId(),playerId == null ? source.getControllerId() : playerId,tapped,attacking,attackedPlayer);
  for (  UUID tokenId : token.getLastAddedTokenIds()) {
    Permanent tokenPermanent=game.getPermanent(tokenId);
    if (tokenPermanent != null) {
      addedTokenPermanents.add(tokenPermanent);
    }
  }
  return true;
}