Program: 178181
Project: 178181
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) private void handleMiddleClick(GuiScreen guiScreen){
  if (Mouse.isButtonDown(2)) {
    if (!cfgManager.makeSureConfigurationIsLoaded()) {
      return;
    }
    InvTweaksConfig config=cfgManager.getConfig();
    String ciCompatibility=config.getProperty(InvTweaksConfig.PROP_CONVENIENT_INVENTORY_COMPATIBILITY);
    if (ciCompatibility == null) {
      try {
        Class convenientInventory=Class.forName("String_Node_Str");
        boolean defaultCISortingShortcutEnabled=false;
        Field actionMapField=convenientInventory.getDeclaredField("String_Node_Str");
        actionMapField.setAccessible(true);
        List<Integer> actionMap[][]=(List[][])actionMapField.get(null);
        if (actionMap[7] != null) {
          for (          List<Integer> combo : actionMap[7]) {
            if (combo != null && combo.size() == 1 && combo.get(0) == 2) {
              defaultCISortingShortcutEnabled=true;
              break;
            }
          }
        }
        if (defaultCISortingShortcutEnabled) {
          config.setProperty(InvTweaksConfig.PROP_CONVENIENT_INVENTORY_COMPATIBILITY,"String_Node_Str");
        }
      }
 catch (      ClassNotFoundException e) {
        logInGameError("String_Node_Str",null);
      }
catch (      Exception e) {
        logInGameError("String_Node_Str",e);
      }
    }
    if (!config.getProperty(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK).equals("String_Node_Str") && (ciCompatibility == null || !ciCompatibility.equals("String_Node_Str"))) {
      if (!chestAlgorithmButtonDown) {
        chestAlgorithmButtonDown=true;
        if (isChestOrDispenser(guiScreen)) {
          GuiContainer guiContainer=(GuiContainer)guiScreen;
          Container container=getContainer((GuiContainer)guiScreen);
          int slotCount=getSlots(container).size();
          int mouseX=(Mouse.getEventX() * guiContainer.width) / mc.displayWidth;
          int mouseY=guiContainer.height - (Mouse.getEventY() * guiContainer.height) / mc.displayHeight - 1;
          int target=0;
          for (int i=0; i < slotCount; i++) {
            Slot slot=getSlot(container,i);
            int k=(guiContainer.width - guiContainer.xSize) / 2;
            int l=(guiContainer.height - guiContainer.ySize) / 2;
            if (mouseX - k >= slot.xDisplayPosition - 1 && mouseX - k < slot.xDisplayPosition + 16 + 1 && mouseY - l >= slot.yDisplayPosition - 1 && mouseY - l < slot.yDisplayPosition + 16 + 1) {
              target=(i < slotCount - Const.INVENTORY_SIZE) ? 1 : 2;
              break;
            }
          }
          if (target == 1) {
            mc.theWorld.playSoundAtEntity(getThePlayer(),"String_Node_Str",0.2F,1.8F);
            long timestamp=System.currentTimeMillis();
            if (timestamp - chestAlgorithmClickTimestamp > Const.CHEST_ALGORITHM_SWAP_MAX_INTERVAL) {
              chestAlgorithm=InventoryAlgorithms.DEFAULT;
            }
            try {
              cfgManager.getInventoryAlgorithms().sortContainer(container,false,chestAlgorithm);
            }
 catch (            TimeoutException e) {
              logInGameError("String_Node_Str",e);
            }
            chestAlgorithm=(chestAlgorithm + 1) % 3;
            chestAlgorithmClickTimestamp=timestamp;
          }
 else           if (target == 2) {
            handleSorting(guiScreen);
          }
        }
 else {
          handleSorting(guiScreen);
        }
      }
    }
  }
 else {
    chestAlgorithmButtonDown=false;
  }
}

Fixed version (ground truth):
private void handleMiddleClick(GuiScreen guiScreen){
  if (Mouse.isButtonDown(2)) {
    if (!cfgManager.makeSureConfigurationIsLoaded()) {
      return;
    }
    InvTweaksConfig config=cfgManager.getConfig();
    if (!config.getProperty(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK).equals(InvTweaksConfig.VALUE_TRUE)) {
      if (!chestAlgorithmButtonDown) {
        chestAlgorithmButtonDown=true;
        if (isChestOrDispenser(guiScreen)) {
          GuiContainer guiContainer=(GuiContainer)guiScreen;
          Container container=getContainer((GuiContainer)guiScreen);
          int slotCount=getSlots(container).size();
          int mouseX=(Mouse.getEventX() * guiContainer.width) / mc.displayWidth;
          int mouseY=guiContainer.height - (Mouse.getEventY() * guiContainer.height) / mc.displayHeight - 1;
          int target=0;
          for (int i=0; i < slotCount; i++) {
            Slot slot=getSlot(container,i);
            int k=(guiContainer.width - guiContainer.xSize) / 2;
            int l=(guiContainer.height - guiContainer.ySize) / 2;
            if (mouseX - k >= slot.xDisplayPosition - 1 && mouseX - k < slot.xDisplayPosition + 16 + 1 && mouseY - l >= slot.yDisplayPosition - 1 && mouseY - l < slot.yDisplayPosition + 16 + 1) {
              target=(i < slotCount - Const.INVENTORY_SIZE) ? 1 : 2;
              break;
            }
          }
          if (target == 1) {
            mc.theWorld.playSoundAtEntity(getThePlayer(),"String_Node_Str",0.2F,1.8F);
            long timestamp=System.currentTimeMillis();
            if (timestamp - chestAlgorithmClickTimestamp > Const.CHEST_ALGORITHM_SWAP_MAX_INTERVAL) {
              chestAlgorithm=InventoryAlgorithms.DEFAULT;
            }
            try {
              cfgManager.getInventoryAlgorithms().sortContainer(container,false,chestAlgorithm);
            }
 catch (            TimeoutException e) {
              logInGameError("String_Node_Str",e);
            }
            chestAlgorithm=(chestAlgorithm + 1) % 3;
            chestAlgorithmClickTimestamp=timestamp;
          }
 else           if (target == 2) {
            handleSorting(guiScreen);
          }
        }
 else {
          handleSorting(guiScreen);
        }
      }
    }
  }
 else {
    chestAlgorithmButtonDown=false;
  }
}