Function wrapAround

Move index into [first, last] range in a cyclic manner

int wrapAround (
  int index,
  int first,
  int last
);

Example

assert(wrapAround(10, 0, 9) == 0);
assert(wrapAround(12, 0, 9) == 2);
assert(wrapAround(25, 0, 9) == 5);
assert(wrapAround(-2, 0, 9) == 8);
assert(wrapAround(-15, 0, 9) == 5);
assert(wrapAround(0, 0, 9) == 0);
assert(wrapAround(9, 0, 9) == 9);