Rotates the range [mid-left, mid+right) such that the element at mid becomes the first
element. Equivalently, rotates the range left elements to the left or right elements to the
right.
Algorithm 2 is used for small values of left + right or for large T. The elements
are moved into their final positions one at a time starting at mid - left and advancing by
right steps modulo left + right, such that only one temporary is needed. Eventually, we
arrive back at mid - left. However, if gcd(left + right, right) is not 1, the above steps
skipped over elements. For example:
Algorithm 1 is used if min(left, right) is small enough to fit onto a stack buffer. The
min(left, right) elements are copied onto the buffer, memmove is applied to the others, and
the ones on the buffer are moved back into the hole on the opposite side of where they
originated.