Explaining a solution to a calculus problem. I tried solving a calculus problem and I got the right result, but I don't understand the solution provided at the end of the exercise. Even though I got the same answer, I would like to understand what's happening in the given solution aswell.

Consider the function: $$\ f(x) = \begin{cases} 
       x^2+ax+b & x\leq 0 \\
       x-1 & x>0 \\    \end{cases} \ $$ Find the antiderivatives of the function $f$ if they exist.

The solution provided goes something like this:

For $f$ to have antiderivatives the function $f$ must have the Darboux
  property. (...Some calculations...), therefore $f$ has the Darboux
  property if and only if $b = -1$ (I understood that now the function
  is continuous, therefore it has an anitederivative). Using the
  consequences of Lagrange's theorem on the intervals $(-\infty, 0)$ and
  $(0, \infty)$ any antiderivative $F : \mathbb{R} \rightarrow
 \mathbb{R}$ of $f$ has the form:
$$ F(x) = \ \begin{cases} 
       \dfrac{x^3}{3} + a \dfrac{x^2}{2} - x + c_1 & x < 0 \\
       \ c_2 & x=0 \\
       \dfrac{x^2}{2} - x + c_3 & x>0     \end{cases} \ $$
$F$ being differentiable, it is also continous, so $F(0) = c_2 = c_1 =
 c_3 $.
Therefore the antiderivatives of $f$ have the form:
$$ F(x) = c + \ \begin{cases} 
       \dfrac{x^3}{3} + a \dfrac{x^2}{2} - x & x\leq 0 \\
       \dfrac{x^2}{2} - x & x>0     \end{cases} \ $$

Again, I got the same result, but I don't understand a lot of the work done above. 
The first thing I didn't understand is the part where they say that $f$ has an antiderivative iff it has the Darboux property. I searched a bit online and I found that a function accepts antiderivatives only if it has the Darboux property. So I guess I have to accept that as a fact.
The second (and more important thing) that I didn't understand was the part where they said that they used the consequences of Lagrange's Theorem on the intervals $(-\infty, 0)$ and $(0, \infty)$ to find that first form of the antiderivative. What theorem are they refering to? How did they use it on those intervals? Why is there a separate case for $x = 0$ with an aditional constant, $c_2$. I only used $2$ constants, why were there needed $3$?  Long  story short, I just don't understand at all how they arrived at that first form of the antiderivative and how they used these "consequences of Langrange's theorem". I understood the second form of the antiderivative, that's what I also got, but the first form put me in the dark.
I know these are all just details, but I really want to understand what was used here, why was it used and how was it used.
 A: At zero, the function $f$ is either continuous or has a jump; by considering a small enough interval around $0$, you can conclude that $f$ has to be continuous. That gives you $b=-1$. 
I assume that by "Lagrange's Theorem" they mean the Mean Value Theorem. And what they are likely using it ("the consequences of Lagrange's theorem") is to say that any two antiderivatives of $f$ differ by a constant (that's what lets you find the antiderivative as your are used to, and by adding a constant be sure that you have all possible antiderivatives). Because if a function $g$ has zero derivative on an interval $(a,b)$, then for any $x,y\in (a,b)$ we have $$ g(x)-g(y)=g'(c)(x-y)=0,$$so $g$ is constant. 
Because the above reasoning requires open intervals, they cannot apply it at $0$; that's why there are three cases initially. From there they work with continuity to reduce the constants. 
A: $f(x)$ is continuous on $(-\infty,0]$ and on $(0,\infty).$ So if $F'(x)=f(x)$ for all $x,$ then by the Fundamental Theorem of Calculus there necessarily exist $k_1$ and $k_2$ such that $$\forall x\le 0\,(F(x)=x^3/3+ax^2/2+bx+k_1);$$ $$ \forall x>0\,(F(x)=x^2/2-x+k_2).$$ For $F'(0)$ to exist we must have continuity of $F(x)$ at $x=0,$ so $$k_1=F(0)=\lim_{x\to 0^+}F(x)=k_2.$$ And we must have  $$b=\lim_{x\to 0^-}\frac {F(x)-F(0)}{x-0}=F'(0)=\lim_{x\to 0^+}\frac {F(x)-F(0)}{x-0}=-1.$$ So if $F'(0)$ exists it is necessary that $b=-1.$
You may check that these necessary conditions are also sufficient: $f(x)$ has an antiderivative for all $x$ iff $b=-1.$ And if $b=-1$ then   $F$ is an antiderivative of $f$ iff, for some $k_1,$ we have $$x\le  0\implies F(x)=x^3/3+ax^2/2+bx+k_1=x^3/3+ax^2/2-x+k_1;$$ $$ x>0\implies F(x)=x^2/2-x+k_1.$$
Appendix. On the Darboux property.
$(I).$ For any $u,v\in \Bbb R$ let $In[u,v]$ be the closed interval with end-points $u,v.$ That is, $In[u,v]=[\min(u,v), \max(u,v)].$ Observe that for any $u,v,w\in \Bbb R$ we have $$In[u,v]\cup In[w,v]=[\min(u,v,w),\max(u,v,w)]\supset In[u,w].$$ $(II).$ Theorem: If $a\ne b$ and if $f$ is differentiable on $In[a,b]$ then $$\{f'(y): y\in In[a,b]\}\supset In[f'(a),f'(b)].$$ Proof: $(i).$ Let $g(a)=f'(a)$ and $g(x)=\frac {f(x)-f(a)}{x-a}$ for $a\ne x\in In[a,b].$ Now $g:[a,b]\to \Bbb R$ is continuous, so $$\{g(x):x\in In[a,b]\}\supset In[g(a),g(b)]=In[f'(a),g(b)].$$
$(ii).$ By the Mean Value Theorem, if $ x\in In[a,b]$ then $g(x)\in \{f'(y): y\in In[a,b]\}.$ So $$\{g(x):x\in In[a,b]\}\subset  \{f'(y):y\in In[a,b]\}.$$ $(iii).$ By $(i)$ and $(ii)$ we have $$In[f'(a),g(b)]\subset \{f'(y):y\in In[a,b]\}.$$ $(iv).$ In $(i),(ii),(iii),$ interchange $a$ with $b$ and replace "$g$" with "$h$". As an analog of $(iii)$ we obtain  $$In[f'(b),h(a)]\subset \{f'(y):y\in In[b,a]\}.$$ (v).Now $g(b)=h(a),$ so by $(I)$ with $u=f'(a),\,v=g(b)=h(a),\,w=f'(b),$ we have by $(iii)$ and $(iv)$ that $$\{f'(y): y\in In [a,b]\}\supset In[u,v]\cup In[w,v]\supset In[u,w]=In[f'(a),f'(b)].$$
