Program: 154077
Project: 154077
Buggy source:
private void intLoop(Raster source,WritableRaster dest,Rectangle destRect){
  float src_rect_x1=source.getMinX();
  float src_rect_y1=source.getMinY();
  float src_rect_x2=src_rect_x1 + source.getWidth();
  float src_rect_y2=src_rect_y1 + source.getHeight();
  MultiPixelPackedSampleModel sourceSM=(MultiPixelPackedSampleModel)source.getSampleModel();
  DataBufferInt sourceDB=(DataBufferInt)source.getDataBuffer();
  int sourceTransX=source.getSampleModelTranslateX();
  int sourceTransY=source.getSampleModelTranslateY();
  int sourceDataBitOffset=sourceSM.getDataBitOffset();
  int sourceScanlineStride=sourceSM.getScanlineStride();
  MultiPixelPackedSampleModel destSM=(MultiPixelPackedSampleModel)dest.getSampleModel();
  DataBufferInt destDB=(DataBufferInt)dest.getDataBuffer();
  int destMinX=dest.getMinX();
  int destMinY=dest.getMinY();
  int destTransX=dest.getSampleModelTranslateX();
  int destTransY=dest.getSampleModelTranslateY();
  int destDataBitOffset=destSM.getDataBitOffset();
  int destScanlineStride=destSM.getScanlineStride();
  int[] sourceData=sourceDB.getData();
  int sourceDBOffset=sourceDB.getOffset();
  int[] destData=destDB.getData();
  int destDBOffset=destDB.getOffset();
  Point2D dst_pt=new Point2D.Float();
  Point2D src_pt=new Point2D.Float();
  int dst_min_x=destRect.x;
  int dst_min_y=destRect.y;
  int dst_max_x=destRect.x + destRect.width;
  int dst_max_y=destRect.y + destRect.height;
  int incyStride=incy * sourceScanlineStride;
  int incy1Stride=incy1 * sourceScanlineStride;
  black=((int)backgroundValues[0]) & 1;
  for (int y=dst_min_y; y < dst_max_y; y++) {
    dst_pt.setLocation((double)dst_min_x + 0.5,(double)y + 0.5);
    mapDestPoint(dst_pt,src_pt);
    float s_x=(float)src_pt.getX();
    float s_y=(float)src_pt.getY();
    int s_ix=(int)Math.floor(s_x);
    int s_iy=(int)Math.floor(s_y);
    double fracx=s_x - (double)s_ix;
    double fracy=s_y - (double)s_iy;
    int ifracx=(int)Math.floor(fracx * geom_frac_max);
    int ifracy=(int)Math.floor(fracy * geom_frac_max);
    int start_s_ix=s_ix;
    int start_s_iy=s_iy;
    int start_ifracx=ifracx;
    int start_ifracy=ifracy;
    Range clipRange=performScanlineClipping(src_rect_x1,src_rect_y1,src_rect_x2,src_rect_y2,s_ix,s_iy,ifracx,ifracy,dst_min_x,dst_max_x,0,0,0,0);
    int clipMinX=((Integer)clipRange.getMinValue()).intValue();
    int clipMaxX=((Integer)clipRange.getMaxValue()).intValue();
    if (clipMinX > clipMaxX)     continue;
    int destYOffset=(y - destTransY) * destScanlineStride + destDBOffset;
    int destXOffset=destDataBitOffset + (dst_min_x - destTransX);
    int sourceYOffset=(s_iy - sourceTransY) * sourceScanlineStride + sourceDBOffset;
    int sourceXOffset=s_ix - sourceTransX + sourceDataBitOffset;
    for (int x=dst_min_x; x < clipMinX; x++) {
      if (setBackground) {
        int dindex=destYOffset + (destXOffset >> 5);
        int dshift=31 - (destXOffset & 31);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(int)delement;
      }
      if (ifracx < ifracdx1) {
        s_ix+=incx;
        ifracx+=ifracdx;
        sourceXOffset+=incx;
      }
 else {
        s_ix+=incx1;
        ifracx-=ifracdx1;
        sourceXOffset+=incx1;
      }
      if (ifracy < ifracdy1) {
        s_iy+=incy;
        ifracy+=ifracdy;
        sourceYOffset+=incyStride;
      }
 else {
        s_iy+=incy1;
        ifracy-=ifracdy1;
        sourceYOffset+=incy1Stride;
      }
      ++destXOffset;
    }
    for (int x=clipMinX; x < clipMaxX; x++) {
      int sindex=sourceYOffset + (sourceXOffset >> 5);
      int selement=sourceData[sindex];
      int val=(selement >> (31 - (sourceXOffset & 31))) & 1;
      int dindex=destYOffset + (destXOffset >> 5);
      int dshift=31 - (destXOffset & 31);
      int delement=destData[dindex];
      delement|=val << dshift;
      destData[dindex]=(int)delement;
      if (ifracx < ifracdx1) {
        s_ix+=incx;
        ifracx+=ifracdx;
        sourceXOffset+=incx;
      }
 else {
        s_ix+=incx1;
        ifracx-=ifracdx1;
        sourceXOffset+=incx1;
      }
      if (ifracy < ifracdy1) {
        s_iy+=incy;
        ifracy+=ifracdy;
        sourceYOffset+=incyStride;
      }
 else {
        s_iy+=incy1;
        ifracy-=ifracdy1;
        sourceYOffset+=incy1Stride;
      }
      ++destXOffset;
    }
    for (int x=clipMaxX; x < dst_max_x; x++) {
      if (setBackground) {
        int dindex=destYOffset + (destXOffset >> 5);
        int dshift=31 - (destXOffset & 31);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(int)delement;
      }
      if (ifracx < ifracdx1) {
        s_ix+=incx;
        ifracx+=ifracdx;
        sourceXOffset+=incx;
      }
 else {
        s_ix+=incx1;
        ifracx-=ifracdx1;
        sourceXOffset+=incx1;
      }
      if (ifracy < ifracdy1) {
        s_iy+=incy;
        ifracy+=ifracdy;
        sourceYOffset+=incyStride;
      }
 else {
        s_iy+=incy1;
        ifracy-=ifracdy1;
        sourceYOffset+=incy1Stride;
      }
      ++destXOffset;
    }
  }
}

