Program: 154076
Project: 154076
Buggy source:
private void byteLoop(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();
  DataBufferByte sourceDB=(DataBufferByte)source.getDataBuffer();
  int sourceTransX=source.getSampleModelTranslateX();
  int sourceTransY=source.getSampleModelTranslateY();
  int sourceDataBitOffset=sourceSM.getDataBitOffset();
  int sourceScanlineStride=sourceSM.getScanlineStride();
  MultiPixelPackedSampleModel destSM=(MultiPixelPackedSampleModel)dest.getSampleModel();
  DataBufferByte destDB=(DataBufferByte)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();
  byte[] sourceData=sourceDB.getData();
  int sourceDBOffset=sourceDB.getOffset();
  byte[] 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 >> 3);
        int dshift=7 - (destXOffset & 7);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(byte)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 >> 3);
      byte selement=sourceData[sindex];
      int val=(selement >> (7 - (sourceXOffset & 7))) & 1;
      int dindex=destYOffset + (destXOffset >> 3);
      int dshift=7 - (destXOffset & 7);
      int delement=destData[dindex];
      delement|=val << dshift;
      destData[dindex]=(byte)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 >> 3);
        int dshift=7 - (destXOffset & 7);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(byte)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 byteLoop(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();
  DataBufferByte sourceDB=(DataBufferByte)source.getDataBuffer();
  int sourceTransX=source.getSampleModelTranslateX();
  int sourceTransY=source.getSampleModelTranslateY();
  int sourceDataBitOffset=sourceSM.getDataBitOffset();
  int sourceScanlineStride=sourceSM.getScanlineStride();
  MultiPixelPackedSampleModel destSM=(MultiPixelPackedSampleModel)dest.getSampleModel();
  DataBufferByte destDB=(DataBufferByte)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();
  byte[] sourceData=sourceDB.getData();
  int sourceDBOffset=sourceDB.getOffset();
  byte[] 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 >> 3);
        int dshift=7 - (destXOffset & 7);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(byte)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 >> 3);
      byte selement=sourceData[sindex];
      int val=(selement >> (7 - (sourceXOffset & 7))) & 1;
      int dindex=destYOffset + (destXOffset >> 3);
      int dshift=7 - (destXOffset & 7);
      int delement=destData[dindex];
      delement|=val << dshift;
      destData[dindex]=(byte)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 >> 3);
        int dshift=7 - (destXOffset & 7);
        int delement=destData[dindex];
        delement|=black << dshift;
        destData[dindex]=(byte)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;
    }
  }
}