Program: 87663
Project: 87663
Buggy source:
/** 
 * Calculate interpolated points between the last interpolated point and the end of the trail. And return the start index of the last interpolated segment of input arrays because it may need to recalculate the interpolated points in the segment if further segments are added to this stroke.
 * @param lastInterpolatedIndex the start index of the last interpolated segment of<code>eventTimes</code>, <code>xCoords</code>, and <code>yCoords</code>.
 * @param eventTimes the event time array of gesture trail to be drawn.
 * @param xCoords the x-coordinates array of gesture trail to be drawn.
 * @param yCoords the y-coordinates array of gesture trail to be drawn.
 * @return the start index of the last interpolated segment of input arrays.
 */
public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex,final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords,final ResizableIntArray types){
  final int size=mPreviewEventTimes.getLength();
  final int[] pt=mPreviewEventTimes.getPrimitiveArray();
  final int[] px=mPreviewXCoordinates.getPrimitiveArray();
  final int[] py=mPreviewYCoordinates.getPrimitiveArray();
  mInterpolator.reset(px,py,0,size);
  int lastInterpolatedDrawIndex=lastInterpolatedIndex;
  int d1=lastInterpolatedIndex;
  for (int p2=mLastInterpolatedPreviewIndex + 1; p2 < size; p2++) {
    final int p1=p2 - 1;
    final int p0=p1 - 1;
    final int p3=p2 + 1;
    mLastInterpolatedPreviewIndex=p1;
    lastInterpolatedDrawIndex=d1;
    mInterpolator.setInterval(p0,p1,p2,p3);
    final double m1=Math.atan2(mInterpolator.mSlope1Y,mInterpolator.mSlope1X);
    final double m2=Math.atan2(mInterpolator.mSlope2Y,mInterpolator.mSlope2X);
    final double deltaAngle=Math.abs(angularDiff(m2,m1));
    final int segmentsByAngle=(int)Math.ceil(deltaAngle / mPreviewParams.mMaxInterpolationAngularThreshold);
    final double deltaDistance=Math.hypot(mInterpolator.mP1X - mInterpolator.mP2X,mInterpolator.mP1Y - mInterpolator.mP2Y);
    final int segmentsByDistance=(int)Math.ceil(deltaDistance / mPreviewParams.mMaxInterpolationDistanceThreshold);
    final int segments=Math.min(mPreviewParams.mMaxInterpolationSegments,Math.max(segmentsByAngle,segmentsByDistance));
    final int t1=eventTimes.get(d1);
    final int dt=pt[p2] - pt[p1];
    d1++;
    for (int i=1; i < segments; i++) {
      final float t=i / (float)segments;
      mInterpolator.interpolate(t);
      eventTimes.add(d1,(int)(dt * t) + t1);
      xCoords.add(d1,(int)mInterpolator.mInterpolatedX);
      yCoords.add(d1,(int)mInterpolator.mInterpolatedY);
      if (GestureTrail.DBG_SHOW_POINTS) {
        types.add(d1,GestureTrail.POINT_TYPE_INTERPOLATED);
      }
      d1++;
    }
    eventTimes.add(d1,pt[p2]);
    xCoords.add(d1,px[p2]);
    yCoords.add(d1,py[p2]);
    if (GestureTrail.DBG_SHOW_POINTS) {
      types.add(d1,GestureTrail.POINT_TYPE_SAMPLED);
    }
  }
  return lastInterpolatedDrawIndex;
}

Fixed version (ground truth):
/** 
 * Calculate interpolated points between the last interpolated point and the end of the trail. And return the start index of the last interpolated segment of input arrays because it may need to recalculate the interpolated points in the segment if further segments are added to this stroke.
 * @param lastInterpolatedIndex the start index of the last interpolated segment of<code>eventTimes</code>, <code>xCoords</code>, and <code>yCoords</code>.
 * @param eventTimes the event time array of gesture trail to be drawn.
 * @param xCoords the x-coordinates array of gesture trail to be drawn.
 * @param yCoords the y-coordinates array of gesture trail to be drawn.
 * @param types the point types array of gesture trail. This is valid only when{@link GestureTrail#DEBUG_SHOW_POINTS} is true.
 * @return the start index of the last interpolated segment of input arrays.
 */
public int interpolateStrokeAndReturnStartIndexOfLastSegment(final int lastInterpolatedIndex,final ResizableIntArray eventTimes,final ResizableIntArray xCoords,final ResizableIntArray yCoords,final ResizableIntArray types){
  final int size=mPreviewEventTimes.getLength();
  final int[] pt=mPreviewEventTimes.getPrimitiveArray();
  final int[] px=mPreviewXCoordinates.getPrimitiveArray();
  final int[] py=mPreviewYCoordinates.getPrimitiveArray();
  mInterpolator.reset(px,py,0,size);
  int lastInterpolatedDrawIndex=lastInterpolatedIndex;
  int d1=lastInterpolatedIndex;
  for (int p2=mLastInterpolatedPreviewIndex + 1; p2 < size; p2++) {
    final int p1=p2 - 1;
    final int p0=p1 - 1;
    final int p3=p2 + 1;
    mLastInterpolatedPreviewIndex=p1;
    lastInterpolatedDrawIndex=d1;
    mInterpolator.setInterval(p0,p1,p2,p3);
    final double m1=Math.atan2(mInterpolator.mSlope1Y,mInterpolator.mSlope1X);
    final double m2=Math.atan2(mInterpolator.mSlope2Y,mInterpolator.mSlope2X);
    final double deltaAngle=Math.abs(angularDiff(m2,m1));
    final int segmentsByAngle=(int)Math.ceil(deltaAngle / mPreviewParams.mMaxInterpolationAngularThreshold);
    final double deltaDistance=Math.hypot(mInterpolator.mP1X - mInterpolator.mP2X,mInterpolator.mP1Y - mInterpolator.mP2Y);
    final int segmentsByDistance=(int)Math.ceil(deltaDistance / mPreviewParams.mMaxInterpolationDistanceThreshold);
    final int segments=Math.min(mPreviewParams.mMaxInterpolationSegments,Math.max(segmentsByAngle,segmentsByDistance));
    final int t1=eventTimes.get(d1);
    final int dt=pt[p2] - pt[p1];
    d1++;
    for (int i=1; i < segments; i++) {
      final float t=i / (float)segments;
      mInterpolator.interpolate(t);
      eventTimes.add(d1,(int)(dt * t) + t1);
      xCoords.add(d1,(int)mInterpolator.mInterpolatedX);
      yCoords.add(d1,(int)mInterpolator.mInterpolatedY);
      if (GestureTrail.DEBUG_SHOW_POINTS) {
        types.add(d1,GestureTrail.POINT_TYPE_INTERPOLATED);
      }
      d1++;
    }
    eventTimes.add(d1,pt[p2]);
    xCoords.add(d1,px[p2]);
    yCoords.add(d1,py[p2]);
    if (GestureTrail.DEBUG_SHOW_POINTS) {
      types.add(d1,GestureTrail.POINT_TYPE_SAMPLED);
    }
  }
  return lastInterpolatedDrawIndex;
}