| 1 |
digraph mul_graph { |
| 2 |
node [shape="octagon", color="black", fillcolor="white", style="filled"]; |
| 3 |
subgraph mul { |
| 4 |
mul [shape="box", label="def recmul(x, y):\l if x == 0:\l return 0\l else:\l z = x - 1\l return recmul(z, y) + y\l", fillcolor="green"]; |
| 5 |
mul_r [shape="ellipse", label="Are we resuming?", color="blue"]; |
| 6 |
mul_0 [label="x == 0?"]; |
| 7 |
mul_1 [shape="box", label="z = x - 1"]; |
| 8 |
mul_chk [shape="ellipse", label="is the stack too big?", color="blue"] |
| 9 |
mul_2 [shape="box", label="return", fillcolor="green"]; |
| 10 |
mul_3 [label="p = recmul(z, y)\n\nis the stack being unwound?"]; |
| 11 |
mul_4 [shape="ellipse", label="store y and z on the heap\nstart unwinding the stack", color="blue"]; |
| 12 |
mul_5 [shape="box", label="result = p + y"]; |
| 13 |
mul_r3 [shape="ellipse", label="load saved variables y and z\lfrom the heap", color="blue"]; |
| 14 |
mul_s3 [shape="ellipse", label="save y and z to the heap\lcontinue unwinding", color="blue"]; |
| 15 |
mul -> mul_r [label="startblock"]; |
| 16 |
mul_r -> mul_0 [label="No: x y"]; |
| 17 |
mul_r -> mul_r3 [label="Yes: (ignore input args)"]; |
| 18 |
mul_r3 -> mul_3 [label="y z"]; |
| 19 |
mul_0 -> mul_1 [label="No: x y"]; |
| 20 |
mul_1 -> mul_chk [label="y z"]; |
| 21 |
mul_0 -> mul_2 [label="Yes: (0)"]; |
| 22 |
mul_chk -> mul_3 [label="No: y z"]; |
| 23 |
mul_chk -> mul_4 [label="Yes: y z"]; |
| 24 |
mul_3 -> mul_5 [label="No: y p"]; |
| 25 |
mul_3 -> mul_s3 [label="Yes: y z"]; |
| 26 |
mul_5 -> mul_2 [label="result"]; |
| 27 |
} |
| 28 |
} |