BEGIN { print "digraph {" } function t(s) { if (s ~ /^[[:digit:]]+$/) { print "S" NR "[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 { # binary op print "O" NR, "[shape=box,label=\"" $2 "\"]" print t($1), "->", "O" NR ";" print t($3), "->", "O" NR ";" print "O" NR, "->", $5 ";" } END { print "}" }