Program: 174707
Project: 174707
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);
    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(itemNewContentsData.getWorldFlag());
    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);
    }
    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);
  }
}