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
omega-mv / src / source-aware / core-v3.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | note Handwritten bounded source-aware layer v3 (spec/universal/translation-s2-v1.md). Accepts semantic header versions 1, 2 and 3. |
| 3 | note Versions 1 and 2 decode exactly as core-v2.om; version 3 carries only profiles 10..15 (S2: u64, i64, bool). |
| 4 | note Lower OSC and checker2 are external unchanged interfaces. M 8 holds the decoded semantic header version. |
| 5 | global Ib uchar 8192 |
| 6 | global Eb uchar 8192 |
| 7 | global El ulong 1 |
| 8 | global M ulong 9 |
| 9 | global Cp ulong 4 |
| 10 | global Oc ulong 64 |
| 11 | global Ot ulong 64 |
| 12 | global Oat ulong 64 |
| 13 | global Oef ulong 64 |
| 14 | global Oal ulong 64 |
| 15 | global Oob ulong 64 |
| 16 | global Oa ulong 64 |
| 17 | global Ob ulong 64 |
| 18 | global Oi ulong 64 |
| 19 | global Ss ulong 64 |
| 20 | global Se ulong 64 |
| 21 | global Src ulong 3 |
| 22 | text Conhex "d4ed6148bfa97cc693d3fa4495e2d7e2e68aba04607a7e96dd9a9c54bf9073a8" |
| 23 | text Semdom "omega.source.semantic.v1" |
| 24 | text Provdom "omega.source.provenance.v1" |
| 25 | |
| 26 | fn number off ulong size ulong to ulong |
| 27 | v = ulong 0 |
| 28 | for i ulong size |
| 29 | v = or v shl ulong get Ib add off i mul i 8 |
| 30 | end |
| 31 | ret v |
| 32 | end |
| 33 | |
| 34 | fn magic off ulong val ulong to bool |
| 35 | ret eq number off 4 val |
| 36 | end |
| 37 | |
| 38 | fn nib c uchar to ulong |
| 39 | if le c 57 |
| 40 | ret sub ulong c 48 |
| 41 | end |
| 42 | ret add sub ulong c 97 10 |
| 43 | end |
| 44 | |
| 45 | fn contract to bool |
| 46 | for i ulong 32 |
| 47 | a = nib get Conhex mul i 2 |
| 48 | b = nib get Conhex add mul i 2 1 |
| 49 | if ne ulong get Ib add 25 i add mul a 16 b |
| 50 | ret false |
| 51 | end |
| 52 | end |
| 53 | ret true |
| 54 | end |
| 55 | |
| 56 | fn part off ulong n ulong to void |
| 57 | for i ulong n |
| 58 | hbyte get Ib add off i |
| 59 | end |
| 60 | end |
| 61 | |
| 62 | fn hashed off ulong n ulong at ulong to bool |
| 63 | hinit |
| 64 | part off n |
| 65 | finish |
| 66 | for i ulong 32 |
| 67 | if ne get Hash i get Ib add at i |
| 68 | ret false |
| 69 | end |
| 70 | end |
| 71 | ret true |
| 72 | end |
| 73 | |
| 74 | fn refok a ulong ty ulong i ulong to bool |
| 75 | if ge a i |
| 76 | ret false |
| 77 | end |
| 78 | ret eq get Ot a ty |
| 79 | end |
| 80 | |
| 81 | fn aliasok a ulong to bool |
| 82 | if eq a 255 |
| 83 | ret true |
| 84 | end |
| 85 | ret and ge a 1 le a 8 |
| 86 | end |
| 87 | |
| 88 | fn pureop i ulong to ulong |
| 89 | if ne get Oef i 0 |
| 90 | ret 71 |
| 91 | end |
| 92 | if ne get Oal i 0 |
| 93 | ret 71 |
| 94 | end |
| 95 | ret 0 |
| 96 | end |
| 97 | |
| 98 | fn arith i ulong to ulong |
| 99 | ty = get Ot i |
| 100 | if gt ty 2 |
| 101 | ret 70 |
| 102 | end |
| 103 | if ne get Oat i ty |
| 104 | ret 70 |
| 105 | end |
| 106 | if eq refok get Oa i ty i false |
| 107 | ret 70 |
| 108 | end |
| 109 | if eq refok get Ob i ty i false |
| 110 | ret 70 |
| 111 | end |
| 112 | if ne get Oi i 0 |
| 113 | ret 65 |
| 114 | end |
| 115 | need = ulong 8 |
| 116 | if eq ty 1 |
| 117 | if ne pureop i 0 |
| 118 | ret 71 |
| 119 | end |
| 120 | need = 1 |
| 121 | if eq get M 1 4 |
| 122 | need = or need 4 |
| 123 | end |
| 124 | if eq get M 1 6 |
| 125 | need = or need 4 |
| 126 | end |
| 127 | else |
| 128 | if ne get Oef i 20 |
| 129 | ret 71 |
| 130 | end |
| 131 | if ne get Oal i 255 |
| 132 | ret 71 |
| 133 | end |
| 134 | end |
| 135 | if eq get Oc i 5 |
| 136 | need = or need 2 |
| 137 | end |
| 138 | if ne get Oob i need |
| 139 | ret 72 |
| 140 | end |
| 141 | ret 0 |
| 142 | end |
| 143 | |
| 144 | fn memop i ulong to ulong |
| 145 | if ne get M 1 6 |
| 146 | ret 68 |
| 147 | end |
| 148 | if ne get Ot i 1 |
| 149 | ret 70 |
| 150 | end |
| 151 | if ne get Oat i 4 |
| 152 | ret 70 |
| 153 | end |
| 154 | if eq refok get Oa i 4 i false |
| 155 | ret 70 |
| 156 | end |
| 157 | if eq refok get Ob i 1 i false |
| 158 | ret 70 |
| 159 | end |
| 160 | if eq aliasok get Oal i false |
| 161 | ret 71 |
| 162 | end |
| 163 | if ne get Oal i get Oal get Oa i |
| 164 | ret 71 |
| 165 | end |
| 166 | need = ulong 17 |
| 167 | if eq get Oc i 8 |
| 168 | need = 19 |
| 169 | if eq refok get Oi i 1 i false |
| 170 | ret 70 |
| 171 | end |
| 172 | else |
| 173 | if ne get Oi i 0 |
| 174 | ret 65 |
| 175 | end |
| 176 | end |
| 177 | if ne get Oef i need |
| 178 | ret 71 |
| 179 | end |
| 180 | if ne get Oob i 24 |
| 181 | ret 72 |
| 182 | end |
| 183 | ret 0 |
| 184 | end |
| 185 | |
| 186 | fn s2 to bool |
| 187 | ret and ge get M 1 10 le get M 1 15 |
| 188 | end |
| 189 | |
| 190 | fn s2const i ulong ty ulong to ulong |
| 191 | if or ne get Oa i 65535 ne get Ob i 65535 |
| 192 | ret 70 |
| 193 | end |
| 194 | if eq ty 1 |
| 195 | if ne get Oat i 1 |
| 196 | ret 70 |
| 197 | end |
| 198 | else |
| 199 | if ne get Oat i 0 |
| 200 | ret 70 |
| 201 | end |
| 202 | end |
| 203 | if eq ty 6 |
| 204 | if gt get Oi i 1 |
| 205 | ret 70 |
| 206 | end |
| 207 | end |
| 208 | if ne get Oob i 0 |
| 209 | ret 72 |
| 210 | end |
| 211 | ret 0 |
| 212 | end |
| 213 | |
| 214 | fn s2input i ulong ty ulong to ulong |
| 215 | if eq ty 6 |
| 216 | ret 70 |
| 217 | end |
| 218 | if ne get Oat i 0 |
| 219 | ret 70 |
| 220 | end |
| 221 | if or ne get Oa i 65535 ne get Ob i 65535 |
| 222 | ret 70 |
| 223 | end |
| 224 | if gt get Oi i 5 |
| 225 | ret 67 |
| 226 | end |
| 227 | for j ulong i |
| 228 | if eq get Oc j 9 |
| 229 | if eq get Oi j get Oi i |
| 230 | ret 70 |
| 231 | end |
| 232 | end |
| 233 | end |
| 234 | if ne get Oob i 1 |
| 235 | ret 72 |
| 236 | end |
| 237 | ret 0 |
| 238 | end |
| 239 | |
| 240 | fn s2arith i ulong ty ulong to ulong |
| 241 | if eq ty 6 |
| 242 | ret 70 |
| 243 | end |
| 244 | if eq refok get Oa i ty i false |
| 245 | ret 70 |
| 246 | end |
| 247 | if eq refok get Ob i ty i false |
| 248 | ret 70 |
| 249 | end |
| 250 | need = ulong 1 |
| 251 | if eq ty 1 |
| 252 | if ne get Oat i 1 |
| 253 | ret 70 |
| 254 | end |
| 255 | else |
| 256 | if eq get Oat i 6 |
| 257 | need = 33 |
| 258 | else |
| 259 | if ne get Oat i 5 |
| 260 | ret 70 |
| 261 | end |
| 262 | end |
| 263 | end |
| 264 | if ne get Oi i 0 |
| 265 | ret 65 |
| 266 | end |
| 267 | if ne get Oob i need |
| 268 | ret 72 |
| 269 | end |
| 270 | ret 0 |
| 271 | end |
| 272 | |
| 273 | fn s2cmp i ulong ty ulong to ulong |
| 274 | if ne ty 6 |
| 275 | ret 70 |
| 276 | end |
| 277 | if ne get Oat i 0 |
| 278 | ret 70 |
| 279 | end |
| 280 | a = get Oa i |
| 281 | if ge a i |
| 282 | ret 70 |
| 283 | end |
| 284 | t = get Ot a |
| 285 | if and ne t 1 ne t 5 |
| 286 | ret 70 |
| 287 | end |
| 288 | if eq refok get Ob i t i false |
| 289 | ret 70 |
| 290 | end |
| 291 | if ne get Oi i 0 |
| 292 | ret 65 |
| 293 | end |
| 294 | if ne get Oob i 0 |
| 295 | ret 72 |
| 296 | end |
| 297 | ret 0 |
| 298 | end |
| 299 | |
| 300 | fn s2sel i ulong ty ulong to ulong |
| 301 | if ne get Oat i 0 |
| 302 | ret 70 |
| 303 | end |
| 304 | if eq refok get Oa i 6 i false |
| 305 | ret 70 |
| 306 | end |
| 307 | if eq refok get Ob i ty i false |
| 308 | ret 70 |
| 309 | end |
| 310 | if ge get Oi i i |
| 311 | ret 70 |
| 312 | end |
| 313 | if ne get Ot get Oi i ty |
| 314 | ret 70 |
| 315 | end |
| 316 | if ne get Oob i 0 |
| 317 | ret 72 |
| 318 | end |
| 319 | ret 0 |
| 320 | end |
| 321 | |
| 322 | fn s2not i ulong ty ulong to ulong |
| 323 | if ne ty 6 |
| 324 | ret 70 |
| 325 | end |
| 326 | if ne get Oat i 0 |
| 327 | ret 70 |
| 328 | end |
| 329 | if eq refok get Oa i 6 i false |
| 330 | ret 70 |
| 331 | end |
| 332 | if ne get Ob i 65535 |
| 333 | ret 70 |
| 334 | end |
| 335 | if ne get Oi i 0 |
| 336 | ret 65 |
| 337 | end |
| 338 | if ne get Oob i 0 |
| 339 | ret 72 |
| 340 | end |
| 341 | ret 0 |
| 342 | end |
| 343 | |
| 344 | note s2op: one S2 record (profiles 10..15). Types 1 u64, 5 i64, 6 bool; ops 1..4, 9, 10..17; effects 0, alias 0. |
| 345 | fn s2op i ulong to ulong |
| 346 | code = get Oc i |
| 347 | ty = get Ot i |
| 348 | if gt ty 6 |
| 349 | ret 70 |
| 350 | end |
| 351 | if and ne ty 1 lt ty 5 |
| 352 | ret 68 |
| 353 | end |
| 354 | if or eq code 0 gt code 17 |
| 355 | ret 69 |
| 356 | end |
| 357 | if and ge code 5 le code 8 |
| 358 | ret 68 |
| 359 | end |
| 360 | if ne pureop i 0 |
| 361 | ret 71 |
| 362 | end |
| 363 | if eq code 1 |
| 364 | ret s2const i ty |
| 365 | end |
| 366 | if eq code 9 |
| 367 | ret s2input i ty |
| 368 | end |
| 369 | if le code 4 |
| 370 | ret s2arith i ty |
| 371 | end |
| 372 | if le code 15 |
| 373 | ret s2cmp i ty |
| 374 | end |
| 375 | if eq code 16 |
| 376 | ret s2sel i ty |
| 377 | end |
| 378 | ret s2not i ty |
| 379 | end |
| 380 | |
| 381 | fn checkop i ulong to ulong |
| 382 | code = get Oc i |
| 383 | ty = get Ot i |
| 384 | if eq ty 0 |
| 385 | ret 70 |
| 386 | end |
| 387 | if eq s2 true |
| 388 | ret s2op i |
| 389 | end |
| 390 | if gt ty 4 |
| 391 | ret 70 |
| 392 | end |
| 393 | if eq get M 1 3 |
| 394 | if ne ty 2 |
| 395 | ret 68 |
| 396 | end |
| 397 | else |
| 398 | if ne get M 1 6 |
| 399 | if ne ty 1 |
| 400 | ret 68 |
| 401 | end |
| 402 | end |
| 403 | end |
| 404 | if eq code 0 |
| 405 | ret 69 |
| 406 | end |
| 407 | if gt code 9 |
| 408 | ret 69 |
| 409 | end |
| 410 | if eq code 1 |
| 411 | if gt ty 2 |
| 412 | ret 70 |
| 413 | end |
| 414 | if ne get Oat i ty |
| 415 | ret 70 |
| 416 | end |
| 417 | if ne get Oa i 65535 |
| 418 | ret 70 |
| 419 | end |
| 420 | if ne get Ob i 65535 |
| 421 | ret 70 |
| 422 | end |
| 423 | if ne get Oob i 0 |
| 424 | ret 72 |
| 425 | end |
| 426 | ret pureop i |
| 427 | end |
| 428 | if le code 5 |
| 429 | ret arith i |
| 430 | end |
| 431 | if eq code 6 |
| 432 | if ne get M 1 6 |
| 433 | ret 68 |
| 434 | end |
| 435 | if ne ty 3 |
| 436 | ret 70 |
| 437 | end |
| 438 | if ne get Oat i 3 |
| 439 | ret 70 |
| 440 | end |
| 441 | if eq refok get Oa i 3 i false |
| 442 | ret 70 |
| 443 | end |
| 444 | if ne get Ob i 65535 |
| 445 | ret 70 |
| 446 | end |
| 447 | if ne get Oi i 0 |
| 448 | ret 65 |
| 449 | end |
| 450 | if ne get Oef i 63 |
| 451 | ret 71 |
| 452 | end |
| 453 | if ne get Oal i 255 |
| 454 | ret 71 |
| 455 | end |
| 456 | if ne get Oob i 8 |
| 457 | ret 72 |
| 458 | end |
| 459 | ret 0 |
| 460 | end |
| 461 | if le code 8 |
| 462 | ret memop i |
| 463 | end |
| 464 | if ne get Oat i 0 |
| 465 | ret 70 |
| 466 | end |
| 467 | if ne get Oa i 65535 |
| 468 | ret 70 |
| 469 | end |
| 470 | if ne get Ob i 65535 |
| 471 | ret 70 |
| 472 | end |
| 473 | if gt get Oi i 5 |
| 474 | ret 67 |
| 475 | end |
| 476 | for j ulong i |
| 477 | if eq get Oc j 9 |
| 478 | if eq get Oi j get Oi i |
| 479 | ret 70 |
| 480 | end |
| 481 | end |
| 482 | end |
| 483 | if ne get Oob i 1 |
| 484 | ret 72 |
| 485 | end |
| 486 | if ne get Oef i 0 |
| 487 | ret 71 |
| 488 | end |
| 489 | if eq ty 4 |
| 490 | if eq aliasok get Oal i false |
| 491 | ret 71 |
| 492 | end |
| 493 | else |
| 494 | if ne get Oal i 0 |
| 495 | ret 71 |
| 496 | end |
| 497 | end |
| 498 | ret 0 |
| 499 | end |
| 500 | |
| 501 | fn profile to ulong |
| 502 | p = get M 1 |
| 503 | l = get M 0 |
| 504 | r = get M 2 |
| 505 | abi = get M 3 |
| 506 | if eq p 0 |
| 507 | ret 68 |
| 508 | end |
| 509 | if gt p 15 |
| 510 | ret 68 |
| 511 | end |
| 512 | if gt p 9 |
| 513 | if ne get M 8 3 |
| 514 | ret 68 |
| 515 | end |
| 516 | else |
| 517 | if gt p 6 |
| 518 | if ne get M 8 2 |
| 519 | ret 68 |
| 520 | end |
| 521 | else |
| 522 | if ne get M 8 1 |
| 523 | ret 68 |
| 524 | end |
| 525 | end |
| 526 | end |
| 527 | if eq p 1 |
| 528 | if ne l 1 |
| 529 | ret 68 |
| 530 | end |
| 531 | end |
| 532 | if eq p 2 |
| 533 | if ne l 2 |
| 534 | ret 68 |
| 535 | end |
| 536 | end |
| 537 | if eq p 5 |
| 538 | if ne l 4 |
| 539 | ret 68 |
| 540 | end |
| 541 | end |
| 542 | if eq p 3 |
| 543 | if ne l 3 |
| 544 | ret 68 |
| 545 | end |
| 546 | end |
| 547 | if eq p 4 |
| 548 | if ne l 3 |
| 549 | ret 68 |
| 550 | end |
| 551 | end |
| 552 | if eq p 6 |
| 553 | if ne l 3 |
| 554 | ret 68 |
| 555 | end |
| 556 | end |
| 557 | if eq p 7 |
| 558 | if ne l 5 |
| 559 | ret 68 |
| 560 | end |
| 561 | end |
| 562 | if eq p 8 |
| 563 | if ne l 6 |
| 564 | ret 68 |
| 565 | end |
| 566 | end |
| 567 | if eq p 9 |
| 568 | if ne l 7 |
| 569 | ret 68 |
| 570 | end |
| 571 | end |
| 572 | if eq p 10 |
| 573 | if ne l 1 |
| 574 | ret 68 |
| 575 | end |
| 576 | end |
| 577 | if eq p 11 |
| 578 | if ne l 2 |
| 579 | ret 68 |
| 580 | end |
| 581 | end |
| 582 | if eq p 12 |
| 583 | if ne l 3 |
| 584 | ret 68 |
| 585 | end |
| 586 | end |
| 587 | if eq p 13 |
| 588 | if ne l 5 |
| 589 | ret 68 |
| 590 | end |
| 591 | end |
| 592 | if eq p 14 |
| 593 | if ne l 6 |
| 594 | ret 68 |
| 595 | end |
| 596 | end |
| 597 | if eq p 15 |
| 598 | if ne l 7 |
| 599 | ret 68 |
| 600 | end |
| 601 | end |
| 602 | if or eq p 3 eq p 6 |
| 603 | if or eq r 0 gt r 2 |
| 604 | ret 68 |
| 605 | end |
| 606 | if eq p 6 |
| 607 | if ne abi 2 |
| 608 | ret 68 |
| 609 | end |
| 610 | else |
| 611 | if ne abi 1 |
| 612 | ret 68 |
| 613 | end |
| 614 | end |
| 615 | else |
| 616 | if ne r 0 |
| 617 | ret 68 |
| 618 | end |
| 619 | if ne abi 1 |
| 620 | ret 68 |
| 621 | end |
| 622 | end |
| 623 | ret 0 |
| 624 | end |
| 625 | |
| 626 | fn ops to ulong |
| 627 | for i ulong get M 4 |
| 628 | off = add 57 mul i 20 |
| 629 | if ne ulong get Ib off get M 0 |
| 630 | ret 68 |
| 631 | end |
| 632 | if ne get Ib add off 1 1 |
| 633 | ret 66 |
| 634 | end |
| 635 | put Oc i number add off 2 1 |
| 636 | put Ot i number add off 3 1 |
| 637 | put Oat i number add off 4 1 |
| 638 | put Oef i number add off 5 1 |
| 639 | put Oal i number add off 6 1 |
| 640 | put Oob i number add off 7 1 |
| 641 | put Oa i number add off 8 2 |
| 642 | put Ob i number add off 10 2 |
| 643 | put Oi i number add off 12 8 |
| 644 | code = checkop i |
| 645 | if ne code 0 |
| 646 | ret code |
| 647 | end |
| 648 | end |
| 649 | ret 0 |
| 650 | end |
| 651 | |
| 652 | fn utf8 off ulong n ulong to bool |
| 653 | pos = ulong 0 |
| 654 | while lt pos n |
| 655 | c = ulong get Ib add off pos |
| 656 | pos = add pos 1 |
| 657 | if ge c 128 |
| 658 | extra = ulong 0 |
| 659 | v = ulong 0 |
| 660 | low = ulong 0 |
| 661 | if and ge c 194 le c 223 |
| 662 | extra = 1 |
| 663 | v = and c 31 |
| 664 | low = 128 |
| 665 | end |
| 666 | if and ge c 224 le c 239 |
| 667 | extra = 2 |
| 668 | v = and c 15 |
| 669 | low = 2048 |
| 670 | end |
| 671 | if and ge c 240 le c 244 |
| 672 | extra = 3 |
| 673 | v = and c 7 |
| 674 | low = 65536 |
| 675 | end |
| 676 | if eq extra 0 |
| 677 | ret false |
| 678 | end |
| 679 | if gt extra sub n pos |
| 680 | ret false |
| 681 | end |
| 682 | for j ulong extra |
| 683 | c = ulong get Ib add off pos |
| 684 | if or lt c 128 gt c 191 |
| 685 | ret false |
| 686 | end |
| 687 | v = or shl v 6 and c 63 |
| 688 | pos = add pos 1 |
| 689 | end |
| 690 | if lt v low |
| 691 | ret false |
| 692 | end |
| 693 | if gt v 1114111 |
| 694 | ret false |
| 695 | end |
| 696 | if and ge v 55296 le v 57343 |
| 697 | ret false |
| 698 | end |
| 699 | end |
| 700 | end |
| 701 | ret true |
| 702 | end |
| 703 | |
| 704 | fn boundary pos ulong to bool |
| 705 | if eq pos get Src 1 |
| 706 | ret true |
| 707 | end |
| 708 | c = ulong get Ib add get Src 0 pos |
| 709 | ret or lt c 128 gt c 191 |
| 710 | end |
| 711 | |
| 712 | fn sidecar to ulong |
| 713 | off = get M 7 |
| 714 | size = get M 6 |
| 715 | if lt size 74 |
| 716 | ret 65 |
| 717 | end |
| 718 | if eq magic off 1347636559 false |
| 719 | ret 65 |
| 720 | end |
| 721 | if ne get Ib add off 4 1 |
| 722 | ret 66 |
| 723 | end |
| 724 | enc = number add off 5 1 |
| 725 | if gt enc 1 |
| 726 | ret 76 |
| 727 | end |
| 728 | n = number add off 6 4 |
| 729 | if gt n 4096 |
| 730 | ret 67 |
| 731 | end |
| 732 | start = add off add 74 mul get M 4 8 |
| 733 | if ne size add add 74 mul get M 4 8 n |
| 734 | ret 65 |
| 735 | end |
| 736 | put Src 0 start |
| 737 | put Src 1 n |
| 738 | put Src 2 enc |
| 739 | if eq hashed 13 get M 5 add off 10 false |
| 740 | ret 74 |
| 741 | end |
| 742 | if eq hashed start n add off 42 false |
| 743 | ret 74 |
| 744 | end |
| 745 | if eq enc 1 |
| 746 | if eq utf8 start n false |
| 747 | ret 76 |
| 748 | end |
| 749 | end |
| 750 | for i ulong get M 4 |
| 751 | at = add off add 74 mul i 8 |
| 752 | a = number at 4 |
| 753 | b = number add at 4 4 |
| 754 | if or gt a b gt b n |
| 755 | ret 75 |
| 756 | end |
| 757 | put Ss i a |
| 758 | put Se i b |
| 759 | if eq enc 1 |
| 760 | if eq boundary a false |
| 761 | ret 75 |
| 762 | end |
| 763 | if eq boundary b false |
| 764 | ret 75 |
| 765 | end |
| 766 | end |
| 767 | end |
| 768 | ret 0 |
| 769 | end |
| 770 | |
| 771 | fn decode n ulong to ulong |
| 772 | put El 0 0 |
| 773 | if gt n 8192 |
| 774 | ret 67 |
| 775 | end |
| 776 | if lt n 13 |
| 777 | ret 65 |
| 778 | end |
| 779 | if eq magic 0 1112755535 false |
| 780 | ret 65 |
| 781 | end |
| 782 | if ne get Ib 4 1 |
| 783 | ret 66 |
| 784 | end |
| 785 | sn = number 5 4 |
| 786 | pn = number 9 4 |
| 787 | if or gt sn 1324 gt pn 4682 |
| 788 | ret 67 |
| 789 | end |
| 790 | if ne n add 13 add sn pn |
| 791 | ret 65 |
| 792 | end |
| 793 | if lt sn 44 |
| 794 | ret 65 |
| 795 | end |
| 796 | if eq magic 13 1095978319 false |
| 797 | ret 65 |
| 798 | end |
| 799 | put M 8 number 17 1 |
| 800 | if or eq get M 8 0 gt get M 8 3 |
| 801 | ret 66 |
| 802 | end |
| 803 | if ne get Ib 20 1 |
| 804 | ret 66 |
| 805 | end |
| 806 | put M 0 number 18 1 |
| 807 | put M 1 number 19 1 |
| 808 | put M 2 number 21 1 |
| 809 | put M 3 number 22 1 |
| 810 | put M 4 number 23 2 |
| 811 | put M 5 sn |
| 812 | put M 6 pn |
| 813 | put M 7 add 13 sn |
| 814 | if or eq get M 4 0 gt get M 4 64 |
| 815 | ret 67 |
| 816 | end |
| 817 | if ne sn add 44 mul get M 4 20 |
| 818 | ret 65 |
| 819 | end |
| 820 | if eq contract false |
| 821 | ret 78 |
| 822 | end |
| 823 | code = profile |
| 824 | if ne code 0 |
| 825 | ret code |
| 826 | end |
| 827 | code = ops |
| 828 | if ne code 0 |
| 829 | ret code |
| 830 | end |
| 831 | if ne pn 0 |
| 832 | ret sidecar |
| 833 | end |
| 834 | ret 0 |
| 835 | end |
| 836 | |
| 837 | fn ebyte v ulong to void |
| 838 | put Eb get El 0 uchar v |
| 839 | put El 0 add get El 0 1 |
| 840 | end |
| 841 | |
| 842 | fn emitnum v ulong n ulong to void |
| 843 | for i ulong n |
| 844 | ebyte and shr v mul i 8 255 |
| 845 | end |
| 846 | end |
| 847 | |
| 848 | fn emitpart off ulong n ulong to void |
| 849 | for i ulong n |
| 850 | ebyte ulong get Ib add off i |
| 851 | end |
| 852 | end |
| 853 | |
| 854 | fn encode to void |
| 855 | emitnum 1112755535 4 |
| 856 | ebyte 1 |
| 857 | emitnum get M 5 4 |
| 858 | emitnum get M 6 4 |
| 859 | emitnum 1095978319 4 |
| 860 | ebyte get M 8 |
| 861 | ebyte get M 0 |
| 862 | ebyte get M 1 |
| 863 | ebyte 1 |
| 864 | ebyte get M 2 |
| 865 | ebyte get M 3 |
| 866 | emitnum get M 4 2 |
| 867 | emitpart 25 32 |
| 868 | for i ulong get M 4 |
| 869 | ebyte get M 0 |
| 870 | ebyte 1 |
| 871 | ebyte get Oc i |
| 872 | ebyte get Ot i |
| 873 | ebyte get Oat i |
| 874 | ebyte get Oef i |
| 875 | ebyte get Oal i |
| 876 | ebyte get Oob i |
| 877 | emitnum get Oa i 2 |
| 878 | emitnum get Ob i 2 |
| 879 | emitnum get Oi i 8 |
| 880 | end |
| 881 | if ne get M 6 0 |
| 882 | emitnum 1347636559 4 |
| 883 | ebyte 1 |
| 884 | ebyte get Src 2 |
| 885 | emitnum get Src 1 4 |
| 886 | emitpart add get M 7 10 64 |
| 887 | for i ulong get M 4 |
| 888 | emitnum get Ss i 4 |
| 889 | emitnum get Se i 4 |
| 890 | end |
| 891 | emitpart get Src 0 get Src 1 |
| 892 | end |
| 893 | end |
| 894 | |
| 895 | fn digout to void |
| 896 | finish |
| 897 | for i ulong 32 |
| 898 | ebyte ulong get Hash i |
| 899 | end |
| 900 | end |
| 901 | |
| 902 | fn legal i ulong to ulong |
| 903 | if ne get Cp 2 get M 3 |
| 904 | ret 4 |
| 905 | end |
| 906 | if ne and get Oef i get Cp 3 get Oef i |
| 907 | ret 4 |
| 908 | end |
| 909 | if ne get M 2 0 |
| 910 | if ne get Cp 1 get M 2 |
| 911 | ret 2 |
| 912 | end |
| 913 | end |
| 914 | if eq get Cp 0 1 |
| 915 | ret 1 |
| 916 | end |
| 917 | if or eq get M 1 3 eq get M 1 6 |
| 918 | ret 4 |
| 919 | end |
| 920 | if ne get Ot i 1 |
| 921 | ret 4 |
| 922 | end |
| 923 | if le get Oc i 5 |
| 924 | ret 3 |
| 925 | end |
| 926 | if eq get Oc i 9 |
| 927 | ret 3 |
| 928 | end |
| 929 | ret 4 |
| 930 | end |
| 931 | |
| 932 | fn caps n ulong to ulong |
| 933 | if lt n 4 |
| 934 | ret 65 |
| 935 | end |
| 936 | for i ulong 4 |
| 937 | put Cp i number i 1 |
| 938 | end |
| 939 | if or eq get Cp 0 0 gt get Cp 0 2 |
| 940 | ret 68 |
| 941 | end |
| 942 | if gt get Cp 1 2 |
| 943 | ret 68 |
| 944 | end |
| 945 | if or eq get Cp 2 0 gt get Cp 2 2 |
| 946 | ret 68 |
| 947 | end |
| 948 | if gt get Cp 3 63 |
| 949 | ret 68 |
| 950 | end |
| 951 | for i ulong sub n 4 |
| 952 | put Ib i get Ib add i 4 |
| 953 | end |
| 954 | ret 0 |
| 955 | end |
| 956 | |
| 957 | fn perform mode ulong n ulong to ulong |
| 958 | put El 0 0 |
| 959 | if gt n 8192 |
| 960 | ret 67 |
| 961 | end |
| 962 | if or eq mode 0 gt mode 6 |
| 963 | ret 64 |
| 964 | end |
| 965 | if eq mode 6 |
| 966 | code = caps n |
| 967 | if ne code 0 |
| 968 | ret code |
| 969 | end |
| 970 | n = sub n 4 |
| 971 | end |
| 972 | code = decode n |
| 973 | if ne code 0 |
| 974 | ret code |
| 975 | end |
| 976 | if le mode 2 |
| 977 | encode |
| 978 | ret 0 |
| 979 | end |
| 980 | if eq mode 3 |
| 981 | hinit |
| 982 | for i ulong len Semdom |
| 983 | hbyte get Semdom i |
| 984 | end |
| 985 | part 13 get M 5 |
| 986 | digout |
| 987 | ret 0 |
| 988 | end |
| 989 | if eq mode 4 |
| 990 | hinit |
| 991 | for i ulong len Provdom |
| 992 | hbyte get Provdom i |
| 993 | end |
| 994 | part 0 n |
| 995 | digout |
| 996 | ret 0 |
| 997 | end |
| 998 | if eq mode 5 |
| 999 | if eq get M 6 0 |
| 1000 | ret 73 |
| 1001 | end |
| 1002 | emitpart get Src 0 get Src 1 |
| 1003 | ret 0 |
| 1004 | end |
| 1005 | for i ulong get M 4 |
| 1006 | ebyte legal i |
| 1007 | ebyte get Oob i |
| 1008 | end |
| 1009 | ret 0 |
| 1010 | end |