curEnd to 0, farCanReach to 0, and total to 0.curEnd is less than time.total to count the number of clips used.curEnd.farCanReach to the maximum of its current value and the end time of the current clip.farCanReach is equal to curEnd, return -1.curEnd to farCanReach.curEnd is greater than or equal to time, return total.