private Instruction findPurgeInstruction(AddressSetView body) {
		InstructionIterator iter = program.getListing().getInstructions(body, true);
		int count = 2048;
		Instruction backupPurge = null;
		while (iter.hasNext() && count > 0) {
			count--;
			Instruction instr = iter.next();

			FlowType ftype = instr.getFlowType();
			if (ftype.isTerminal()) {
				String mnemonicStr = instr.getMnemonicString().toLowerCase();
				if ("ret".equals(mnemonicStr) || "retf".equals(mnemonicStr)) {
					// x86 has a scalar operand to purge value from the stack
					return instr;
				}
				else if (ftype.isCall()) {
					backupPurge = instr;	// Use as last resort, if we can't find RET
				}
			}
		}

		return backupPurge;
	}
Find a terminating instruction in the given set of addresses with a purge encoded in it.
This routine prefers a RET instruction, but if none is available, it will use a
terminating CALL.
@param body is the set of addresses to look through
@return a terminating instruction or null
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/FunctionPurgeAnalysisCmd.java