You could be asking for several things here. One possible interpretation of your question is that you are looking for a slicer, a tool that takes a program and produces a program made of a selection of the instructions from the original program, and that computes some or all of the results of the original. In other words, a slicer removes that instructions that are not necessary for at least one of the results you are interested in.
There is an Open-Source slicer for C programs here.
For making programs more concise, perhaps the constraint of keeping only instructions from the original program as they are is too strong. You may also want to allow some transformations other than "keeping" or "removing". The framework that the slicer linked above is part of provides this kind of transformation too. For instance:
int main(int c, char **v)
{
int x = 2;
int y = x + c;
return y;
}
In the above program, a slicer instructed to preserve the exit code cannot remove any instruction: they all contribute to the result. But if you first apply a constant propagation, transforming every constant expression in its value:
int main(int c, char **v)
{
int x = 2;
int y = 2 + c;
return y;
}
Then a slicer can in a second pass remove the useless variable x
:
int main(int c, char **v)
{
int y = 2 + c;
return y;
}