in reply to Equivalency of Code

Your examples are _not_ the same. But maybe give the same results in your context. If you really want to know how to do this very hard task, read the Dragon Book.
And read how others do it gccsummit-2003-proceedings. Search for SSA or GIMPLE as a start.