If there are more than 512 items, the MoreChangesAvailable flag is set. In your code, the do...while(changeList.MoreChangesAvailable) will run till there are more items than returned by the SyncFolderItems() call.(in this case 512) Each time the do loop is executed, it sets the SyncState to the value obtained in the previous call at this line:
u.SyncStates[folderContentsChange.FolderId] = changeList.SyncState;
This ensures that you do not receive items already received.