You request a loop from 1 to count , but you assume that count will always be greater than or equal to one; the generated code does not make this assumption.
So, if count is> = 1, then the loop counter is incremented every time:
for (x = 1; x < count; x++) { }
But if count 1, then the loop counter decreases every time:
for (x = 1; x > count; x--) { }
Lukeh
source share