private int getPurgeValue(Instruction instr) {
		if (instr.getFlowType().isCall()) {
			// is an override call-return, terminal/call
			// find a reference to a function, and take it's purge
			Reference[] referencesFrom = instr.getReferencesFrom();
			for (Reference reference : referencesFrom) {
				if (reference.getReferenceType().isFlow()) {
					Function functionAt =
						program.getFunctionManager().getFunctionAt(reference.getToAddress());
					// don't take the purge of a non-returning function
					if (functionAt != null && !functionAt.hasNoReturn()) {
						return functionAt.getStackPurgeSize();
					}
				}
			}
		}
		else {
			int tempPurge = 0;
			Scalar scalar = instr.getScalar(0);
			if (scalar != null) {
				tempPurge = (int) scalar.getSignedValue();
			}
			return tempPurge;
		}
		return -1;
	}
Given a terminating instruction, discover the purge value encoded in it
@param instr is the terminating instruction
@return the purge value (or -1 if a value can't be found)
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/FunctionPurgeAnalysisCmd.java