xref: /freebsd/contrib/cortex-strings/benchmarks/dhry/dhry_1.c (revision 580744621f33383027108364dcadad718df46ffe)
1 /*
2  *************************************************************************
3  *
4  *                   "DHRYSTONE" Benchmark Program
5  *                   -----------------------------
6  *
7  *  Version:    C, Version 2.1
8  *
9  *  File:       dhry_1.c (part 2 of 3)
10  *
11  *  Date:       May 25, 1988
12  *
13  *  Author:     Reinhold P. Weicker
14  *
15  *************************************************************************
16  */
17 
18  #include <time.h>
19  #include <stdlib.h>
20  #include <stdio.h>
21  #include "dhry.h"
22  /*COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER*/
23 
24  #ifdef COW
25     #define compiler  "Watcom C/C++ 10.5 Win386"
26     #define options   "  -otexan -zp8 -5r -ms"
27  #endif
28  #ifdef CNW
29     #define compiler  "Watcom C/C++ 10.5 Win386"
30     #define options   "   No optimisation"
31  #endif
32  #ifdef COD
33     #define compiler  "Watcom C/C++ 10.5 Dos4GW"
34     #define options   "  -otexan -zp8 -5r -ms"
35  #endif
36  #ifdef CND
37     #define compiler  "Watcom C/C++ 10.5 Dos4GW"
38     #define options   "   No optimisation"
39  #endif
40  #ifdef CONT
41     #define compiler  "Watcom C/C++ 10.5 Win32NT"
42     #define options   "  -otexan -zp8 -5r -ms"
43  #endif
44  #ifdef CNNT
45     #define compiler  "Watcom C/C++ 10.5 Win32NT"
46     #define options   "   No optimisation"
47  #endif
48  #ifdef COO2
49     #define compiler  "Watcom C/C++ 10.5 OS/2-32"
50     #define options   "  -otexan -zp8 -5r -ms"
51  #endif
52  #ifdef CNO2
53     #define compiler  "Watcom C/C++ 10.5 OS/2-32"
54     #define options   "   No optimisation"
55  #endif
56 
57 
58 /* Global Variables: */
59 
60 Rec_Pointer     Ptr_Glob,
61                  Next_Ptr_Glob;
62 int             Int_Glob;
63  Boolean         Bool_Glob;
64  char            Ch_1_Glob,
65                  Ch_2_Glob;
66  int             Arr_1_Glob [50];
67  int             Arr_2_Glob [50] [50];
68  int             getinput = 1;
69 
70 
71  char Reg_Define[100] = "Register option      Selected.";
72 
73  Enumeration Func_1 (Capital_Letter Ch_1_Par_Val,
74                                            Capital_Letter Ch_2_Par_Val);
75    /*
76    forward declaration necessary since Enumeration may not simply be int
77    */
78 
79  #ifndef ROPT
80  #define REG
81          /* REG becomes defined as empty */
82          /* i.e. no register variables   */
83  #else
84  #define REG register
85  #endif
86 
87  void Proc_1 (REG Rec_Pointer Ptr_Val_Par);
88  void Proc_2 (One_Fifty *Int_Par_Ref);
89  void Proc_3 (Rec_Pointer *Ptr_Ref_Par);
90  void Proc_4 ();
91  void Proc_5 ();
92  void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par);
93  void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val,
94                                               One_Fifty *Int_Par_Ref);
95  void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
96                                int Int_1_Par_Val, int Int_2_Par_Val);
97 
98  Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref);
99 
100 
101  /* variables for time measurement: */
102 
103  #define Too_Small_Time 2
104                  /* Measurements should last at least 2 seconds */
105 
106  double          Begin_Time,
107                  End_Time,
108                  User_Time;
109 
110  double          Microseconds,
111                  Dhrystones_Per_Second,
112                  Vax_Mips;
113 
114  /* end of variables for time measurement */
115 
116 
117  void main (int argc, char *argv[])
118  /*****/
119 
120    /* main program, corresponds to procedures        */
121    /* Main and Proc_0 in the Ada version             */
122  {
123    double   dtime();
124 
125          One_Fifty   Int_1_Loc;
126    REG   One_Fifty   Int_2_Loc;
127          One_Fifty   Int_3_Loc;
128    REG   char        Ch_Index;
129          Enumeration Enum_Loc;
130          Str_30      Str_1_Loc;
131          Str_30      Str_2_Loc;
132    REG   int         Run_Index;
133    REG   int         Number_Of_Runs;
134          int         endit, count = 10;
135          FILE        *Ap;
136          char        general[9][80] = {" "};
137 
138    /* Initializations */
139     if (argc > 1)
140      {
141         switch (argv[1][0])
142          {
143              case 'N':
144                 getinput = 0;
145                 break;
146              case 'n':
147                 getinput = 0;
148                 break;
149          }
150       }
151 
152    if ((Ap = fopen("Dhry.txt","a+")) == NULL)
153      {
154         printf("Can not open Dhry.txt\n\n");
155         printf("Press any key\n");
156         exit(1);
157      }
158 
159 /***********************************************************************
160  *         Change for compiler and optimisation used                   *
161  ***********************************************************************/
162 
163    Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
164    Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
165 
166    Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
167    Ptr_Glob->Discr                       = Ident_1;
168    Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
169    Ptr_Glob->variant.var_1.Int_Comp      = 40;
170    strcpy (Ptr_Glob->variant.var_1.Str_Comp,
171            "DHRYSTONE PROGRAM, SOME STRING");
172    strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
173 
174    Arr_2_Glob [8][7] = 10;
175          /* Was missing in published program. Without this statement,   */
176          /* Arr_2_Glob [8][7] would have an undefined value.            */
177          /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
178          /* overflow may occur for this array element.                  */
179 
180    printf ("\n");
181    printf ("Dhrystone Benchmark, Version 2.1 (Language: C or C++)\n");
182    printf ("\n");
183 
184    if (getinput == 0)
185     {
186         printf ("No run time input data\n\n");
187     }
188    else
189     {
190          printf ("With run time input data\n\n");
191     }
192 
193    printf ("Compiler        %s\n", compiler);
194    printf ("Optimisation    %s\n", options);
195    #ifdef ROPT
196        printf ("Register option selected\n\n");
197    #else
198        printf ("Register option not selected\n\n");
199        strcpy(Reg_Define, "Register option      Not selected.");
200    #endif
201 
202  /*
203    if (Reg)
204    {
205      printf ("Program compiled with 'register' attribute\n");
206      printf ("\n");
207    }
208    else
209    {
210      printf ("Program compiled without 'register' attribute\n");
211      printf ("\n");
212    }
213 
214    printf ("Please give the number of runs through the benchmark: ");
215    {
216      int n;
217      scanf ("%d", &n);
218      Number_Of_Runs = n;
219    }
220    printf ("\n");
221    printf ("Execution starts, %d runs through Dhrystone\n",
222                                                  Number_Of_Runs);
223  */
224 
225    Number_Of_Runs = 5000;
226 
227    do
228      {
229 
230        Number_Of_Runs = Number_Of_Runs * 2;
231        count = count - 1;
232        Arr_2_Glob [8][7] = 10;
233 
234        /***************/
235        /* Start timer */
236        /***************/
237 
238        Begin_Time = dtime();
239 
240        for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
241        {
242 
243          Proc_5();
244          Proc_4();
245            /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
246          Int_1_Loc = 2;
247          Int_2_Loc = 3;
248          strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
249          Enum_Loc = Ident_2;
250          Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
251            /* Bool_Glob == 1 */
252          while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
253          {
254            Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
255              /* Int_3_Loc == 7 */
256            Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
257              /* Int_3_Loc == 7 */
258            Int_1_Loc += 1;
259          }   /* while */
260             /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
261          Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
262            /* Int_Glob == 5 */
263          Proc_1 (Ptr_Glob);
264          for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
265                               /* loop body executed twice */
266          {
267            if (Enum_Loc == Func_1 (Ch_Index, 'C'))
268                /* then, not executed */
269              {
270                Proc_6 (Ident_1, &Enum_Loc);
271                strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
272                Int_2_Loc = Run_Index;
273                Int_Glob = Run_Index;
274              }
275          }
276            /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
277          Int_2_Loc = Int_2_Loc * Int_1_Loc;
278          Int_1_Loc = Int_2_Loc / Int_3_Loc;
279          Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
280            /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
281          Proc_2 (&Int_1_Loc);
282            /* Int_1_Loc == 5 */
283 
284        }   /* loop "for Run_Index" */
285 
286        /**************/
287        /* Stop timer */
288        /**************/
289 
290        End_Time = dtime();
291        User_Time = End_Time - Begin_Time;
292 
293        printf ("%12.0f runs %6.2f seconds \n",(double) Number_Of_Runs, User_Time);
294        if (User_Time > 5)
295          {
296              count = 0;
297          }
298        else
299          {
300              if (User_Time < 0.1)
301                {
302                   Number_Of_Runs = Number_Of_Runs * 5;
303                }
304          }
305      }   /* calibrate/run do while */
306    while (count >0);
307 
308    printf ("\n");
309    printf ("Final values (* implementation-dependent):\n");
310    printf ("\n");
311    printf ("Int_Glob:      ");
312    if (Int_Glob == 5)  printf ("O.K.  ");
313    else                printf ("WRONG ");
314    printf ("%d  ", Int_Glob);
315 
316    printf ("Bool_Glob:     ");
317    if (Bool_Glob == 1) printf ("O.K.  ");
318    else                printf ("WRONG ");
319    printf ("%d\n", Bool_Glob);
320 
321    printf ("Ch_1_Glob:     ");
322    if (Ch_1_Glob == 'A')  printf ("O.K.  ");
323    else                   printf ("WRONG ");
324    printf ("%c  ", Ch_1_Glob);
325 
326    printf ("Ch_2_Glob:     ");
327    if (Ch_2_Glob == 'B')  printf ("O.K.  ");
328    else                   printf ("WRONG ");
329    printf ("%c\n",  Ch_2_Glob);
330 
331    printf ("Arr_1_Glob[8]: ");
332    if (Arr_1_Glob[8] == 7)  printf ("O.K.  ");
333    else                     printf ("WRONG ");
334    printf ("%d  ", Arr_1_Glob[8]);
335 
336    printf ("Arr_2_Glob8/7: ");
337    if (Arr_2_Glob[8][7] == Number_Of_Runs + 10)
338                           printf ("O.K.  ");
339    else                   printf ("WRONG ");
340    printf ("%10d\n", Arr_2_Glob[8][7]);
341 
342    printf ("Ptr_Glob->            ");
343    printf ("  Ptr_Comp:       *    %d\n", (int) Ptr_Glob->Ptr_Comp);
344 
345    printf ("  Discr:       ");
346    if (Ptr_Glob->Discr == 0)  printf ("O.K.  ");
347    else                       printf ("WRONG ");
348    printf ("%d  ", Ptr_Glob->Discr);
349 
350    printf ("Enum_Comp:     ");
351    if (Ptr_Glob->variant.var_1.Enum_Comp == 2)
352                         printf ("O.K.  ");
353    else                printf ("WRONG ");
354    printf ("%d\n", Ptr_Glob->variant.var_1.Enum_Comp);
355 
356    printf ("  Int_Comp:    ");
357    if (Ptr_Glob->variant.var_1.Int_Comp == 17)  printf ("O.K.  ");
358    else                                         printf ("WRONG ");
359    printf ("%d ", Ptr_Glob->variant.var_1.Int_Comp);
360 
361    printf ("Str_Comp:      ");
362    if (strcmp(Ptr_Glob->variant.var_1.Str_Comp,
363                         "DHRYSTONE PROGRAM, SOME STRING") == 0)
364                         printf ("O.K.  ");
365    else                printf ("WRONG ");
366    printf ("%s\n", Ptr_Glob->variant.var_1.Str_Comp);
367 
368    printf ("Next_Ptr_Glob->       ");
369    printf ("  Ptr_Comp:       *    %d", (int) Next_Ptr_Glob->Ptr_Comp);
370    printf (" same as above\n");
371 
372    printf ("  Discr:       ");
373    if (Next_Ptr_Glob->Discr == 0)
374                         printf ("O.K.  ");
375    else                printf ("WRONG ");
376    printf ("%d  ", Next_Ptr_Glob->Discr);
377 
378    printf ("Enum_Comp:     ");
379    if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1)
380                         printf ("O.K.  ");
381    else                printf ("WRONG ");
382    printf ("%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
383 
384    printf ("  Int_Comp:    ");
385    if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18)
386                         printf ("O.K.  ");
387    else                printf ("WRONG ");
388    printf ("%d ", Next_Ptr_Glob->variant.var_1.Int_Comp);
389 
390    printf ("Str_Comp:      ");
391    if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp,
392                         "DHRYSTONE PROGRAM, SOME STRING") == 0)
393                         printf ("O.K.  ");
394    else                printf ("WRONG ");
395    printf ("%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
396 
397    printf ("Int_1_Loc:     ");
398    if (Int_1_Loc == 5)
399                         printf ("O.K.  ");
400    else                printf ("WRONG ");
401    printf ("%d  ", Int_1_Loc);
402 
403    printf ("Int_2_Loc:     ");
404    if (Int_2_Loc == 13)
405                         printf ("O.K.  ");
406    else                printf ("WRONG ");
407    printf ("%d\n", Int_2_Loc);
408 
409    printf ("Int_3_Loc:     ");
410    if (Int_3_Loc == 7)
411                         printf ("O.K.  ");
412    else                printf ("WRONG ");
413    printf ("%d  ", Int_3_Loc);
414 
415    printf ("Enum_Loc:      ");
416    if (Enum_Loc == 1)
417                         printf ("O.K.  ");
418    else                printf ("WRONG ");
419    printf ("%d\n", Enum_Loc);
420 
421    printf ("Str_1_Loc:                             ");
422    if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0)
423                         printf ("O.K.  ");
424    else                printf ("WRONG ");
425    printf ("%s\n", Str_1_Loc);
426 
427    printf ("Str_2_Loc:                             ");
428    if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0)
429                         printf ("O.K.  ");
430    else                printf ("WRONG ");
431    printf ("%s\n", Str_2_Loc);
432 
433    printf ("\n");
434 
435 
436    if (User_Time < Too_Small_Time)
437    {
438      printf ("Measured time too small to obtain meaningful results\n");
439      printf ("Please increase number of runs\n");
440      printf ("\n");
441    }
442    else
443    {
444      Microseconds = User_Time * Mic_secs_Per_Second
445                          / (double) Number_Of_Runs;
446      Dhrystones_Per_Second = (double) Number_Of_Runs / User_Time;
447      Vax_Mips = Dhrystones_Per_Second / 1757.0;
448 
449      printf ("Microseconds for one run through Dhrystone: ");
450      printf ("%12.2lf \n", Microseconds);
451      printf ("Dhrystones per Second:                      ");
452      printf ("%10.0lf \n", Dhrystones_Per_Second);
453      printf ("VAX  MIPS rating =                          ");
454      printf ("%12.2lf \n",Vax_Mips);
455      printf ("\n");
456 
457 /************************************************************************
458  *             Type details of hardware, software etc.                  *
459  ************************************************************************/
460 
461    if (getinput == 1)
462      {
463         printf ("Enter the following which will be added with results to file DHRY.TXT\n");
464         printf ("When submitting a number of results you need only provide details once\n");
465         printf ("but a cross reference such as an abbreviated CPU type would be useful.\n");
466         printf ("You can kill (exit or close) the program now and no data will be added.\n\n");
467 
468         printf ("PC Supplier/model     ? ");
469         gets(general[1]);
470 
471         printf ("CPU chip              ? ");
472         gets(general[2]);
473 
474         printf ("Clock MHz             ? ");
475         gets(general[3]);
476 
477         printf ("Cache size            ? ");
478         gets(general[4]);
479 
480         printf ("Chipset & H/W options ? ");
481         gets(general[5]);
482 
483         printf ("OS/DOS version        ? ");
484         gets(general[6]);
485 
486         printf ("Your name             ? ");
487         gets(general[7]);
488 
489         printf ("Company/Location      ? ");
490         gets(general[8]);
491 
492         printf ("E-mail address        ? ");
493         gets(general[0]);
494      }
495 /************************************************************************
496  *                Add results to output file Dhry.txt                   *
497  ************************************************************************/
498    fprintf (Ap, "-------------------- -----------------------------------"
499                          "\n");
500    fprintf (Ap, "Dhrystone Benchmark  Version 2.1 (Language: C++)\n\n");
501    fprintf (Ap, "PC model             %s\n", general[1]);
502    fprintf (Ap, "CPU                  %s\n", general[2]);
503    fprintf (Ap, "Clock MHz            %s\n", general[3]);
504    fprintf (Ap, "Cache                %s\n", general[4]);
505    fprintf (Ap, "Options              %s\n", general[5]);
506    fprintf (Ap, "OS/DOS               %s\n", general[6]);
507    fprintf (Ap, "Compiler             %s\n", compiler);
508    fprintf (Ap, "OptLevel             %s\n", options);
509    fprintf (Ap, "Run by               %s\n", general[7]);
510    fprintf (Ap, "From                 %s\n", general[8]);
511    fprintf (Ap, "Mail                 %s\n\n", general[0]);
512 
513    fprintf (Ap, "Final values         (* implementation-dependent):\n");
514    fprintf (Ap, "\n");
515    fprintf (Ap, "Int_Glob:      ");
516    if (Int_Glob == 5)  fprintf (Ap, "O.K.  ");
517    else                fprintf (Ap, "WRONG ");
518    fprintf (Ap, "%d\n", Int_Glob);
519 
520    fprintf (Ap, "Bool_Glob:     ");
521    if (Bool_Glob == 1) fprintf (Ap, "O.K.  ");
522    else                fprintf (Ap, "WRONG ");
523    fprintf (Ap, "%d\n", Bool_Glob);
524 
525    fprintf (Ap, "Ch_1_Glob:     ");
526    if (Ch_1_Glob == 'A')  fprintf (Ap, "O.K.  ");
527    else                   fprintf (Ap, "WRONG ");
528    fprintf (Ap, "%c\n", Ch_1_Glob);
529 
530    fprintf (Ap, "Ch_2_Glob:     ");
531    if (Ch_2_Glob == 'B')  fprintf (Ap, "O.K.  ");
532    else                   fprintf (Ap, "WRONG ");
533    fprintf (Ap, "%c\n",  Ch_2_Glob);
534 
535    fprintf (Ap, "Arr_1_Glob[8]: ");
536    if (Arr_1_Glob[8] == 7)  fprintf (Ap, "O.K.  ");
537    else                     fprintf (Ap, "WRONG ");
538    fprintf (Ap, "%d\n", Arr_1_Glob[8]);
539 
540    fprintf (Ap, "Arr_2_Glob8/7: ");
541    if (Arr_2_Glob[8][7] == Number_Of_Runs + 10)
542                           fprintf (Ap, "O.K.  ");
543    else                   fprintf (Ap, "WRONG ");
544    fprintf (Ap, "%10d\n", Arr_2_Glob[8][7]);
545 
546    fprintf (Ap, "Ptr_Glob->  \n");
547    fprintf (Ap, "  Ptr_Comp:       *  %d\n", (int) Ptr_Glob->Ptr_Comp);
548 
549    fprintf (Ap, "  Discr:       ");
550    if (Ptr_Glob->Discr == 0)  fprintf (Ap, "O.K.  ");
551    else                       fprintf (Ap, "WRONG ");
552    fprintf (Ap, "%d\n", Ptr_Glob->Discr);
553 
554    fprintf (Ap, "  Enum_Comp:   ");
555    if (Ptr_Glob->variant.var_1.Enum_Comp == 2)
556                         fprintf (Ap, "O.K.  ");
557    else                fprintf (Ap, "WRONG ");
558    fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Enum_Comp);
559 
560    fprintf (Ap, "  Int_Comp:    ");
561    if (Ptr_Glob->variant.var_1.Int_Comp == 17)  fprintf (Ap, "O.K.  ");
562    else                                         fprintf (Ap, "WRONG ");
563    fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Int_Comp);
564 
565    fprintf (Ap, "  Str_Comp:    ");
566    if (strcmp(Ptr_Glob->variant.var_1.Str_Comp,
567                         "DHRYSTONE PROGRAM, SOME STRING") == 0)
568                         fprintf (Ap, "O.K.  ");
569    else                fprintf (Ap, "WRONG ");
570    fprintf (Ap, "%s\n", Ptr_Glob->variant.var_1.Str_Comp);
571 
572    fprintf (Ap, "Next_Ptr_Glob-> \n");
573    fprintf (Ap, "  Ptr_Comp:       *  %d", (int) Next_Ptr_Glob->Ptr_Comp);
574    fprintf (Ap, " same as above\n");
575 
576    fprintf (Ap, "  Discr:       ");
577    if (Next_Ptr_Glob->Discr == 0)
578                         fprintf (Ap, "O.K.  ");
579    else                fprintf (Ap, "WRONG ");
580    fprintf (Ap, "%d\n", Next_Ptr_Glob->Discr);
581 
582    fprintf (Ap, "  Enum_Comp:   ");
583    if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1)
584                         fprintf (Ap, "O.K.  ");
585    else                fprintf (Ap, "WRONG ");
586    fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
587 
588    fprintf (Ap, "  Int_Comp:    ");
589    if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18)
590                         fprintf (Ap, "O.K.  ");
591    else                fprintf (Ap, "WRONG ");
592    fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
593 
594    fprintf (Ap, "  Str_Comp:    ");
595    if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp,
596                         "DHRYSTONE PROGRAM, SOME STRING") == 0)
597                         fprintf (Ap, "O.K.  ");
598    else                fprintf (Ap, "WRONG ");
599    fprintf (Ap, "%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
600 
601    fprintf (Ap, "Int_1_Loc:     ");
602    if (Int_1_Loc == 5)
603                         fprintf (Ap, "O.K.  ");
604    else                fprintf (Ap, "WRONG ");
605    fprintf (Ap, "%d\n", Int_1_Loc);
606 
607    fprintf (Ap, "Int_2_Loc:     ");
608    if (Int_2_Loc == 13)
609                         fprintf (Ap, "O.K.  ");
610    else                fprintf (Ap, "WRONG ");
611    fprintf (Ap, "%d\n", Int_2_Loc);
612 
613    fprintf (Ap, "Int_3_Loc:     ");
614    if (Int_3_Loc == 7)
615                         fprintf (Ap, "O.K.  ");
616    else                fprintf (Ap, "WRONG ");
617    fprintf (Ap, "%d\n", Int_3_Loc);
618 
619    fprintf (Ap, "Enum_Loc:      ");
620    if (Enum_Loc == 1)
621                         fprintf (Ap, "O.K.  ");
622    else                fprintf (Ap, "WRONG ");
623    fprintf (Ap, "%d\n", Enum_Loc);
624 
625    fprintf (Ap, "Str_1_Loc:     ");
626    if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0)
627                         fprintf (Ap, "O.K.  ");
628    else                fprintf (Ap, "WRONG ");
629    fprintf (Ap, "%s\n", Str_1_Loc);
630 
631    fprintf (Ap, "Str_2_Loc:     ");
632    if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0)
633                         fprintf (Ap, "O.K.  ");
634    else                fprintf (Ap, "WRONG ");
635    fprintf (Ap, "%s\n", Str_2_Loc);
636 
637 
638    fprintf (Ap, "\n");
639    fprintf(Ap,"%s\n",Reg_Define);
640    fprintf (Ap, "\n");
641    fprintf(Ap,"Microseconds 1 loop:  %12.2lf\n",Microseconds);
642    fprintf(Ap,"Dhrystones / second:  %10.0lf\n",Dhrystones_Per_Second);
643    fprintf(Ap,"VAX MIPS rating:      %12.2lf\n\n",Vax_Mips);
644    fclose(Ap);
645    }
646 
647     printf ("\n");
648     printf ("A new results file will have been created in the same directory as the\n");
649     printf (".EXE files if one did not already exist. If you made a mistake on input, \n");
650     printf ("you can use a text editor to correct it, delete the results or copy \n");
651     printf ("them to a different file name. If you intend to run multiple tests you\n");
652     printf ("you may wish to rename DHRY.TXT with a more informative title.\n\n");
653     printf ("Please submit feedback and results files as a posting in Section 12\n");
654     printf ("or to Roy_Longbottom@compuserve.com\n\n");
655 
656     if (getinput == 1)
657      {
658         printf("Press any key to exit\n");
659         printf ("\nIf this is displayed you must close the window in the normal way\n");
660      }
661  }
662 
663 
664  void Proc_1 (REG Rec_Pointer Ptr_Val_Par)
665  /******************/
666 
667      /* executed once */
668  {
669    REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
670                                          /* == Ptr_Glob_Next */
671    /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp,    */
672    /* corresponds to "rename" in Ada, "with" in Pascal           */
673 
674    structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
675    Ptr_Val_Par->variant.var_1.Int_Comp = 5;
676    Next_Record->variant.var_1.Int_Comp
677          = Ptr_Val_Par->variant.var_1.Int_Comp;
678    Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
679    Proc_3 (&Next_Record->Ptr_Comp);
680      /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
681                          == Ptr_Glob->Ptr_Comp */
682    if (Next_Record->Discr == Ident_1)
683      /* then, executed */
684    {
685      Next_Record->variant.var_1.Int_Comp = 6;
686      Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
687             &Next_Record->variant.var_1.Enum_Comp);
688      Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
689      Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
690             &Next_Record->variant.var_1.Int_Comp);
691    }
692    else /* not executed */
693      structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
694  } /* Proc_1 */
695 
696 
697  void Proc_2 (One_Fifty *Int_Par_Ref)
698  /******************/
699      /* executed once */
700      /* *Int_Par_Ref == 1, becomes 4 */
701 
702  {
703    One_Fifty  Int_Loc;
704    Enumeration   Enum_Loc;
705 
706    Int_Loc = *Int_Par_Ref + 10;
707    do /* executed once */
708      if (Ch_1_Glob == 'A')
709        /* then, executed */
710      {
711        Int_Loc -= 1;
712        *Int_Par_Ref = Int_Loc - Int_Glob;
713        Enum_Loc = Ident_1;
714      } /* if */
715    while (Enum_Loc != Ident_1); /* true */
716  } /* Proc_2 */
717 
718 
719  void Proc_3 (Rec_Pointer *Ptr_Ref_Par)
720  /******************/
721      /* executed once */
722      /* Ptr_Ref_Par becomes Ptr_Glob */
723 
724  {
725    if (Ptr_Glob != Null)
726      /* then, executed */
727      *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
728    Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
729  } /* Proc_3 */
730 
731 
732 void Proc_4 () /* without parameters */
733  /*******/
734      /* executed once */
735  {
736    Boolean Bool_Loc;
737 
738    Bool_Loc = Ch_1_Glob == 'A';
739    Bool_Glob = Bool_Loc | Bool_Glob;
740    Ch_2_Glob = 'B';
741  } /* Proc_4 */
742 
743 
744  void Proc_5 () /* without parameters */
745  /*******/
746      /* executed once */
747  {
748    Ch_1_Glob = 'A';
749    Bool_Glob = false;
750  } /* Proc_5 */
751 
752 
753          /* Procedure for the assignment of structures,          */
754          /* if the C compiler doesn't support this feature       */
755  #ifdef  NOSTRUCTASSIGN
756  memcpy (d, s, l)
757  register char   *d;
758  register char   *s;
759  register int    l;
760  {
761          while (l--) *d++ = *s++;
762  }
763  #endif
764 
765 
766 double dtime()
767 {
768 
769   /* #include <ctype.h> */
770 
771   #define HZ CLOCKS_PER_SEC
772   clock_t tnow;
773 
774   double q;
775   tnow = clock();
776   q = (double)tnow / (double)HZ;
777   return q;
778 }
779