First off, indent and space your code - it makes it a lot more readable. (I've done that for your question - see how much easier it is to see what is going on?)
The for loop is simple:
for (a; b; c)
1) Before the loop starts, the statement
is executed to initialise the loop.
2) Then the statement
is ecxcuted - if it returns a non-zero value the loop body
is executed, if not the loop exits.
3) After each time
has been executed,
is executed to advance the loop to the next iteration, and the process continues from (2) above.
Nice and simple, just like your code...
If you still don't understand your loop, then use the debugger to step through the loop while it is running and watch exactly what happens - that should help you to work it out in a few seconds.