This is a problem from the book Stochastic Calculus for Finance II: Continuous-Time Models by S, Schreve.
Exercise 5.9 (Implying the risk-neutral distribution). Let S(t) be the price of an underlying asset, which is not necessarily a geometric Brownian motion (i.e., does not necessarily have constant volatility). With $S(0) = x$, the risk-neutral pricing formula for the price at time zero of a European call on this asset, paying $(S(T) - Kt)^+$ at time T, is \begin{equation} c(0,T,x,k)=e^{-rT}\int_K^{\infty}(y-K)\tilde{p}(0,T,x,y)dy \end{equation} Differentiate the last equation with respect to $K$ to obtain the equation \begin{equation} \tilde{p}(0,T,x,K)=e^{rT}\frac{d^2}{dK^2}c(0,t,x,K) \end{equation} where $\tilde{p}(0,T,x,y)$ is the irsk neutral density in the $y$ variable of the distribution of $S(T)$ when $S(0)=x$.
My try is using $(y-K)^+$, so \begin{equation} \begin{aligned} \frac{d}{dK}c(0,t,x,K)&=e^{-rT}\frac{d}{dK}\int_{-\infty}^{\infty}(y-K)^+\tilde{p}(0,T,x,y)dy\\ &=-e^{-rT}\int_{K}^{\infty}\tilde{p}(0,T,x,y)dy \end{aligned} \end{equation} and uses the fundamental thoerem of calculus and the fact that $\lim_{y\rightarrow\infty}\tilde{p}(y)=0$ \begin{equation} \frac{d^2}{dK^2}c(0,t,x,K)=-e^{-rT}\tilde{p}(0,T,x,K)dy \end{equation} but I am not very sure about if I can introduce the differential operator into the integral because the function $(y-K)^+$ is not differentiable in $y=K$. If someone knows about another way to solve the problem I really appreciate the help. Thank you very much.