static boolean equivalentReferences(AddressTranslator p2ToP1Translator, Reference p1Ref,
			final Reference p2Ref) {
		if (p1Ref == p2Ref) {
			return true;
		}
		if (p1Ref == null || p2Ref == null) {
			return false;
		}
		if (p1Ref.getOperandIndex() != p2Ref.getOperandIndex() ||
			p1Ref.getReferenceType() != p2Ref.getReferenceType() ||
			//        		p1Ref.getSource() != p2Ref.getSource() || // ignore source type since we can't change it anyway.
			p1Ref.isPrimary() != p2Ref.isPrimary()) {
			return false;
		}
		Address fromAddr1 = p1Ref.getFromAddress();
		Address fromAddr2 = p2Ref.getFromAddress();
		Address fromAddr2AsP1 = p2ToP1Translator.getAddress(fromAddr2);
		if (!fromAddr1.equals(fromAddr2AsP1)) {
			return false;
		}
		if (!p1Ref.isExternalReference()) {
			Address toAddr1 = p1Ref.getToAddress();
			Address toAddr2 = p2Ref.getToAddress();
			Address toAddr2AsP1 = p2ToP1Translator.getAddress(toAddr2);
			if (!toAddr1.equals(toAddr2AsP1)) {
				return false;
			}
		}
		Symbol p1Symbol = p2ToP1Translator.getDestinationProgram()
				.getSymbolTable()
				.getSymbol(p1Ref.getSymbolID());
		Symbol p2Symbol =
			p2ToP1Translator.getSourceProgram().getSymbolTable().getSymbol(p2Ref.getSymbolID());
		if (!ProgramDiff.equivalentSymbols(p2ToP1Translator, p1Symbol, p2Symbol)) {
			return false;
		}

		// Entry Point Reference
		if (p1Ref.isEntryPointReference()) {
			return p2Ref.isEntryPointReference();
		}
		// External Reference
		if (p1Ref.isExternalReference()) {
			if (!p2Ref.isExternalReference()) {
				return false;
			}
			ExternalReference extRef1 = (ExternalReference) p1Ref;
			ExternalReference extRef2 = (ExternalReference) p2Ref;
			ExternalLocation extLoc1 = extRef1.getExternalLocation();
			ExternalLocation extLoc2 = extRef2.getExternalLocation();
			return SystemUtilities.isEqual(extLoc1, extLoc2);
		}
		// Offset Reference
		if (p1Ref.isOffsetReference()) {
			if (!p2Ref.isOffsetReference()) {
				return false;
			}
			OffsetReference offsetRef1 = (OffsetReference) p1Ref;
			OffsetReference offsetRef2 = (OffsetReference) p2Ref;
			return offsetRef1.getOffset() == offsetRef2.getOffset();
		}
		// Shifted Reference
		if (p1Ref.isShiftedReference()) {
			if (!p2Ref.isShiftedReference()) {
				return false;
			}
			ShiftedReference shiftedRef1 = (ShiftedReference) p1Ref;
			ShiftedReference shiftedRef2 = (ShiftedReference) p2Ref;
			return shiftedRef1.getShift() == shiftedRef2.getShift();
		}
		// Stack Reference
		if (p1Ref.isStackReference()) {
			if (!p2Ref.isStackReference()) {
				return false;
			}
			StackReference stackRef1 = (StackReference) p1Ref;
			StackReference stackRef2 = (StackReference) p2Ref;
			return stackRef1.getStackOffset() == stackRef2.getStackOffset();
		}
		// Register Reference
		if (p1Ref.isRegisterReference()) {
			if (!p2Ref.isRegisterReference()) {
				return false;
			}
		}
		// Memory Reference
		if (p1Ref.isMemoryReference()) {
			return p2Ref.isMemoryReference();
		}

		return true; // Don't recognize this kind of reference.
	}
Determine if two references from the two programs are equivalent.
@param p2ToP1Translator program2-to-program1 address translator
@param p1Ref reference from program1
@param p2Ref reference from program2
@return true if references are equivalent
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramDiff.java