Program: 11348
Project: 11348
Buggy source:
public void put(int firstVertex,FloatBuffer xys){
  if (xys.remaining() >= 2) {
    int putFirst=firstVertex + 1;
    int putCount=xys.remaining() / 2;
    boolean putLeader=(firstVertex == 0);
    if (putLeader) {
      putFirst--;
      putCount++;
    }
    int oldCount=this.flagsBuffer.numBytes();
    boolean putTrailer=(putFirst + putCount >= oldCount - 1);
    if (putTrailer) {
      putCount++;
    }
    FloatBuffer xyEdit=this.xyBuffer.editFloats(2 * putFirst,2 * putCount);
{
      if (putLeader) {
        float xLeader=xys.get(0);
        float yLeader=xys.get(1);
        xyEdit.put(xLeader).put(yLeader);
      }
      xyEdit.put(xys);
      if (putTrailer) {
        int iLast=xys.limit() - 2;
        float xTrailer=xys.get(iLast + 0);
        float yTrailer=xys.get(iLast + 1);
        xyEdit.put(xTrailer).put(yTrailer);
      }
    }
    ByteBuffer flagsEdit=this.flagsBuffer.editBytes(1 * putFirst,1 * putCount);
    int newCount=this.flagsBuffer.numBytes();
    for (int i=putFirst; i < putFirst + putCount; i++) {
      if (i == 0) {
        flagsEdit.put((byte)0);
      }
 else       if (i == 1) {
        flagsEdit.put((byte)0);
      }
 else       if (i == newCount - 2) {
        flagsEdit.put((byte)FLAGS_CONNECT);
      }
 else       if (i == newCount - 1) {
        flagsEdit.put((byte)0);
      }
 else {
        flagsEdit.put((byte)(FLAGS_CONNECT | FLAGS_JOIN));
      }
    }
    FloatBuffer mileageEdit=this.mileageBuffer.editFloats(1 * putFirst,1 * newCount);
{
      updateMileageBuffer(this.xyBuffer.hostFloats(),this.flagsBuffer.hostBytes(),mileageEdit,false,1.0);
    }
  }
}

Fixed version (ground truth):
public void put(int firstVertex,FloatBuffer xys){
  if (xys.remaining() >= 2) {
    int putFirst=firstVertex + 1;
    int putCount=xys.remaining() / 2;
    boolean putLeader=(firstVertex == 0);
    if (putLeader) {
      putFirst--;
      putCount++;
    }
    int oldCount=this.flagsBuffer.numBytes();
    boolean putTrailer=(putFirst + putCount >= oldCount - 1);
    if (putTrailer) {
      putCount++;
    }
{
      int xyFirst=2 * putFirst;
      int xyCount=2 * putCount;
      FloatBuffer xyEdit=this.xyBuffer.editFloats(xyFirst,xyCount);
      if (putLeader) {
        float xLeader=xys.get(0);
        float yLeader=xys.get(1);
        xyEdit.put(xLeader).put(yLeader);
      }
      xyEdit.put(xys);
      if (putTrailer) {
        int iLast=xys.limit() - 2;
        float xTrailer=xys.get(iLast + 0);
        float yTrailer=xys.get(iLast + 1);
        xyEdit.put(xTrailer).put(yTrailer);
      }
    }
{
      int flagsFirst=(putTrailer ? max(0,min(putFirst,oldCount - 2)) : putFirst);
      int flagsCount=putFirst + putCount - flagsFirst;
      ByteBuffer flagsEdit=this.flagsBuffer.editBytes(flagsFirst,flagsCount);
      int newCount=this.flagsBuffer.numBytes();
      for (int i=flagsFirst; i < flagsFirst + flagsCount; i++) {
        if (i == 0) {
          flagsEdit.put((byte)0);
        }
 else         if (i == 1) {
          flagsEdit.put((byte)0);
        }
 else         if (i == newCount - 2) {
          flagsEdit.put((byte)FLAGS_CONNECT);
        }
 else         if (i == newCount - 1) {
          flagsEdit.put((byte)0);
        }
 else {
          flagsEdit.put((byte)(FLAGS_CONNECT | FLAGS_JOIN));
        }
      }
    }
{
      int mileageFirst=max(0,putFirst - 1);
      int mileageCount=this.flagsBuffer.numBytes() - mileageFirst;
      FloatBuffer mileageEdit=this.mileageBuffer.editFloats(mileageFirst,mileageCount);
      mileageEdit.position(putFirst - mileageFirst);
      FloatBuffer xySlice=sliced(this.xyBuffer.hostFloats(),2 * mileageFirst,2 * mileageCount);
      ByteBuffer flagsSlice=sliced(this.flagsBuffer.hostBytes(),1 * mileageFirst,1 * mileageCount);
      updateMileageBuffer(xySlice,flagsSlice,mileageEdit,false,1.0);
    }
  }
}