1*433d6423SLionel Sambuc /* dhrystone - benchmark program */
2*433d6423SLionel Sambuc
3*433d6423SLionel Sambuc #define REGISTER
4*433d6423SLionel Sambuc /*
5*433d6423SLionel Sambuc *
6*433d6423SLionel Sambuc * "DHRYSTONE" Benchmark Program
7*433d6423SLionel Sambuc *
8*433d6423SLionel Sambuc * Version: C/1.1, 12/01/84
9*433d6423SLionel Sambuc *
10*433d6423SLionel Sambuc * Date: PROGRAM updated 01/06/86, COMMENTS changed 01/31/87
11*433d6423SLionel Sambuc *
12*433d6423SLionel Sambuc * Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg.1013
13*433d6423SLionel Sambuc * Translated from ADA by Rick Richardson
14*433d6423SLionel Sambuc * Every method to preserve ADA-likeness has been used,
15*433d6423SLionel Sambuc * at the expense of C-ness.
16*433d6423SLionel Sambuc *
17*433d6423SLionel Sambuc * Compile: cc -O dry.c -o drynr : No registers
18*433d6423SLionel Sambuc * cc -O -DREG=register dry.c -o dryr : Registers
19*433d6423SLionel Sambuc *
20*433d6423SLionel Sambuc * Defines: Defines are provided for old C compiler's
21*433d6423SLionel Sambuc * which don't have enums, and can't assign structures.
22*433d6423SLionel Sambuc * The time(2) function is library dependant; Most
23*433d6423SLionel Sambuc * return the time in seconds, but beware of some, like
24*433d6423SLionel Sambuc * Aztec C, which return other units.
25*433d6423SLionel Sambuc * The LOOPS define is initially set for 50000 loops.
26*433d6423SLionel Sambuc * If you have a machine with large integers and is
27*433d6423SLionel Sambuc * very fast, please change this number to 500000 to
28*433d6423SLionel Sambuc * get better accuracy. Please select the way to
29*433d6423SLionel Sambuc * measure the execution time using the TIME define.
30*433d6423SLionel Sambuc * For single user machines, time(2) is adequate. For
31*433d6423SLionel Sambuc * multi-user machines where you cannot get single-user
32*433d6423SLionel Sambuc * access, use the times(2) function. Be careful to
33*433d6423SLionel Sambuc * adjust the HZ parameter below for the units which
34*433d6423SLionel Sambuc * are returned by your times(2) function. You can
35*433d6423SLionel Sambuc * sometimes find this in <sys/param.h>. If you have
36*433d6423SLionel Sambuc * neither time(2) nor times(2), use a stopwatch in
37*433d6423SLionel Sambuc * the dead of the night.
38*433d6423SLionel Sambuc * Use a "printf" at the point marked "start timer"
39*433d6423SLionel Sambuc * to begin your timings. DO NOT use the UNIX "time(1)"
40*433d6423SLionel Sambuc * command, as this will measure the total time to
41*433d6423SLionel Sambuc * run this program, which will (erroneously) include
42*433d6423SLionel Sambuc * the time to malloc(3) storage and to compute the
43*433d6423SLionel Sambuc * time it takes to do nothing.
44*433d6423SLionel Sambuc *
45*433d6423SLionel Sambuc * Run: drynr; dryr
46*433d6423SLionel Sambuc *
47*433d6423SLionel Sambuc * Results: If you get any new machine/OS results, please send to:
48*433d6423SLionel Sambuc *
49*433d6423SLionel Sambuc * ihnp4!castor!pcrat!rick
50*433d6423SLionel Sambuc *
51*433d6423SLionel Sambuc * and thanks to all that do.
52*433d6423SLionel Sambuc *
53*433d6423SLionel Sambuc * Note: I order the list in increasing performance of the
54*433d6423SLionel Sambuc * "with registers" benchmark. If the compiler doesn't
55*433d6423SLionel Sambuc * provide register variables, then the benchmark
56*433d6423SLionel Sambuc * is the same for both REG and NOREG.
57*433d6423SLionel Sambuc *
58*433d6423SLionel Sambuc * PLEASE: Send complete information about the machine type,
59*433d6423SLionel Sambuc * clock speed, OS and C manufacturer/version. If
60*433d6423SLionel Sambuc * the machine is modified, tell me what was done.
61*433d6423SLionel Sambuc * On UNIX, execute uname -a and cc -V to get this info.
62*433d6423SLionel Sambuc *
63*433d6423SLionel Sambuc * 80x8x NOTE: 80x8x benchers: please try to do all memory models
64*433d6423SLionel Sambuc * for a particular compiler.
65*433d6423SLionel Sambuc *
66*433d6423SLionel Sambuc *
67*433d6423SLionel Sambuc * The following program contains statements of a high-level programming
68*433d6423SLionel Sambuc * language (C) in a distribution considered representative:
69*433d6423SLionel Sambuc *
70*433d6423SLionel Sambuc * assignments 53%
71*433d6423SLionel Sambuc * control statements 32%
72*433d6423SLionel Sambuc * procedure, function calls 15%
73*433d6423SLionel Sambuc *
74*433d6423SLionel Sambuc * 100 statements are dynamically executed. The program is balanced with
75*433d6423SLionel Sambuc * respect to the three aspects:
76*433d6423SLionel Sambuc * - statement type
77*433d6423SLionel Sambuc * - operand type (for simple data types)
78*433d6423SLionel Sambuc * - operand access
79*433d6423SLionel Sambuc * operand global, local, parameter, or constant.
80*433d6423SLionel Sambuc *
81*433d6423SLionel Sambuc * The combination of these three aspects is balanced only approximately.
82*433d6423SLionel Sambuc *
83*433d6423SLionel Sambuc * The program does not compute anything meaningfull, but it is
84*433d6423SLionel Sambuc * syntactically and semantically correct.
85*433d6423SLionel Sambuc *
86*433d6423SLionel Sambuc */
87*433d6423SLionel Sambuc
88*433d6423SLionel Sambuc
89*433d6423SLionel Sambuc #include <sys/types.h>
90*433d6423SLionel Sambuc #include <stdlib.h>
91*433d6423SLionel Sambuc #include <string.h>
92*433d6423SLionel Sambuc #include <time.h>
93*433d6423SLionel Sambuc #include <stdio.h>
94*433d6423SLionel Sambuc #include <signal.h>
95*433d6423SLionel Sambuc #include <unistd.h>
96*433d6423SLionel Sambuc
97*433d6423SLionel Sambuc /* Accuracy of timings and human fatigue controlled by next two lines */
98*433d6423SLionel Sambuc /*#define LOOPS 50000 */ /* Use this for slow or 16 bit machines */
99*433d6423SLionel Sambuc /*#define LOOPS 500000 */ /* Use this for faster machines */
100*433d6423SLionel Sambuc /*#define LOOPS (sizeof(int) == 2 ? 50000 : 1000000)*/
101*433d6423SLionel Sambuc
102*433d6423SLionel Sambuc /* Seconds to run */
103*433d6423SLionel Sambuc #define SECONDS 15
104*433d6423SLionel Sambuc
105*433d6423SLionel Sambuc /* Compiler dependent options */
106*433d6423SLionel Sambuc #define NOENUM /* Define if compiler has no enum's */
107*433d6423SLionel Sambuc /* #define NOSTRUCTASSIGN */ /* Define if compiler can't assign structures*/
108*433d6423SLionel Sambuc
109*433d6423SLionel Sambuc
110*433d6423SLionel Sambuc /* Define only one of the next two defines */
111*433d6423SLionel Sambuc #define TIMES /* Use times(2) time function */
112*433d6423SLionel Sambuc /*#define TIME */ /* Use time(2) time function */
113*433d6423SLionel Sambuc
114*433d6423SLionel Sambuc
115*433d6423SLionel Sambuc #ifdef TIME
116*433d6423SLionel Sambuc /* Ganularity of time(2) is of course 1 second */
117*433d6423SLionel Sambuc #define HZ 1
118*433d6423SLionel Sambuc #endif
119*433d6423SLionel Sambuc
120*433d6423SLionel Sambuc #ifdef TIMES
121*433d6423SLionel Sambuc /* Define the granularity of your times(2) function */
122*433d6423SLionel Sambuc /*#define HZ 50 */ /* times(2) returns 1/50 second (europe?) */
123*433d6423SLionel Sambuc /*#define HZ 60 */ /* times(2) returns 1/60 second (most) */
124*433d6423SLionel Sambuc /*#define HZ 100 */ /* times(2) returns 1/100 second (WECo) */
125*433d6423SLionel Sambuc #endif
126*433d6423SLionel Sambuc
127*433d6423SLionel Sambuc /* For compatibility with goofed up version */
128*433d6423SLionel Sambuc /*#undef GOOF */ /* Define if you want the goofed up version */
129*433d6423SLionel Sambuc
130*433d6423SLionel Sambuc
131*433d6423SLionel Sambuc #ifdef GOOF
132*433d6423SLionel Sambuc char Version[] = "1.0";
133*433d6423SLionel Sambuc #else
134*433d6423SLionel Sambuc char Version[] = "1.1";
135*433d6423SLionel Sambuc #endif
136*433d6423SLionel Sambuc
137*433d6423SLionel Sambuc
138*433d6423SLionel Sambuc #ifdef NOSTRUCTASSIGN
139*433d6423SLionel Sambuc #define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
140*433d6423SLionel Sambuc #else
141*433d6423SLionel Sambuc #define structassign(d, s) d = s
142*433d6423SLionel Sambuc #endif
143*433d6423SLionel Sambuc
144*433d6423SLionel Sambuc
145*433d6423SLionel Sambuc #ifdef NOENUM
146*433d6423SLionel Sambuc #define Ident1 1
147*433d6423SLionel Sambuc #define Ident2 2
148*433d6423SLionel Sambuc #define Ident3 3
149*433d6423SLionel Sambuc #define Ident4 4
150*433d6423SLionel Sambuc #define Ident5 5
151*433d6423SLionel Sambuc typedef int Enumeration;
152*433d6423SLionel Sambuc #else
153*433d6423SLionel Sambuc typedef enum {
154*433d6423SLionel Sambuc Ident1, Ident2, Ident3, Ident4, Ident5
155*433d6423SLionel Sambuc } Enumeration;
156*433d6423SLionel Sambuc #endif
157*433d6423SLionel Sambuc
158*433d6423SLionel Sambuc typedef int OneToThirty;
159*433d6423SLionel Sambuc typedef int OneToFifty;
160*433d6423SLionel Sambuc typedef char CapitalLetter;
161*433d6423SLionel Sambuc typedef char String30[31];
162*433d6423SLionel Sambuc typedef int Array1Dim[51];
163*433d6423SLionel Sambuc typedef int Array2Dim[51][51];
164*433d6423SLionel Sambuc
165*433d6423SLionel Sambuc struct Record {
166*433d6423SLionel Sambuc struct Record *PtrComp;
167*433d6423SLionel Sambuc Enumeration Discr;
168*433d6423SLionel Sambuc Enumeration EnumComp;
169*433d6423SLionel Sambuc OneToFifty IntComp;
170*433d6423SLionel Sambuc String30 StringComp;
171*433d6423SLionel Sambuc };
172*433d6423SLionel Sambuc
173*433d6423SLionel Sambuc typedef struct Record RecordType;
174*433d6423SLionel Sambuc typedef RecordType *RecordPtr;
175*433d6423SLionel Sambuc typedef int boolean;
176*433d6423SLionel Sambuc
177*433d6423SLionel Sambuc #ifdef NULL
178*433d6423SLionel Sambuc #undef NULL
179*433d6423SLionel Sambuc #endif
180*433d6423SLionel Sambuc
181*433d6423SLionel Sambuc #define NULL 0
182*433d6423SLionel Sambuc #define TRUE 1
183*433d6423SLionel Sambuc #define FALSE 0
184*433d6423SLionel Sambuc
185*433d6423SLionel Sambuc #ifndef REG
186*433d6423SLionel Sambuc #define REG
187*433d6423SLionel Sambuc #endif
188*433d6423SLionel Sambuc
189*433d6423SLionel Sambuc
190*433d6423SLionel Sambuc #ifdef TIMES
191*433d6423SLionel Sambuc #include <sys/times.h>
192*433d6423SLionel Sambuc #endif
193*433d6423SLionel Sambuc
194*433d6423SLionel Sambuc int main(void);
195*433d6423SLionel Sambuc void prep_timer(void);
196*433d6423SLionel Sambuc void timeout(int sig);
197*433d6423SLionel Sambuc void Proc0(void);
198*433d6423SLionel Sambuc void Proc1(RecordPtr PtrParIn);
199*433d6423SLionel Sambuc void Proc2(OneToFifty *IntParIO);
200*433d6423SLionel Sambuc void Proc3(RecordPtr *PtrParOut);
201*433d6423SLionel Sambuc void Proc4(void);
202*433d6423SLionel Sambuc void Proc5(void);
203*433d6423SLionel Sambuc void Proc6(Enumeration EnumParIn, Enumeration *EnumParOut);
204*433d6423SLionel Sambuc void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty
205*433d6423SLionel Sambuc *IntParOut);
206*433d6423SLionel Sambuc void Proc8(Array1Dim Array1Par, Array2Dim Array2Par, OneToFifty
207*433d6423SLionel Sambuc IntParI1, OneToFifty IntParI2);
208*433d6423SLionel Sambuc boolean Func2(String30 StrParI1, String30 StrParI2);
209*433d6423SLionel Sambuc boolean Func3(Enumeration EnumParIn);
210*433d6423SLionel Sambuc
211*433d6423SLionel Sambuc Enumeration Func1(int CharPar1, int CharPar2);
212*433d6423SLionel Sambuc
213*433d6423SLionel Sambuc
main()214*433d6423SLionel Sambuc int main()
215*433d6423SLionel Sambuc {
216*433d6423SLionel Sambuc Proc0();
217*433d6423SLionel Sambuc return(0);
218*433d6423SLionel Sambuc }
219*433d6423SLionel Sambuc
220*433d6423SLionel Sambuc
221*433d6423SLionel Sambuc #if __STDC__
222*433d6423SLionel Sambuc volatile int done;
223*433d6423SLionel Sambuc #else
224*433d6423SLionel Sambuc int done;
225*433d6423SLionel Sambuc #endif
226*433d6423SLionel Sambuc
prep_timer()227*433d6423SLionel Sambuc void prep_timer()
228*433d6423SLionel Sambuc {
229*433d6423SLionel Sambuc signal(SIGALRM, timeout);
230*433d6423SLionel Sambuc done = 0;
231*433d6423SLionel Sambuc }
232*433d6423SLionel Sambuc
timeout(sig)233*433d6423SLionel Sambuc void timeout(sig)
234*433d6423SLionel Sambuc int sig;
235*433d6423SLionel Sambuc {
236*433d6423SLionel Sambuc done = 1;
237*433d6423SLionel Sambuc }
238*433d6423SLionel Sambuc
239*433d6423SLionel Sambuc /* Package 1 */
240*433d6423SLionel Sambuc int IntGlob;
241*433d6423SLionel Sambuc boolean BoolGlob;
242*433d6423SLionel Sambuc char Char1Glob;
243*433d6423SLionel Sambuc char Char2Glob;
244*433d6423SLionel Sambuc Array1Dim Array1Glob;
245*433d6423SLionel Sambuc Array2Dim Array2Glob;
246*433d6423SLionel Sambuc RecordPtr PtrGlb;
247*433d6423SLionel Sambuc RecordPtr PtrGlbNext;
248*433d6423SLionel Sambuc
249*433d6423SLionel Sambuc
Proc0()250*433d6423SLionel Sambuc void Proc0()
251*433d6423SLionel Sambuc {
252*433d6423SLionel Sambuc OneToFifty IntLoc1;
253*433d6423SLionel Sambuc REG OneToFifty IntLoc2;
254*433d6423SLionel Sambuc OneToFifty IntLoc3;
255*433d6423SLionel Sambuc REG char CharIndex;
256*433d6423SLionel Sambuc Enumeration EnumLoc;
257*433d6423SLionel Sambuc String30 String1Loc;
258*433d6423SLionel Sambuc String30 String2Loc;
259*433d6423SLionel Sambuc register unsigned long i;
260*433d6423SLionel Sambuc unsigned long starttime;
261*433d6423SLionel Sambuc unsigned long benchtime;
262*433d6423SLionel Sambuc unsigned long nulltime;
263*433d6423SLionel Sambuc unsigned long nullloops;
264*433d6423SLionel Sambuc unsigned long benchloops;
265*433d6423SLionel Sambuc unsigned long ticks_per_sec;
266*433d6423SLionel Sambuc #ifdef TIMES
267*433d6423SLionel Sambuc struct tms tms;
268*433d6423SLionel Sambuc #endif
269*433d6423SLionel Sambuc
270*433d6423SLionel Sambuc #ifdef HZ
271*433d6423SLionel Sambuc #define ticks_per_sec HZ
272*433d6423SLionel Sambuc #else
273*433d6423SLionel Sambuc ticks_per_sec = sysconf(_SC_CLK_TCK);
274*433d6423SLionel Sambuc #endif
275*433d6423SLionel Sambuc
276*433d6423SLionel Sambuc i = 0;
277*433d6423SLionel Sambuc prep_timer();
278*433d6423SLionel Sambuc
279*433d6423SLionel Sambuc #ifdef TIME
280*433d6423SLionel Sambuc starttime = time((long *) 0);
281*433d6423SLionel Sambuc #endif
282*433d6423SLionel Sambuc
283*433d6423SLionel Sambuc #ifdef TIMES
284*433d6423SLionel Sambuc times(&tms);
285*433d6423SLionel Sambuc starttime = tms.tms_utime;
286*433d6423SLionel Sambuc #endif
287*433d6423SLionel Sambuc
288*433d6423SLionel Sambuc alarm(1);
289*433d6423SLionel Sambuc while (!done) i++;
290*433d6423SLionel Sambuc
291*433d6423SLionel Sambuc #ifdef TIME
292*433d6423SLionel Sambuc nulltime = time((long *) 0) - starttime; /* Computes o'head of loop */
293*433d6423SLionel Sambuc #endif
294*433d6423SLionel Sambuc
295*433d6423SLionel Sambuc #ifdef TIMES
296*433d6423SLionel Sambuc times(&tms);
297*433d6423SLionel Sambuc nulltime = tms.tms_utime - starttime; /* Computes overhead of looping */
298*433d6423SLionel Sambuc #endif
299*433d6423SLionel Sambuc
300*433d6423SLionel Sambuc nullloops = i;
301*433d6423SLionel Sambuc
302*433d6423SLionel Sambuc
303*433d6423SLionel Sambuc PtrGlbNext = (RecordPtr) malloc(sizeof(RecordType));
304*433d6423SLionel Sambuc PtrGlb = (RecordPtr) malloc(sizeof(RecordType));
305*433d6423SLionel Sambuc PtrGlb->PtrComp = PtrGlbNext;
306*433d6423SLionel Sambuc PtrGlb->Discr = Ident1;
307*433d6423SLionel Sambuc PtrGlb->EnumComp = Ident3;
308*433d6423SLionel Sambuc PtrGlb->IntComp = 40;
309*433d6423SLionel Sambuc strcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING");
310*433d6423SLionel Sambuc #ifndef GOOF
311*433d6423SLionel Sambuc strcpy(String1Loc, "DHRYSTONE PROGRAM, 1'ST STRING"); /* GOOF */
312*433d6423SLionel Sambuc #endif
313*433d6423SLionel Sambuc
314*433d6423SLionel Sambuc Array2Glob[8][7] = 10; /* Was missing in published program */
315*433d6423SLionel Sambuc
316*433d6423SLionel Sambuc
317*433d6423SLionel Sambuc /*****************
318*433d6423SLionel Sambuc -- Start Timer --
319*433d6423SLionel Sambuc *****************/
320*433d6423SLionel Sambuc i = 0;
321*433d6423SLionel Sambuc prep_timer();
322*433d6423SLionel Sambuc
323*433d6423SLionel Sambuc #ifdef TIME
324*433d6423SLionel Sambuc starttime = time((long *) 0);
325*433d6423SLionel Sambuc #endif
326*433d6423SLionel Sambuc
327*433d6423SLionel Sambuc #ifdef TIMES
328*433d6423SLionel Sambuc times(&tms);
329*433d6423SLionel Sambuc starttime = tms.tms_utime;
330*433d6423SLionel Sambuc #endif
331*433d6423SLionel Sambuc
332*433d6423SLionel Sambuc alarm(SECONDS);
333*433d6423SLionel Sambuc while (!done) {
334*433d6423SLionel Sambuc i++;
335*433d6423SLionel Sambuc Proc5();
336*433d6423SLionel Sambuc Proc4();
337*433d6423SLionel Sambuc IntLoc1 = 2;
338*433d6423SLionel Sambuc IntLoc2 = 3;
339*433d6423SLionel Sambuc strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
340*433d6423SLionel Sambuc EnumLoc = Ident2;
341*433d6423SLionel Sambuc BoolGlob = !Func2(String1Loc, String2Loc);
342*433d6423SLionel Sambuc while (IntLoc1 < IntLoc2) {
343*433d6423SLionel Sambuc IntLoc3 = 5 * IntLoc1 - IntLoc2;
344*433d6423SLionel Sambuc Proc7(IntLoc1, IntLoc2, &IntLoc3);
345*433d6423SLionel Sambuc ++IntLoc1;
346*433d6423SLionel Sambuc }
347*433d6423SLionel Sambuc Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3);
348*433d6423SLionel Sambuc Proc1(PtrGlb);
349*433d6423SLionel Sambuc for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)
350*433d6423SLionel Sambuc if (EnumLoc == Func1(CharIndex, 'C'))
351*433d6423SLionel Sambuc Proc6(Ident1, &EnumLoc);
352*433d6423SLionel Sambuc IntLoc3 = IntLoc2 * IntLoc1;
353*433d6423SLionel Sambuc IntLoc2 = IntLoc3 / IntLoc1;
354*433d6423SLionel Sambuc IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
355*433d6423SLionel Sambuc Proc2(&IntLoc1);
356*433d6423SLionel Sambuc }
357*433d6423SLionel Sambuc
358*433d6423SLionel Sambuc
359*433d6423SLionel Sambuc /*****************
360*433d6423SLionel Sambuc -- Stop Timer --
361*433d6423SLionel Sambuc *****************/
362*433d6423SLionel Sambuc
363*433d6423SLionel Sambuc
364*433d6423SLionel Sambuc #ifdef TIME
365*433d6423SLionel Sambuc benchtime = time((long *) 0) - starttime;
366*433d6423SLionel Sambuc #endif
367*433d6423SLionel Sambuc
368*433d6423SLionel Sambuc #ifdef TIMES
369*433d6423SLionel Sambuc times(&tms);
370*433d6423SLionel Sambuc benchtime = tms.tms_utime - starttime;
371*433d6423SLionel Sambuc #endif
372*433d6423SLionel Sambuc benchloops = i;
373*433d6423SLionel Sambuc
374*433d6423SLionel Sambuc /* Approximately correct benchtime to the nulltime. */
375*433d6423SLionel Sambuc benchtime -= nulltime / (nullloops / benchloops);
376*433d6423SLionel Sambuc
377*433d6423SLionel Sambuc printf("Dhrystone(%s) time for %lu passes = %lu.%02lu\n",
378*433d6423SLionel Sambuc Version,
379*433d6423SLionel Sambuc benchloops, benchtime / ticks_per_sec,
380*433d6423SLionel Sambuc benchtime % ticks_per_sec * 100 / ticks_per_sec);
381*433d6423SLionel Sambuc printf("This machine benchmarks at %lu dhrystones/second\n",
382*433d6423SLionel Sambuc benchloops * ticks_per_sec / benchtime);
383*433d6423SLionel Sambuc }
384*433d6423SLionel Sambuc
385*433d6423SLionel Sambuc
Proc1(PtrParIn)386*433d6423SLionel Sambuc void Proc1(PtrParIn)
387*433d6423SLionel Sambuc REG RecordPtr PtrParIn;
388*433d6423SLionel Sambuc {
389*433d6423SLionel Sambuc #define NextRecord (*(PtrParIn->PtrComp))
390*433d6423SLionel Sambuc
391*433d6423SLionel Sambuc
392*433d6423SLionel Sambuc structassign(NextRecord, *PtrGlb);
393*433d6423SLionel Sambuc PtrParIn->IntComp = 5;
394*433d6423SLionel Sambuc NextRecord.IntComp = PtrParIn->IntComp;
395*433d6423SLionel Sambuc NextRecord.PtrComp = PtrParIn->PtrComp;
396*433d6423SLionel Sambuc Proc3((RecordPtr *)NextRecord.PtrComp);
397*433d6423SLionel Sambuc if (NextRecord.Discr == Ident1) {
398*433d6423SLionel Sambuc NextRecord.IntComp = 6;
399*433d6423SLionel Sambuc Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp);
400*433d6423SLionel Sambuc NextRecord.PtrComp = PtrGlb->PtrComp;
401*433d6423SLionel Sambuc Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp);
402*433d6423SLionel Sambuc } else
403*433d6423SLionel Sambuc structassign(*PtrParIn, NextRecord);
404*433d6423SLionel Sambuc
405*433d6423SLionel Sambuc
406*433d6423SLionel Sambuc #undef NextRecord
407*433d6423SLionel Sambuc }
408*433d6423SLionel Sambuc
409*433d6423SLionel Sambuc
Proc2(IntParIO)410*433d6423SLionel Sambuc void Proc2(IntParIO)
411*433d6423SLionel Sambuc OneToFifty *IntParIO;
412*433d6423SLionel Sambuc {
413*433d6423SLionel Sambuc REG OneToFifty IntLoc;
414*433d6423SLionel Sambuc REG Enumeration EnumLoc;
415*433d6423SLionel Sambuc
416*433d6423SLionel Sambuc
417*433d6423SLionel Sambuc IntLoc = *IntParIO + 10;
418*433d6423SLionel Sambuc for (;;) {
419*433d6423SLionel Sambuc if (Char1Glob == 'A') {
420*433d6423SLionel Sambuc --IntLoc;
421*433d6423SLionel Sambuc *IntParIO = IntLoc - IntGlob;
422*433d6423SLionel Sambuc EnumLoc = Ident1;
423*433d6423SLionel Sambuc }
424*433d6423SLionel Sambuc if (EnumLoc == Ident1) break;
425*433d6423SLionel Sambuc }
426*433d6423SLionel Sambuc }
427*433d6423SLionel Sambuc
428*433d6423SLionel Sambuc
Proc3(PtrParOut)429*433d6423SLionel Sambuc void Proc3(PtrParOut)
430*433d6423SLionel Sambuc RecordPtr *PtrParOut;
431*433d6423SLionel Sambuc {
432*433d6423SLionel Sambuc if (PtrGlb != NULL)
433*433d6423SLionel Sambuc *PtrParOut = PtrGlb->PtrComp;
434*433d6423SLionel Sambuc else
435*433d6423SLionel Sambuc IntGlob = 100;
436*433d6423SLionel Sambuc Proc7(10, IntGlob, &PtrGlb->IntComp);
437*433d6423SLionel Sambuc }
438*433d6423SLionel Sambuc
439*433d6423SLionel Sambuc
Proc4()440*433d6423SLionel Sambuc void Proc4()
441*433d6423SLionel Sambuc {
442*433d6423SLionel Sambuc REG boolean BoolLoc;
443*433d6423SLionel Sambuc
444*433d6423SLionel Sambuc
445*433d6423SLionel Sambuc BoolLoc = Char1Glob == 'A';
446*433d6423SLionel Sambuc BoolLoc |= BoolGlob;
447*433d6423SLionel Sambuc Char2Glob = 'B';
448*433d6423SLionel Sambuc }
449*433d6423SLionel Sambuc
450*433d6423SLionel Sambuc
Proc5()451*433d6423SLionel Sambuc void Proc5()
452*433d6423SLionel Sambuc {
453*433d6423SLionel Sambuc Char1Glob = 'A';
454*433d6423SLionel Sambuc BoolGlob = FALSE;
455*433d6423SLionel Sambuc }
456*433d6423SLionel Sambuc
457*433d6423SLionel Sambuc
Proc6(EnumParIn,EnumParOut)458*433d6423SLionel Sambuc void Proc6(EnumParIn, EnumParOut)
459*433d6423SLionel Sambuc REG Enumeration EnumParIn;
460*433d6423SLionel Sambuc REG Enumeration *EnumParOut;
461*433d6423SLionel Sambuc {
462*433d6423SLionel Sambuc *EnumParOut = EnumParIn;
463*433d6423SLionel Sambuc if (!Func3(EnumParIn)) *EnumParOut = Ident4;
464*433d6423SLionel Sambuc switch (EnumParIn) {
465*433d6423SLionel Sambuc case Ident1: *EnumParOut = Ident1; break;
466*433d6423SLionel Sambuc case Ident2:
467*433d6423SLionel Sambuc if (IntGlob > 100)
468*433d6423SLionel Sambuc *EnumParOut = Ident1;
469*433d6423SLionel Sambuc else
470*433d6423SLionel Sambuc *EnumParOut = Ident4;
471*433d6423SLionel Sambuc break;
472*433d6423SLionel Sambuc case Ident3: *EnumParOut = Ident2; break;
473*433d6423SLionel Sambuc case Ident4:
474*433d6423SLionel Sambuc break;
475*433d6423SLionel Sambuc case Ident5: *EnumParOut = Ident3;
476*433d6423SLionel Sambuc }
477*433d6423SLionel Sambuc }
478*433d6423SLionel Sambuc
479*433d6423SLionel Sambuc
Proc7(IntParI1,IntParI2,IntParOut)480*433d6423SLionel Sambuc void Proc7(IntParI1, IntParI2, IntParOut)
481*433d6423SLionel Sambuc OneToFifty IntParI1;
482*433d6423SLionel Sambuc OneToFifty IntParI2;
483*433d6423SLionel Sambuc OneToFifty *IntParOut;
484*433d6423SLionel Sambuc {
485*433d6423SLionel Sambuc REG OneToFifty IntLoc;
486*433d6423SLionel Sambuc
487*433d6423SLionel Sambuc
488*433d6423SLionel Sambuc IntLoc = IntParI1 + 2;
489*433d6423SLionel Sambuc *IntParOut = IntParI2 + IntLoc;
490*433d6423SLionel Sambuc }
491*433d6423SLionel Sambuc
492*433d6423SLionel Sambuc
Proc8(Array1Par,Array2Par,IntParI1,IntParI2)493*433d6423SLionel Sambuc void Proc8(Array1Par, Array2Par, IntParI1, IntParI2)
494*433d6423SLionel Sambuc Array1Dim Array1Par;
495*433d6423SLionel Sambuc Array2Dim Array2Par;
496*433d6423SLionel Sambuc OneToFifty IntParI1;
497*433d6423SLionel Sambuc OneToFifty IntParI2;
498*433d6423SLionel Sambuc {
499*433d6423SLionel Sambuc REG OneToFifty IntLoc;
500*433d6423SLionel Sambuc REG OneToFifty IntIndex;
501*433d6423SLionel Sambuc
502*433d6423SLionel Sambuc
503*433d6423SLionel Sambuc IntLoc = IntParI1 + 5;
504*433d6423SLionel Sambuc Array1Par[IntLoc] = IntParI2;
505*433d6423SLionel Sambuc Array1Par[IntLoc + 1] = Array1Par[IntLoc];
506*433d6423SLionel Sambuc Array1Par[IntLoc + 30] = IntLoc;
507*433d6423SLionel Sambuc for (IntIndex = IntLoc; IntIndex <= (IntLoc + 1); ++IntIndex)
508*433d6423SLionel Sambuc Array2Par[IntLoc][IntIndex] = IntLoc;
509*433d6423SLionel Sambuc ++Array2Par[IntLoc][IntLoc - 1];
510*433d6423SLionel Sambuc Array2Par[IntLoc + 20][IntLoc] = Array1Par[IntLoc];
511*433d6423SLionel Sambuc IntGlob = 5;
512*433d6423SLionel Sambuc }
513*433d6423SLionel Sambuc
514*433d6423SLionel Sambuc
Func1(CharPar1,CharPar2)515*433d6423SLionel Sambuc Enumeration Func1(CharPar1, CharPar2)
516*433d6423SLionel Sambuc CapitalLetter CharPar1;
517*433d6423SLionel Sambuc CapitalLetter CharPar2;
518*433d6423SLionel Sambuc {
519*433d6423SLionel Sambuc REG CapitalLetter CharLoc1;
520*433d6423SLionel Sambuc REG CapitalLetter CharLoc2;
521*433d6423SLionel Sambuc
522*433d6423SLionel Sambuc
523*433d6423SLionel Sambuc CharLoc1 = CharPar1;
524*433d6423SLionel Sambuc CharLoc2 = CharLoc1;
525*433d6423SLionel Sambuc if (CharLoc2 != CharPar2)
526*433d6423SLionel Sambuc return(Ident1);
527*433d6423SLionel Sambuc else
528*433d6423SLionel Sambuc return(Ident2);
529*433d6423SLionel Sambuc }
530*433d6423SLionel Sambuc
531*433d6423SLionel Sambuc
Func2(StrParI1,StrParI2)532*433d6423SLionel Sambuc boolean Func2(StrParI1, StrParI2)
533*433d6423SLionel Sambuc String30 StrParI1;
534*433d6423SLionel Sambuc String30 StrParI2;
535*433d6423SLionel Sambuc {
536*433d6423SLionel Sambuc REG OneToThirty IntLoc;
537*433d6423SLionel Sambuc REG CapitalLetter CharLoc;
538*433d6423SLionel Sambuc
539*433d6423SLionel Sambuc
540*433d6423SLionel Sambuc IntLoc = 1;
541*433d6423SLionel Sambuc while (IntLoc <= 1)
542*433d6423SLionel Sambuc if (Func1(StrParI1[IntLoc], StrParI2[IntLoc + 1]) == Ident1) {
543*433d6423SLionel Sambuc CharLoc = 'A';
544*433d6423SLionel Sambuc ++IntLoc;
545*433d6423SLionel Sambuc }
546*433d6423SLionel Sambuc if (CharLoc >= 'W' && CharLoc <= 'Z') IntLoc = 7;
547*433d6423SLionel Sambuc if (CharLoc == 'X')
548*433d6423SLionel Sambuc return(TRUE);
549*433d6423SLionel Sambuc else {
550*433d6423SLionel Sambuc if (strcmp(StrParI1, StrParI2) > 0) {
551*433d6423SLionel Sambuc IntLoc += 7;
552*433d6423SLionel Sambuc return(TRUE);
553*433d6423SLionel Sambuc } else
554*433d6423SLionel Sambuc return(FALSE);
555*433d6423SLionel Sambuc }
556*433d6423SLionel Sambuc }
557*433d6423SLionel Sambuc
558*433d6423SLionel Sambuc
Func3(EnumParIn)559*433d6423SLionel Sambuc boolean Func3(EnumParIn)
560*433d6423SLionel Sambuc REG Enumeration EnumParIn;
561*433d6423SLionel Sambuc {
562*433d6423SLionel Sambuc REG Enumeration EnumLoc;
563*433d6423SLionel Sambuc
564*433d6423SLionel Sambuc
565*433d6423SLionel Sambuc EnumLoc = EnumParIn;
566*433d6423SLionel Sambuc if (EnumLoc == Ident3) return(TRUE);
567*433d6423SLionel Sambuc return(FALSE);
568*433d6423SLionel Sambuc }
569*433d6423SLionel Sambuc
570*433d6423SLionel Sambuc
571*433d6423SLionel Sambuc #ifdef NOSTRUCTASSIGN
memcpy(d,s,l)572*433d6423SLionel Sambuc memcpy(d, s, l)
573*433d6423SLionel Sambuc register char *d;
574*433d6423SLionel Sambuc register char *s;
575*433d6423SLionel Sambuc register int l;
576*433d6423SLionel Sambuc {
577*433d6423SLionel Sambuc while (l--) *d++ = *s++;
578*433d6423SLionel Sambuc }
579*433d6423SLionel Sambuc
580*433d6423SLionel Sambuc #endif
581