Program: 81775
Project: 81775
Buggy source:
public static boolean profileForFoliageShader(int radialRange,boolean trimRange){
  World world=Minecraft.getMinecraft().world;
  Entity entityIn=Minecraft.getMinecraft().player;
  BlockPos pos=entityIn.getPosition();
  boolean add=true;
  boolean trim=true;
  int xzRange=radialRange;
  int yRange=radialRange;
  Random rand=new Random();
  double centerX=entityIn.posX;
  double centerY=entityIn.posY;
  double centerZ=entityIn.posZ;
  for (  TextureAtlasSprite sprite : ExtendedRenderer.foliageRenderer.foliage.keySet()) {
    InstancedMeshFoliage mesh=MeshBufferManagerFoliage.getMesh(sprite);
    mesh.lastAdditionCount=0;
    mesh.lastRemovalCount=0;
  }
  if (trim) {
    Iterator<Map.Entry<BlockPos,FoliageLocationData>> it=lookupPosToFoliage.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<BlockPos,FoliageLocationData> entry=it.next();
      if (!entry.getValue().foliageReplacer.validFoliageSpot(world,entry.getKey().down())) {
        it.remove();
        for (        Foliage entry2 : entry.getValue().listFoliage) {
          entry.getValue().foliageReplacer.markMeshesDirty();
          ExtendedRenderer.foliageRenderer.getFoliageForSprite(entry2.particleTexture).remove(entry2);
          MeshBufferManagerFoliage.getMesh(entry2.particleTexture).lastRemovalCount++;
        }
      }
 else       if (trimRange && entry.getKey().distanceSq(centerX,centerY,centerZ) > radialRange * radialRange) {
        it.remove();
        for (        Foliage entry2 : entry.getValue().listFoliage) {
          entry.getValue().foliageReplacer.markMeshesDirty();
          ExtendedRenderer.foliageRenderer.getFoliageForSprite(entry2.particleTexture).remove(entry2);
          MeshBufferManagerFoliage.getMesh(entry2.particleTexture).lastRemovalCount++;
        }
      }
    }
  }
  if (add) {
    for (int x=-xzRange; x <= xzRange; x++) {
      for (int z=-xzRange; z <= xzRange; z++) {
        for (int y=-yRange; y <= yRange; y++) {
          BlockPos posScan=pos.add(x,y,z);
          if (!lookupPosToFoliage.containsKey(posScan)) {
            if (posScan.distanceSq(centerX,centerY,centerZ) <= radialRange * radialRange) {
              boolean tryAll=true;
              if (tryAll) {
                for (                FoliageReplacerBase replacer : listFoliageReplacers) {
                  if (replacer.validFoliageSpot(entityIn.world,posScan.down())) {
                    replacer.addForPos(entityIn.world,posScan);
                    replacer.markMeshesDirty();
                    for (                    TextureAtlasSprite sprite : replacer.sprites) {
                      MeshBufferManagerFoliage.getMesh(sprite).lastAdditionCount++;
                    }
                  }
                }
              }
 else {
                int randTry=rand.nextInt(listFoliageReplacers.size());
                FoliageReplacerBase replacer=listFoliageReplacers.get(randTry);
                if (replacer.validFoliageSpot(entityIn.world,posScan.down())) {
                  replacer.addForPos(entityIn.world,posScan);
                  replacer.markMeshesDirty();
                }
              }
            }
          }
 else {
          }
        }
      }
    }
  }
  try {
    for (    Map.Entry<TextureAtlasSprite,List<Foliage>> entry : ExtendedRenderer.foliageRenderer.foliage.entrySet()) {
      InstancedMeshFoliage mesh=MeshBufferManagerFoliage.getMesh(entry.getKey());
      if (mesh.dirtyVBO2Flag) {
        mesh.interpPosXThread=entityIn.posX;
        mesh.interpPosYThread=entityIn.posY;
        mesh.interpPosZThread=entityIn.posZ;
        updateVBO2Threaded(entry.getKey());
      }
    }
  }
  finally {
    return true;
  }
}

