rem: if (first->count <= i1) { if (second->count > i2) { clipping_rect secondRect = second->data[i2];
add: *index1 = -1; *index2 = -1;  long foundCount = 0; long x = 0;  for (x = i1; x < first->count; x++) { if (first->data[x].bottom >= top && *index1 == -1) *index1 = x;  if (first->data[x].top <= top && first->data[x].bottom >= bottom) { lefts[foundCount] = first->data[x].left; rights[foundCount] = first->data[x].right; foundCount++; } else if (first->data[x].top > bottom) break; }  if (*index1 == -1) *index1 = i1;  for (x = i2; x < second->count; x++) { if (second->data[x].bottom >= top && *index2 == -1) *index2 = x;
context: r_or(long top, long bottom, BRegion *first, BRegion *second, BRegion *dest, long *index1, long *index2){	PRINT(("%s\n", __PRETTY_FUNCTION__));	long i1 = *index1;	long i2 = *index2;		if (first->count <= i1) {		if (second->count > i2) {			clipping_rect secondRect = second->data[i2];					secondRect.top = max_c(secondRect.top, top);			secondRect.bottom = min_c(secondRect.bottom, bottom);						if (valid_rect(secondRect))				dest->_AddRect(secondRect);			if (second->data[i2].bottom <= bottom)				i2++;	 	}	 		 } else if (second->count <= i2) {	 	 	clipping_rect firstRect = first->data[i1];	 		 	firstRect.top = max_c(firstRect.top, top);	 	firstRect.bottom = min_c(firstRect.bottom, bottom);	 		 	if (valid_rect(firstRect))	 		dest->_AddRect(firstRect);	 	if (first->data[i1].bottom <= bottom)	 		i1++;	 			 } else {	 	clipping_rect firstRect = first->data[i1];	 	clipping_rect secondRect = second->data[i2];	 		 	firstRect.top = max_c(firstRect.top, top);	 	firstRect.bottom = min_c(firstRect.bottom, bottom);	 		 	secondRect.top = max_c(secondRect.top, top);		secondRect.bottom = min_c(secondRect.bottom, bottom);	 		 	if (valid_rect(sect_rect(firstRect, secondRect)))	 		dest->_AddRect(union_rect(firstRect, secondRect));	 		 	else {	 		if (valid_rect(firstRect))	 			dest->_AddRect(firstRect);	 		if (valid_rect(secondRect))	 			dest->_AddRect(secondRect);	 	}	 			 	if (first->data[i1].bottom <= bottom)	 		i1++;	 	if (second->data[i2].bottom <= bottom)			i2++;	}			*index1 = i1;	*index2 = i2;    }