public Function createFunctionBefore(Address address, Byte expectedFiller) {

		PseudoDisassembler pseudoDisassembler = new PseudoDisassembler(currentProgram);

		// skip any undefineds and get the defined instruction before the given address
		Instruction instructionBefore = getInstructionBefore(address);

		if (instructionBefore == null) {
			return null;
		}

		Address instBeforeAddr = instructionBefore.getAddress();

		Memory memory = currentProgram.getMemory();
		if (!memory.getBlock(address).equals(memory.getBlock(instBeforeAddr))) {
			return null;
		}

		// set some arbritrary limit on how far back to go
		if (address.subtract(instBeforeAddr) > 2000) {
			return null;
		}

		// if the instruction before all the undefines bytes doesn't indicate that it is the end 
		// of a function or an end of a range of a function then return
		FlowType flowType = instructionBefore.getFlowType();
		if (!flowType.isTerminal() && !flowType.isJump()) {
			return null;
		}

		//get the last address in the instruction
		Address maxAddress = instructionBefore.getMaxAddress();
		int maxLen = (int) (address.getOffset() - maxAddress.getOffset());
		if (maxLen <= 0) {
			return null;
		}

		int offset = 1;

		// skip the filler
		Byte filler;
		try {
			filler = getByte(maxAddress.add(offset));
			while (expectedFiller.equals(filler) && offset <= maxLen) {
				offset++;
				filler = getByte(maxAddress.add(offset));
			}
		}
		catch (MemoryAccessException e) {
			return null;
		}
		catch (AddressOutOfBoundsException e) {
			return null;
		}

		Address functionStart = maxAddress.add(offset);

		// check to see if the address after the instruction and filler is the start of a valid 
		// subroutine
		if (!pseudoDisassembler.isValidSubroutine(functionStart, true)) {
			return null;
		}
		if (getInstructionAt(functionStart) == null) {
			disassemble(functionStart);
		}

		// if so, create a function there
		Function function = createFunction(functionStart, null);

		return function;
	}
Method to create the first function after the last terminating function before the given 
address which is in the middle of undefined bytes
@param address the given address
@param expectedFiller the expected filler byte value
@return the created function or null if not created
Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/ExtendedFlatProgramAPI.java