Program: 178149
Project: 178149
Buggy source:
private void handleGUILayout(apm guiScreen){
  InvTweaksConfig config=cfgManager.getConfig();
  boolean isValidChest=isValidChest(guiScreen);
  if (isValidChest || (isStandardInventory(guiScreen) && !isGuiEnchantmentTable(guiScreen))) {
    aqg guiContainer=asGuiContainer(guiScreen);
    int w=10, h=10;
    boolean customButtonsAdded=false;
    List<Object> controlList=getControlList(guiScreen);
    for (    Object o : controlList) {
      if (isGuiButton(o)) {
        aog button=asGuiButton(o);
        if (getId(button) == InvTweaksConst.JIMEOWAN_ID) {
          customButtonsAdded=true;
          break;
        }
      }
    }
    if (!customButtonsAdded) {
      if (!isValidChest) {
        int offsetX=isGuiContainerCreative(guiContainer) ? 19 : 14, offsetY=isGuiContainerCreative(guiContainer) ? 5 : 4;
        controlList.add(new InvTweaksGuiSettingsButton(cfgManager,InvTweaksConst.JIMEOWAN_ID,getGuiX(guiContainer) + getGuiWidth(guiContainer) - offsetX,getGuiY(guiContainer) + offsetY,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str")));
      }
 else {
        chestAlgorithmClickTimestamp=0;
        int id=InvTweaksConst.JIMEOWAN_ID, x=getGuiX(guiContainer) + getGuiWidth(guiContainer) - 16, y=getGuiY(guiContainer) + 5;
        boolean isChestWayTooBig=mods.isChestWayTooBig(guiScreen);
        if (isChestWayTooBig && classExists("String_Node_Str")) {
          if (isNotEnoughItemsEnabled()) {
            x=getGuiX(guiContainer) + getGuiWidth(guiContainer) - 35;
            y+=50;
          }
        }
        controlList.add(new InvTweaksGuiSettingsButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 1,(isChestWayTooBig) ? y - 3 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str")));
        if (!config.getProperty(InvTweaksConfig.PROP_SHOW_CHEST_BUTTONS).equals("String_Node_Str")) {
          int rowSize=getContainerRowSize(guiContainer);
          InvTweaksObfuscationGuiButton button=new InvTweaksGuiSortingButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 13,(isChestWayTooBig) ? y + 12 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str"),InvTweaksHandlerSorting.ALGORITHM_HORIZONTAL,rowSize);
          controlList.add(button);
          button=new InvTweaksGuiSortingButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 25,(isChestWayTooBig) ? y + 25 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str"),InvTweaksHandlerSorting.ALGORITHM_VERTICAL,rowSize);
          controlList.add(button);
          button=new InvTweaksGuiSortingButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 37,(isChestWayTooBig) ? y + 38 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str"),InvTweaksHandlerSorting.ALGORITHM_DEFAULT,rowSize);
          controlList.add(button);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void handleGUILayout(apm guiScreen){
  InvTweaksConfig config=cfgManager.getConfig();
  boolean isValidChest=isValidChest(guiScreen);
  if (isValidChest || (isStandardInventory(guiScreen) && !isGuiEnchantmentTable(guiScreen))) {
    aqg guiContainer=asGuiContainer(guiScreen);
    int w=10, h=10;
    boolean customButtonsAdded=false;
    List<Object> controlList=getControlList(guiScreen);
    for (    Object o : controlList) {
      if (isGuiButton(o)) {
        aog button=asGuiButton(o);
        if (getId(button) == InvTweaksConst.JIMEOWAN_ID) {
          customButtonsAdded=true;
          break;
        }
      }
    }
    if (!customButtonsAdded) {
      if (!isValidChest) {
        controlList.add(new InvTweaksGuiSettingsButton(cfgManager,InvTweaksConst.JIMEOWAN_ID,getGuiX(guiContainer) + getGuiWidth(guiContainer) - 15,getGuiY(guiContainer) + 5,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str")));
      }
 else {
        chestAlgorithmClickTimestamp=0;
        int id=InvTweaksConst.JIMEOWAN_ID, x=getGuiX(guiContainer) + getGuiWidth(guiContainer) - 16, y=getGuiY(guiContainer) + 5;
        boolean isChestWayTooBig=mods.isChestWayTooBig(guiScreen);
        if (isChestWayTooBig && classExists("String_Node_Str")) {
          if (isNotEnoughItemsEnabled()) {
            x=getGuiX(guiContainer) + getGuiWidth(guiContainer) - 35;
            y+=50;
          }
        }
        controlList.add(new InvTweaksGuiSettingsButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 1,(isChestWayTooBig) ? y - 3 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str")));
        if (!config.getProperty(InvTweaksConfig.PROP_SHOW_CHEST_BUTTONS).equals("String_Node_Str")) {
          int rowSize=getContainerRowSize(guiContainer);
          InvTweaksObfuscationGuiButton button=new InvTweaksGuiSortingButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 13,(isChestWayTooBig) ? y + 12 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str"),InvTweaksHandlerSorting.ALGORITHM_HORIZONTAL,rowSize);
          controlList.add(button);
          button=new InvTweaksGuiSortingButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 25,(isChestWayTooBig) ? y + 25 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str"),InvTweaksHandlerSorting.ALGORITHM_VERTICAL,rowSize);
          controlList.add(button);
          button=new InvTweaksGuiSortingButton(cfgManager,id++,(isChestWayTooBig) ? x + 22 : x - 37,(isChestWayTooBig) ? y + 38 : y,w,h,"String_Node_Str",InvTweaksLocalization.get("String_Node_Str"),InvTweaksHandlerSorting.ALGORITHM_DEFAULT,rowSize);
          controlList.add(button);
        }
      }
    }
  }
 else {
    if (isGuiContainerCreative(guiScreen)) {
      List<Object> controlList=getControlList(guiScreen);
      aog buttonToRemove=null;
      for (      Object o : controlList) {
        if (isGuiButton(o)) {
          if (getId(asGuiButton(o)) == InvTweaksConst.JIMEOWAN_ID) {
            buttonToRemove=asGuiButton(o);
            break;
          }
        }
      }
      if (buttonToRemove != null) {
        controlList.remove(buttonToRemove);
      }
    }
  }
}