This paper presents a structuring algorithm for arbitrary reducible, unstructured graphs. Graphs are structured into semantically equivalent graphs, without the need of code replication or introduction of new variables. The algorithm makes use of structures such as, if..then..elses, while, repeat and loop loops, and case statements. Gotos are only used when the graph cannot be structured with any of the above constructs. This algorithm is adequate for the analysis needed in the decompilation of programs, given that a binary program does not contain information as to the language and compiler used to compile the original source program. And given that unstructuredness is introduced by the use of gotos (still widely available in today's compilers) and optimizations produced by the compiler, we have to assume an unstructured graph for our decompilation analysis. This algorithm has been implemented as part of the dcc decompiler, currently under development at the Queensland University of Technology. [
[1]
Jeffrey D. Ullman,et al.
A Simple Algorithm for Global Data Flow Analysis Problems
,
1975,
SIAM J. Comput..
[2]
S. Rao Kosaraju,et al.
Analysis of structured programs
,
1973,
STOC.
[3]
Barron Cornelius Housel.
A study of decompiling machine languages into high-level machine independent languages
,
1973
.
[4]
J. Cocke.
Global common subexpression elimination
,
1970,
Symposium on Compiler Optimization.
[5]
M. Howard Williams,et al.
Restructuring Pascal Programs Containing Goto Statements
,
1985,
Comput. J..
[6]
Micha Sharir,et al.
Structural Analysis: A New Approach to Flow Analysis in Optimizing Compilers
,
2015
.
[7]
Frances E. Allen,et al.
A Basis for Program Optimization
,
1971,
IFIP Congress.
[8]
Lyle Ramshaw,et al.
Eliminating go to's while preserving program structure
,
1988,
JACM.