Flipping and circular shifting of a matrix expressed as single pointer