1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2015 Google, Inc
4  *
5  * Dhrystone is widely available in the public domain. A GPL license is
6  * chosen for U-Boot.
7  */
8 
9 /*****************************************************************************
10  *  The BYTE UNIX Benchmarks - Release 3
11  *          Module: dhry_2.c   SID: 3.4 5/15/91 19:30:22
12  *
13  *****************************************************************************
14  * Bug reports, patches, comments, suggestions should be sent to:
15  *
16  *	Ben Smith, Rick Grehan or Tom Yager
17  *	ben@bytepb.byte.com   rick_g@bytepb.byte.com   tyager@bytepb.byte.com
18  *
19  *****************************************************************************
20  *  Modification Log:
21  *  10/22/97 - code cleanup to remove ANSI C compiler warnings
22  *             Andy Kahn <kahn@zk3.dec.com>
23  *
24  *  Adapted from:
25  *
26  *                   "DHRYSTONE" Benchmark Program
27  *                   -----------------------------
28  *
29  * **** WARNING **** See warning in n.dhry_1.c
30  *
31  *  Version:    C, Version 2.1
32  *
33  *  File:       dhry_2.c (part 3 of 3)
34  *
35  *  Date:       May 25, 1988
36  *
37  *  Author:     Reinhold P. Weicker
38  *
39  ****************************************************************************/
40 /* SCCSid is defined in dhry_1.c */
41 
42 #include <linux/string.h>
43 #include "dhry.h"
44 
45 #ifndef REG
46 #define REG
47         /* REG becomes defined as empty */
48         /* i.e. no register variables   */
49 #endif
50 
51 extern  int     Int_Glob;
52 extern  char    Ch_1_Glob;
53 
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);
60 
Proc_6(Enumeration Enum_Val_Par,Enumeration * Enum_Ref_Par)61 void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
62     /* executed once */
63     /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
64 {
65   *Enum_Ref_Par = Enum_Val_Par;
66   if (! Func_3 (Enum_Val_Par))
67     /* then, not executed */
68     *Enum_Ref_Par = Ident_4;
69   switch (Enum_Val_Par)
70   {
71     case Ident_1:
72       *Enum_Ref_Par = Ident_1;
73       break;
74     case Ident_2:
75       if (Int_Glob > 100)
76         /* then */
77       *Enum_Ref_Par = Ident_1;
78       else *Enum_Ref_Par = Ident_4;
79       break;
80     case Ident_3: /* executed */
81       *Enum_Ref_Par = Ident_2;
82       break;
83     case Ident_4: break;
84     case Ident_5:
85       *Enum_Ref_Par = Ident_3;
86       break;
87   } /* switch */
88 } /* Proc_6 */
89 
Proc_7(Int_1_Par_Val,Int_2_Par_Val,Int_Par_Ref)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                   */
102 {
103   One_Fifty Int_Loc;
104 
105   Int_Loc = Int_1_Par_Val + 2;
106   *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
107 } /* Proc_7 */
108 
Proc_8(Arr_1_Par_Ref,Arr_2_Par_Ref,Int_1_Par_Val,Int_2_Par_Val)109 void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
110 /*********************************************************************/
111     /* executed once      */
112     /* Int_Par_Val_1 == 3 */
113     /* Int_Par_Val_2 == 7 */
114 Arr_1_Dim       Arr_1_Par_Ref;
115 Arr_2_Dim       Arr_2_Par_Ref;
116 int             Int_1_Par_Val;
117 int             Int_2_Par_Val;
118 {
119   REG One_Fifty Int_Index;
120   REG One_Fifty Int_Loc;
121 
122   Int_Loc = Int_1_Par_Val + 5;
123   Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
124   Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
125   Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
126   for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
127     Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
128   Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
129   Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
130   Int_Glob = 5;
131 } /* Proc_8 */
132 
Func_1(Capital_Letter Ch_1_Par_Val,Capital_Letter Ch_2_Par_Val)133 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
134 /*************************************************/
135     /* executed three times                                         */
136     /* first call:      Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R'    */
137     /* second call:     Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C'    */
138     /* third call:      Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C'    */
139 {
140   Capital_Letter        Ch_1_Loc;
141   Capital_Letter        Ch_2_Loc;
142 
143   Ch_1_Loc = Ch_1_Par_Val;
144   Ch_2_Loc = Ch_1_Loc;
145   if (Ch_2_Loc != Ch_2_Par_Val)
146     /* then, executed */
147     return (Ident_1);
148   else  /* not executed */
149   {
150     Ch_1_Glob = Ch_1_Loc;
151     return (Ident_2);
152    }
153 } /* Func_1 */
154 
Func_2(Str_1_Par_Ref,Str_2_Par_Ref)155 Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
156 /*************************************************/
157     /* executed once */
158     /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
159     /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
160 
161 Str_30  Str_1_Par_Ref;
162 Str_30  Str_2_Par_Ref;
163 {
164   REG One_Thirty        Int_Loc;
165       Capital_Letter    Ch_Loc;
166 
167   Ch_Loc = 'A';
168   Int_Loc = 2;
169   while (Int_Loc <= 2) /* loop body executed once */
170     if (Func_1 (Str_1_Par_Ref[Int_Loc],
171                 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
172       /* then, executed */
173     {
174       Ch_Loc = 'A';
175       Int_Loc += 1;
176     } /* if, while */
177   if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
178     /* then, not executed */
179     Int_Loc = 7;
180   if (Ch_Loc == 'R')
181     /* then, not executed */
182     return (true);
183   else /* executed */
184   {
185     if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
186       /* then, not executed */
187     {
188       Int_Loc += 7;
189       Int_Glob = Int_Loc;
190       return (true);
191     }
192     else /* executed */
193       return (false);
194   } /* if Ch_Loc */
195 } /* Func_2 */
196 
Func_3(Enum_Par_Val)197 Boolean Func_3 (Enum_Par_Val)
198 /***************************/
199     /* executed once        */
200     /* Enum_Par_Val == Ident_3 */
201 Enumeration Enum_Par_Val;
202 {
203   Enumeration Enum_Loc;
204 
205   Enum_Loc = Enum_Par_Val;
206   if (Enum_Loc == Ident_3)
207     /* then, executed */
208     return (true);
209   else /* not executed */
210     return (false);
211 } /* Func_3 */
212