dhry_2.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * (C) Copyright 2015 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. *
  6. * Dhrystone is widely available in the public domain. A GPL license is
  7. * chosen for U-Boot.
  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. #include <common.h>
  42. #include "dhry.h"
  43. #ifndef REG
  44. #define REG
  45. /* REG becomes defined as empty */
  46. /* i.e. no register variables */
  47. #endif
  48. extern int Int_Glob;
  49. extern char Ch_1_Glob;
  50. void Proc_6(Enumeration, Enumeration *);
  51. void Proc_7(One_Fifty, One_Fifty, One_Fifty *);
  52. void Proc_8(Arr_1_Dim, Arr_2_Dim, int, int);
  53. Enumeration Func_1(Capital_Letter, Capital_Letter);
  54. Boolean Func_2(Str_30, Str_30);
  55. Boolean Func_3(Enumeration);
  56. void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
  57. /* executed once */
  58. /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
  59. {
  60. *Enum_Ref_Par = Enum_Val_Par;
  61. if (! Func_3 (Enum_Val_Par))
  62. /* then, not executed */
  63. *Enum_Ref_Par = Ident_4;
  64. switch (Enum_Val_Par)
  65. {
  66. case Ident_1:
  67. *Enum_Ref_Par = Ident_1;
  68. break;
  69. case Ident_2:
  70. if (Int_Glob > 100)
  71. /* then */
  72. *Enum_Ref_Par = Ident_1;
  73. else *Enum_Ref_Par = Ident_4;
  74. break;
  75. case Ident_3: /* executed */
  76. *Enum_Ref_Par = Ident_2;
  77. break;
  78. case Ident_4: break;
  79. case Ident_5:
  80. *Enum_Ref_Par = Ident_3;
  81. break;
  82. } /* switch */
  83. } /* Proc_6 */
  84. void Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
  85. One_Fifty Int_1_Par_Val;
  86. One_Fifty Int_2_Par_Val;
  87. One_Fifty *Int_Par_Ref;
  88. /**********************************************/
  89. /* executed three times */
  90. /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
  91. /* Int_Par_Ref becomes 7 */
  92. /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
  93. /* Int_Par_Ref becomes 17 */
  94. /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
  95. /* Int_Par_Ref becomes 18 */
  96. {
  97. One_Fifty Int_Loc;
  98. Int_Loc = Int_1_Par_Val + 2;
  99. *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
  100. } /* Proc_7 */
  101. void Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
  102. /*********************************************************************/
  103. /* executed once */
  104. /* Int_Par_Val_1 == 3 */
  105. /* Int_Par_Val_2 == 7 */
  106. Arr_1_Dim Arr_1_Par_Ref;
  107. Arr_2_Dim Arr_2_Par_Ref;
  108. int Int_1_Par_Val;
  109. int Int_2_Par_Val;
  110. {
  111. REG One_Fifty Int_Index;
  112. REG One_Fifty Int_Loc;
  113. Int_Loc = Int_1_Par_Val + 5;
  114. Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
  115. Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
  116. Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
  117. for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
  118. Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
  119. Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
  120. Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
  121. Int_Glob = 5;
  122. } /* Proc_8 */
  123. Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
  124. /*************************************************/
  125. /* executed three times */
  126. /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
  127. /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
  128. /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
  129. {
  130. Capital_Letter Ch_1_Loc;
  131. Capital_Letter Ch_2_Loc;
  132. Ch_1_Loc = Ch_1_Par_Val;
  133. Ch_2_Loc = Ch_1_Loc;
  134. if (Ch_2_Loc != Ch_2_Par_Val)
  135. /* then, executed */
  136. return (Ident_1);
  137. else /* not executed */
  138. {
  139. Ch_1_Glob = Ch_1_Loc;
  140. return (Ident_2);
  141. }
  142. } /* Func_1 */
  143. Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
  144. /*************************************************/
  145. /* executed once */
  146. /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
  147. /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
  148. Str_30 Str_1_Par_Ref;
  149. Str_30 Str_2_Par_Ref;
  150. {
  151. REG One_Thirty Int_Loc;
  152. Capital_Letter Ch_Loc;
  153. Ch_Loc = 'A';
  154. Int_Loc = 2;
  155. while (Int_Loc <= 2) /* loop body executed once */
  156. if (Func_1 (Str_1_Par_Ref[Int_Loc],
  157. Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
  158. /* then, executed */
  159. {
  160. Ch_Loc = 'A';
  161. Int_Loc += 1;
  162. } /* if, while */
  163. if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
  164. /* then, not executed */
  165. Int_Loc = 7;
  166. if (Ch_Loc == 'R')
  167. /* then, not executed */
  168. return (true);
  169. else /* executed */
  170. {
  171. if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
  172. /* then, not executed */
  173. {
  174. Int_Loc += 7;
  175. Int_Glob = Int_Loc;
  176. return (true);
  177. }
  178. else /* executed */
  179. return (false);
  180. } /* if Ch_Loc */
  181. } /* Func_2 */
  182. Boolean Func_3 (Enum_Par_Val)
  183. /***************************/
  184. /* executed once */
  185. /* Enum_Par_Val == Ident_3 */
  186. Enumeration Enum_Par_Val;
  187. {
  188. Enumeration Enum_Loc;
  189. Enum_Loc = Enum_Par_Val;
  190. if (Enum_Loc == Ident_3)
  191. /* then, executed */
  192. return (true);
  193. else /* not executed */
  194. return (false);
  195. } /* Func_3 */