Program: 3328
Project: 3328
Buggy source:
/** 
 * Based on the passed in array compute the shape,offsets, and strides for the given indexes
 * @param indexes the indexesto compute this based on
 */
public void exec(INDArrayIndex... indexes){
  indexes=NDArrayIndex.resolve(arr.shape(),indexes);
  int[] shape=arr.shape();
  int numIntervals=0;
  int newAxesPrepend=0;
  boolean encounteredAll=false;
  List<Integer> accumShape=new ArrayList<>();
  List<Integer> accumStrides=new ArrayList<>();
  List<Integer> accumOffsets=new ArrayList<>();
  List<Integer> intervalStrides=new ArrayList<>();
  List<Integer> pointStrides=new ArrayList<>();
  List<Integer> pointOffsets=new ArrayList<>();
  int numPointIndexes=0;
  int shapeIndex=0;
  int strideIndex=0;
  List<Integer> prependNewAxes=new ArrayList<>();
  for (int i=0; i < indexes.length; i++) {
    INDArrayIndex idx=indexes[i];
    if (idx instanceof NDArrayIndexAll)     encounteredAll=true;
    if (idx instanceof PointIndex) {
      pointOffsets.add(idx.offset());
      pointStrides.add(arr.stride(strideIndex));
      numPointIndexes++;
      shapeIndex++;
      strideIndex++;
      continue;
    }
 else     if (idx instanceof NewAxis) {
      if (encounteredAll) {
        prependNewAxes.add(i);
      }
 else       newAxesPrepend++;
      continue;
    }
 else     if (idx instanceof IntervalIndex && !(idx instanceof NDArrayIndexAll) || idx instanceof SpecifiedIndex) {
      if (idx instanceof IntervalIndex) {
        accumStrides.add(arr.stride(strideIndex) * idx.stride());
        intervalStrides.add(idx.stride());
        if (idx.stride() > 1)         numIntervals++;
      }
 else       accumStrides.add(arr.stride(strideIndex));
      accumShape.add(idx.length());
      if (idx instanceof IntervalIndex) {
        accumOffsets.add(idx.offset());
      }
 else       accumOffsets.add(idx.offset());
      shapeIndex++;
      strideIndex++;
      continue;
    }
    accumShape.add(shape[shapeIndex++]);
    accumStrides.add(arr.stride(strideIndex++));
    accumOffsets.add(idx.offset());
  }
  while (shapeIndex < shape.length) {
    if (Shape.isVector(shape)) {
      accumShape.add(1);
      shapeIndex++;
    }
 else     accumShape.add(shape[shapeIndex++]);
  }
  int delta=(shape.length <= 2 ? shape.length : shape.length - numPointIndexes);
  boolean needsFilledIn=accumShape.size() != accumStrides.size() && accumOffsets.size() != accumShape.size();
  while (accumOffsets.size() < delta && needsFilledIn)   accumOffsets.add(0);
  while (accumShape.size() < 2) {
    if (Shape.isRowVectorShape(arr.shape()))     accumShape.add(0,1);
 else     accumShape.add(1);
  }
  while (strideIndex < accumShape.size()) {
    accumStrides.add(arr.stride(strideIndex++));
  }
  if (newAxesPrepend > 0) {
    for (int i=0; i < newAxesPrepend; i++) {
      accumShape.add(0,1);
      accumStrides.add(0,0);
      accumOffsets.add(0,0);
    }
  }
  int numAdded=0;
  for (int i=0; i < prependNewAxes.size(); i++) {
    accumShape.add(prependNewAxes.get(i) - numAdded,1);
    accumStrides.add(prependNewAxes.get(i) - numAdded,0);
    numAdded++;
  }
  int trailingZeroRemove=accumOffsets.size() - 1;
  while (accumOffsets.size() > accumShape.size()) {
    if (accumOffsets.get(trailingZeroRemove) == 0)     accumOffsets.remove(accumOffsets.size() - 1);
    trailingZeroRemove--;
  }
  if (accumStrides.size() < accumOffsets.size())   accumStrides.addAll(pointStrides);
  while (accumOffsets.size() < accumShape.size()) {
    if (Shape.isRowVectorShape(arr.shape()))     accumOffsets.add(0,0);
 else     accumOffsets.add(0);
  }
  while (accumStrides.size() < accumOffsets.size()) {
    if (arr.isRowVector())     accumStrides.add(0,arr.elementStride());
 else     accumStrides.add(arr.elementStride());
  }
  this.strides=Ints.toArray(accumStrides);
  this.shapes=Ints.toArray(accumShape);
  this.offsets=Ints.toArray(accumOffsets);
  if (numPointIndexes > 0 && !pointStrides.isEmpty()) {
    if (newAxesPrepend >= 1) {
      while (pointStrides.size() < accumOffsets.size()) {
        pointStrides.add(1);
      }
      for (int i=0; i < accumStrides.size(); i++) {
        if (accumStrides.get(i) == 0)         pointStrides.set(i,0);
      }
    }
    while (pointOffsets.size() < pointStrides.size()) {
      pointOffsets.add(0);
    }
    if (arr.isRowVector() && !intervalStrides.isEmpty() && pointOffsets.get(0) == 0)     this.offset=indexes[1].offset();
 else     this.offset=ArrayUtil.dotProduct(pointOffsets,pointStrides);
  }
 else   if (numIntervals > 0) {
    this.offset=ArrayUtil.dotProduct(accumOffsets,accumStrides) / numIntervals;
  }
 else   this.offset=ArrayUtil.calcOffset(accumShape,accumOffsets,accumStrides);
}

Fixed version (ground truth):
/** 
 * Based on the passed in array compute the shape,offsets, and strides for the given indexes
 * @param indexes the indexesto compute this based on
 */
