xref: /freebsd/contrib/cortex-strings/benchmarks/dhry/dhry_2.c (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1  /*
2   *************************************************************************
3   *
4   *                   "DHRYSTONE" Benchmark Program
5   *                   -----------------------------
6   *
7   *  Version:    C, Version 2.1
8   *
9   *  File:       dhry_2.c (part 3 of 3)
10   *
11   *  Date:       May 25, 1988
12   *
13   *  Author:     Reinhold P. Weicker
14   *
15   *************************************************************************
16   */
17 
18  #include "dhry.h"
19 
20  #ifndef REG
21  #define REG
22          /* REG becomes defined as empty */
23          /* i.e. no register variables   */
24  #else
25  #define REG register
26  #endif
27 
28  extern  int     Int_Glob;
29  extern  char    Ch_1_Glob;
30 
31  Boolean Func_3 (Enumeration Enum_Par_Val);
32 
33  void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
34  /*********************************/
35      /* executed once */
36      /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
37 
38  {
39    *Enum_Ref_Par = Enum_Val_Par;
40    if (! Func_3 (Enum_Val_Par))
41      /* then, not executed */
42      *Enum_Ref_Par = Ident_4;
43    switch (Enum_Val_Par)
44    {
45      case Ident_1:
46        *Enum_Ref_Par = Ident_1;
47        break;
48      case Ident_2:
49        if (Int_Glob > 100)
50          /* then */
51        *Enum_Ref_Par = Ident_1;
52        else *Enum_Ref_Par = Ident_4;
53        break;
54      case Ident_3: /* executed */
55        *Enum_Ref_Par = Ident_2;
56        break;
57      case Ident_4: break;
58      case Ident_5:
59        *Enum_Ref_Par = Ident_3;
60        break;
61    } /* switch */
62  } /* Proc_6 */
63 
64 
65  void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val,
66                                               One_Fifty *Int_Par_Ref)
67  /**********************************************/
68      /* executed three times                                      */
69      /* first call:      Int_1_Par_Val == 2, Int_2_Par_Val == 3,  */
70      /*                  Int_Par_Ref becomes 7                    */
71      /* second call:     Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
72      /*                  Int_Par_Ref becomes 17                   */
73      /* third call:      Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
74      /*                  Int_Par_Ref becomes 18                   */
75 
76  {
77    One_Fifty Int_Loc;
78 
79    Int_Loc = Int_1_Par_Val + 2;
80    *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
81  } /* Proc_7 */
82 
83 
84  void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
85                                   int Int_1_Par_Val, int Int_2_Par_Val)
86  /*********************************************************************/
87      /* executed once      */
88      /* Int_Par_Val_1 == 3 */
89      /* Int_Par_Val_2 == 7 */
90 
91  {
92    REG One_Fifty Int_Index;
93    REG One_Fifty Int_Loc;
94 
95    Int_Loc = Int_1_Par_Val + 5;
96    Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
97    Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
98    Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
99    for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
100      Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
101    Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
102    Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
103    Int_Glob = 5;
104  } /* Proc_8 */
105 
106 
107  Enumeration Func_1 (Capital_Letter Ch_1_Par_Val,
108                                            Capital_Letter Ch_2_Par_Val)
109  /*************************************************/
110      /* executed three times                                         */
111      /* first call:      Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R'    */
112      /* second call:     Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C'    */
113      /* third call:      Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C'    */
114 
115  {
116    Capital_Letter        Ch_1_Loc;
117    Capital_Letter        Ch_2_Loc;
118 
119    Ch_1_Loc = Ch_1_Par_Val;
120    Ch_2_Loc = Ch_1_Loc;
121    if (Ch_2_Loc != Ch_2_Par_Val)
122      /* then, executed */
123      return (Ident_1);
124    else  /* not executed */
125    {
126      Ch_1_Glob = Ch_1_Loc;
127      return (Ident_2);
128     }
129  } /* Func_1 */
130 
131 
132  Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref)
133  /*************************************************/
134      /* executed once */
135      /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
136      /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
137 
138  {
139    REG One_Thirty        Int_Loc;
140        Capital_Letter    Ch_Loc;
141 
142    Int_Loc = 2;
143    while (Int_Loc <= 2) /* loop body executed once */
144      if (Func_1 (Str_1_Par_Ref[Int_Loc],
145                  Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
146        /* then, executed */
147      {
148        Ch_Loc = 'A';
149        Int_Loc += 1;
150      } /* if, while */
151    if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
152      /* then, not executed */
153      Int_Loc = 7;
154    if (Ch_Loc == 'R')
155      /* then, not executed */
156      return (true);
157    else /* executed */
158    {
159      if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
160        /* then, not executed */
161      {
162        Int_Loc += 7;
163        Int_Glob = Int_Loc;
164        return (true);
165      }
166      else /* executed */
167        return (false);
168    } /* if Ch_Loc */
169  } /* Func_2 */
170 
171 
172  Boolean Func_3 (Enumeration Enum_Par_Val)
173  /***************************/
174      /* executed once        */
175      /* Enum_Par_Val == Ident_3 */
176 
177  {
178    Enumeration Enum_Loc;
179 
180    Enum_Loc = Enum_Par_Val;
181    if (Enum_Loc == Ident_3)
182      /* then, executed */
183      return (true);
184    else /* not executed */
185      return (false);
186  } /* Func_3 */
187