Given functions $\phi,\psi:\mathbb R\to \mathbb R$, set $$\Phi=\phi\circ\mathrm{dist}_ {\partial M},\ \ \ \Psi=\psi\circ\mathrm{dist}_ {\partial M} $$ $$f=\Psi\cdot(R-\mathrm{dist}_ p)+\Phi$$ for some fixed $R>\mathrm{diam}\\, M$.
Further, $$d\\,f=(R-\mathrm{dist}_ p)\cdot d\\,\Psi +d\\,\Phi-\Psi\cdot d\\,\mathrm{dist}_ p$$ Thus, we may choose smooth increasing $\phi$ and $\psi$, such that $\phi(0)=\psi(0)=0$ and both $\phi$, $\psi$ are constant outside of little nbhd of $0$ so that $\Phi$ and $\Psi$ are smooth. (It is possible since the function $\mathrm{dist}_ {\partial M}$ is smooth and has no critical points in a small neighborhood of $\partial M$.) Note that $d\\,\Phi$ and $d\\,\Psi$ both positive muliple of $d\\,\mathrm{dist}_ {\partial M}$. Thus $d_x\\,f=0$ means that geodesic from $x$ to $p$ goes directly in the direction of minimizing geodesic from $x$ to $\partial M$, which can not happen.
Now we can apply Morse theory for $f$...