For context, I'm attempting to write a decompiler from AVM2 (ActionScript Virtual machine 2) bytecode/assembly to high-level ActionScript 3 code. As far as I am aware, this requires me to analyze the assembly and generate resulting Control Flow Graph from this, in order to deduce structures such as loops, and conditional branching (if/else).
Given some assembly like:
0 getlocal0
1 pushscope
2 findpropstrict {, private, }::trace
4 pushstring "one"
6 callproperty {, private, }::trace (1)
9 pop
10 pushbyte 5
12 pushbyte 3
14 ifngt L1
18 findpropstrict {, private, }::trace
20 pushstring "two"
22 callproperty {, private, }::trace (1)
25 pop
L1:
26 findpropstrict {, private, }::trace
28 pushstring "three"
30 callproperty {, private, }::trace (1)
33 coerce_a
34 setlocal1
35 getlocal1
36 returnvalue
37 kill 1
What is an algorithm to generate a Control Flow Graph?