1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2015 Google, Inc
5 * Dhrystone is widely available in the public domain. A GPL license is
9 /*****************************************************************************
10 * The BYTE UNIX Benchmarks - Release 3
11 * Module: dhry_2.c SID: 3.4 5/15/91 19:30:22
13 *****************************************************************************
14 * Bug reports, patches, comments, suggestions should be sent to:
16 * Ben Smith, Rick Grehan or Tom Yager
17 * ben@bytepb.byte.com rick_g@bytepb.byte.com tyager@bytepb.byte.com
19 *****************************************************************************
21 * 10/22/97 - code cleanup to remove ANSI C compiler warnings
22 * Andy Kahn <kahn@zk3.dec.com>
26 * "DHRYSTONE" Benchmark Program
27 * -----------------------------
29 * **** WARNING **** See warning in n.dhry_1.c
31 * Version: C, Version 2.1
33 * File: dhry_2.c (part 3 of 3)
37 * Author: Reinhold P. Weicker
39 ****************************************************************************/
40 /* SCCSid is defined in dhry_1.c */
47 /* REG becomes defined as empty */
48 /* i.e. no register variables */
52 extern char Ch_1_Glob;
54 void Proc_6(Enumeration, Enumeration *);
55 void Proc_7(One_Fifty, One_Fifty, One_Fifty *);
56 void Proc_8(Arr_1_Dim, Arr_2_Dim, int, int);
57 Enumeration Func_1(Capital_Letter, Capital_Letter);
58 Boolean Func_2(Str_30, Str_30);
59 Boolean Func_3(Enumeration);
61 void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
63 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
65 *Enum_Ref_Par = Enum_Val_Par;
66 if (! Func_3 (Enum_Val_Par))
67 /* then, not executed */
68 *Enum_Ref_Par = Ident_4;
72 *Enum_Ref_Par = Ident_1;
77 *Enum_Ref_Par = Ident_1;
78 else *Enum_Ref_Par = Ident_4;
80 case Ident_3: /* executed */
81 *Enum_Ref_Par = Ident_2;
85 *Enum_Ref_Par = Ident_3;
90 void Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
91 One_Fifty Int_1_Par_Val;
92 One_Fifty Int_2_Par_Val;
93 One_Fifty *Int_Par_Ref;
94 /**********************************************/
95 /* executed three times */
96 /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
97 /* Int_Par_Ref becomes 7 */
98 /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
99 /* Int_Par_Ref becomes 17 */
100 /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
101 /* Int_Par_Ref becomes 18 */
105 Int_Loc = Int_1_Par_Val + 2;
106 *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
110 void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
111 /*********************************************************************/
113 /* Int_Par_Val_1 == 3 */
114 /* Int_Par_Val_2 == 7 */
115 Arr_1_Dim Arr_1_Par_Ref;
116 Arr_2_Dim Arr_2_Par_Ref;
120 REG One_Fifty Int_Index;
121 REG One_Fifty Int_Loc;
123 Int_Loc = Int_1_Par_Val + 5;
124 Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
125 Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
126 Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
127 for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
128 Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
129 Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
130 Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
135 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
136 /*************************************************/
137 /* executed three times */
138 /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
139 /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
140 /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
142 Capital_Letter Ch_1_Loc;
143 Capital_Letter Ch_2_Loc;
145 Ch_1_Loc = Ch_1_Par_Val;
147 if (Ch_2_Loc != Ch_2_Par_Val)
150 else /* not executed */
152 Ch_1_Glob = Ch_1_Loc;
159 Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
160 /*************************************************/
162 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
163 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
165 Str_30 Str_1_Par_Ref;
166 Str_30 Str_2_Par_Ref;
168 REG One_Thirty Int_Loc;
169 Capital_Letter Ch_Loc;
173 while (Int_Loc <= 2) /* loop body executed once */
174 if (Func_1 (Str_1_Par_Ref[Int_Loc],
175 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
181 if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
182 /* then, not executed */
185 /* then, not executed */
189 if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
190 /* then, not executed */
202 Boolean Func_3 (Enum_Par_Val)
203 /***************************/
205 /* Enum_Par_Val == Ident_3 */
206 Enumeration Enum_Par_Val;
208 Enumeration Enum_Loc;
210 Enum_Loc = Enum_Par_Val;
211 if (Enum_Loc == Ident_3)
214 else /* not executed */