public static int getOffcutXRefCount(CodeUnit cu) {

		Program prog = cu.getProgram();
		if (prog == null) {
			return 0;
		}
		int refCount = 0;
		if (cu.getLength() > 1) {
			ReferenceManager refMgr = prog.getReferenceManager();
			AddressSet set =
				new AddressSet(cu.getMinAddress().add(1), cu.getMaxAddress());
			AddressIterator iter = refMgr.getReferenceDestinationIterator(set, true);
			while (iter.hasNext()) {
				Address addr = iter.next();
				ReferenceIterator refIter = refMgr.getReferencesTo(addr);
				while (refIter.hasNext()) {
					refIter.next();
					++refCount;
				}
			}
		}
		return refCount;
	}
Returns the count of all offcut xref addresses to the specified code unit
@param cu the code unit to generate the offcut xrefs
@return count of all offcut xrefs to the code unit
Ghidra/Features/Base/src/main/java/ghidra/app/util/XReferenceUtil.java