Program: 56567
Project: 56567
Buggy source:
private Ref copyRef(Ref srcRef,int colRepeat,int rowRepeat,Ref dstRef,int pasteType,int pasteOp,boolean skipBlanks,boolean transpose,ChangeInfo info){
  final int srcRowCount=srcRef.getRowCount();
  final int srcColCount=srcRef.getColumnCount();
  final Ref pasteRef=getPasteRef(srcRowCount,srcColCount,rowRepeat,colRepeat,dstRef,transpose);
  if (pasteRef == null) {
    return null;
  }
  if (pasteType == XRange.PASTE_COLUMN_WIDTHS) {
    final int srclCol=srcRef.getLeftCol();
    final XSheet srcSheet=BookHelper.getSheet(_sheet,srcRef.getOwnerSheet());
    copyColumnWidths(srcSheet,srcColCount,srclCol,pasteRef);
    return pasteRef;
  }
  final int tRow=srcRef.getTopRow();
  final int lCol=srcRef.getLeftCol();
  final int bRow=srcRef.getBottomRow();
  final int rCol=srcRef.getRightCol();
  final RefSheet dstRefsheet=dstRef.getOwnerSheet();
  final XSheet srcSheet=BookHelper.getSheet(_sheet,srcRef.getOwnerSheet());
  final XSheet dstSheet=BookHelper.getSheet(_sheet,dstRefsheet);
  final Set<Ref> toEval=info.getToEval();
  final Set<Ref> affected=info.getAffected();
  final List<MergeChange> mergeChanges=info.getMergeChanges();
  if (!transpose) {
    int[][] repeatArea=new int[rowRepeat * colRepeat][2];
    for (int rr=rowRepeat, areaCount=0; rr > 0; --rr) {
      for (int cr=colRepeat; cr > 0; --cr, ++areaCount) {
        repeatArea[areaCount][0]=dstRef.getTopRow() + (srcRef.getRowCount() * (rowRepeat - rr));
        repeatArea[areaCount][1]=dstRef.getLeftCol() + (srcRef.getColumnCount() * (colRepeat - cr));
      }
    }
    Set<String> blankMap=new HashSet<String>();
    for (int areaCount=0; areaCount < repeatArea.length; areaCount++) {
      int srcRowPointer=areaCount <= 0 ? srcRef.getTopRow() : repeatArea[0][0];
      int srcColPointer=areaCount <= 0 ? srcRef.getLeftCol() : repeatArea[0][1];
      int dstRowPointer=areaCount <= 0 ? dstRef.getTopRow() : repeatArea[areaCount][0];
      int dstColPointer=areaCount <= 0 ? dstRef.getLeftCol() : repeatArea[areaCount][1];
      int rowStep=1;
      int colStep=1;
      int srcTopRow=srcRowPointer;
      int srcLeftCol=srcColPointer;
      if (srcRowPointer < dstRowPointer) {
        srcRowPointer+=srcRowCount - 1;
        dstRowPointer+=srcRowCount - 1;
        rowStep=-1;
      }
      if (srcColPointer < dstColPointer) {
        srcColPointer+=srcColCount - 1;
        dstColPointer+=srcColCount - 1;
        colStep=-1;
      }
      for (int rowCount=srcRef.getRowCount(); rowCount > 0; rowCount--, srcRowPointer+=rowStep, dstRowPointer+=rowStep) {
        for (int colCount=srcRef.getColumnCount(); colCount > 0; colCount--, srcColPointer+=colStep, dstColPointer+=colStep) {
          final Cell cell=BookHelper.getCell(srcSheet,srcRowPointer,srcColPointer);
          String hitBlankKey=Math.abs(srcRowPointer - srcTopRow) + "String_Node_Str" + Math.abs(srcColPointer - srcLeftCol);
          boolean hitBlank=(blankMap.contains(hitBlankKey));
          if (!hitBlank && (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK)) {
            final ChangeInfo changeInfo0=BookHelper.copyCell(cell,dstSheet,dstRowPointer,dstColPointer,pasteType,pasteOp,transpose);
            BookHelper.assignChangeInfo(toEval,affected,mergeChanges,changeInfo0);
          }
 else {
            if (!hitBlank) {
              blankMap.add(hitBlankKey);
            }
            if (!skipBlanks) {
              final Set<Ref>[] refs=BookHelper.removeCell(dstSheet,dstRowPointer,dstColPointer);
              BookHelper.assignRefs(toEval,affected,refs);
            }
          }
        }
        srcColPointer-=(colStep * srcColCount);
        dstColPointer-=(colStep * srcColCount);
      }
    }
  }
 else {
    int dstCol=dstRef.getLeftCol();
    for (int rr=rowRepeat; rr > 0; --rr) {
      for (int srcRow=tRow; srcRow <= bRow; ++srcRow, ++dstCol) {
        int dstRow=dstRef.getTopRow();
        for (int cr=colRepeat; cr > 0; --cr) {
          for (int srcCol=lCol; srcCol <= rCol; ++srcCol, ++dstRow) {
            final Cell cell=BookHelper.getCell(srcSheet,srcRow,srcCol);
            if (cell != null) {
              if (!skipBlanks || cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                final ChangeInfo changeInfo0=BookHelper.copyCell(cell,dstSheet,dstRow,dstCol,pasteType,pasteOp,transpose);
                BookHelper.assignChangeInfo(toEval,affected,mergeChanges,changeInfo0);
              }
            }
 else             if (!skipBlanks) {
              final Set<Ref>[] refs=BookHelper.removeCell(dstSheet,dstRow,dstCol);
              BookHelper.assignRefs(toEval,affected,refs);
            }
          }
        }
      }
    }
  }
  affected.add(pasteRef);
  return pasteRef;
}

