5.2.3 Shift Rows
This step operates on the rows of the current State. The first row is left untouched, while the last three are cycled left one, two, and three times, respectively. To cycle left once, the leftmost byte is moved to the rightmost column, and the three remaining bytes are moved one column to the left. The process is shown in the following figure.
The naive implementation would be to write a subroutine that cycles a row left one time, and then call it the required number of times on each row. However, tests show that implementing the byte shuffling directly, without any loops or subroutines, results in only a small penalty in code size but a significant gain (3x) in speed. Therefore, the direct implementation has been chosen. Refer to the ShiftRows() function in the source code for details.