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