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