Fixed version (ground truth):
private void intLoop(Raster source,WritableRaster dest,Rectangle destRect){
  float src_rect_x1=source.getMinX();
  float src_rect_y1=source.getMinY();
  float src_rect_x2=src_rect_x1 + source.getWidth();
  float src_rect_y2=src_rect_y1 + source.getHeight();
  MultiPixelPackedSampleModel sourceSM=(MultiPixelPackedSampleModel)source.getSampleModel();
  DataBufferInt sourceDB=(DataBufferInt)source.getDataBuffer();
  int sourceTransX=source.getSampleModelTranslateX();
  int sourceTransY=source.getSampleModelTranslateY();
  int sourceDataBitOffset=sourceSM.getDataBitOffset();
  int sourceScanlineStride=sourceSM.getScanlineStride();
  MultiPixelPackedSampleModel destSM=(MultiPixelPackedSampleModel)dest.getSampleModel();
  DataBufferInt destDB=(DataBufferInt)dest.getDataBuffer();
  int destMinX=dest.getMinX();
  int destMinY=dest.getMinY();
  int destTransX=dest.getSampleModelTranslateX();
  int destTransY=dest.getSampleModelTranslateY();
  int destDataBitOffset=destSM.getDataBitOffset();
  int destScanlineStride=destSM.getScanlineStride();
  int[] sourceData=sourceDB.getData();
  int sourceDBOffset=sourceDB.getOffset();
  int[] destData=destDB.getData();
  int destDBOffset=destDB.getOffset();
  Point2D dst_pt=new Point2D.Float();
  Point2D src_pt=new Point2D.Float();
  int dst_min_x=destRect.x;
  int dst_min_y=destRect.y;
  int dst_max_x=destRect.x + destRect.width;
  int dst_max_y=destRect.y + destRect.height;
  int incyStride=incy * sourceScanlineStride;
  int incy1Stride=incy1 * sourceScanlineStride;
  black=((int)backgroundValues[0]) & 1;
  for (int y=dst_min_y; y < dst_max_y; y++) {
    dst_pt.setLocation((double)dst_min_x + 0.5,(double)y + 0.5);
    mapDestPoint(dst_pt,src_pt);
    float s_x=(float)src_pt.getX();
    float s_y=(float)src_pt.getY();
    int s_ix=(int)Math.floor(s_x);
    int s_iy=(int)Math.floor(s_y);
    double fracx=s_x - (double)s_ix;
    double fracy=s_y - (double)s_iy;
    int ifracx=(int)Math.floor(fracx * geom_frac_max);
    int ifracy=(int)Math.floor(fracy * geom_frac_max);
    int start_s_ix=s_ix;
    int start_s_iy=s_iy;
    int start_ifracx=ifracx;
    int start_ifracy=ifracy;
    Range clipRange=performScanlineClipping(src_rect_x1,src_rect_y1,src_rect_x2 - 1,src_rect_y2 - 1,s_ix,s_iy,ifracx,ifracy,dst_min_x,dst_max_x,0,0,0,0);
    int clipMinX=((Integer)clipRange.getMinValue()).intValue();
    int clipMaxX=((Integer)clipRange.getMaxValue()).intValue();
    if (clipMinX > clipMaxX)     continue;
    int destYOffset=(y - destTransY) * destScanlineStride + destDBOffset;
    int destXOffset=destDataBitOffset + (dst_min_x - destTransX);
    int sourceYOffset=(s_iy - sourceTransY) * sourceScanlineStride + sourceDBOffset;
    int sourceXOffset=s_ix - sourceTransX + sourceDataBitOffset;
    for (int x=dst_min_x; x < clipMinX; x++) {
      if (setBackground) {
        int dindex=destYOffset + (destXOffset >> 5);
        int dshift=31 - (destXOffset & 31);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(int)delement;
      }
      if (ifracx < ifracdx1) {
        ifracx+=ifracdx;
        sourceXOffset+=incx;
      }
 else {
        ifracx-=ifracdx1;
        sourceXOffset+=incx1;
      }
      if (ifracy < ifracdy1) {
        ifracy+=ifracdy;
        sourceYOffset+=incyStride;
      }
 else {
        ifracy-=ifracdy1;
        sourceYOffset+=incy1Stride;
      }
      ++destXOffset;
    }
    for (int x=clipMinX; x < clipMaxX; x++) {
      int sindex=sourceYOffset + (sourceXOffset >> 5);
      int selement=sourceData[sindex];
      int val=(selement >> (31 - (sourceXOffset & 31))) & 1;
      int dindex=destYOffset + (destXOffset >> 5);
      int dshift=31 - (destXOffset & 31);
      int delement=destData[dindex];
      delement|=val << dshift;
      destData[dindex]=(int)delement;
      if (ifracx < ifracdx1) {
        ifracx+=ifracdx;
        sourceXOffset+=incx;
      }
 else {
        ifracx-=ifracdx1;
        sourceXOffset+=incx1;
      }
      if (ifracy < ifracdy1) {
        ifracy+=ifracdy;
        sourceYOffset+=incyStride;
      }
 else {
        ifracy-=ifracdy1;
        sourceYOffset+=incy1Stride;
      }
      ++destXOffset;
    }
    for (int x=clipMaxX; x < dst_max_x; x++) {
      if (setBackground) {
        int dindex=destYOffset + (destXOffset >> 5);
        int dshift=31 - (destXOffset & 31);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(int)delement;
      }
      if (ifracx < ifracdx1) {
        ifracx+=ifracdx;
        sourceXOffset+=incx;
      }
 else {
        ifracx-=ifracdx1;
        sourceXOffset+=incx1;
      }
      if (ifracy < ifracdy1) {
        ifracy+=ifracdy;
        sourceYOffset+=incyStride;
      }
 else {
        ifracy-=ifracdy1;
        sourceYOffset+=incy1Stride;
      }
      ++destXOffset;
    }
  }
}