improve static local variable correlation

Improve the static local variable correlation logic, for the case where
a static local is used by multiple functions.  For each usage of the
variable, look for a corresponding usage in the base object.  If we find
at least one matching usage, consider it a twin.
Yeah.  The below loops were moved to the new function so that they could be called from this loop.