private void accumulateVariable(Function func, int offset, int refSize,
			List<Variable> sortedVariables) throws InvalidInputException {
		if (dontCreateNewVariables) {
			return;
		}

		int size = refSize > 0 ? refSize : 1;

		StackFrame frame = func.getStackFrame();
		int paramOffset = frame.getParameterOffset();
		boolean growsNegative = frame.growsNegative();

		boolean isParam =
			(growsNegative && offset >= paramOffset) || (!growsNegative && offset <= paramOffset);

		// Check exclusion options
		if (!createLocalStackVars && !isParam) {
			return;
		}
		if (!createStackParams && isParam) {
			return;
		}

		DataType dt;

		List<Variable> variablesIntersecting =
			getVariablesIntersecting(offset, size, sortedVariables);
		if (variablesIntersecting != null) {
			Variable firstVar = variablesIntersecting.get(0);
			if (firstVar.getLength() == size) {
				return; // exact match
			}

			int endOffset = (offset + size - 1);

			Variable lastVar = variablesIntersecting.get(variablesIntersecting.size() - 1);
			int minOffset = firstVar.getStackOffset();
			int maxOffset = lastVar.getStackOffset() + lastVar.getLength() - 1;
			for (int i = 0; i < variablesIntersecting.size(); i++) {
				sortedVariables.remove(variablesIntersecting.get(i));
			}

			// combine all intersecting variables into one
			if (minOffset > offset) {
				minOffset = offset;
			}
			if (maxOffset < endOffset) {
				maxOffset = endOffset;
			}

			dt = Undefined.getUndefinedDataType(Math.abs(maxOffset - minOffset) + 1);
			offset = minOffset;
		}
		else {
			dt = Undefined.getUndefinedDataType(refSize);
		}

		Variable var;
		if (isParam) {
			var = new ParameterImpl(null, dt, offset, program);
		}
		else {
			var = new LocalVariableImpl(null, dt, offset, program);
		}

		addVariableToSortedList(var, sortedVariables);
	}
Add non-overlapping stack variable to sorted variable list.  
The caller is responsible for ensuring that no overlap/conflict
with other variables in the list exist.
@param var
@param sortedVariables
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/NewFunctionStackAnalysisCmd.java