Keep the linkinfo structure in-sync with the optree

Used in the next commit, but I wanted to keep the two
separate (especially since this one is tricky while the
next commit is mostly shuffling code around).
Add an object interface

An advantage in case of repeated replaces, it avoids always
re-traversing the optree to gather connectivity information.
Replace the boolean 'keep' parameter with a flags bitfield
Avoid clobbering op_next pointer for conditional nodes

In most cases control flow leaves through the root node of a tree,
notable exception are conditional ops.  It would be nice to automatically
find and update it, but for now just avoid breaking it.
Add more comprehensive test for the object interface

It randomly mangles an sub and then tries to reverse the changes.
Add basic documentation