When there exists function $f$ such that for given $g$ we have $f'=g$? I am looking for a theorem that states when function $g: \mathbb R \mapsto \mathbb R$ is a derrivative, i.e. there exists $f$ such that $f'=g$. 
What about if we just need this condition almost everywhere?
I have looked at Lebesgue differentiation theorem but I either it is not the way to go or i can't extract it from there. I think I have seen such a theorem few years ago, but I can't recall it.
Maybe I'll provide some background. I am considering the following integral:
$$\int_{\mathbb R} \frac{ - g ( \bar x - y)}{|y|^{\alpha +1}} \phi (y/R) d y$$
Where $g$ is bounded function that is twice-differentiable everywhere except zero. At zero there may be some strange behaviour, not sure how strange. I assume  $\alpha \in (0,2)$ (it has to do with fractional laplacian) and that $\varphi$ is smooth cut-off function thtat is zero at a ball around orgin. I want to write the following:
$$\int_{\mathbb R} \frac{ - g ( \bar x - y)}{|y|^{\alpha +1}} \phi (y/R) d y =  \int_{\mathbb R} \partial_k f(\bar x -y) \frac{\phi (y/R)}{|y|^{\alpha+1}} d y = \int_{\mathbb R}  f(\bar x -y) \partial_k \left[ \frac{\phi (y/R) }{|y|^{\alpha+1}} \right] d y$$
If I explicitly assume that $g$ is a derrivative of $f$ it works. I think I can also works when $g$ is Schwartz function. Am I right? But I want to obtain the most general result, hence my question.
 A: Most likely the problem that you have posed will not help at all in the situation you describe, but it is an interesting problem with interesting answers and so, if you approach this as a side topic that offers you a holiday from your real work you might be entertained.
First the problem of when a function is a derivative (pointwise everywhere) is an old problem with no completely satisfying answers.  There are sufficient conditions (continuity of course, bounded and approximately continuous) and there are necessary conditions (Baire one with the Darboux  property, the Denjoy-Clarkson property, Zahorski's properties).  What characterizations exist won't thrill you (even my own characterization, which I will spare you).
The second problem of when a function is an a.e. derivative has quite an interesting answer:  

Theorem (Lusin) A necessary and sufficient condition that a function $f$ should be the
  a.e. derivative of a continuous function is that it be measurable and
  a.e. finite.

For all of this and much more you should consult the definitive reference

Andrew M. Bruckner, Differentiation of Real Functions,  CRM Monograph
  Series,  American Mathematical Society, Centre de Recherches
  Mathematiques (1994) ISBN-10: 0821869906, ISBN-13: 978-0821869901

A supplementary article in the Real Analysis Exchange by Andy will also help:

Bruckner, Andrew M.  The problem of characterizing derivatives
  revisited.  Real Anal. Exchange  21  (1995/96),  no. 1, 112--133.

