public Function getCalledFunctionByCallOrder(Function callingFunction, int callIndex,
			boolean getThunkedFunction) throws CancelledException {

		int callNumber = 0;
		InstructionIterator instructions = callingFunction.getProgram()
				.getListing()
				.getInstructions(callingFunction.getBody(), true);
		while (instructions.hasNext() && callNumber < callIndex) {
			monitor.checkCancelled();
			Instruction instruction = instructions.next();
			if (instruction.getFlowType().isCall()) {
				callNumber++;
				if (callNumber == callIndex) {
					Function referencedFunction =
						getReferencedFunction(instruction.getMinAddress(), getThunkedFunction);
					return referencedFunction;
				}
			}
		}
		return null;
	}
Get the nth called function from calling function
@param callingFunction The calling function
@param callIndex the called function index (ie 1 = first called function)
@param getThunkedFunction if true get the thunked function, if false get the thunk itself, if
there is a thunk
@return the nth called function in calling function
@throws CancelledException if cancelled
Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/ExtendedFlatProgramAPI.java