Program: 158889
Project: 158889
Buggy source:
/** 
 * @param damageAmount
 * @param sourceId
 * @param game
 * @param preventable
 * @param combat
 * @param markDamage   If true, damage will be dealt later in applyDamage method
 * @return
 */
private int damage(int damageAmount,UUID sourceId,Game game,boolean preventable,boolean combat,boolean markDamage,ArrayList<UUID> appliedEffects){
  int damageDone=0;
  if (damageAmount > 0 && canDamage(game.getObject(sourceId),game)) {
    if (cardType.contains(CardType.PLANESWALKER)) {
      damageDone=damagePlaneswalker(damageAmount,sourceId,game,preventable,combat,markDamage,appliedEffects);
    }
 else {
      damageDone=damageCreature(damageAmount,sourceId,game,preventable,combat,markDamage,appliedEffects);
    }
    if (damageDone > 0) {
      UUID sourceControllerId=null;
      Abilities sourceAbilities=null;
      MageObject source=game.getPermanentOrLKIBattlefield(sourceId);
      if (source == null) {
        StackObject stackObject=game.getStack().getStackObject(sourceId);
        if (stackObject != null) {
          source=stackObject.getStackAbility().getSourceObject(game);
        }
 else {
          source=game.getObject(sourceId);
        }
        if (source instanceof Spell) {
          sourceAbilities=((Spell)source).getAbilities(game);
          sourceControllerId=((Spell)source).getControllerId();
        }
 else         if (source instanceof Card) {
          sourceAbilities=((Card)source).getAbilities(game);
          sourceControllerId=((Card)source).getOwnerId();
        }
 else         if (source instanceof CommandObject) {
          sourceControllerId=((CommandObject)source).getControllerId();
          sourceAbilities=((CommandObject)source).getAbilities();
        }
 else {
          source=null;
        }
      }
 else {
        sourceAbilities=((Permanent)source).getAbilities(game);
        sourceControllerId=((Permanent)source).getControllerId();
      }
      if (source != null && sourceAbilities != null) {
        if (sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) {
          Player player=game.getPlayer(sourceControllerId);
          player.gainLife(damageAmount,game);
        }
        if (sourceAbilities.containsKey(DeathtouchAbility.getInstance().getId())) {
          deathtouched=true;
        }
        if (dealtDamageByThisTurn == null) {
          dealtDamageByThisTurn=new HashSet<>();
        }
        dealtDamageByThisTurn.add(new MageObjectReference(source,game));
      }
    }
  }
  return damageDone;
}

Fixed version (ground truth):
/** 
 * @param damageAmount
 * @param sourceId
 * @param game
 * @param preventable
 * @param combat
 * @param markDamage If true, damage will be dealt later in applyDamagemethod
 * @return
 */
private int damage(int damageAmount,UUID sourceId,Game game,boolean preventable,boolean combat,boolean markDamage,ArrayList<UUID> appliedEffects){
  int damageDone=0;
  if (damageAmount > 0 && canDamage(game.getObject(sourceId),game)) {
    if (cardType.contains(CardType.PLANESWALKER)) {
      damageDone=damagePlaneswalker(damageAmount,sourceId,game,preventable,combat,markDamage,appliedEffects);
    }
 else {
      damageDone=damageCreature(damageAmount,sourceId,game,preventable,combat,markDamage,appliedEffects);
    }
    if (damageDone > 0) {
      UUID sourceControllerId=null;
      Abilities sourceAbilities=null;
      MageObject source=game.getPermanentOrLKIBattlefield(sourceId);
      if (source == null) {
        StackObject stackObject=game.getStack().getStackObject(sourceId);
        if (stackObject != null) {
          source=stackObject.getStackAbility().getSourceObject(game);
        }
 else {
          source=game.getObject(sourceId);
        }
        if (source instanceof Spell) {
          sourceAbilities=((Spell)source).getAbilities(game);
          sourceControllerId=((Spell)source).getControllerId();
        }
 else         if (source instanceof Card) {
          sourceAbilities=((Card)source).getAbilities(game);
          sourceControllerId=((Card)source).getOwnerId();
        }
 else         if (source instanceof CommandObject) {
          sourceControllerId=((CommandObject)source).getControllerId();
          sourceAbilities=((CommandObject)source).getAbilities();
        }
 else {
          source=null;
        }
      }
 else {
        sourceAbilities=((Permanent)source).getAbilities(game);
        sourceControllerId=((Permanent)source).getControllerId();
      }
      if (source != null && sourceAbilities != null) {
        if (sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) {
          Player player=game.getPlayer(sourceControllerId);
          player.gainLife(damageAmount,game);
        }
        if (sourceAbilities.containsKey(DeathtouchAbility.getInstance().getId())) {
          deathtouched=true;
        }
        if (dealtDamageByThisTurn == null) {
          dealtDamageByThisTurn=new HashSet<>();
        }
        dealtDamageByThisTurn.add(new MageObjectReference(source,game));
      }
    }
  }
  return damageDone;
}