That you would see. Yet. Sadly.
You are taking the address of function argument
i
(which is an integer), casting (with the crude C-style cast) it to be a pointer to double, and returning the pointer from function.
The function arguments are static local variables of the function, allocated from stack, and exist only for the duration of the function call. The address returned by the function points to deallocated memory.
Undefined behaviour.
A double might use more memory than an int. If you do use the address of an int as the address of a double, then you are accessing bytes that succeed the bytes of the int too.
Undefined behaviour.
What are the function arguments p and i anyway? You do call the function with p=<two-element-array> and i=<3>.
It is ok to study function pointers (p1, p2), but why your test harness is full of undefined behaviour?