3 # binarytrees.pir N (N = 16 for shootout)
4 # by Joshua Isom, modified by Leopold Toetsch
5 # modified by karl : default value of N=10 to match shootout output
31 .local pmc left, right, tree
33 unless dep > 0 goto else
37 left = bottomuptree($I0, dep)
38 right = bottomuptree(item2, dep)
44 tree = new 'FixedPMCArray'
55 .local int N, dep, mindepth, maxdepth, stretchdepth
56 .local pmc stretchtree, longlivedtree, tmptree
60 if argc == 1 goto default
65 unless N < 6 goto else
66 maxdepth = mindepth + 2
71 stretchdepth = maxdepth + 1
73 stretchtree = bottomuptree($I0, stretchdepth)
74 $I0 = itemcheck(stretchtree)
76 print "stretch tree of depth "
84 longlivedtree = bottomuptree($I0, maxdepth)
89 .local int i, iterations, check
103 tmptree = bottomuptree(i, dep)
104 $I0 = itemcheck(tmptree)
107 tmptree = bottomuptree($I0, dep)
108 $I0 = itemcheck(tmptree)
112 if i <= iterations goto beginfor_2
115 print "\t trees of depth "
123 if dep <= maxdepth goto beginfor_1
125 $I0 = itemcheck(longlivedtree)
126 print "long lived tree of depth "
138 # vim: expandtab shiftwidth=4: