public synchronized DecompileResults decompileFunction(Function func, int timeoutSecs,
			TaskMonitor monitor) {

		dtmanage.clearTemporaryIds();
		decompileMessage = "";

		if (program == null || (monitor != null && monitor.isCancelled())) {
			return new DecompileResults(func, pcodelanguage, compilerSpec, dtmanage,
				decompileMessage, null, DecompileProcess.DisposeState.DISPOSED_ON_CANCEL);
		}

		if (monitor != null) {
			monitor.addCancelledListener(monitorListener);
		}

		Decoder decoder = null;
		try {
			Address funcEntry = func.getEntryPoint();
			if (debug != null) {
				debug.setFunction(func);
			}
			decompCallback.setFunction(func, funcEntry, debug);
			EncodeDecodeSet activeSet = setupEncodeDecode(funcEntry);
			decoder = activeSet.mainResponse;
			verifyProcess();
			activeSet.mainQuery.clear();
			AddressXML.encode(activeSet.mainQuery, funcEntry);
			decompProcess.sendCommandTimeout("decompileAt", timeoutSecs, activeSet);
			decompileMessage = decompCallback.getNativeMessage();
		}
		catch (Exception ex) {
			decoder.clear(); 	// Clear any partial result
			decompileMessage = "Exception while decompiling " + func.getEntryPoint() + ": " +
				ex.getMessage() + '\n';
		}
		finally {
			if (monitor != null) {
				monitor.removeCancelledListener(monitorListener);
			}
		}

		try {
			if (debug != null) {
				XmlEncode xmlEncode = new XmlEncode();
				options.encode(xmlEncode, this);
				debug.shutdown(pcodelanguage, xmlEncode.toString());
				debug = null;
			}
		}
		catch (IOException e) {
			Msg.error(debug, "Could not dump debug info");
		}
		DecompileProcess.DisposeState processState;
		if (decompProcess != null) {
			processState = decompProcess.getDisposeState();
			if (decompProcess.getDisposeState() == DecompileProcess.DisposeState.NOT_DISPOSED) {
				flushCache();
			}
		}
		else {
			processState = DecompileProcess.DisposeState.DISPOSED_ON_CANCEL;
		}

		return new DecompileResults(func, pcodelanguage, compilerSpec, dtmanage, decompileMessage,
			decoder, processState);
	}
Decompile function
@param func function to be decompiled
@param timeoutSecs if decompile does not complete in this time a null value
will be returned and a timeout error set.
@param monitor optional task monitor which may be used to cancel decompile
@return decompiled function text
Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/DecompInterface.java