3.4.8 How Can I Rotate a Variable?

The C language does not have a rotate operator, but rotations can be performed using the shift and bitwise OR operators. Since the 32-bit devices have a rotate instruction, the compiler will look for code expressions that implement rotates (using shifts and ORs) and use the rotate instruction in the generated output wherever possible.

For the following example C code:
unsigned rotate_left (unsigned a, unsigned s)
{
  return (a << s) | (a >> (32 - s));
}
the compiler may generate assembly instructions similar to the following:
rotate_left:
  rsb r1, r1, #32
  rors r0, r0, r1
  bx lr