BEGIN { print "digraph {" } function t(s) { if (s ~ /^[[:digit:]]+$/) { print "S" NR, "[shape=doublecircle,label=\"" s "\"];" return "S" NR } else { return s } } NF == 3 { # register or int print t($1), "->", $3 } NF == 4 { # unary op print "O" NR, "[shape=box,label=\"" $1 "\"];" print t($2), "->", "O" NR ";" print "O" NR, "->", $4 ";" } NF == 5 && substr($2,2) == "SHIFT" { # binary op (R/L)SHIFT print "O" NR, "[shape=box,label=\"" $2 " " $3 "\"]" print t($1), "->", "O" NR ";" print "O" NR, "->", $5 ";" next } NF == 5 { # binary op, AND or OR print "O" NR, "[shape=box,label=\"" $2 "\"]" print t($1), "->", "O" NR ";" print t($3), "->", "O" NR ";" print "O" NR, "->", $5 ";" } END { print "}" }