I have recently came up against this code lacking any comment. It finds minimal cyclic shift of word (this code specifically returns its index in string) and its called Duval al
It may be the same as this algorithm, whose explanation can be found here:
int ComputeMaxSufPos(string w)
{
int i = 0, n = w.Length;
for (int j = 1; j < n; ++j)
{
int c, k = 0;
while ((c = w[(i + k) % n].CompareTo(w[(j + k) % n])) == 0 && k != n)
{ k++; }
j += c > 0 ? k / (j - i) * (j - i) : k;
i = c > 0 ? j : i;
}
return i;
}