Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/front/gate-front-ir.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / front / gate-front-ir.om` 1553 lines · 31957 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note seed/ng/front/gate-front-ir.om: the ΩIR emission gate of ng-front (Hive NG M1). Owner: ng-front lane. 3 note Handwritten seeded Omega, program mode, Linux AArch64. The child and file helpers follow 4 note seed/ng/gate-ir.om; seed/ng/sha256.om supplies sh_dat, sh_all and sh_dig. 5 note Build: cat seed/ng/sha256.om seed/ng/front/gate-front-ir.om | seed/out/omc > gate-front-ir 6 note Run from the repository root: gate-front-ir OMC OMC_SHA256 SCRATCH CASES 7 note OMC the oracle compiler; its sha256 must be OMC_SHA256 (64 lowercase hex) or nothing runs (INVALID) 8 note SCRATCH a new directory (created 0700; an existing one is INVALID) 9 note CASES lines `run NAME SRC`, `refuse NAME SRC` or `host NAME SRC C` (SRC a path from the repository 10 note root, C a decimal exit); lines starting 11 note with # and blank lines are skipped 12 note 1. OMC builds ng (the units of seed/ng/ng.units concatenated in order, so a stage unit such as src/a64.om 13 note comes with the list), ngcheck (seed/ng/sha256.om, seed/ng/ngcheck.om) and ngrun (seed/ng/src/ir.om, 14 note seed/ng/ngrun.om); a failed build is exit 3. The mutants must occur exactly once in all the units. 15 note 2. run: OMC compiles SRC and the binary runs (empty stdin). ng reads `@ng front-ir` then SRC and must exit 16 note 0; ngcheck must exit 0 on its stdout with a line starting "ACCEPT "; ngrun runs that ΩIR. The exit 17 note status and the stdout of ngrun must equal the OMC binary's (stderr is not compared: the bench kernels 18 note write their timing there; a trap is exit 100 + code on both sides). 19 note refuse: OMC refuses SRC (exit not 0); ng in front-ir mode exits with the same code and the same stderr 20 note bytes and writes no stdout (fe_check is the refusal path of front-ir). 21 note host: a host-word fixture. OMC compiles SRC and the binary runs (empty stdin, the repository root as its 22 note working directory: the host fixtures name only empty or /dev/null paths and invalid descriptors). ng 23 note front-ir exits 0 and ngcheck ACCEPTs its stdout; ngrun runs that ΩIR with --scratch SCRATCH/hK (K a new 24 note number, so a new directory per run). C 0: exit and stdout equal the binary's, as for run. C 115..123: 25 note ngrun refuses the word by that class of IR.md s7.11 (exit C, no stdout): the ΩIR is checked, not run. 26 note 3. negative controls, each must fail a case: eighteen lowering mutants of seed/ng/src/front.om (the for 27 note latch adds 2; and, or, xor shifted to the next op; a part's offset and count swapped; a mixed-type 28 note shift amount checked against its own width; fma's second and third operands swapped; a struct 29 note field index that adds the length for the offset, an array bound taken from the offset, a big-endian layout 30 note field read and written with the byte order reversed, the dup32 retained check with eq as ne) over the run 31 note cases; two host lowering mutants (a long argument typed int; chk.bounds for a host slice's chk.slice) 32 note over the host cases; fmin lowered as max and fmax as min, qty add/sub/mul without their checks, and every array parameter declared read-only, over the run cases; the first run case through ng in `@ng front-check` mode (no ΩIR); the first refuse case 33 note through ng in `@ng ir-copy` mode. 34 note Deadline: every child (omc, the binary, ng, ngcheck, ngrun) is killed after 600 s of wall time (ngrun has 35 note no step cap of its own yet); a case with a killed child prints `NOT_RUN NAME: ...` and is neither ok nor 36 note FAIL, and does not kill a mutant or trip a control. 37 note Output: a line per case (ok / FAIL / NOT_RUN), a line per control, then 38 note FRONTIRGATE PASS|FAIL|NOT_RUN cases=N run=R refuse=F host=H classed=Q fail=K mutants=M killed=X controls=C 39 note tripped=T notrun=U (N = R + F + H; Q of the H host cases were checked and refused by ngrun's class) 40 note Exit 0 PASS, 1 FAIL, 2 INVALID (usage, oracle, scratch, case list), 3 a tool did not build, 4 NOT_RUN (no 41 note failure, but U > 0 cases passed the deadline: never PASS). 42 note Globals g_*, functions gi_*. 43 text g_w "seed/ng/ src/ir.om src/front.om src/main.om sha256.om ngcheck.om ngrun.om ng ngcheck ngrun src.om bin in ir o1 o2 e1 e2 ck err nul ngm run refuse ng.units host --scratch h " 44 text g_m "FAIL |ok |: omc exit |: ng exit |: ngcheck exit |: ngcheck did not accept|: exit omc=| ngrun=|: stdout differs|: omc accepted a refuse case|: ng stderr differs|: ng wrote stdout| exit=|FRONTIRGATE PASS|FRONTIRGATE FAIL|FRONTIRGATE INVALID: | cases=| run=| refuse=| fail=| mutants=| killed=| controls=| tripped=|usage: gate-front-ir OMC OMC_SHA256 SCRATCH CASES|oracle sha256 differs from OMC_SHA256|scratch exists or cannot be made|case list unreadable|build failed: |malformed case line|mutant |: survived every run case|: killed by |control front-check mode|control ir-copy mode|: not tripped|: tripped by |: pattern not present exactly once|: source unreadable|NOT_RUN |: a child passed the 600 s deadline and was killed|FRONTIRGATE NOT_RUN| notrun=| host=| classed=|: ngrun exit is not the expected class |: ngrun wrote stdout|" 45 text g_pfr "@ng front-ir\n" 46 text g_acc "ACCEPT " 47 text g_pfc "@ng front-check\n" 48 text g_pic "@ng ir-copy\n" 49 note the lowering mutants (pattern, replacement of the same length; each pattern occurs once in front.om) 50 text g_mu0 "\nar_pu 71 n0 fe_lp2 10 t iv fe_lcst t 1\n" 51 text g_mu1 "\nar_pu 71 n0 fe_lp2 10 t iv fe_lcst t 2\n" 52 text g_mu2 "\nfe_lval fe_lp2 uint add sub c 38 16 t a b t\n" 53 text g_mu3 "\nfe_lval fe_lp2 uint add sub c 38 17 t a b t\n" 54 text g_mu4 "\nir_set o 2 off\nir_set o 3 n\n" 55 text g_mu5 "\nir_set o 2 n\nir_set o 3 off\n" 56 note 4: a mixed-type shift amount checked against its own width, not the value's (fe_lsham); 5: fma's 57 note second and third operands swapped (fe_lfma) 58 text g_mu6 "\nk = fe_lp2 32 1 u fe_lcst 5 fe_twid a\n" 59 text g_mu7 "\nk = fe_lp2 32 1 u fe_lcst 5 fe_twid b\n" 60 text g_mu8 "\nir_set o 1 fb\nir_set o 2 fc\n" 61 text g_mu9 "\nir_set o 1 fc\nir_set o 2 fb\n" 62 note 6: a long host argument lowered as int (fe_lhost); 7: chk.bounds in place of a host slice's chk.slice 63 text g_mu10 "\nif eq ch 108\nt = ulong 9\n" 64 text g_mu11 "\nif eq ch 108\nt = ulong 8\n" 65 text g_mu12 "\nfe_lck3 80 ar ao an\n" 66 text g_mu13 "\nfe_lck3 79 ar ao an\n" 67 note 8: fmin lowered as max and fmax as min (fe_lfmm). The real opcode is 24+(c-93). 68 note A same-length swap is sub 118 add c 0 (25 when c is 93, 24 when c is 94). 69 note add 25 sub c 93 is not that swap: fmax becomes opcode 26 (fsqrt, one operand). 70 text g_mu14 "\nfe_lval fe_lp2 uint add 24 sub c 93 t a get f_lrv 0 t\n" 71 text g_mu15 "\nfe_lval fe_lp2 uint sub 118 add c 0 t a get f_lrv 0 t\n" 72 note 9: qty add, sub and mul without their chk (fe_lbop tests type 14, which no value has) 73 text g_mu16 "\nif or s eq t 13\n" 74 text g_mu17 "\nif or s eq t 14\n" 75 note 10: every array parameter declared with access 0 (fe_lfpar), so an edit parameter is read-only 76 text g_mu18 "\nv = ir_fpar f ir_tslc fe_lty t a 0\n" 77 text g_mu19 "\nv = ir_fpar f ir_tslc fe_lty t 0 0\n" 78 text g_mu20 "\nfe_lck1 82 code get f_lrv 0\n" 79 text g_mu21 "\nfe_lck1 82 code fe_lcst 1 1\n" 80 text g_mu22 "\nfe_lcscan 2\n" 81 text g_mu23 "\nfe_lcscan 0\n" 82 text g_mu24 "\nfe_lck1 82 10 get f_lrv 0\n" 83 text g_mu25 "\nfe_lck1 82 10 fe_lcst 1 1\n" 84 note 11-15: struct, layout and nominal lowering (fe_lstindex, fe_llyget, fe_llyput, fe_lseal): a struct field 85 note index adds the length in place of the offset (11); the array bound is the offset in place of the length 86 note (12); a big-endian layout field read and written from the wrong byte (13, 14); the dup32 retained check 87 note compares the halves with ne in place of eq (15) 88 text g_mu26 "\nend\nret fe_lp2 10 5 ix fe_lcst 5 off\n" 89 text g_mu27 "\nend\nret fe_lp2 10 5 ix fe_lcst 5 cnt\n" 90 text g_mu28 "fe_lcst 5 cnt\nend\nret fe_lp2 10 5 ix" 91 text g_mu29 "fe_lcst 5 off\nend\nret fe_lp2 10 5 ix" 92 text g_mu30 "\nk = sub sub n 1 j\nend\nb = fe_lp2 20 5 b" 93 text g_mu31 "\nk = sub sub n 0 j\nend\nb = fe_lp2 20 5 b" 94 text g_mu32 "\nk = sub sub n 1 j\nend\nb = fe_lp2 21 5 v" 95 text g_mu33 "\nk = sub sub n 0 j\nend\nb = fe_lp2 21 5 v" 96 text g_mu34 "\nok = fe_lp2 30 1 hi lo\n" 97 text g_mu35 "\nok = fe_lp2 31 1 hi lo\n" 98 global g_wo uint 64 99 global g_wl uint 64 100 global g_mo uint 64 101 global g_ml uint 64 102 global g_omc uchar 4096 103 global g_scr uchar 4096 104 global g_pa uchar 8192 105 global g_av uchar 16384 106 global g_b1 uchar `16777216` 107 global g_b2 uchar `16777216` 108 global g_cs uchar `1048576` 109 global g_o uchar 4096 110 global g_stb uchar 4 111 global g_hx uchar 128 112 global g_ma uchar 64 113 global g_mb uchar 64 114 global g_n ulong 32 115 note g_hc: the expected class C of the current host case; g_hk: the last ngrun scratch number 116 global g_hc ulong 1 117 global g_hk ulong 1 118 note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 b1 length, 119 note 6 b2 length, 7 cases length, 8 cases cursor, 9 out length, 10 cases, 11 run cases, 12 refuse cases, 120 note 13 failed cases, 14 quiet (controls and mutants), 15 current case failed, 16 name start, 17 name end, 121 note 18 source start, 19 source end, 20 mutants, 21 killed, 22 controls, 23 tripped, 24 ng mode (0 front-ir, 122 note 1 front-check, 2 ir-copy), 25 ng binary word, 26 line start, 27 mutant pattern length, 28 NOT_RUN cases, 123 note 29 a child of the current case passed the deadline (g_n 15 is 0 ok, 1 failed, 2 NOT_RUN), 30 host cases, 124 note 31 host cases ngrun refused by their class 125 126 note ---- words and output ------------------------------------------------------------------------ 127 fn gi_init to void 128 w = ulong 0 129 s = ulong 0 130 for i ulong len g_w 131 if eq get g_w i 32 132 put g_wo w uint s 133 put g_wl w uint sub i s 134 w = add w 1 135 s = add i 1 136 end 137 end 138 w = 0 139 s = 0 140 for i ulong len g_m 141 if eq get g_m i 124 142 put g_mo w uint s 143 put g_ml w uint sub i s 144 w = add w 1 145 s = add i 1 146 end 147 end 148 put g_n 25 7 149 end 150 fn gi_c b ulong to void 151 n = get g_n 9 152 if lt n len g_o 153 put g_o n uchar b 154 put g_n 9 add n 1 155 end 156 end 157 fn gi_nl to void 158 gi_c 10 159 r = write 1 g_o 0 get g_n 9 160 put g_n 9 0 161 end 162 fn gi_say i ulong to void 163 s = ulong get g_mo i 164 for j ulong ulong get g_ml i bound 128 165 gi_c ulong get g_m add s j 166 end 167 end 168 fn gi_num v ulong to void 169 if ge v 10 170 gi_num div v 10 171 end 172 gi_c add 48 rem v 10 173 end 174 note the name of the current case 175 fn gi_name to void 176 for p ulong sub get g_n 17 get g_n 16 bound 4096 177 gi_c ulong get g_cs add get g_n 16 p 178 end 179 end 180 note a failure of the current case: FAIL NAME, unless quiet 181 fn gi_fail i ulong to void 182 put g_n 15 1 183 if ne get g_n 14 0 184 ret 185 end 186 gi_say 0 187 gi_name 188 gi_say i 189 end 190 fn gi_fail0 i ulong to void 191 gi_fail i 192 if eq get g_n 14 0 193 gi_nl 194 end 195 end 196 fn gi_failv i ulong v ulong to void 197 gi_fail i 198 if eq get g_n 14 0 199 gi_num v 200 gi_nl 201 end 202 end 203 204 note ---- paths -------------------------------------------------------------------------------------- 205 fn gi_pclr to void 206 put g_n 0 0 207 end 208 fn gi_pc c ulong to void 209 n = get g_n 0 210 if lt n len g_pa 211 put g_pa n uchar c 212 put g_n 0 add n 1 213 end 214 end 215 fn gi_pw i ulong to void 216 s = ulong get g_wo i 217 for j ulong ulong get g_wl i bound 64 218 gi_pc ulong get g_w add s j 219 end 220 end 221 note scratch file word i 222 fn gi_ps i ulong to void 223 gi_pclr 224 for j ulong get g_n 2 bound 4096 225 gi_pc ulong get g_scr j 226 end 227 gi_pw i 228 end 229 note repository file seed/ng/ + word i 230 fn gi_pr i ulong to void 231 gi_pclr 232 gi_pw 0 233 gi_pw i 234 end 235 note the source path of the current case 236 fn gi_psrc to void 237 gi_pclr 238 for p ulong sub get g_n 19 get g_n 18 bound 4096 239 gi_pc ulong get g_cs add get g_n 18 p 240 end 241 end 242 fn gi_open fl ulong to int 243 r = fopen g_pa 0 get g_n 0 int fl 420 244 if lt r 0 245 ret -1 246 end 247 ret int r 248 end 249 fn gi_rdonly to int 250 ret gi_open 524288 251 end 252 fn gi_wronly to int 253 ret gi_open 524865 254 end 255 note open scratch g_pa for writing with mode 0755 (created fresh: unlink first) 256 fn gi_exe to int 257 r = unlink g_pa 0 get g_n 0 258 x = fopen g_pa 0 get g_n 0 524865 493 259 if lt x 0 260 ret -1 261 end 262 ret int x 263 end 264 fn gi_fclo fd int to void 265 if ge fd 0 266 r = fclose fd 267 end 268 end 269 270 note ---- whole files ---------------------------------------------------------------------------------- 271 note read the file at g_pa into b1 (k 1) or b2 (k 2) at offset o; its length, or 2^63 when unreadable or too big 272 fn gi_slurp k ulong o ulong to ulong 273 fd = gi_rdonly 274 if lt fd 0 275 ret shl ulong 1 63 276 end 277 n = o 278 ok = true 279 while true bound `16777218` 280 x = long 0 281 if eq k 1 282 x = read fd g_b1 n sub len g_b1 n 283 else 284 x = read fd g_b2 n sub len g_b2 n 285 end 286 if lt x 0 287 ok = false 288 break 289 end 290 if eq x 0 291 break 292 end 293 n = add n ulong x 294 if ge n len g_b1 295 ok = false 296 break 297 end 298 end 299 gi_fclo fd 300 if not ok 301 ret shl ulong 1 63 302 end 303 ret sub n o 304 end 305 note write b1[0, n) to the file at g_pa (fd from gi_wronly or gi_exe when ex) 306 fn gi_spill n ulong ex bool to bool 307 fd = int -1 308 if ex 309 fd = gi_exe 310 else 311 fd = gi_wronly 312 end 313 if lt fd 0 314 ret false 315 end 316 o = ulong 0 317 while lt o n bound `16777217` 318 x = write fd g_b1 o sub n o 319 if le x 0 320 gi_fclo fd 321 ret false 322 end 323 o = add o ulong x 324 end 325 gi_fclo fd 326 ret true 327 end 328 note read up to m bytes of fd into b1 (k 1) or b2 (k 2); the count (0 at the end) 329 fn gi_rdn fd int k ulong m ulong to ulong 330 n = ulong 0 331 while lt n m bound `1048577` 332 x = long 0 333 if eq k 1 334 x = read fd g_b1 n sub m n 335 else 336 x = read fd g_b2 n sub m n 337 end 338 if le x 0 339 ret n 340 end 341 n = add n ulong x 342 end 343 ret n 344 end 345 fn gi_eqn n ulong to bool 346 for j ulong n bound `1048576` 347 if ne get g_b1 j get g_b2 j 348 ret false 349 end 350 end 351 ret true 352 end 353 note the scratch files w1 and w2 have the same bytes 354 fn gi_fcmp w1 ulong w2 ulong to bool 355 gi_ps w1 356 f1 = gi_rdonly 357 gi_ps w2 358 f2 = gi_rdonly 359 ok = and ge f1 0 ge f2 0 360 dn = false 361 while and ok not dn bound 4096 362 a = gi_rdn f1 1 `1048576` 363 b = gi_rdn f2 2 `1048576` 364 if ne a b 365 ok = false 366 else 367 if eq a 0 368 dn = true 369 end 370 ok = gi_eqn a 371 end 372 end 373 gi_fclo f1 374 gi_fclo f2 375 ret ok 376 end 377 note bytes in scratch file w (2^63 when it cannot be opened) 378 fn gi_size w ulong to ulong 379 gi_ps w 380 fd = gi_rdonly 381 if lt fd 0 382 ret shl ulong 1 63 383 end 384 r = fseek fd 0 2 385 gi_fclo fd 386 if lt r 0 387 ret shl ulong 1 63 388 end 389 ret ulong r 390 end 391 392 note ---- children ------------------------------------------------------------------------------------ 393 fn gi_aclr to void 394 put g_n 3 2 395 put g_n 4 0 396 end 397 note append g_pa as the next argument 398 fn gi_apa to void 399 p = get g_n 3 400 n = get g_n 0 401 for j ulong n bound 8192 402 put g_av add add p 2 j get g_pa j 403 end 404 put g_av p uchar and n 255 405 put g_av add p 1 uchar shr n 8 406 put g_n 3 add p add n 2 407 c = add get g_n 4 1 408 put g_n 4 c 409 put g_av 0 uchar and c 255 410 put g_av 1 uchar shr c 8 411 end 412 fn gi_redir s int d int to void 413 if ne dupfd s d 0 long d 414 exit 127 415 end 416 end 417 note run the argument list with stdin, stdout, stderr fds (closed here); the exit code, 256 + the signal 418 fn gi_spawn fi int fo int fe int to ulong 419 if or lt fi 0 or lt fo 0 lt fe 0 420 gi_fclo fi 421 gi_fclo fo 422 gi_fclo fe 423 ret 512 424 end 425 pid = fork 426 if lt pid 0 427 exit 2 428 end 429 if eq pid 0 430 gi_redir fi 0 431 gi_redir fo 1 432 gi_redir fe 2 433 r = execprog g_av 0 get g_n 3 434 exit 127 435 end 436 gi_fclo fi 437 gi_fclo fo 438 gi_fclo fe 439 t0 = monons 440 while true bound `1000000000` 441 r = waitpid int pid g_stb 0 len g_stb 1 442 if eq r pid 443 x = ulong get g_stb 0 444 if ne x 0 445 ret add 256 x 446 end 447 ret ulong get g_stb 1 448 end 449 if lt r 0 450 exit 2 451 end 452 if gt sub monons t0 `600000000000` 453 r = killpid int pid 9 454 r = waitpid int pid g_stb 0 len g_stb 0 455 put g_n 29 1 456 ret 1000 457 end 458 q = sleepns `1000000` 459 end 460 exit 2 461 end 462 note a child of the current case passed the deadline: the case is NOT_RUN (g_n 15 = 2), never ok or FAIL 463 fn gi_dl to bool 464 if eq get g_n 29 0 465 ret false 466 end 467 put g_n 15 2 468 if eq get g_n 14 0 469 gi_say 39 470 gi_name 471 gi_say 40 472 gi_nl 473 end 474 ret true 475 end 476 note run program word p (a scratch file) with optional argument scratch word a (0 none); stdin scratch word 477 note i, stdout scratch word o (an executable when ex), stderr scratch word e 478 fn gi_run p ulong a ulong i ulong o ulong e ulong to ulong 479 gi_ps i 480 fi = gi_rdonly 481 gi_aclr 482 gi_ps p 483 gi_apa 484 if ne a 0 485 gi_ps a 486 gi_apa 487 end 488 gi_ps o 489 fo = gi_wronly 490 gi_ps e 491 fe = gi_wronly 492 ret gi_spawn fi fo fe 493 end 494 note OMC with stdin at g_pa (already set), stdout scratch word o (an executable), stderr scratch word e 495 fn gi_omc o ulong e ulong to ulong 496 fi = gi_rdonly 497 gi_aclr 498 gi_pclr 499 for j ulong get g_n 1 bound 4096 500 gi_pc ulong get g_omc j 501 end 502 gi_apa 503 gi_ps o 504 fo = gi_exe 505 gi_ps e 506 fe = gi_wronly 507 ret gi_spawn fi fo fe 508 end 509 510 note ---- building ------------------------------------------------------------------------------------- 511 note append seed/ng/ + word i to b1 at its length (g_n 5); false when unreadable 512 fn gi_cat i ulong to bool 513 gi_pr i 514 n = gi_slurp 1 get g_n 5 515 if ge n shl ulong 1 63 516 ret false 517 end 518 put g_n 5 add get g_n 5 n 519 ret true 520 end 521 note compile b1[0, g_n 5) with OMC to scratch word o 522 fn gi_bld o ulong to bool 523 gi_ps 10 524 if not gi_spill get g_n 5 false 525 ret false 526 end 527 ret eq gi_omc o 19 0 528 end 529 note the units of seed/ng/ng.units (lines `SHA256 PATH`, in order) appended to b1: ng's source, whatever 530 note stage units the list holds (the pins are ngbuild's to check, gate-ir's ngbuild phase); false when the 531 note list or a unit cannot be read 532 fn gi_units to bool 533 gi_pr 24 534 k = gi_slurp 2 0 535 if ge k shl ulong 1 63 536 ret false 537 end 538 s = ulong 0 539 for i ulong k bound 65536 540 if eq get g_b2 i 10 541 if not gi_unit s i 542 ret false 543 end 544 s = add i 1 545 end 546 end 547 ret gi_unit s k 548 end 549 note the unit on the units-list line b2[s, e) (64 hex digits, a space, the path) appended to b1; an empty 550 note line adds nothing 551 fn gi_unit s ulong e ulong to bool 552 if eq s e 553 ret true 554 end 555 if le e add s 65 556 ret false 557 end 558 gi_pclr 559 for i ulong sub e add s 65 bound 4096 560 gi_pc ulong get g_b2 add add s 65 i 561 end 562 n = gi_slurp 1 get g_n 5 563 if ge n shl ulong 1 63 564 ret false 565 end 566 put g_n 5 add get g_n 5 n 567 ret true 568 end 569 fn gi_tools to bool 570 put g_n 5 0 571 if not gi_units 572 ret false 573 end 574 if not gi_bld 7 575 ret false 576 end 577 put g_n 5 0 578 if or not gi_cat 4 not gi_cat 5 579 ret false 580 end 581 if not gi_bld 8 582 ret false 583 end 584 put g_n 5 0 585 if or not gi_cat 1 not gi_cat 6 586 ret false 587 end 588 ret gi_bld 9 589 end 590 note ng with mutant m (1 to 5) of front.om, built to scratch ngm; false unless its pattern occurs exactly once 591 note in the units 592 fn gi_mbld m ulong to bool 593 gi_msel m 594 put g_n 5 0 595 if not gi_units 596 ret false 597 end 598 if ne gi_msub 0 get g_n 5 1 599 ret false 600 end 601 ret gi_bld 21 602 end 603 fn gi_msel m ulong to void 604 if eq m 1 605 put g_n 27 len g_mu0 606 for j ulong len g_mu0 bound 64 607 put g_ma j get g_mu0 j 608 put g_mb j get g_mu1 j 609 end 610 end 611 if eq m 2 612 put g_n 27 len g_mu2 613 for j ulong len g_mu2 bound 64 614 put g_ma j get g_mu2 j 615 put g_mb j get g_mu3 j 616 end 617 end 618 if eq m 3 619 put g_n 27 len g_mu4 620 for j ulong len g_mu4 bound 64 621 put g_ma j get g_mu4 j 622 put g_mb j get g_mu5 j 623 end 624 end 625 if eq m 4 626 put g_n 27 len g_mu6 627 for j ulong len g_mu6 bound 64 628 put g_ma j get g_mu6 j 629 put g_mb j get g_mu7 j 630 end 631 end 632 if eq m 5 633 put g_n 27 len g_mu8 634 for j ulong len g_mu8 bound 64 635 put g_ma j get g_mu8 j 636 put g_mb j get g_mu9 j 637 end 638 end 639 if eq m 6 640 put g_n 27 len g_mu10 641 for j ulong len g_mu10 bound 64 642 put g_ma j get g_mu10 j 643 put g_mb j get g_mu11 j 644 end 645 end 646 if eq m 7 647 put g_n 27 len g_mu12 648 for j ulong len g_mu12 bound 64 649 put g_ma j get g_mu12 j 650 put g_mb j get g_mu13 j 651 end 652 end 653 if eq m 8 654 put g_n 27 len g_mu14 655 for j ulong len g_mu14 bound 64 656 put g_ma j get g_mu14 j 657 put g_mb j get g_mu15 j 658 end 659 end 660 if eq m 9 661 put g_n 27 len g_mu16 662 for j ulong len g_mu16 bound 64 663 put g_ma j get g_mu16 j 664 put g_mb j get g_mu17 j 665 end 666 end 667 if eq m 10 668 put g_n 27 len g_mu18 669 for j ulong len g_mu18 bound 64 670 put g_ma j get g_mu18 j 671 put g_mb j get g_mu19 j 672 end 673 end 674 if eq m 11 675 put g_n 27 len g_mu20 676 for j ulong len g_mu20 bound 64 677 put g_ma j get g_mu20 j 678 put g_mb j get g_mu21 j 679 end 680 end 681 if eq m 12 682 put g_n 27 len g_mu22 683 for j ulong len g_mu22 bound 64 684 put g_ma j get g_mu22 j 685 put g_mb j get g_mu23 j 686 end 687 end 688 if eq m 13 689 put g_n 27 len g_mu24 690 for j ulong len g_mu24 bound 64 691 put g_ma j get g_mu24 j 692 put g_mb j get g_mu25 j 693 end 694 end 695 if eq m 14 696 put g_n 27 len g_mu26 697 for j ulong len g_mu26 bound 64 698 put g_ma j get g_mu26 j 699 put g_mb j get g_mu27 j 700 end 701 end 702 if eq m 15 703 put g_n 27 len g_mu28 704 for j ulong len g_mu28 bound 64 705 put g_ma j get g_mu28 j 706 put g_mb j get g_mu29 j 707 end 708 end 709 if eq m 16 710 put g_n 27 len g_mu30 711 for j ulong len g_mu30 bound 64 712 put g_ma j get g_mu30 j 713 put g_mb j get g_mu31 j 714 end 715 end 716 if eq m 17 717 put g_n 27 len g_mu32 718 for j ulong len g_mu32 bound 64 719 put g_ma j get g_mu32 j 720 put g_mb j get g_mu33 j 721 end 722 end 723 if eq m 18 724 put g_n 27 len g_mu34 725 for j ulong len g_mu34 bound 64 726 put g_ma j get g_mu34 j 727 put g_mb j get g_mu35 j 728 end 729 end 730 end 731 note the places of the pattern in b1[s, e), counted; when there is exactly one it is replaced 732 fn gi_msub s ulong e ulong to ulong 733 k = get g_n 27 734 c = ulong 0 735 if lt e k 736 ret 0 737 end 738 p = s 739 while le add p k e bound `16777216` 740 if gi_mat p k 741 c = add c 1 742 end 743 p = add p 1 744 end 745 if ne c 1 746 ret c 747 end 748 p = s 749 while le add p k e bound `16777216` 750 if gi_mat p k 751 for j ulong k bound 64 752 put g_b1 add p j get g_mb j 753 end 754 ret 1 755 end 756 p = add p 1 757 end 758 ret 0 759 end 760 fn gi_mat p ulong k ulong to bool 761 for j ulong k bound 64 762 if ne get g_b1 add p j get g_ma j 763 ret false 764 end 765 end 766 ret true 767 end 768 769 note ---- one case -------------------------------------------------------------------------------------- 770 note scratch in = the mode line of g_n 24, then the source; false when the source cannot be read 771 fn gi_mkin to bool 772 md = get g_n 24 773 n = ulong 0 774 if eq md 0 775 n = len g_pfr 776 for j ulong n bound 64 777 put g_b1 j get g_pfr j 778 end 779 end 780 if eq md 1 781 n = len g_pfc 782 for j ulong n bound 64 783 put g_b1 j get g_pfc j 784 end 785 end 786 if eq md 2 787 n = len g_pic 788 for j ulong n bound 64 789 put g_b1 j get g_pic j 790 end 791 end 792 gi_psrc 793 m = gi_slurp 1 n 794 if ge m shl ulong 1 63 795 ret false 796 end 797 gi_ps 12 798 ret gi_spill add n m false 799 end 800 note run NAME SRC 801 fn gi_rcase to void 802 if not gi_mkin 803 gi_fail0 38 804 ret 805 end 806 gi_psrc 807 x = gi_omc 11 16 808 if gi_dl 809 ret 810 end 811 if ne x 0 812 gi_failv 2 x 813 ret 814 end 815 x = gi_run get g_n 25 0 12 13 17 816 if gi_dl 817 ret 818 end 819 if ne x 0 820 gi_failv 3 x 821 ret 822 end 823 note Compare compile diagnostics before the runtime overwrites its stderr file. 824 if not gi_fcmp 16 17 825 gi_fail0 10 826 ret 827 end 828 x1 = gi_run 11 0 20 14 16 829 if gi_dl 830 ret 831 end 832 x = gi_run 8 0 13 18 19 833 if gi_dl 834 ret 835 end 836 if ne x 0 837 gi_failv 4 x 838 ret 839 end 840 if not gi_acc 841 gi_fail0 5 842 ret 843 end 844 x2 = gi_run 9 13 20 15 17 845 if gi_dl 846 ret 847 end 848 if ne x1 x2 849 gi_fail 6 850 if eq get g_n 14 0 851 gi_num x1 852 gi_say 7 853 gi_num x2 854 gi_nl 855 end 856 ret 857 end 858 if not gi_fcmp 14 15 859 gi_fail0 8 860 ret 861 end 862 if eq get g_n 14 0 863 gi_say 1 864 gi_name 865 gi_say 12 866 gi_num x1 867 gi_nl 868 end 869 end 870 note host NAME SRC C (header, host) 871 fn gi_hcase to void 872 if not gi_mkin 873 gi_fail0 38 874 ret 875 end 876 gi_psrc 877 x = gi_omc 11 16 878 if gi_dl 879 ret 880 end 881 if ne x 0 882 gi_failv 2 x 883 ret 884 end 885 x1 = gi_run 11 0 20 14 16 886 if gi_dl 887 ret 888 end 889 x = gi_run get g_n 25 0 12 13 17 890 if gi_dl 891 ret 892 end 893 if ne x 0 894 gi_failv 3 x 895 ret 896 end 897 x = gi_run 8 0 13 18 19 898 if gi_dl 899 ret 900 end 901 if ne x 0 902 gi_failv 4 x 903 ret 904 end 905 if not gi_acc 906 gi_fail0 5 907 ret 908 end 909 x2 = gi_hng 910 if gi_dl 911 ret 912 end 913 c = get g_hc 0 914 if eq c 0 915 if ne x1 x2 916 gi_fail 6 917 if eq get g_n 14 0 918 gi_num x1 919 gi_say 7 920 gi_num x2 921 gi_nl 922 end 923 ret 924 end 925 if not gi_fcmp 14 15 926 gi_fail0 8 927 ret 928 end 929 else 930 if ne x2 c 931 gi_fail 45 932 if eq get g_n 14 0 933 gi_num c 934 gi_say 7 935 gi_num x2 936 gi_nl 937 end 938 ret 939 end 940 if ne gi_size 15 0 941 gi_fail0 46 942 ret 943 end 944 if eq get g_n 14 0 945 put g_n 31 add get g_n 31 1 946 end 947 end 948 if eq get g_n 14 0 949 gi_say 1 950 gi_name 951 gi_say 12 952 gi_num x2 953 gi_nl 954 end 955 end 956 note ngrun ir --scratch SCRATCH/hK (K the next number), stdin nul, stdout o2, stderr e2 957 fn gi_hng to ulong 958 gi_ps 20 959 fi = gi_rdonly 960 gi_aclr 961 gi_ps 9 962 gi_apa 963 gi_ps 13 964 gi_apa 965 gi_pclr 966 gi_pw 26 967 gi_apa 968 gi_ps 27 969 k = add get g_hk 0 1 970 put g_hk 0 k 971 gi_pnum k 972 gi_apa 973 gi_ps 15 974 fo = gi_wronly 975 gi_ps 17 976 fe = gi_wronly 977 ret gi_spawn fi fo fe 978 end 979 fn gi_pnum v ulong to void 980 if ge v 10 981 gi_pnum div v 10 982 end 983 gi_pc add 48 rem v 10 984 end 985 note scratch ck starts with "ACCEPT " 986 fn gi_acc to bool 987 gi_ps 18 988 fd = gi_rdonly 989 if lt fd 0 990 ret false 991 end 992 n = gi_rdn fd 1 7 993 gi_fclo fd 994 if ne n 7 995 ret false 996 end 997 for j ulong 7 998 if ne get g_b1 j get g_acc j 999 ret false 1000 end 1001 end 1002 ret true 1003 end 1004 note refuse NAME SRC 1005 fn gi_fcase to void 1006 if not gi_mkin 1007 gi_fail0 38 1008 ret 1009 end 1010 gi_psrc 1011 x1 = gi_omc 11 16 1012 if gi_dl 1013 ret 1014 end 1015 if eq x1 0 1016 gi_fail0 9 1017 ret 1018 end 1019 x2 = gi_run get g_n 25 0 12 13 17 1020 if gi_dl 1021 ret 1022 end 1023 if ne x1 x2 1024 gi_fail 6 1025 if eq get g_n 14 0 1026 gi_num x1 1027 gi_say 7 1028 gi_num x2 1029 gi_nl 1030 end 1031 ret 1032 end 1033 if not gi_fcmp 16 17 1034 gi_fail0 10 1035 ret 1036 end 1037 if ne gi_size 13 0 1038 gi_fail0 11 1039 ret 1040 end 1041 if eq get g_n 14 0 1042 gi_say 1 1043 gi_name 1044 gi_say 12 1045 gi_num x1 1046 gi_nl 1047 end 1048 end 1049 1050 note ---- the case list --------------------------------------------------------------------------------- 1051 fn gi_sp p ulong to bool 1052 c = get g_cs p 1053 ret or eq c 32 eq c 9 1054 end 1055 note the next field of the line at or after p (before e) into (start, end) at g_n s, s+1; false when none 1056 fn gi_fld p ulong e ulong s ulong to ulong 1057 q = p 1058 while and lt q e gi_sp q bound `1048576` 1059 q = add q 1 1060 end 1061 put g_n s q 1062 while and lt q e not gi_sp q bound `1048576` 1063 q = add q 1 1064 end 1065 put g_n add s 1 q 1066 ret q 1067 end 1068 note the next case line from the cursor: 0 none left, 1 run, 2 refuse, 3 malformed, 4 host (fields in g_n 16..19, 1069 note a host case's C in g_hc) 1070 fn gi_next to ulong 1071 cs = get g_n 7 1072 while lt get g_n 8 cs bound `1048576` 1073 p = get g_n 8 1074 e = p 1075 while and lt e cs ne get g_cs e 10 bound `1048576` 1076 e = add e 1 1077 end 1078 put g_n 8 add e 1 1079 put g_n 26 p 1080 q = p 1081 while and lt q e gi_sp q bound `1048576` 1082 q = add q 1 1083 end 1084 if and lt q e ne get g_cs q 35 1085 q = gi_fld q e 16 1086 k = sub get g_n 17 get g_n 16 1087 a = get g_n 16 1088 q = gi_fld q e 16 1089 q = gi_fld q e 18 1090 if eq get g_n 18 get g_n 19 1091 ret 3 1092 end 1093 if gi_isw a k 22 1094 ret 1 1095 end 1096 if gi_isw a k 23 1097 ret 2 1098 end 1099 if gi_isw a k 25 1100 ret gi_hcls q e 1101 end 1102 ret 3 1103 end 1104 end 1105 ret 0 1106 end 1107 note hcls: the class field of a host line, after the cursor q (before e): 1 to 3 decimal digits into g_hc and 1108 note kind 4, else 3 (malformed); nothing may follow it 1109 fn gi_hcls q ulong e ulong to ulong 1110 p = q 1111 while and lt p e gi_sp p bound `1048576` 1112 p = add p 1 1113 end 1114 v = ulong 0 1115 d = ulong 0 1116 while and lt p e not gi_sp p bound `1048576` 1117 c = ulong get g_cs p 1118 if or lt c 48 gt c 57 1119 ret 3 1120 end 1121 v = add mul v 10 sub c 48 1122 d = add d 1 1123 p = add p 1 1124 end 1125 while and lt p e gi_sp p bound `1048576` 1126 p = add p 1 1127 end 1128 if or or eq d 0 gt d 3 lt p e 1129 ret 3 1130 end 1131 put g_hc 0 v 1132 ret 4 1133 end 1134 note cases[a, a + k) is word i 1135 fn gi_isw a ulong k ulong i ulong to bool 1136 if ne k ulong get g_wl i 1137 ret false 1138 end 1139 s = ulong get g_wo i 1140 for j ulong k bound 64 1141 if ne get g_cs add a j get g_w add s j 1142 ret false 1143 end 1144 end 1145 ret true 1146 end 1147 note every case of the list (kinds in kd: bit 1 run, 2 refuse, 4 host); in quiet mode stop at the first failure; 1148 note true when some case failed. A case past the deadline is NOT_RUN (g_n 28 counts them outside quiet mode), 1149 note neither a failure nor, under a mutant, a kill 1150 fn gi_all kd ulong to bool 1151 put g_n 8 0 1152 while true bound 65536 1153 k = gi_next 1154 if eq k 0 1155 ret false 1156 end 1157 put g_n 15 0 1158 put g_n 29 0 1159 if eq k 3 1160 gi_fail0 29 1161 else 1162 if eq k 1 1163 if ne and kd 1 0 1164 gi_rcase 1165 if eq get g_n 14 0 1166 put g_n 11 add get g_n 11 1 1167 end 1168 end 1169 else 1170 if eq k 4 1171 if ne and kd 4 0 1172 gi_hcase 1173 if eq get g_n 14 0 1174 put g_n 30 add get g_n 30 1 1175 end 1176 end 1177 else 1178 if ne and kd 2 0 1179 gi_fcase 1180 if eq get g_n 14 0 1181 put g_n 12 add get g_n 12 1 1182 end 1183 end 1184 end 1185 end 1186 end 1187 if eq get g_n 15 2 1188 if eq get g_n 14 0 1189 put g_n 28 add get g_n 28 1 1190 end 1191 end 1192 if eq get g_n 15 1 1193 if ne get g_n 14 0 1194 ret true 1195 end 1196 put g_n 13 add get g_n 13 1 1197 end 1198 end 1199 ret false 1200 end 1201 note the first case of kind kd only, quietly; true when it failed (a NOT_RUN case does not trip a control) 1202 fn gi_first kd ulong to bool 1203 put g_n 8 0 1204 while true bound 65536 1205 k = gi_next 1206 if eq k 0 1207 ret false 1208 end 1209 put g_n 15 0 1210 put g_n 29 0 1211 if eq k kd 1212 if eq kd 1 1213 gi_rcase 1214 else 1215 gi_fcase 1216 end 1217 ret eq get g_n 15 1 1218 end 1219 end 1220 ret false 1221 end 1222 1223 note ---- negative controls ----------------------------------------------------------------------------- 1224 fn gi_mut m ulong kd ulong to void 1225 put g_n 20 add get g_n 20 1 1226 gi_say 30 1227 gi_num m 1228 if not gi_mbld m 1229 gi_say 37 1230 gi_nl 1231 put g_n 13 add get g_n 13 1 1232 ret 1233 end 1234 put g_n 14 1 1235 put g_n 25 21 1236 hit = gi_all kd 1237 put g_n 14 0 1238 put g_n 25 7 1239 if hit 1240 put g_n 21 add get g_n 21 1 1241 gi_say 32 1242 gi_name 1243 else 1244 gi_say 31 1245 put g_n 13 add get g_n 13 1 1246 end 1247 gi_nl 1248 end 1249 fn gi_ctl md ulong kd ulong to void 1250 put g_n 22 add get g_n 22 1 1251 gi_say add 32 md 1252 put g_n 14 1 1253 put g_n 24 md 1254 hit = gi_first kd 1255 put g_n 24 0 1256 put g_n 14 0 1257 if hit 1258 put g_n 23 add get g_n 23 1 1259 gi_say 36 1260 gi_name 1261 else 1262 gi_say 35 1263 put g_n 13 add get g_n 13 1 1264 end 1265 gi_nl 1266 end 1267 1268 note ---- main ---------------------------------------------------------------------------------------------- 1269 fn gi_inval i ulong to int 1270 gi_say 15 1271 gi_say i 1272 gi_nl 1273 ret 2 1274 end 1275 note OMC hashes to the hex of argument 2 1276 fn gi_oracle to bool 1277 gi_pclr 1278 for j ulong get g_n 1 bound 4096 1279 gi_pc ulong get g_omc j 1280 end 1281 fd = gi_rdonly 1282 if lt fd 0 1283 ret false 1284 end 1285 n = ulong 0 1286 while true bound `16777218` 1287 x = read fd sh_dat n sub len sh_dat n 1288 if le x 0 1289 break 1290 end 1291 n = add n ulong x 1292 if ge n len sh_dat 1293 gi_fclo fd 1294 ret false 1295 end 1296 end 1297 gi_fclo fd 1298 sh_all n 1299 r = argread 2 g_hx 0 128 1300 if ne r 64 1301 ret false 1302 end 1303 for j ulong 32 1304 b = get sh_dig j 1305 if ne get g_hx mul j 2 sh_hexd uint shr b 4 1306 ret false 1307 end 1308 if ne get g_hx add mul j 2 1 sh_hexd uint and b 15 1309 ret false 1310 end 1311 end 1312 ret true 1313 end 1314 note Import run/refuse/emit sources directly from the compiler's contract manifest. 1315 note Emit rows also exercise runtime here; compiler diagnostic text is the check-parity gate's job. 1316 text g_contracts "seed/omc/contracts/contracts.cases" 1317 text g_crun "run " 1318 text g_cref "refuse " 1319 text g_cemit "emit " 1320 global g_cf ulong 6 1321 fn gi_ccopy a ulong b ulong to void 1322 for i ulong sub b a 1323 n = get g_n 7 1324 if ge n len g_cs 1325 exit gi_inval 27 1326 end 1327 put g_cs n get g_b2 add a i 1328 put g_n 7 add n 1 1329 end 1330 end 1331 fn gi_cbyte c uchar to void 1332 n = get g_n 7 1333 if ge n len g_cs 1334 exit gi_inval 27 1335 end 1336 put g_cs n c 1337 put g_n 7 add n 1 1338 end 1339 fn gi_cmatch a ulong b ulong kind ulong to bool 1340 n = ulong 3 1341 if eq kind 2 1342 n = ulong 6 1343 end 1344 if eq kind 3 1345 n = ulong 4 1346 end 1347 if ne sub b a n 1348 ret false 1349 end 1350 for i ulong n 1351 c = uchar 0 1352 if eq kind 1 1353 c = get g_crun i 1354 end 1355 if eq kind 2 1356 c = get g_cref i 1357 end 1358 if eq kind 3 1359 c = get g_cemit i 1360 end 1361 if ne get g_b2 add a i c 1362 ret false 1363 end 1364 end 1365 ret true 1366 end 1367 fn gi_contracts to void 1368 gi_pclr 1369 for i ulong len g_contracts 1370 gi_pc ulong get g_contracts i 1371 end 1372 n = gi_slurp 2 0 1373 if ge n shl ulong 1 63 1374 exit gi_inval 27 1375 end 1376 p = ulong 0 1377 gi_cbyte 10 1378 while lt p n 1379 q = p 1380 while and lt q n ne get g_b2 q 10 1381 q = add q 1 1382 end 1383 x = p 1384 for f ulong 3 1385 while and lt x q le get g_b2 x 32 1386 x = add x 1 1387 end 1388 put g_cf mul f 2 x 1389 while and lt x q gt get g_b2 x 32 1390 x = add x 1 1391 end 1392 put g_cf add mul f 2 1 x 1393 end 1394 a = get g_cf 2 1395 b = get g_cf 3 1396 kind = ulong 0 1397 if or gi_cmatch a b 1 gi_cmatch a b 3 1398 kind = ulong 1 1399 end 1400 if gi_cmatch a b 2 1401 kind = ulong 2 1402 end 1403 if ne kind 0 1404 if eq get g_cf 4 get g_cf 5 1405 exit gi_inval 27 1406 end 1407 if eq kind 1 1408 for i ulong len g_crun 1409 gi_cbyte get g_crun i 1410 end 1411 else 1412 for i ulong len g_cref 1413 gi_cbyte get g_cref i 1414 end 1415 end 1416 gi_ccopy get g_cf 0 get g_cf 1 1417 gi_cbyte 32 1418 gi_ccopy get g_cf 4 get g_cf 5 1419 gi_cbyte 10 1420 end 1421 p = add q 1 1422 end 1423 end 1424 fn gi_contract_front original ulong to void 1425 total = get g_n 7 1426 extra = sub total original 1427 for j ulong total 1428 put g_b1 j get g_cs j 1429 end 1430 for j ulong extra 1431 put g_cs j get g_b1 add original j 1432 end 1433 for j ulong original 1434 put g_cs add extra j get g_b1 j 1435 end 1436 end 1437 fn main to int 1438 gi_init 1439 if ne argcnt 5 1440 ret gi_inval 24 1441 end 1442 r = argread 1 g_omc 0 4095 1443 if lt r 1 1444 ret gi_inval 24 1445 end 1446 put g_n 1 ulong r 1447 if not gi_oracle 1448 ret gi_inval 25 1449 end 1450 r = argread 3 g_scr 0 4094 1451 if lt r 1 1452 ret gi_inval 24 1453 end 1454 n = ulong r 1455 x = makedir g_scr 0 n 448 1456 if ne x 0 1457 ret gi_inval 26 1458 end 1459 put g_scr n 47 1460 put g_n 2 add n 1 1461 r = argread 4 g_pa 0 4095 1462 if lt r 1 1463 ret gi_inval 24 1464 end 1465 put g_n 0 ulong r 1466 fd = gi_rdonly 1467 if lt fd 0 1468 ret gi_inval 27 1469 end 1470 k = read fd g_cs 0 len g_cs 1471 gi_fclo fd 1472 if or le k 0 ge ulong k len g_cs 1473 ret gi_inval 27 1474 end 1475 put g_n 7 ulong k 1476 gi_contracts 1477 gi_contract_front ulong k 1478 gi_ps 20 1479 put g_n 5 0 1480 if not gi_spill 0 false 1481 ret gi_inval 26 1482 end 1483 if not gi_tools 1484 gi_say 28 1485 gi_ps 19 1486 r = write 1 g_pa 0 get g_n 0 1487 gi_nl 1488 ret 3 1489 end 1490 hit = gi_all 7 1491 gi_mut 1 1 1492 gi_mut 2 1 1493 gi_mut 3 1 1494 gi_mut 4 1 1495 gi_mut 5 1 1496 gi_mut 6 4 1497 gi_mut 7 4 1498 gi_mut 8 1 1499 gi_mut 9 1 1500 gi_mut 10 1 1501 gi_mut 11 1 1502 gi_mut 12 1 1503 gi_mut 13 1 1504 gi_mut 14 1 1505 gi_mut 15 1 1506 gi_mut 16 1 1507 gi_mut 17 1 1508 gi_mut 18 1 1509 gi_ctl 1 1 1510 gi_ctl 2 2 1511 f = get g_n 13 1512 nr = get g_n 28 1513 if ne f 0 1514 gi_say 14 1515 else 1516 if ne nr 0 1517 gi_say 41 1518 else 1519 gi_say 13 1520 end 1521 end 1522 gi_say 16 1523 nc = add get g_n 11 get g_n 12 1524 gi_num add nc get g_n 30 1525 gi_say 17 1526 gi_num get g_n 11 1527 gi_say 18 1528 gi_num get g_n 12 1529 gi_say 43 1530 gi_num get g_n 30 1531 gi_say 44 1532 gi_num get g_n 31 1533 gi_say 19 1534 gi_num f 1535 gi_say 20 1536 gi_num get g_n 20 1537 gi_say 21 1538 gi_num get g_n 21 1539 gi_say 22 1540 gi_num get g_n 22 1541 gi_say 23 1542 gi_num get g_n 23 1543 gi_say 42 1544 gi_num nr 1545 gi_nl 1546 if ne f 0 1547 ret 1 1548 end 1549 if ne nr 0 1550 ret 4 1551 end 1552 ret 0 1553 end