public void exec(INDArrayIndex... indexes){
  indexes=NDArrayIndex.resolve(arr.shape(),indexes);
  int[] shape=arr.shape();
  int numIntervals=0;
  int newAxesPrepend=0;
  boolean encounteredAll=false;
  List<Integer> accumShape=new ArrayList<>();
  List<Integer> accumStrides=new ArrayList<>();
  List<Integer> accumOffsets=new ArrayList<>();
  List<Integer> intervalStrides=new ArrayList<>();
  List<Integer> pointStrides=new ArrayList<>();
  List<Integer> pointOffsets=new ArrayList<>();
  int numPointIndexes=0;
  int shapeIndex=0;
  int strideIndex=0;
  List<Integer> prependNewAxes=new ArrayList<>();
  for (int i=0; i < indexes.length; i++) {
    INDArrayIndex idx=indexes[i];
    if (idx instanceof NDArrayIndexAll)     encounteredAll=true;
    if (idx instanceof PointIndex) {
      pointOffsets.add(idx.offset());
      pointStrides.add(arr.stride(strideIndex));
      numPointIndexes++;
      shapeIndex++;
      strideIndex++;
      continue;
    }
 else     if (idx instanceof NewAxis) {
      if (encounteredAll) {
        prependNewAxes.add(i);
      }
 else       newAxesPrepend++;
      continue;
    }
 else     if (idx instanceof IntervalIndex && !(idx instanceof NDArrayIndexAll) || idx instanceof SpecifiedIndex) {
      if (idx instanceof IntervalIndex) {
        accumStrides.add(arr.stride(strideIndex) * idx.stride());
        intervalStrides.add(idx.stride());
        if (idx.stride() > 1)         numIntervals++;
      }
 else       accumStrides.add(arr.stride(strideIndex));
      accumShape.add(idx.length());
      if (idx instanceof IntervalIndex) {
        accumOffsets.add(idx.offset());
      }
 else       accumOffsets.add(idx.offset());
      shapeIndex++;
      strideIndex++;
      continue;
    }
    accumShape.add(shape[shapeIndex++]);
    accumStrides.add(arr.stride(strideIndex++));
    accumOffsets.add(idx.offset());
  }
  while (shapeIndex < shape.length) {
    if (Shape.isVector(shape)) {
      accumShape.add(1);
      shapeIndex++;
    }
 else     accumShape.add(shape[shapeIndex++]);
  }
  int delta=(shape.length <= 2 ? shape.length : shape.length - numPointIndexes);
  boolean needsFilledIn=accumShape.size() != accumStrides.size() && accumOffsets.size() != accumShape.size();
  while (accumOffsets.size() < delta && needsFilledIn)   accumOffsets.add(0);
  while (accumShape.size() < 2) {
    if (Shape.isRowVectorShape(arr.shape()))     accumShape.add(0,1);
 else     accumShape.add(1);
  }
  while (strideIndex < accumShape.size()) {
    accumStrides.add(arr.stride(strideIndex++));
  }
  if (newAxesPrepend > 0) {
    for (int i=0; i < newAxesPrepend; i++) {
      accumShape.add(0,1);
      accumStrides.add(0,0);
      accumOffsets.add(0,0);
    }
  }
  int numAdded=0;
  for (int i=0; i < prependNewAxes.size(); i++) {
    accumShape.add(prependNewAxes.get(i) - numAdded,1);
    accumStrides.add(prependNewAxes.get(i) - numAdded,0);
    numAdded++;
  }
  int trailingZeroRemove=accumOffsets.size() - 1;
  while (accumOffsets.size() > accumShape.size()) {
    if (accumOffsets.get(trailingZeroRemove) == 0)     accumOffsets.remove(accumOffsets.size() - 1);
    trailingZeroRemove--;
  }
  if (accumStrides.size() < accumOffsets.size())   accumStrides.addAll(pointStrides);
  while (accumOffsets.size() < accumShape.size()) {
    if (Shape.isRowVectorShape(arr.shape()))     accumOffsets.add(0,0);
 else     accumOffsets.add(0);
  }
  if (Shape.isMatrix(shape)) {
    if (indexes[0] instanceof PointIndex && indexes[1] instanceof NDArrayIndexAll)     Collections.reverse(accumShape);
  }
  this.shapes=Ints.toArray(accumShape);
  boolean isColumnVector=Shape.isColumnVectorShape(this.shapes);
  while (accumStrides.size() < accumOffsets.size()) {
    if (!isColumnVector)     accumStrides.add(0,arr.elementStride());
 else     accumStrides.add(arr.elementStride());
  }
  this.strides=Ints.toArray(accumStrides);
  this.offsets=Ints.toArray(accumOffsets);
  if (numPointIndexes > 0 && !pointStrides.isEmpty()) {
    if (newAxesPrepend >= 1) {
      while (pointStrides.size() < accumOffsets.size()) {
        pointStrides.add(1);
      }
      for (int i=0; i < accumStrides.size(); i++) {
        if (accumStrides.get(i) == 0)         pointStrides.set(i,0);
      }
    }
    while (pointOffsets.size() < pointStrides.size()) {
      pointOffsets.add(0);
    }
    if (arr.isRowVector() && !intervalStrides.isEmpty() && pointOffsets.get(0) == 0)     this.offset=indexes[1].offset();
 else     this.offset=ArrayUtil.dotProduct(pointOffsets,pointStrides);
  }
 else   if (numIntervals > 0) {
    this.offset=ArrayUtil.dotProduct(accumOffsets,accumStrides) / numIntervals;
  }
 else   this.offset=ArrayUtil.calcOffset(accumShape,accumOffsets,accumStrides);
}