dhry_2.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
  2. /*
  3. ****************************************************************************
  4. *
  5. * "DHRYSTONE" Benchmark Program
  6. * -----------------------------
  7. *
  8. * Version: C, Version 2.1
  9. *
  10. * File: dhry_2.c (part 3 of 3)
  11. *
  12. * Date: May 25, 1988
  13. *
  14. * Author: Reinhold P. Weicker
  15. *
  16. ****************************************************************************
  17. */
  18. #include "dhry.h"
  19. #include <linux/string.h>
  20. static Boolean Func_3(Enumeration Enum_Par_Val)
  21. /***************************/
  22. /* executed once */
  23. /* Enum_Par_Val == Ident_3 */
  24. {
  25. Enumeration Enum_Loc;
  26. Enum_Loc = Enum_Par_Val;
  27. if (Enum_Loc == Ident_3) {
  28. /* then, executed */
  29. return true;
  30. } else {
  31. /* not executed */
  32. return false;
  33. }
  34. } /* Func_3 */
  35. void Proc_6(Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
  36. /*********************************/
  37. /* executed once */
  38. /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
  39. {
  40. *Enum_Ref_Par = Enum_Val_Par;
  41. if (!Func_3(Enum_Val_Par)) {
  42. /* then, not executed */
  43. *Enum_Ref_Par = Ident_4;
  44. }
  45. switch (Enum_Val_Par) {
  46. case Ident_1:
  47. *Enum_Ref_Par = Ident_1;
  48. break;
  49. case Ident_2:
  50. if (Int_Glob > 100) {
  51. /* then */
  52. *Enum_Ref_Par = Ident_1;
  53. } else {
  54. *Enum_Ref_Par = Ident_4;
  55. }
  56. break;
  57. case Ident_3: /* executed */
  58. *Enum_Ref_Par = Ident_2;
  59. break;
  60. case Ident_4:
  61. break;
  62. case Ident_5:
  63. *Enum_Ref_Par = Ident_3;
  64. break;
  65. } /* switch */
  66. } /* Proc_6 */
  67. void Proc_7(One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, One_Fifty *Int_Par_Ref)
  68. /**********************************************/
  69. /* executed three times */
  70. /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
  71. /* Int_Par_Ref becomes 7 */
  72. /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
  73. /* Int_Par_Ref becomes 17 */
  74. /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
  75. /* Int_Par_Ref becomes 18 */
  76. {
  77. One_Fifty Int_Loc;
  78. Int_Loc = Int_1_Par_Val + 2;
  79. *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
  80. } /* Proc_7 */
  81. 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)
  82. /*********************************************************************/
  83. /* executed once */
  84. /* Int_Par_Val_1 == 3 */
  85. /* Int_Par_Val_2 == 7 */
  86. {
  87. One_Fifty Int_Index;
  88. One_Fifty Int_Loc;
  89. Int_Loc = Int_1_Par_Val + 5;
  90. Arr_1_Par_Ref[Int_Loc] = Int_2_Par_Val;
  91. Arr_1_Par_Ref[Int_Loc+1] = Arr_1_Par_Ref[Int_Loc];
  92. Arr_1_Par_Ref[Int_Loc+30] = Int_Loc;
  93. for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
  94. Arr_2_Par_Ref[Int_Loc][Int_Index] = Int_Loc;
  95. Arr_2_Par_Ref[Int_Loc][Int_Loc-1] += 1;
  96. Arr_2_Par_Ref[Int_Loc+20][Int_Loc] = Arr_1_Par_Ref[Int_Loc];
  97. Int_Glob = 5;
  98. } /* Proc_8 */
  99. Enumeration Func_1(Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
  100. /*************************************************/
  101. /* executed three times */
  102. /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
  103. /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
  104. /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
  105. {
  106. Capital_Letter Ch_1_Loc;
  107. Capital_Letter Ch_2_Loc;
  108. Ch_1_Loc = Ch_1_Par_Val;
  109. Ch_2_Loc = Ch_1_Loc;
  110. if (Ch_2_Loc != Ch_2_Par_Val) {
  111. /* then, executed */
  112. return Ident_1;
  113. } else {
  114. /* not executed */
  115. Ch_1_Glob = Ch_1_Loc;
  116. return Ident_2;
  117. }
  118. } /* Func_1 */
  119. Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref)
  120. /*************************************************/
  121. /* executed once */
  122. /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
  123. /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
  124. {
  125. One_Thirty Int_Loc;
  126. Capital_Letter Ch_Loc;
  127. Int_Loc = 2;
  128. while (Int_Loc <= 2) {
  129. /* loop body executed once */
  130. if (Func_1(Str_1_Par_Ref[Int_Loc],
  131. Str_2_Par_Ref[Int_Loc+1]) == Ident_1) {
  132. /* then, executed */
  133. Ch_Loc = 'A';
  134. Int_Loc += 1;
  135. }
  136. } /* if, while */
  137. if (Ch_Loc >= 'W' && Ch_Loc < 'Z') {
  138. /* then, not executed */
  139. Int_Loc = 7;
  140. }
  141. if (Ch_Loc == 'R') {
  142. /* then, not executed */
  143. return true;
  144. } else {
  145. /* executed */
  146. if (strcmp(Str_1_Par_Ref, Str_2_Par_Ref) > 0) {
  147. /* then, not executed */
  148. Int_Loc += 7;
  149. Int_Glob = Int_Loc;
  150. return true;
  151. } else {
  152. /* executed */
  153. return false;
  154. }
  155. } /* if Ch_Loc */
  156. } /* Func_2 */