In Example 1, think of it like this :
(a - b) * c .
Then the algorithm performs these operations :
[(a-b) + 10]*c + 100 -10*c - 100
a*c - b*c + 10*c + 100 - 10*c - 100 .
a*c - b*c
(a - b) * c which is the original equation.
In Example 2, write it as :
a * b .
The algorithm does these operations.
(a + 100) * b + 10000 - 100*b - 10000.
This is the same as :
a * b + 100 * b + 10000 - 100 * b - 10000
a * b which is the original equation.