public Function replaceExternalFunction(Function toFunction, Function fromFunction,
			TaskMonitor monitor) throws CancelledException, UnsupportedOperationException {

		if (!toFunction.isExternal()) {
			throw new IllegalArgumentException("The function being replaced is not an external.");
		}
		if (!fromFunction.isExternal()) {
			throw new IllegalArgumentException(
				"The function being used as the source of information for a replace is not an external.");
		}

		StackFrame originFrame = fromFunction.getStackFrame();

		// Do not replace the function name here, since the symbols need to get sorted out first.
		// After the symbols are merged you will need to replace the function symbol in case the
		// merge of symbols was not chosen.

		if (toFunction.hasCustomVariableStorage() != fromFunction.hasCustomVariableStorage()) {
			toFunction.setCustomVariableStorage(fromFunction.hasCustomVariableStorage());
		}

		try {
			toFunction.setCallingConvention(fromFunction.getCallingConventionName());
		}
		catch (InvalidInputException e) {
			errorMsg.append(
				"Address = " + toFunction.getEntryPoint() + ": " + e.getMessage() + "\n");
		}
		StackFrame newToFrame = toFunction.getStackFrame();
		try {
			if (toFunction.hasCustomVariableStorage()) {
				Variable returnVar = fromFunction.getReturn();
				toFunction.setReturn(fromFunction.getReturnType(), returnVar.getVariableStorage(),
					returnVar.getSource());
			}
			else {
				toFunction.setReturnType(fromFunction.getReturnType(), SourceType.ANALYSIS);
			}
//			if (newToFrame.getParameterOffset() != originFrame.getParameterOffset()) {
//				newToFrame.setParameterOffset(originFrame.getParameterOffset());
//			}
		}
		catch (InvalidInputException e) {
			Msg.error(this, "Unexpected Exception: " + e.getMessage(), e);
			errorMsg.append(
				"InvalidInputException replacing external function: " + e.getMessage() + "\n");
		}

		if (newToFrame.getLocalSize() != originFrame.getLocalSize()) {
			newToFrame.setLocalSize(originFrame.getLocalSize());
		}

		toFunction.setStackPurgeSize(fromFunction.getStackPurgeSize());

		toFunction.setVarArgs(fromFunction.hasVarArgs());
		toFunction.setInline(fromFunction.isInline());
		toFunction.setNoReturn(fromFunction.hasNoReturn());
		toFunction.setSignatureSource(fromFunction.getSignatureSource());
		replaceVariables(toFunction, fromFunction, monitor);
//		restoreVariableRefs(newResultFunction, restoreRefs);

		return toFunction;
	}
Replaces the external result function with the origin Function.
<br>Note: This method will replace the function, but does not create
the parent namespace or put the function in the parent namespace.
This must be done separately.
@param toFunction the result function to replace.
@param fromFunction the function to use as the model when replacing the result function.
@param monitor the task monitor for notifying the user of this merge's progress.
@return the new function that was created in the resultListing or null
if no function was created. If null is returned you should call
getErrorMessage() to see if an error occurred.
@throws CancelledException if user cancels via the monitor.
@throws UnsupportedOperationException if the ProgramMerge translators are not
"one for one translators".
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramMerge.java