#include #include "common.h" #include "counts.h" /* rotates left */ void rotate(char *base, size_t size, size_t shift) { int dir = 1; counts[CURRENT].rotate++; while (shift) { while (2*shift <= size) { swap(base, base + dir*shift, shift); size -= shift; base += shift*dir; } shift = size - shift; base = dir > 0 ? base + size - shift : base - shift; dir *= -1; } }