  Let $I, J\subset \mathbb{R}$ be closed intervals, and let $H$ be $C^{3}$
smooth real valued function on $I\times J$ with nonvanishing $H_{x}$ and
$H_{y}$. Take any fixed positive numbers $a,b$, and let $d\mu$ be a probability
measure with finite moments and absolutely continuous with respect to Lebesgue
measure. We show that for the inequality $$ \int_{\mathbb{R}^{n}}
\mathrm{ess\,sup}_{y \in \mathbb{R}^{n}}\; H\left(
f\left(\frac{x-y}{a}\right),g\left(\frac{y}{b}\right)\right)d\mu (x) \geq
H\left(\int_{\mathbb{R}^{n}}fd\mu, \int_{\mathbb{R}^{n}}gd\mu \right) $$ to
hold for all Borel functions $f,g$ with values in $I$ and $J$ correspondingly
it is necessary that $$
a^{2}\frac{H_{xx}}{H_{x}^{2}}+(1-a^{2}-b^{2})\frac{H_{xy}}{H_{x}H_{y}}+b^{2}\frac{H_{yy}}{H_{y}^{2}}\geq
0, $$ $|a-b|\leq 1$, $a+b\geq 1$ and $\int_{\mathbb{R}^{n}}xd\mu=0$ if $a+b>1$.
Moreover, if $d\mu$ is a Gaussian measure then the necessary condition becomes
sufficient. This extends Pr\'ekopa--Leindler and Ehrhard inequalities to an
arbitrary function $H(x,y)$. As an immediate application we obtain the new
proof of the Ehrhard inequality. In particular, we show that in the class of
even probability measures with smooth positive density and finite moments the
Gaussian measure is the only one which satisfies the functional form of the
Ehrhard inequality on the real line with their own distribution functions.
