Program: 3323
Project: 3323
Buggy source:
/** 
 * Prepares two arrays for raw iteration linearly through the data. It uses the same data for allocation
 * @param dst the first array
 * @param src the second array
 */
public static Pair<INDArray,INDArray> prepareTwoRawArrayIter(INDArray dst,INDArray src){
  StridePermutation[] perms=Shape.createSortedStrides(dst.stride());
  int[] outShape=new int[dst.rank()];
  int[] outStridesA=new int[dst.rank()];
  int[] outStridesB=new int[src.rank()];
  int dstOffset=dst.offset();
  int sourceOffset=src.offset();
  for (int i=0; i < dst.rank(); i++) {
    int iPerm=perms[dst.rank() - i - i].getPermutation();
    outShape[i]=dst.size(iPerm);
    outStridesA[i]=dst.stride(iPerm);
    outStridesB[i]=dst.stride(iPerm);
  }
  for (int i=0; i < dst.rank(); i++) {
    int outStrideA=outStridesA[i];
    int outStrideB=outStridesB[i];
    int shapeI=outShape[i];
    if (outStrideA < 0) {
      dstOffset+=outStrideA * shapeI - 1;
      sourceOffset+=outStrideB * shapeI - 1;
      outStridesA[i]-=outStrideA;
      outStridesB[i]-=outStrideB;
    }
  }
  for (int i=0, j=1; j < dst.rank(); j++) {
    if (outShape[i] == 1) {
      outShape[i]=outShape[j];
      outStridesA[i]=outStridesA[j];
      outStridesB[i]=outStridesB[j];
    }
 else     if (outShape[j] == 1) {
    }
 else     if (outStridesA[i] * outShape[i] == outStridesA[j] && outStridesB[i] * outShape[i] == outStridesB[j]) {
      outShape[i]*=outShape[j];
    }
 else {
      i++;
      outShape[i]=outShape[j];
      outStridesA[i]=outStridesA[j];
      outStridesB[i]=outStridesB[j];
    }
  }
  INDArray retDst=Nd4j.create(dst.data(),outShape,outStridesA,dstOffset,dst.ordering());
  INDArray sourceDst=Nd4j.create(src.data(),outShape,outStridesB,sourceOffset,src.ordering());
  return new Pair<>(retDst,sourceDst);
}

Fixed version (ground truth):
/** 
 * Prepares two arrays for raw iteration linearly through the data. It uses the same data for allocation
 * @param dst the first array
 * @param src the second array
 */
public static Pair<INDArray,INDArray> prepareTwoRawArrayIter(INDArray dst,INDArray src){
  StridePermutation[] perms=Shape.createSortedStrides(dst.stride());
  int[] outShape=new int[dst.rank()];
  int[] outStridesA=new int[dst.rank()];
  int[] outStridesB=new int[src.rank()];
  int dstOffset=dst.offset();
  int sourceOffset=src.offset();
  for (int i=0; i < dst.rank(); i++) {
    int iPerm=perms[dst.rank() - i - 1].getPermutation();
    outShape[i]=dst.size(iPerm);
    outStridesA[i]=dst.stride(iPerm);
    outStridesB[i]=src.stride(iPerm);
  }
  for (int i=0; i < dst.rank(); i++) {
    int outStrideA=outStridesA[i];
    int outStrideB=outStridesB[i];
    int shapeI=outShape[i];
    if (outStrideA < 0) {
      dstOffset+=outStrideA * shapeI - 1;
      sourceOffset+=outStrideB * shapeI - 1;
      outStridesA[i]-=outStrideA;
      outStridesB[i]-=outStrideB;
    }
  }
  for (int i=0, j=1; j < dst.rank(); j++) {
    if (outShape[i] == 1) {
      outShape[i]=outShape[j];
      outStridesA[i]=outStridesA[j];
      outStridesB[i]=outStridesB[j];
    }
 else     if (outShape[j] == 1) {
    }
 else     if (outStridesA[i] * outShape[i] == outStridesA[j] && outStridesB[i] * outShape[i] == outStridesB[j]) {
      outShape[i]*=outShape[j];
    }
 else {
      i++;
      outShape[i]=outShape[j];
      outStridesA[i]=outStridesA[j];
      outStridesB[i]=outStridesB[j];
    }
  }
  INDArray retDst=Nd4j.create(dst.data(),outShape,outStridesA,dstOffset,dst.ordering());
  INDArray sourceDst=Nd4j.create(src.data(),src.shape(),outStridesB,sourceOffset,src.ordering());
  return new Pair<>(retDst,sourceDst);
}