AES S-box calculation
This is first half of the calculation presented on the Wiki page.

Notice that every bit of the result is actually a XOR of just five bits:



Now we slightly modify the algorithm you wrote to create five numbers by rotating the original number to the left and only then XOR them together:



As you can see the result is exactly the same.