1ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot#! /usr/bin/env python
2ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
3ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot"""
4ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot"PYSTONE" Benchmark Program
5ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
6ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotVersion:        Python/1.1 (corresponds to C/1.1 plus 2 Pystone fixes)
7ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
8ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotAuthor:         Reinhold P. Weicker,  CACM Vol 27, No 10, 10/84 pg. 1013.
9ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
10ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                Translated from ADA to C by Rick Richardson.
11ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                Every method to preserve ADA-likeness has been used,
12ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                at the expense of C-ness.
13ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
14ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                Translated from C to Python by Guido van Rossum.
15ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
16ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotVersion History:
17ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
18ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                Version 1.1 corrects two bugs in version 1.0:
19ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
20ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                First, it leaked memory: in Proc1(), NextRecord ends
21ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                up having a pointer to itself.  I have corrected this
22ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                by zapping NextRecord.PtrComp at the end of Proc1().
23ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
24ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                Second, Proc3() used the operator != to compare a
25ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                record to None.  This is rather inefficient and not
26ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                true to the intention of the original benchmark (where
27ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                a pointer comparison to None is intended; the !=
28ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                operator attempts to find a method __cmp__ to do value
29ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                comparison of the record).  Version 1.1 runs 5-10
30ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                percent faster than version 1.0, so benchmark figures
31ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                of different versions can't be compared directly.
32ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
33ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot"""
34ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
35ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotLOOPS = 50000
36ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
37ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotfrom time import clock
38ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
39ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot__version__ = "1.1"
40ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
41ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot[Ident1, Ident2, Ident3, Ident4, Ident5] = range(1, 6)
42ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
43ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotclass Record:
44ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
45ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    def __init__(self, PtrComp = None, Discr = 0, EnumComp = 0,
46ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                       IntComp = 0, StringComp = 0):
47ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        self.PtrComp = PtrComp
48ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        self.Discr = Discr
49ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        self.EnumComp = EnumComp
50ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        self.IntComp = IntComp
51ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        self.StringComp = StringComp
52ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
53ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    def copy(self):
54ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        return Record(self.PtrComp, self.Discr, self.EnumComp,
55ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                      self.IntComp, self.StringComp)
56ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
57ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotTRUE = 1
58ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotFALSE = 0
59ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
60ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef main(loops=LOOPS):
61ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    benchtime, stones = pystones(loops)
62ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    print "Pystone(%s) time for %d passes = %g" % \
63ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot          (__version__, loops, benchtime)
64ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    print "This machine benchmarks at %g pystones/second" % stones
65ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
66ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
67ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef pystones(loops=LOOPS):
68ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return Proc0(loops)
69ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
70ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotIntGlob = 0
71ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotBoolGlob = FALSE
72ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotChar1Glob = '\0'
73ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotChar2Glob = '\0'
74ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotArray1Glob = [0]*51
75ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotArray2Glob = map(lambda x: x[:], [Array1Glob]*51)
76ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotPtrGlb = None
77ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team RobotPtrGlbNext = None
78ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
79ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc0(loops=LOOPS):
80ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global IntGlob
81ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global BoolGlob
82ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global Char1Glob
83ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global Char2Glob
84ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global Array1Glob
85ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global Array2Glob
86ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global PtrGlb
87ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global PtrGlbNext
88ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
89ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    starttime = clock()
90ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    for i in range(loops):
91ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        pass
92ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    nulltime = clock() - starttime
93ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
94ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlbNext = Record()
95ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb = Record()
96ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb.PtrComp = PtrGlbNext
97ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb.Discr = Ident1
98ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb.EnumComp = Ident3
99ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb.IntComp = 40
100ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb.StringComp = "DHRYSTONE PROGRAM, SOME STRING"
101ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    String1Loc = "DHRYSTONE PROGRAM, 1'ST STRING"
102ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Array2Glob[8][7] = 10
103ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
104ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    starttime = clock()
105ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
106ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    for i in range(loops):
107ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        Proc5()
108ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        Proc4()
109ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc1 = 2
110ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc2 = 3
111ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        String2Loc = "DHRYSTONE PROGRAM, 2'ND STRING"
112ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        EnumLoc = Ident2
113ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        BoolGlob = not Func2(String1Loc, String2Loc)
114ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        while IntLoc1 < IntLoc2:
115ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntLoc3 = 5 * IntLoc1 - IntLoc2
116ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntLoc3 = Proc7(IntLoc1, IntLoc2)
117ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntLoc1 = IntLoc1 + 1
118ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3)
119ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        PtrGlb = Proc1(PtrGlb)
120ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        CharIndex = 'A'
121ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        while CharIndex <= Char2Glob:
122ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            if EnumLoc == Func1(CharIndex, 'C'):
123ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot                EnumLoc = Proc6(Ident1)
124ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            CharIndex = chr(ord(CharIndex)+1)
125ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc3 = IntLoc2 * IntLoc1
126ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc2 = IntLoc3 / IntLoc1
127ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1
128ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc1 = Proc2(IntLoc1)
129ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
130ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    benchtime = clock() - starttime - nulltime
131ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if benchtime == 0.0:
132ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        loopsPerBenchtime = 0.0
133ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    else:
134ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        loopsPerBenchtime = (loops / benchtime)
135ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return benchtime, loopsPerBenchtime
136ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
137ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc1(PtrParIn):
138ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrParIn.PtrComp = NextRecord = PtrGlb.copy()
139ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrParIn.IntComp = 5
140ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    NextRecord.IntComp = PtrParIn.IntComp
141ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    NextRecord.PtrComp = PtrParIn.PtrComp
142ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    NextRecord.PtrComp = Proc3(NextRecord.PtrComp)
143ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if NextRecord.Discr == Ident1:
144ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        NextRecord.IntComp = 6
145ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        NextRecord.EnumComp = Proc6(PtrParIn.EnumComp)
146ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        NextRecord.PtrComp = PtrGlb.PtrComp
147ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        NextRecord.IntComp = Proc7(NextRecord.IntComp, 10)
148ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    else:
149ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        PtrParIn = NextRecord.copy()
150ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    NextRecord.PtrComp = None
151ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return PtrParIn
152ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
153ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc2(IntParIO):
154ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    IntLoc = IntParIO + 10
155ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    while 1:
156ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        if Char1Glob == 'A':
157ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntLoc = IntLoc - 1
158ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntParIO = IntLoc - IntGlob
159ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            EnumLoc = Ident1
160ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        if EnumLoc == Ident1:
161ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            break
162ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return IntParIO
163ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
164ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc3(PtrParOut):
165ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global IntGlob
166ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
167ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if PtrGlb is not None:
168ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        PtrParOut = PtrGlb.PtrComp
169ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    else:
170ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntGlob = 100
171ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    PtrGlb.IntComp = Proc7(10, IntGlob)
172ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return PtrParOut
173ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
174ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc4():
175ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global Char2Glob
176ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
177ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    BoolLoc = Char1Glob == 'A'
178ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    BoolLoc = BoolLoc or BoolGlob
179ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Char2Glob = 'B'
180ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
181ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc5():
182ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global Char1Glob
183ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global BoolGlob
184ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
185ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Char1Glob = 'A'
186ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    BoolGlob = FALSE
187ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
188ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc6(EnumParIn):
189ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    EnumParOut = EnumParIn
190ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if not Func3(EnumParIn):
191ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        EnumParOut = Ident4
192ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if EnumParIn == Ident1:
193ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        EnumParOut = Ident1
194ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    elif EnumParIn == Ident2:
195ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        if IntGlob > 100:
196ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            EnumParOut = Ident1
197ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        else:
198ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            EnumParOut = Ident4
199ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    elif EnumParIn == Ident3:
200ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        EnumParOut = Ident2
201ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    elif EnumParIn == Ident4:
202ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        pass
203ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    elif EnumParIn == Ident5:
204ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        EnumParOut = Ident3
205ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return EnumParOut
206ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
207ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc7(IntParI1, IntParI2):
208ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    IntLoc = IntParI1 + 2
209ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    IntParOut = IntParI2 + IntLoc
210ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return IntParOut
211ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
212ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Proc8(Array1Par, Array2Par, IntParI1, IntParI2):
213ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    global IntGlob
214ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
215ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    IntLoc = IntParI1 + 5
216ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Array1Par[IntLoc] = IntParI2
217ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Array1Par[IntLoc+1] = Array1Par[IntLoc]
218ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Array1Par[IntLoc+30] = IntLoc
219ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    for IntIndex in range(IntLoc, IntLoc+2):
220ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        Array2Par[IntLoc][IntIndex] = IntLoc
221ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Array2Par[IntLoc][IntLoc-1] = Array2Par[IntLoc][IntLoc-1] + 1
222ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc]
223ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    IntGlob = 5
224ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
225ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Func1(CharPar1, CharPar2):
226ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    CharLoc1 = CharPar1
227ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    CharLoc2 = CharLoc1
228ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if CharLoc2 != CharPar2:
229ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        return Ident1
230ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    else:
231ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        return Ident2
232ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
233ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Func2(StrParI1, StrParI2):
234ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    IntLoc = 1
235ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    while IntLoc <= 1:
236ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        if Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1:
237ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            CharLoc = 'A'
238ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntLoc = IntLoc + 1
239ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if CharLoc >= 'W' and CharLoc <= 'Z':
240ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        IntLoc = 7
241ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if CharLoc == 'X':
242ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        return TRUE
243ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    else:
244ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        if StrParI1 > StrParI2:
245ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            IntLoc = IntLoc + 7
246ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            return TRUE
247ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        else:
248ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            return FALSE
249ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
250ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotdef Func3(EnumParIn):
251ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    EnumLoc = EnumParIn
252ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if EnumLoc == Ident3: return TRUE
253ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    return FALSE
254ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot
255ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robotif __name__ == '__main__':
256ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    import sys
257ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    def error(msg):
258ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        print >>sys.stderr, msg,
259ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        print >>sys.stderr, "usage: %s [number_of_loops]" % sys.argv[0]
260ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        sys.exit(100)
261ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    nargs = len(sys.argv) - 1
262ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    if nargs > 1:
263ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        error("%d arguments are too many;" % nargs)
264ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    elif nargs == 1:
265ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        try: loops = int(sys.argv[1])
266ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        except ValueError:
267ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot            error("Invalid argument %r;" % sys.argv[1])
268ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    else:
269ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot        loops = LOOPS
270ec1a0b3abe08fb9a3952e8f48231cda1f6d9b1fandroid-build-team Robot    main(loops)
271