dhrystone.c 4.7 KB

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