Fixed version (ground truth):
private Ref copyRef(Ref srcRef,int colRepeat,int rowRepeat,Ref dstRef,int pasteType,int pasteOp,boolean skipBlanks,boolean transpose,ChangeInfo info){
  final int srcRowCount=srcRef.getRowCount();
  final int srcColCount=srcRef.getColumnCount();
  final Ref pasteRef=getPasteRef(srcRowCount,srcColCount,rowRepeat,colRepeat,dstRef,transpose);
  if (pasteRef == null) {
    return null;
  }
  if (pasteType == XRange.PASTE_COLUMN_WIDTHS) {
    final int srclCol=srcRef.getLeftCol();
    final XSheet srcSheet=BookHelper.getSheet(_sheet,srcRef.getOwnerSheet());
    copyColumnWidths(srcSheet,srcColCount,srclCol,pasteRef);
    return pasteRef;
  }
  final int tRow=srcRef.getTopRow();
  final int lCol=srcRef.getLeftCol();
  final int bRow=srcRef.getBottomRow();
  final int rCol=srcRef.getRightCol();
  final RefSheet dstRefsheet=dstRef.getOwnerSheet();
  final XSheet srcSheet=BookHelper.getSheet(_sheet,srcRef.getOwnerSheet());
  final XSheet dstSheet=BookHelper.getSheet(_sheet,dstRefsheet);
  final Set<Ref> toEval=info.getToEval();
  final Set<Ref> affected=info.getAffected();
  final List<MergeChange> mergeChanges=info.getMergeChanges();
  if (!transpose) {
    int[][] repeatArea=new int[rowRepeat * colRepeat][2];
    for (int rr=rowRepeat, areaCount=0; rr > 0; --rr) {
      for (int cr=colRepeat; cr > 0; --cr, ++areaCount) {
        repeatArea[areaCount][0]=dstRef.getTopRow() + (srcRef.getRowCount() * (rowRepeat - rr));
        repeatArea[areaCount][1]=dstRef.getLeftCol() + (srcRef.getColumnCount() * (colRepeat - cr));
      }
    }
    Set<String> blankMap=new HashSet<String>();
    for (int areaCount=0; areaCount < repeatArea.length; areaCount++) {
      int srcRowPointer=areaCount <= 0 ? srcRef.getTopRow() : repeatArea[0][0];
      int srcColPointer=areaCount <= 0 ? srcRef.getLeftCol() : repeatArea[0][1];
      int dstRowPointer=areaCount <= 0 ? dstRef.getTopRow() : repeatArea[areaCount][0];
      int dstColPointer=areaCount <= 0 ? dstRef.getLeftCol() : repeatArea[areaCount][1];
      int rowStep=1;
      int colStep=1;
      int srcTopRow=srcRowPointer;
      int srcLeftCol=srcColPointer;
      if (srcRowPointer < dstRowPointer) {
        srcRowPointer+=srcRowCount - 1;
        dstRowPointer+=srcRowCount - 1;
        rowStep=-1;
      }
      if (srcColPointer < dstColPointer) {
        srcColPointer+=srcColCount - 1;
        dstColPointer+=srcColCount - 1;
        colStep=-1;
      }
      for (int rowCount=srcRef.getRowCount(); rowCount > 0; rowCount--, srcRowPointer+=rowStep, dstRowPointer+=rowStep) {
        for (int colCount=srcRef.getColumnCount(); colCount > 0; colCount--, srcColPointer+=colStep, dstColPointer+=colStep) {
          final Cell cell=BookHelper.getCell(srcSheet,srcRowPointer,srcColPointer);
          String hitBlankKey=Math.abs(srcRowPointer - srcTopRow) + "String_Node_Str" + Math.abs(srcColPointer - srcLeftCol);
          boolean hitBlank=(blankMap.contains(hitBlankKey));
          if (!hitBlank && cell != null) {
            if (!(skipBlanks && cell.getCellType() == Cell.CELL_TYPE_BLANK)) {
              final ChangeInfo changeInfo0=BookHelper.copyCell(cell,dstSheet,dstRowPointer,dstColPointer,pasteType,pasteOp,transpose);
              BookHelper.assignChangeInfo(toEval,affected,mergeChanges,changeInfo0);
            }
          }
 else           if (!skipBlanks) {
            final Set<Ref>[] refs=BookHelper.removeCell(dstSheet,dstRowPointer,dstColPointer);
            BookHelper.assignRefs(toEval,affected,refs);
          }
          if (!hitBlank && cell != null && cell.getCellType() == Cell.CELL_TYPE_BLANK) {
            blankMap.add(hitBlankKey);
          }
        }
        srcColPointer-=(colStep * srcColCount);
        dstColPointer-=(colStep * srcColCount);
      }
    }
  }
 else {
    int dstCol=dstRef.getLeftCol();
    for (int rr=rowRepeat; rr > 0; --rr) {
      for (int srcRow=tRow; srcRow <= bRow; ++srcRow, ++dstCol) {
        int dstRow=dstRef.getTopRow();
        for (int cr=colRepeat; cr > 0; --cr) {
          for (int srcCol=lCol; srcCol <= rCol; ++srcCol, ++dstRow) {
            final Cell cell=BookHelper.getCell(srcSheet,srcRow,srcCol);
            if (cell != null) {
              if (!skipBlanks || cell.getCellType() != Cell.CELL_TYPE_BLANK) {
                final ChangeInfo changeInfo0=BookHelper.copyCell(cell,dstSheet,dstRow,dstCol,pasteType,pasteOp,transpose);
                BookHelper.assignChangeInfo(toEval,affected,mergeChanges,changeInfo0);
              }
            }
 else             if (!skipBlanks) {
              final Set<Ref>[] refs=BookHelper.removeCell(dstSheet,dstRow,dstCol);
              BookHelper.assignRefs(toEval,affected,refs);
            }
          }
        }
      }
    }
  }
  affected.add(pasteRef);
  return pasteRef;
}