Program: 174701
Project: 174701
Buggy source:
private static void updateChestContents(GameObject objectToModify,GameObjectId itemLocationData,GameObjectId itemNewContentsData,boolean itemChest){
  WriteByteOperation puzzleFlag=objectToModify.getWriteByteOperations().get(1);
  objectToModify.getWriteByteOperations().clear();
  if (itemChest) {
    boolean nonShrineMap=Settings.isReplaceMapsWithWeights() && itemNewContentsData.getInventoryArg() == 70 && itemNewContentsData.getWorldFlag() != 218;
    if (nonShrineMap) {
      objectToModify.getArgs().set(0,(short)2);
    }
 else {
      objectToModify.getArgs().set(0,(short)(itemNewContentsData.getInventoryArg() + 11));
    }
    objectToModify.getArgs().set(1,(short)1);
    if (Settings.isCoinChestGraphics()) {
      objectToModify.getArgs().set(2,(short)0);
    }
 else {
      objectToModify.getArgs().set(2,(short)1);
    }
    int newChestWorldFlag=nonShrineMap ? nextReplacedItemFlag : itemNewContentsData.getWorldFlag();
    for (    TestByteOperation flagTest : objectToModify.getTestByteOperations()) {
      if (flagTest.getIndex() == itemLocationData.getWorldFlag()) {
        flagTest.setIndex(newChestWorldFlag);
      }
    }
    WriteByteOperation updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(newChestWorldFlag);
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    objectToModify.getWriteByteOperations().add(puzzleFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(newChestWorldFlag);
    if (nonShrineMap) {
      updateFlag.setValue(2);
    }
 else {
      updateFlag.setValue(1);
    }
    objectToModify.getWriteByteOperations().add(updateFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(newChestWorldFlag);
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    if (nonShrineMap) {
      nextReplacedItemFlag+=1;
    }
  }
 else {
    objectToModify.getArgs().set(0,(short)1);
    objectToModify.getArgs().set(1,itemNewContentsData.getInventoryArg());
    objectToModify.getArgs().set(2,(short)0);
    for (    TestByteOperation flagTest : objectToModify.getTestByteOperations()) {
      if (flagTest.getIndex() == itemLocationData.getWorldFlag()) {
        flagTest.setIndex(itemNewContentsData.getWorldFlag());
      }
    }
    WriteByteOperation updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(itemNewContentsData.getWorldFlag());
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    objectToModify.getWriteByteOperations().add(puzzleFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(itemNewContentsData.getWorldFlag());
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ADD_FLAG);
    updateFlag.setIndex(119);
    updateFlag.setValue(1);
    objectToModify.getWriteByteOperations().add(updateFlag);
  }
}

Fixed version (ground truth):
private static void updateChestContents(GameObject objectToModify,GameObjectId itemLocationData,GameObjectId itemNewContentsData,boolean itemChest){
  WriteByteOperation puzzleFlag=objectToModify.getWriteByteOperations().get(1);
  objectToModify.getWriteByteOperations().clear();
  if (itemChest) {
    boolean nonShrineMap=Settings.isReplaceMapsWithWeights() && itemNewContentsData.getInventoryArg() == 70 && itemNewContentsData.getWorldFlag() != 218;
    if (nonShrineMap) {
      objectToModify.getArgs().set(0,(short)2);
    }
 else {
      objectToModify.getArgs().set(0,(short)(itemNewContentsData.getInventoryArg() + 11));
    }
    objectToModify.getArgs().set(1,(short)1);
    if (Settings.isCoinChestGraphics()) {
      objectToModify.getArgs().set(2,(short)0);
    }
 else {
      objectToModify.getArgs().set(2,(short)1);
    }
    Integer newChestWorldFlag;
    if (nonShrineMap) {
      newChestWorldFlag=mapOfWorldFlagToAssignedReplacementFlag.get(itemLocationData.getWorldFlag());
      if (newChestWorldFlag == null) {
        newChestWorldFlag=nextReplacedItemFlag++;
        mapOfWorldFlagToAssignedReplacementFlag.put(itemLocationData.getWorldFlag(),newChestWorldFlag);
      }
    }
 else {
      newChestWorldFlag=itemNewContentsData.getWorldFlag();
    }
    for (    TestByteOperation flagTest : objectToModify.getTestByteOperations()) {
      if (flagTest.getIndex() == itemLocationData.getWorldFlag()) {
        flagTest.setIndex(newChestWorldFlag);
      }
    }
    WriteByteOperation updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(newChestWorldFlag);
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    objectToModify.getWriteByteOperations().add(puzzleFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(newChestWorldFlag);
    if (nonShrineMap) {
      updateFlag.setValue(2);
    }
 else {
      updateFlag.setValue(1);
    }
    objectToModify.getWriteByteOperations().add(updateFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(newChestWorldFlag);
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
  }
 else {
    objectToModify.getArgs().set(0,(short)1);
    objectToModify.getArgs().set(1,itemNewContentsData.getInventoryArg());
    objectToModify.getArgs().set(2,(short)0);
    for (    TestByteOperation flagTest : objectToModify.getTestByteOperations()) {
      if (flagTest.getIndex() == itemLocationData.getWorldFlag()) {
        flagTest.setIndex(itemNewContentsData.getWorldFlag());
      }
    }
    WriteByteOperation updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(itemNewContentsData.getWorldFlag());
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    objectToModify.getWriteByteOperations().add(puzzleFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ASSIGN_FLAG);
    updateFlag.setIndex(itemNewContentsData.getWorldFlag());
    updateFlag.setValue(2);
    objectToModify.getWriteByteOperations().add(updateFlag);
    updateFlag=new WriteByteOperation();
    updateFlag.setOp(ByteOp.ADD_FLAG);
    updateFlag.setIndex(119);
    updateFlag.setValue(1);
    objectToModify.getWriteByteOperations().add(updateFlag);
  }
}