Program: 3148
Project: 3148
Buggy source:
/** 
 * @param indexes
 * @return
 */
public boolean tryShortCircuit(INDArrayIndex... indexes){
  int pointIndex=0;
  int interval=0;
  int newAxis=0;
  int numAll=0;
  int numSpecified=0;
  for (int i=0; i < indexes.length; i++) {
    if (indexes[i] instanceof PointIndex) {
      pointIndex++;
    }
    if (indexes[i] instanceof SpecifiedIndex)     numSpecified++;
 else     if (indexes[i] instanceof IntervalIndex && !(indexes[i] instanceof NDArrayIndexAll))     interval++;
 else     if (indexes[i] instanceof NewAxis)     newAxis++;
 else     if (indexes[i] instanceof NDArrayIndexAll)     numAll++;
  }
  if (arr.isVector()) {
    if (indexes[0] instanceof NDArrayIndexAll && indexes.length == 1) {
      offset=0;
      this.shapes=LongUtils.toLongs(arr.shape());
      this.strides=LongUtils.toLongs(arr.stride());
      this.offsets=new long[arr.rank()];
      return true;
    }
 else     if (indexes[0] instanceof PointIndex && indexes[1] instanceof NDArrayIndexAll) {
      this.shapes=new long[2];
      this.strides=new long[2];
      for (int i=0; i < 2; i++) {
        shapes[i]=1;
        strides[i]=arr.stride(i);
      }
      this.offsets=new long[arr.rank()];
      this.offset=indexes[0].offset() * ArrayUtil.prod(strides);
      return true;
    }
    if (indexes[0] instanceof PointIndex && indexes.length == 1) {
      this.shapes=new long[2];
      this.strides=new long[2];
      for (int i=0; i < 2; i++) {
        shapes[i]=1;
        strides[i]=arr.stride(i);
      }
      this.offset=indexes[0].offset() * ArrayUtil.prod(strides);
      return true;
    }
    if (arr.isRowVector()) {
      if (indexes[0] instanceof PointIndex) {
        if (indexes.length > 1 && indexes[1] instanceof IntervalIndex) {
          offset=indexes[1].offset();
          this.shapes=new long[2];
          shapes[0]=1;
          shapes[1]=indexes[1].length();
          this.strides=new long[2];
          strides[0]=0;
          strides[1]=indexes[1].stride();
          this.offsets=new long[2];
          return true;
        }
      }
 else       if (indexes[0] instanceof IntervalIndex) {
      }
 else {
        return false;
      }
    }
 else {
      if (indexes.length > 1 && indexes[1] instanceof PointIndex) {
        if (indexes[0] instanceof IntervalIndex) {
          offset=indexes[0].offset();
          this.shapes=new long[2];
          shapes[1]=1;
          shapes[0]=indexes[1].length();
          this.strides=new long[2];
          strides[1]=0;
          strides[0]=indexes[1].stride();
          this.offsets=new long[2];
          return true;
        }
      }
 else       if (indexes[0] instanceof IntervalIndex) {
      }
 else {
        return false;
      }
    }
  }
  if (numSpecified > 0 && interval < 1 && newAxis < 1 && numAll > 0 && pointIndex < 1 && arr.rank() == 2) {
    shapes=new long[arr.rank()];
    strides=new long[arr.rank()];
    offsets=new long[arr.rank()];
    offset=0;
    boolean allSpecified=true;
    for (int i=0; i < 2; i++) {
      allSpecified=allSpecified && indexes[i] instanceof SpecifiedIndex;
    }
    for (int i=0; i < arr.rank(); i++) {
      if (indexes[i] instanceof SpecifiedIndex) {
        SpecifiedIndex specifiedIndex=(SpecifiedIndex)indexes[i];
        if (specifiedIndex.getIndexes().length >= arr.rank())         return false;
        shapes[i]=indexes[i].length();
        offsets[i]=indexes[i].offset();
        if (!allSpecified || i == 0 && allSpecified)         offset=offsets[i] * arr.stride(i);
        if (indexes[i].length() != 1) {
          strides[i]=arr.stride(i) * specifiedIndex.getIndexes()[i];
        }
 else         strides[i]=1;
      }
 else       if (indexes[i] instanceof NDArrayIndexAll) {
        shapes[i]=arr.size(i);
        strides[i]=arr.tensorAlongDimension(0,i).elementWiseStride();
      }
 else       throw new IllegalArgumentException("String_Node_Str" + indexes[i].getClass().getName());
    }
    return true;
  }
  if (numSpecified < 1 && interval < 1 && newAxis < 1 && pointIndex > 0 && numAll > 0) {
    int minDimensions=Math.max(arr.rank() - pointIndex,2);
    long[] shape=new long[minDimensions];
    Arrays.fill(shape,1);
    long[] stride=new long[minDimensions];
    Arrays.fill(stride,arr.elementStride());
    long[] offsets=new long[minDimensions];
    long offset=0;
    int currIndex=0;
    int arrIndex=0;
    for (int i=0; i < indexes.length; i++) {
      if (indexes[i] instanceof NDArrayIndexAll) {
        shape[currIndex]=arr.size(arrIndex);
        stride[currIndex]=arr.stride(arrIndex);
        currIndex++;
        arrIndex++;
      }
 else {
        offset+=indexes[i].offset() * arr.stride(i);
        arrIndex++;
      }
    }
    if (arr.isMatrix() && indexes[0] instanceof PointIndex) {
      shape=ArrayUtil.reverseCopy(shape);
      stride=ArrayUtil.reverseCopy(stride);
    }
 else     if (arr.isMatrix() && indexes[0] instanceof PointIndex && indexes[1] instanceof IntervalIndex) {
      shape=new long[2];
      shape[0]=1;
      IntervalIndex idx=(IntervalIndex)indexes[1];
      shape[1]=idx.length();
    }
    this.strides=stride;
    this.shapes=shape;
    this.offsets=offsets;
    this.offset=offset;
    return true;
  }
 else   if (numSpecified < 1 && interval > 0 && newAxis < 1 && pointIndex < 1 && numAll > 0) {
    int minDimensions=Math.max(arr.rank(),2);
    long[] shape=new long[minDimensions];
    Arrays.fill(shape,1);
    long[] stride=new long[minDimensions];
    Arrays.fill(stride,arr.elementStride());
    long[] offsets=new long[minDimensions];
    for (int i=0; i < shape.length; i++) {
      if (indexes[i] instanceof NDArrayIndexAll) {
        shape[i]=arr.size(i);
        stride[i]=arr.stride(i);
        offsets[i]=indexes[i].offset();
      }
 else       if (indexes[i] instanceof IntervalIndex) {
        shape[i]=indexes[i].length();
        stride[i]=indexes[i].stride() * arr.stride(i);
        offsets[i]=indexes[i].offset();
      }
    }
    this.shapes=shape;
    this.strides=stride;
    this.offsets=offsets;
    this.offset=0;
    for (int i=0; i < indexes.length; i++) {
      offset+=offsets[i] * (stride[i] / indexes[i].stride());
    }
    return true;
  }
 else   if (numSpecified < 1 && interval < 1 && newAxis > 0 && pointIndex < 1 && numAll > 0) {
    int minDimensions=Math.max(arr.rank(),2) + newAxis;
    long[] shape=new long[minDimensions];
    Arrays.fill(shape,1);
    long[] stride=new long[minDimensions];
    Arrays.fill(stride,arr.elementStride());
    long[] offsets=new long[minDimensions];
    int prependNewAxes=0;
    boolean allFirst=false;
    int shapeAxis=0;
    int allEncountered=0;
    for (int i=0; i < minDimensions; i++) {
      if (i >= (indexes.length)) {
        shape[i]=arr.size(allEncountered);
        stride[i]=arr.stride(allEncountered);
        allEncountered++;
      }
 else       if (!(indexes[i] instanceof NewAxis) && indexes[i] instanceof NDArrayIndexAll) {
        shape[allEncountered]=arr.size(allEncountered);
        stride[allEncountered]=arr.stride(allEncountered);
        allEncountered++;
      }
    }
    this.shapes=shape;
    this.strides=stride;
    this.offsets=offsets;
    for (int i=0; i < indexes.length; i++) {
      offset+=offsets[i] * (stride[i] / indexes[i].stride());
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @param indexes
 * @return
 */
public boolean tryShortCircuit(INDArrayIndex... indexes){
  int pointIndex=0;
  int interval=0;
  int newAxis=0;
  int numAll=0;
  int numSpecified=0;
  for (int i=0; i < indexes.length; i++) {
    if (indexes[i] instanceof PointIndex) {
      pointIndex++;
    }
    if (indexes[i] instanceof SpecifiedIndex)     numSpecified++;
 else     if (indexes[i] instanceof IntervalIndex && !(indexes[i] instanceof NDArrayIndexAll))     interval++;
 else     if (indexes[i] instanceof NewAxis)     newAxis++;
 else     if (indexes[i] instanceof NDArrayIndexAll)     numAll++;
  }
  if (arr.isVector()) {
    if (indexes[0] instanceof NDArrayIndexAll && indexes.length == 1) {
      offset=0;
      this.shapes=LongUtils.toLongs(arr.shape());
      this.strides=LongUtils.toLongs(arr.stride());
      this.offsets=new long[arr.rank()];
      return true;
    }
 else     if (indexes[0] instanceof PointIndex && indexes[1] instanceof NDArrayIndexAll) {
      this.shapes=new long[2];
      this.strides=new long[2];
      for (int i=0; i < 2; i++) {
        shapes[i]=1;
        strides[i]=arr.stride(i);
      }
      this.offsets=new long[arr.rank()];
      if (arr.isRowVector())       this.offset=indexes[0].offset() * strides[1];
 else {
        this.offset=indexes[0].offset() * strides[0];
      }
      return true;
    }
    if (indexes[0] instanceof PointIndex && indexes.length == 1) {
      this.shapes=new long[2];
      this.strides=new long[2];
      for (int i=0; i < 2; i++) {
        shapes[i]=1;
        strides[i]=arr.stride(i);
      }
      if (arr.isRowVector())       this.offset=indexes[0].offset() * strides[1];
 else {
        this.offset=indexes[0].offset() * strides[0];
      }
      return true;
    }
    if (arr.isRowVector()) {
      if (indexes[0] instanceof PointIndex) {
        if (indexes.length > 1 && indexes[1] instanceof IntervalIndex) {
          offset=indexes[1].offset();
          this.shapes=new long[2];
          shapes[0]=1;
          shapes[1]=indexes[1].length();
          this.strides=new long[2];
          strides[0]=0;
          strides[1]=indexes[1].stride();
          this.offsets=new long[2];
          return true;
        }
      }
 else       if (indexes[0] instanceof IntervalIndex) {
      }
 else {
        return false;
      }
    }
 else {
      if (indexes.length > 1 && indexes[1] instanceof PointIndex) {
        if (indexes[0] instanceof IntervalIndex) {
          offset=indexes[0].offset();
          this.shapes=new long[2];
          shapes[1]=1;
          shapes[0]=indexes[1].length();
          this.strides=new long[2];
          strides[1]=0;
          strides[0]=indexes[1].stride();
          this.offsets=new long[2];
          return true;
        }
      }
 else       if (indexes[0] instanceof IntervalIndex) {
      }
 else {
        return false;
      }
    }
  }
  if (numSpecified > 0 && interval < 1 && newAxis < 1 && numAll > 0 && pointIndex < 1 && arr.rank() == 2) {
    shapes=new long[arr.rank()];
    strides=new long[arr.rank()];
    offsets=new long[arr.rank()];
    offset=0;
    boolean allSpecified=true;
    for (int i=0; i < 2; i++) {
      allSpecified=allSpecified && indexes[i] instanceof SpecifiedIndex;
    }
    for (int i=0; i < arr.rank(); i++) {
      if (indexes[i] instanceof SpecifiedIndex) {
        SpecifiedIndex specifiedIndex=(SpecifiedIndex)indexes[i];
        if (specifiedIndex.getIndexes().length >= arr.rank())         return false;
        shapes[i]=indexes[i].length();
        offsets[i]=indexes[i].offset();
        if (!allSpecified || i == 0 && allSpecified)         offset=offsets[i] * arr.stride(i);
        if (indexes[i].length() != 1) {
          strides[i]=arr.stride(i) * specifiedIndex.getIndexes()[i];
        }
 else         strides[i]=1;
      }
 else       if (indexes[i] instanceof NDArrayIndexAll) {
        shapes[i]=arr.size(i);
        strides[i]=arr.tensorAlongDimension(0,i).elementWiseStride();
      }
 else       throw new IllegalArgumentException("String_Node_Str" + indexes[i].getClass().getName());
    }
    return true;
  }
  if (numSpecified < 1 && interval < 1 && newAxis < 1 && pointIndex > 0 && numAll > 0) {
    int minDimensions=Math.max(arr.rank() - pointIndex,2);
    long[] shape=new long[minDimensions];
    Arrays.fill(shape,1);
    long[] stride=new long[minDimensions];
    Arrays.fill(stride,arr.elementStride());
    long[] offsets=new long[minDimensions];
    long offset=0;
    int currIndex=0;
    int arrIndex=0;
    for (int i=0; i < indexes.length; i++) {
      if (indexes[i] instanceof NDArrayIndexAll) {
        shape[currIndex]=arr.size(arrIndex);
        stride[currIndex]=arr.stride(arrIndex);
        currIndex++;
        arrIndex++;
      }
 else {
        offset+=indexes[i].offset() * arr.stride(i);
        arrIndex++;
      }
    }
    if (arr.isMatrix() && indexes[0] instanceof PointIndex) {
      shape=ArrayUtil.reverseCopy(shape);
      stride=ArrayUtil.reverseCopy(stride);
    }
 else     if (arr.isMatrix() && indexes[0] instanceof PointIndex && indexes[1] instanceof IntervalIndex) {
      shape=new long[2];
      shape[0]=1;
      IntervalIndex idx=(IntervalIndex)indexes[1];
      shape[1]=idx.length();
    }
    this.strides=stride;
    this.shapes=shape;
    this.offsets=offsets;
    this.offset=offset;
    return true;
  }
 else   if (numSpecified < 1 && interval > 0 && newAxis < 1 && pointIndex < 1 && numAll > 0) {
    int minDimensions=Math.max(arr.rank(),2);
    long[] shape=new long[minDimensions];
    Arrays.fill(shape,1);
    long[] stride=new long[minDimensions];
    Arrays.fill(stride,arr.elementStride());
    long[] offsets=new long[minDimensions];
    for (int i=0; i < shape.length; i++) {
      if (indexes[i] instanceof NDArrayIndexAll) {
        shape[i]=arr.size(i);
        stride[i]=arr.stride(i);
        offsets[i]=indexes[i].offset();
      }
 else       if (indexes[i] instanceof IntervalIndex) {
        shape[i]=indexes[i].length();
        stride[i]=indexes[i].stride() * arr.stride(i);
        offsets[i]=indexes[i].offset();
      }
    }
    this.shapes=shape;
    this.strides=stride;
    this.offsets=offsets;
    this.offset=0;
    for (int i=0; i < indexes.length; i++) {
      offset+=offsets[i] * (stride[i] / indexes[i].stride());
    }
    return true;
  }
 else   if (numSpecified < 1 && interval < 1 && newAxis > 0 && pointIndex < 1 && numAll > 0) {
    int minDimensions=Math.max(arr.rank(),2) + newAxis;
    long[] shape=new long[minDimensions];
    Arrays.fill(shape,1);
    long[] stride=new long[minDimensions];
    Arrays.fill(stride,arr.elementStride());
    long[] offsets=new long[minDimensions];
    int prependNewAxes=0;
    boolean allFirst=false;
    int shapeAxis=0;
    int allEncountered=0;
    for (int i=0; i < minDimensions; i++) {
      if (i >= (indexes.length)) {
        shape[i]=arr.size(allEncountered);
        stride[i]=arr.stride(allEncountered);
        allEncountered++;
      }
 else       if (!(indexes[i] instanceof NewAxis) && indexes[i] instanceof NDArrayIndexAll) {
        shape[allEncountered]=arr.size(allEncountered);
        stride[allEncountered]=arr.stride(allEncountered);
        allEncountered++;
      }
    }
    this.shapes=shape;
    this.strides=stride;
    this.offsets=offsets;
    for (int i=0; i < indexes.length; i++) {
      offset+=offsets[i] * (stride[i] / indexes[i].stride());
    }
    return true;
  }
  return false;
}