title: Flatten control flow graph to list of bytecode instructions
body: <p>I am using the ObjectWeb ASM library found <a href="http://asm.ow2.org/" rel="nofollow">here</a> to parse jar files and read the bytecode of methods. I have already written code to generate a control flow graph from the bytecode instruction lists.</p>
  
  <p>However, after I perform some operations on the control flow graph I want to be able to "export" the control flow graph back to a (simple) list of instructions.
  In theory, I should be able to iterate through all of the basic blocks and print out the instructions that are stored in each one. However, doing this will most likely result in the instructions being in a very bizarre order because there is no ordering to the list of basic blocks.</p>
  
  <p>I have read that forming a "dominator tree" can help figure out the best (most logical) ordering of the basic blocks.
  I'm not sure how to calculate the dominator tree and how to use it to sort the basic blocks.</p>
  
  <p>Does anyone have any knowledge on this topic that they could share?</p>
  
  <p>Thanks.</p>