Fixed version (ground truth):
public static boolean profileForFoliageShader(int radialRange,boolean trimRange){
  World world=Minecraft.getMinecraft().world;
  Entity entityIn=Minecraft.getMinecraft().player;
  BlockPos pos=entityIn.getPosition();
  boolean add=true;
  boolean trim=true;
  int xzRange=radialRange;
  int yRange=radialRange;
  Random rand=new Random();
  double centerX=entityIn.posX;
  double centerY=entityIn.posY;
  double centerZ=entityIn.posZ;
  for (  TextureAtlasSprite sprite : ExtendedRenderer.foliageRenderer.foliage.keySet()) {
    InstancedMeshFoliage mesh=MeshBufferManagerFoliage.getMesh(sprite);
    mesh.lastAdditionCount=0;
    mesh.lastRemovalCount=0;
  }
  if (trim) {
    Iterator<Map.Entry<BlockPos,FoliageLocationData>> it=lookupPosToFoliage.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<BlockPos,FoliageLocationData> entry=it.next();
      if (!entry.getValue().foliageReplacer.isActive() || !entry.getValue().foliageReplacer.validFoliageSpot(world,entry.getKey().down())) {
        it.remove();
        for (        Foliage entry2 : entry.getValue().listFoliage) {
          entry.getValue().foliageReplacer.markMeshesDirty();
          ExtendedRenderer.foliageRenderer.getFoliageForSprite(entry2.particleTexture).remove(entry2);
          MeshBufferManagerFoliage.getMesh(entry2.particleTexture).lastRemovalCount++;
        }
      }
 else       if (trimRange && entry.getKey().distanceSq(centerX,centerY,centerZ) > radialRange * radialRange) {
        it.remove();
        for (        Foliage entry2 : entry.getValue().listFoliage) {
          entry.getValue().foliageReplacer.markMeshesDirty();
          ExtendedRenderer.foliageRenderer.getFoliageForSprite(entry2.particleTexture).remove(entry2);
          MeshBufferManagerFoliage.getMesh(entry2.particleTexture).lastRemovalCount++;
        }
      }
    }
  }
  if (add) {
    for (int x=-xzRange; x <= xzRange; x++) {
      for (int z=-xzRange; z <= xzRange; z++) {
        for (int y=-yRange; y <= yRange; y++) {
          BlockPos posScan=pos.add(x,y,z);
          if (!lookupPosToFoliage.containsKey(posScan)) {
            if (posScan.distanceSq(centerX,centerY,centerZ) <= radialRange * radialRange) {
              boolean tryAll=true;
              if (tryAll) {
                for (                FoliageReplacerBase replacer : listFoliageReplacers) {
                  if (replacer.isActive() && replacer.validFoliageSpot(entityIn.world,posScan.down())) {
                    replacer.addForPos(entityIn.world,posScan);
                    replacer.markMeshesDirty();
                    for (                    TextureAtlasSprite sprite : replacer.sprites) {
                      MeshBufferManagerFoliage.getMesh(sprite).lastAdditionCount++;
                    }
                  }
                }
              }
 else {
                int randTry=rand.nextInt(listFoliageReplacers.size());
                FoliageReplacerBase replacer=listFoliageReplacers.get(randTry);
                if (replacer.isActive() && replacer.validFoliageSpot(entityIn.world,posScan.down())) {
                  replacer.addForPos(entityIn.world,posScan);
                  replacer.markMeshesDirty();
                }
              }
            }
          }
 else {
          }
        }
      }
    }
  }
  try {
    for (    Map.Entry<TextureAtlasSprite,List<Foliage>> entry : ExtendedRenderer.foliageRenderer.foliage.entrySet()) {
      InstancedMeshFoliage mesh=MeshBufferManagerFoliage.getMesh(entry.getKey());
      if (mesh.dirtyVBO2Flag) {
        mesh.interpPosXThread=entityIn.posX;
        mesh.interpPosYThread=entityIn.posY;
        mesh.interpPosZThread=entityIn.posZ;
        updateVBO2Threaded(entry.getKey());
      }
    }
  }
  finally {
    return true;
  }
}