private static AddressSetView subtractBodyFromExisting(Program program, Address entry,
			AddressSetView newFuncBody, Map<Function, AddressSetView> bodyChangeMap,
			TaskMonitor monitor) throws CancelledException, OverlappingFunctionException {
		// get all functions that overlap new function body
		Iterator<Function> iter = program.getFunctionManager().getFunctionsOverlapping(newFuncBody);

		while (iter.hasNext()) {
			monitor.checkCancelled();
			Function overlapFunc = iter.next();
			Address overlapEntryPoint = overlapFunc.getEntryPoint();
			if (overlapEntryPoint.equals(entry)) {
				// function found is possibly existing function
				continue;
			}
			AddressSetView overlapFuncBody = overlapFunc.getBody();
			// catch functions that are place-holders for a function yet to be disassembled
			if (overlapFuncBody.getNumAddresses() == 1) {
				overlapFuncBody = getFunctionBody(program, overlapEntryPoint, false, monitor);
				if (overlapFuncBody.contains(entry)) {
					continue;
				}
			}

			// get new body for overlapping function, by carving out addresses that
			// should belong in the new function
			Address overlapEndAddr;
			if (overlapEntryPoint.compareTo(entry) < 0) {
				// overlap function is before, subtract from entry to end of new function
				overlapEndAddr = newFuncBody.getMaxAddress();
			}
			else {
				// overlap function is after, subtract from entry to entry of overlapping function
				overlapEndAddr = overlapEntryPoint.previous();
			}
			AddressSet overlapAddrsShouldBeInNewFunction = new AddressSet(entry, overlapEndAddr);
			AddressSetView newOverlapFuncBody =
				overlapFuncBody.subtract(overlapAddrsShouldBeInNewFunction);
			try {
				if (!overlapFuncBody.equals(newOverlapFuncBody)) {
					overlapFunc.setBody(newOverlapFuncBody); // set overlap body with new function body addresses removed
					bodyChangeMap.put(overlapFunc, overlapFuncBody); // save old overlap body
				}
				overlapFuncBody = newOverlapFuncBody;
			}
			catch (OverlappingFunctionException oe) {
				// do nothing, will just subtract entire overlapping body from new function body
			}

			// remove overlapping functions body from new function body
			newFuncBody = newFuncBody.subtract(overlapFuncBody);
		}

		return newFuncBody;
	}
Subtract this functions entire body from existing functions.
NewFuncBody keeps any overlapping code that occurs between its entry point and the next entry point.
This rule helps functions keep a contiguous function body if functions share code such as a return, or
even an internal branch.

NOTE: This will change the other functions bodies

@param entry - entry point of new function
@param newFuncBody - new functions body
@param bodyChangeMap - map of functions that have their bodies changed by creating this function
@param monitor task monitor

@return address set of non-overlapping function body, some addresses may be grabbed from existing functions

@throws CancelledException user cancelled
@throws OverlappingFunctionException existing functions overlap and couldn't reconcile
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/CreateFunctionCmd.java