x86: move more disp processing out of md_assemble()
Put it in optimize_disp() such that it can then be re-used by .insn
handling. The movement makes it necessary (or at least very desirable,
to avoid introducing a fragile cast) to convert to local variable to
"unsigned", which in turn requires an adjustment to the pre-existing
loop header.
Having the caller pass in the specific template under consideration has
another benefit then: We can replace the two uses of current_templates
in the function as well, thus no longer looking at some merely "related"
template. (This may allow further tightening, but if so that's to be the
subject of another change.)