Well, but it's inside the loop -- this is binary exponentiation. So x^9 = x^8 * x (since that's the binary representation of 9), and the repeated squaring of alap gives alap^2, alap^4, alap^8, etc., so that when the right-most bit of the power is one the correct power of alap gets multiplied in.