For K-G field, the lagrangian density
$$L=\frac{1}{2}\partial_\mu\phi\partial^\mu\phi-\frac{1}{2}m^2\phi^2$$
In ryder quantum field theory book i saw that in next step he writes
$$L=-\frac{1}{2}\phi(\partial_\mu\partial^\mu+m^2)\phi$$
My question is how did we got to second step from first,where did the minus sign came from and how did he pulled out a phi from the derivative in first step?