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 / gpu / nvidia / native / learn53 / moe-closure.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note #35/#53/#159 joint operation instance binding, NOT qualification or authentication. |
| 3 | note Dependencies: authoritative moe_windows/moe_alias, compose_check/launchread and kc SHA. |
| 4 | note Canonical LE64 scalar128, SHA256 groups64, ordered window LE64 cells1024. |
| 5 | note Exact active11264 in capacity16384; all reserved/inactive/capacity bytes zero. |
| 6 | fn mc_word b view uchar 16384 i ulong to ulong |
| 7 | v = ulong 0 |
| 8 | for j ulong 8 |
| 9 | v = or v shl ulong get b add mul i 8 j mul j 8 |
| 10 | end |
| 11 | ret v |
| 12 | end |
| 13 | fn mc_put b edit uchar 16384 i ulong v ulong to void |
| 14 | for j ulong 8 |
| 15 | put b add mul i 8 j uchar and shr v mul j 8 255 |
| 16 | end |
| 17 | end |
| 18 | fn mc_hash b view uchar 16384 i ulong h view uchar 32 to bool |
| 19 | if ge i 64 |
| 20 | ret false |
| 21 | end |
| 22 | for j ulong 32 |
| 23 | if ne get b add add 1024 mul i 32 j get h j |
| 24 | ret false |
| 25 | end |
| 26 | end |
| 27 | ret true |
| 28 | end |
| 29 | fn mc_base i ulong to ulong |
| 30 | if lt i 8 |
| 31 | ret add 32 mul i 4 |
| 32 | end |
| 33 | ret add 80 mul sub i 8 4 |
| 34 | end |
| 35 | fn mc_need b view uchar 16384 i ulong to ulong |
| 36 | n = mc_word b 5 |
| 37 | if lt i 4 |
| 38 | width = ulong 144 |
| 39 | if lt i 2 |
| 40 | width = 32 |
| 41 | end |
| 42 | ret add mul sub n 1 mc_word b 16 width |
| 43 | end |
| 44 | if lt i 6 |
| 45 | ret mul mc_word b 74 32 |
| 46 | end |
| 47 | if lt i 8 |
| 48 | ret mul mc_word b 73 4 |
| 49 | end |
| 50 | if eq i 8 |
| 51 | ret mul mul n mc_word b 9 4 |
| 52 | end |
| 53 | if eq i 9 |
| 54 | ret mul mul mul n 9 mc_word b 10 8 |
| 55 | end |
| 56 | if lt i 12 |
| 57 | ret mul mul mul n 9 mc_word b 10 4 |
| 58 | end |
| 59 | if eq i 12 |
| 60 | ret mul mul mul n 9 mc_word b 9 4 |
| 61 | end |
| 62 | if eq i 13 |
| 63 | ret mul mul n mc_word b 9 4 |
| 64 | end |
| 65 | note Tensor extents come from immutable tensor/directory owner, not a guessed packing. |
| 66 | ret 1 |
| 67 | end |
| 68 | fn mc_ranges b view uchar 16384 to long |
| 69 | r = new ulong 16 0 |
| 70 | for i ulong 16 |
| 71 | p = mc_base i |
| 72 | va = mc_word b p |
| 73 | size = mc_word b add p 1 |
| 74 | if or eq va 0 ne rem va 8 0 |
| 75 | ret 3 |
| 76 | end |
| 77 | if lt size mc_need b i |
| 78 | ret 3 |
| 79 | end |
| 80 | if gt va sub ulong 18446744073709551615 size |
| 81 | ret 3 |
| 82 | end |
| 83 | wantgen = mc_word b 19 |
| 84 | if ge i 14 |
| 85 | wantgen = mc_word b 22 |
| 86 | end |
| 87 | if ne mc_word b add p 2 wantgen |
| 88 | ret 3 |
| 89 | end |
| 90 | if eq mc_word b add p 3 0 |
| 91 | ret 3 |
| 92 | end |
| 93 | end |
| 94 | note GROUP's existing span/alias checker is authoritative; no alternate overlap algorithm. |
| 95 | put r 0 add mc_word b 32 mul mc_word b 6 mc_word b 16 |
| 96 | put r 1 add mc_word b 40 mul mc_word b 6 mc_word b 16 |
| 97 | put r 2 add mc_word b 44 mul mc_word b 6 mc_word b 16 |
| 98 | put r 3 mc_word b 48 |
| 99 | put r 4 mc_word b 52 |
| 100 | put r 5 mc_word b 56 |
| 101 | put r 6 mc_word b 60 |
| 102 | put r 7 mc_word b 16 |
| 103 | put r 8 mc_word b 7 |
| 104 | if moe_alias r |
| 105 | ret 3 |
| 106 | end |
| 107 | for i ulong 4 |
| 108 | if ne mc_word b add mc_base i 3 mc_word b 16 |
| 109 | ret 3 |
| 110 | end |
| 111 | end |
| 112 | for i ulong 2 |
| 113 | if ne mc_word b add mc_base add i 4 3 32 |
| 114 | ret 3 |
| 115 | end |
| 116 | if ne mc_word b add mc_base add i 6 3 4 |
| 117 | ret 3 |
| 118 | end |
| 119 | end |
| 120 | if ne mc_word b 83 mul mc_word b 9 4 |
| 121 | ret 3 |
| 122 | end |
| 123 | if ne mc_word b 87 mul mul ulong 9 mc_word b 10 8 |
| 124 | ret 3 |
| 125 | end |
| 126 | for i ulong 2 |
| 127 | if ne mc_word b add 91 mul i 4 mul mul ulong 9 mc_word b 10 4 |
| 128 | ret 3 |
| 129 | end |
| 130 | end |
| 131 | if ne mc_word b 99 mul mul ulong 9 mc_word b 9 4 |
| 132 | ret 3 |
| 133 | end |
| 134 | if ne mc_word b 103 mul mc_word b 9 4 |
| 135 | ret 3 |
| 136 | end |
| 137 | ret 0 |
| 138 | end |
| 139 | fn mc_windows b view uchar 16384 to long |
| 140 | cfg = new ulong 8 0 |
| 141 | rows = new ulong 1024 0 |
| 142 | meta = new ulong 4 0 |
| 143 | put cfg 0 1 |
| 144 | put cfg 1 mc_word b 5 |
| 145 | put cfg 2 mc_word b 9 |
| 146 | put cfg 3 mc_word b 10 |
| 147 | put cfg 4 mc_word b 13 |
| 148 | put cfg 5 mc_word b 16 |
| 149 | put cfg 6 mc_word b 15 |
| 150 | put cfg 7 mc_word b 75 |
| 151 | if ne moe_windows cfg edit rows edit meta 0 |
| 152 | ret 2 |
| 153 | end |
| 154 | if ne get meta 0 mc_word b 3 |
| 155 | ret 2 |
| 156 | end |
| 157 | for i ulong 1024 |
| 158 | if ne mc_word b add 384 i get rows i |
| 159 | ret 2 |
| 160 | end |
| 161 | end |
| 162 | p = mul mc_word b 4 8 |
| 163 | for i ulong 3 |
| 164 | if ne mc_word b add 6 i get rows add p i |
| 165 | ret 2 |
| 166 | end |
| 167 | end |
| 168 | ret 0 |
| 169 | end |
| 170 | fn mc_valid b view uchar 16384 n ulong to long |
| 171 | if ne n 11264 |
| 172 | ret 1 |
| 173 | end |
| 174 | if or ne mc_word b 0 2 ne mc_word b 1 159 |
| 175 | ret 1 |
| 176 | end |
| 177 | if ne mc_word b 2 n |
| 178 | ret 1 |
| 179 | end |
| 180 | if or eq mc_word b 3 0 gt mc_word b 3 128 |
| 181 | ret 1 |
| 182 | end |
| 183 | if ge mc_word b 4 mc_word b 3 |
| 184 | ret 1 |
| 185 | end |
| 186 | if or eq mc_word b 5 0 gt mc_word b 5 128 |
| 187 | ret 1 |
| 188 | end |
| 189 | if or ne mc_word b 9 2048 ne mc_word b 10 512 |
| 190 | ret 2 |
| 191 | end |
| 192 | if or ne mc_word b 11 256 ne mc_word b 12 8 |
| 193 | ret 2 |
| 194 | end |
| 195 | if or ne mc_word b 13 9 ne mc_word b 14 256 |
| 196 | ret 2 |
| 197 | end |
| 198 | if ne mc_word b 15 128 |
| 199 | ret 2 |
| 200 | end |
| 201 | if or lt mc_word b 16 144 gt mc_word b 16 4294967295 |
| 202 | ret 2 |
| 203 | end |
| 204 | if ne rem mc_word b 16 16 0 |
| 205 | ret 2 |
| 206 | end |
| 207 | note Epoch0 is valid; identities match owner context separately. |
| 208 | if ne mc_word b 18 121 |
| 209 | ret 2 |
| 210 | end |
| 211 | if eq mc_word b 20 0 |
| 212 | ret 1 |
| 213 | end |
| 214 | if or eq mc_word b 77 0 ge mc_word b 21 mc_word b 77 |
| 215 | ret 1 |
| 216 | end |
| 217 | lastly = ulong 0 |
| 218 | if eq add mc_word b 21 1 mc_word b 77 |
| 219 | lastly = 1 |
| 220 | end |
| 221 | if ne mc_word b 78 lastly |
| 222 | ret 2 |
| 223 | end |
| 224 | if ne mc_word b 23 0 |
| 225 | ret 2 |
| 226 | end |
| 227 | for i ulong 8 |
| 228 | if ne mc_word b add 24 i 1 |
| 229 | ret 2 |
| 230 | end |
| 231 | end |
| 232 | for i ulong 9 |
| 233 | if ne mc_word b add 64 i i |
| 234 | ret 2 |
| 235 | end |
| 236 | end |
| 237 | if or ne mc_word b 73 add mul mc_word b 5 9 8 ne mc_word b 74 128 |
| 238 | ret 2 |
| 239 | end |
| 240 | if or ne mc_word b 75 0 gt mc_word b 76 1 |
| 241 | ret 2 |
| 242 | end |
| 243 | if ne mc_word b 79 1 |
| 244 | ret 2 |
| 245 | end |
| 246 | note Window-local X/Y, GU X/Y, DN Y/Y, padding8, duplicate-preserving sort. |
| 247 | if or ne mc_word b 112 1 ne mc_word b 113 2 |
| 248 | ret 2 |
| 249 | end |
| 250 | if or ne mc_word b 114 2 ne mc_word b 115 2 |
| 251 | ret 2 |
| 252 | end |
| 253 | if ne mc_word b 116 8 |
| 254 | ret 2 |
| 255 | end |
| 256 | for i ulong 5 |
| 257 | if ne mc_word b add 117 i 1 |
| 258 | ret 2 |
| 259 | end |
| 260 | end |
| 261 | for i ulong 2 |
| 262 | v = mc_word b add 122 i |
| 263 | if or eq v 0 gt v 16384 |
| 264 | ret 1 |
| 265 | end |
| 266 | if ne rem v 16 0 |
| 267 | ret 1 |
| 268 | end |
| 269 | end |
| 270 | for i ulong 4 |
| 271 | if ne mc_word b add 124 i 0 |
| 272 | ret 1 |
| 273 | end |
| 274 | end |
| 275 | for i ulong 64 |
| 276 | nz = uchar 0 |
| 277 | for j ulong 32 |
| 278 | nz = or nz get b add add 1024 mul i 32 j |
| 279 | end |
| 280 | if eq nz 0 |
| 281 | ret 1 |
| 282 | end |
| 283 | end |
| 284 | for i ulong 5120 |
| 285 | if ne get b add 11264 i 0 |
| 286 | ret 1 |
| 287 | end |
| 288 | end |
| 289 | s = mc_windows b |
| 290 | if ne s 0 |
| 291 | ret s |
| 292 | end |
| 293 | ret mc_ranges b |
| 294 | end |
| 295 | fn mc_bind want view uchar 16384 got view uchar 16384 n ulong out edit uchar 32 to long |
| 296 | for i ulong 32 |
| 297 | put out i 0 |
| 298 | end |
| 299 | s = mc_valid want n |
| 300 | if ne s 0 |
| 301 | ret s |
| 302 | end |
| 303 | s = mc_valid got n |
| 304 | if ne s 0 |
| 305 | ret s |
| 306 | end |
| 307 | for i ulong 11264 |
| 308 | if ne get want i get got i |
| 309 | ret 4 |
| 310 | end |
| 311 | end |
| 312 | if ne kc_codesha got n edit out 0 |
| 313 | ret 1 |
| 314 | end |
| 315 | ret 0 |
| 316 | end |
| 317 | fn mc_limb b view uchar 16384 group ulong limb ulong to ulong |
| 318 | ret mc_word b add add 128 mul group 4 limb |
| 319 | end |
| 320 | fn mc_context b view uchar 16384 q view ulong 64 row view ulong 64 role ulong to long |
| 321 | if ne mc_valid b 11264 0 |
| 322 | ret 1 |
| 323 | end |
| 324 | if or gt role 1 ne get q 0 1 |
| 325 | ret 5 |
| 326 | end |
| 327 | if ne get row 0 3 |
| 328 | ret 5 |
| 329 | end |
| 330 | for i ulong 4 |
| 331 | if ne get q add i 3 mc_word b add i 17 |
| 332 | ret 5 |
| 333 | end |
| 334 | if ne get row add i 17 get q add i 3 |
| 335 | ret 5 |
| 336 | end |
| 337 | end |
| 338 | for i ulong 6 |
| 339 | group = add i 38 |
| 340 | if and eq role 1 ge i 4 |
| 341 | group = add i 49 |
| 342 | end |
| 343 | for j ulong 4 |
| 344 | v = mc_limb b group j |
| 345 | if ne get q add add 14 mul i 4 j v |
| 346 | ret 5 |
| 347 | end |
| 348 | if ne get row add add 33 mul i 4 j v |
| 349 | ret 5 |
| 350 | end |
| 351 | end |
| 352 | end |
| 353 | for i ulong 4 |
| 354 | if ne get row add 21 i mc_limb b add 22 mul role 8 i |
| 355 | ret 5 |
| 356 | end |
| 357 | if ne get row add 25 i mc_limb b add 24 mul role 8 i |
| 358 | ret 5 |
| 359 | end |
| 360 | if ne get row add 29 i mc_limb b 44 i |
| 361 | ret 5 |
| 362 | end |
| 363 | if ne get row add 57 i mc_limb b add 23 mul role 8 i |
| 364 | ret 5 |
| 365 | end |
| 366 | end |
| 367 | ret 0 |
| 368 | end |
| 369 | fn mc_bindctx want view uchar 16384 got view uchar 16384 q view ulong 64 row view ulong 64 role ulong out edit uchar 32 to long |
| 370 | for i ulong 32 |
| 371 | put out i 0 |
| 372 | end |
| 373 | s = mc_context got q row role |
| 374 | if ne s 0 |
| 375 | ret s |
| 376 | end |
| 377 | ret mc_bind want got 11264 edit out |
| 378 | end |
| 379 | fn mc_chashes b view uchar 16384 c view uchar 4096 role ulong to long |
| 380 | h = new uchar 32 0 |
| 381 | q = new uchar 4096 0 |
| 382 | for k ulong 3 |
| 383 | pos = add 544 mul k 32 |
| 384 | for i ulong 32 |
| 385 | put h i get c add pos i |
| 386 | end |
| 387 | if not mc_hash b add k 4 h |
| 388 | ret 6 |
| 389 | end |
| 390 | end |
| 391 | for i ulong 32 |
| 392 | put h i get c add 512 i |
| 393 | end |
| 394 | if not mc_hash b add 61 role h |
| 395 | ret 6 |
| 396 | end |
| 397 | if ne kc_sha c 1152 edit h 0 |
| 398 | ret 6 |
| 399 | end |
| 400 | if not mc_hash b add 22 mul role 8 h |
| 401 | ret 6 |
| 402 | end |
| 403 | for i ulong 384 |
| 404 | put q i get c add 768 i |
| 405 | end |
| 406 | if ne kc_sha q 384 edit h 0 |
| 407 | ret 6 |
| 408 | end |
| 409 | if not mc_hash b add 29 mul role 8 h |
| 410 | ret 6 |
| 411 | end |
| 412 | ret 0 |
| 413 | end |
| 414 | fn mc_codeblob b view uchar 16384 c view uchar 4096 code view uchar 16384 n ulong role ulong to long |
| 415 | h = new uchar 32 0 |
| 416 | if ne kc_codesha code n edit h 0 |
| 417 | ret 6 |
| 418 | end |
| 419 | if not compose_codeid c h |
| 420 | ret 6 |
| 421 | end |
| 422 | if not mc_hash b add 23 mul role 8 h |
| 423 | ret 6 |
| 424 | end |
| 425 | ret 0 |
| 426 | end |
| 427 | fn mc_launchblob b view uchar 16384 c view uchar 4096 l view uchar 256 role ulong to long |
| 428 | h = new uchar 32 0 |
| 429 | lw = new uchar 4096 0 |
| 430 | for i ulong 256 |
| 431 | put lw i get l i |
| 432 | end |
| 433 | if ne compose_launchread c lw 256 0 |
| 434 | ret 6 |
| 435 | end |
| 436 | if ne kc_sha lw 256 edit h 0 |
| 437 | ret 6 |
| 438 | end |
| 439 | if not compose_launchid c h |
| 440 | ret 6 |
| 441 | end |
| 442 | if not mc_hash b add 24 mul role 8 h |
| 443 | ret 6 |
| 444 | end |
| 445 | for k ulong 3 |
| 446 | pos = add 120 mul k 32 |
| 447 | for i ulong 32 |
| 448 | put h i get l add pos i |
| 449 | end |
| 450 | group = add add 26 mul role 8 k |
| 451 | if not mc_hash b group h |
| 452 | ret 6 |
| 453 | end |
| 454 | end |
| 455 | ret 0 |
| 456 | end |
| 457 | fn mc_blob b view uchar 16384 c view uchar 4096 code view uchar 16384 n ulong l view uchar 256 role ulong to long |
| 458 | if gt role 1 |
| 459 | ret 1 |
| 460 | end |
| 461 | if ne mc_valid b 11264 0 |
| 462 | ret 1 |
| 463 | end |
| 464 | note Preserve canonical family3 refusal. No host result can replace that gate. |
| 465 | if ne compose_word c 19 3 |
| 466 | ret 6 |
| 467 | end |
| 468 | if ne compose_check c 1152 0 |
| 469 | ret 6 |
| 470 | end |
| 471 | if or eq n 0 gt n 16384 |
| 472 | ret 6 |
| 473 | end |
| 474 | if ne rem n 16 0 |
| 475 | ret 6 |
| 476 | end |
| 477 | if ne n mc_word b add 122 role |
| 478 | ret 6 |
| 479 | end |
| 480 | if ne compose_word c 4 mc_word b 8 |
| 481 | ret 6 |
| 482 | end |
| 483 | if eq role 0 |
| 484 | if or ne compose_word c 5 mul mc_word b 10 2 ne compose_word c 6 mc_word b 9 |
| 485 | ret 6 |
| 486 | end |
| 487 | else |
| 488 | if or ne compose_word c 5 mc_word b 9 ne compose_word c 6 mc_word b 10 |
| 489 | ret 6 |
| 490 | end |
| 491 | end |
| 492 | if ne mc_chashes b c role 0 |
| 493 | ret 6 |
| 494 | end |
| 495 | if ne mc_codeblob b c code n role 0 |
| 496 | ret 6 |
| 497 | end |
| 498 | ret mc_launchblob b c l role |
| 499 | end |
| 500 | note Custody identities are frozen executor metadata, not candidate claims or signed receipts. |
| 501 | note ctx/got32: version1,class1HOST_ONLY,instance4,evaluator4,source4,resultprotocol4, |
| 502 | note approved subject4,independently frozen qualification-context4,reserved6zero. |
| 503 | note No device class accepted here; existing independent owner handles actual qualification. |
| 504 | fn mc_custody b view uchar 16384 held view uchar 32 ctx view ulong 32 got view ulong 32 to long |
| 505 | h = new uchar 32 0 |
| 506 | if ne mc_valid b 11264 0 |
| 507 | ret 1 |
| 508 | end |
| 509 | if ne kc_codesha b 11264 edit h 0 |
| 510 | ret 1 |
| 511 | end |
| 512 | for i ulong 32 |
| 513 | if ne get held i get h i |
| 514 | ret 5 |
| 515 | end |
| 516 | end |
| 517 | if or ne get ctx 0 1 ne get ctx 1 1 |
| 518 | ret 5 |
| 519 | end |
| 520 | for i ulong 32 |
| 521 | if ne get ctx i get got i |
| 522 | ret 5 |
| 523 | end |
| 524 | end |
| 525 | for i ulong 4 |
| 526 | v = ulong 0 |
| 527 | for j ulong 8 |
| 528 | v = or v shl ulong get h add mul i 8 j mul j 8 |
| 529 | end |
| 530 | if ne get ctx add i 2 v |
| 531 | ret 5 |
| 532 | end |
| 533 | if ne get ctx add i 6 mc_limb b 7 i |
| 534 | ret 5 |
| 535 | end |
| 536 | if ne get ctx add i 10 mc_limb b 3 i |
| 537 | ret 5 |
| 538 | end |
| 539 | end |
| 540 | for i ulong 4 |
| 541 | if ne get ctx add i 14 mc_limb b 63 i |
| 542 | ret 5 |
| 543 | end |
| 544 | if ne get ctx add i 18 mc_limb b 39 i |
| 545 | ret 5 |
| 546 | end |
| 547 | if ne get ctx add i 22 mc_limb b 44 i |
| 548 | ret 5 |
| 549 | end |
| 550 | end |
| 551 | for i ulong 6 |
| 552 | if ne get ctx add i 26 0 |
| 553 | ret 5 |
| 554 | end |
| 555 | end |
| 556 | ret 0 |
| 557 | end |
| 558 | fn mc_pack scalars view ulong 128 hashes view uchar 2048 windows view ulong 1024 out edit uchar 16384 to long |
| 559 | for i ulong 16384 |
| 560 | put out i 0 |
| 561 | end |
| 562 | for i ulong 128 |
| 563 | mc_put edit out i get scalars i |
| 564 | end |
| 565 | for i ulong 2048 |
| 566 | put out add 1024 i get hashes i |
| 567 | end |
| 568 | for i ulong 1024 |
| 569 | mc_put edit out add 384 i get windows i |
| 570 | end |
| 571 | s = mc_valid out 11264 |
| 572 | if ne s 0 |
| 573 | for i ulong 16384 |
| 574 | put out i 0 |
| 575 | end |
| 576 | end |
| 577 | ret s |
| 578 | end |
| 579 | note Nested live-instance preimages, not admitted native artifact template identities. |
| 580 | note All input arrays and out32 MUST be disjoint; existing owner supplies actual retained snapshots. |
| 581 | fn mc_clear out edit uchar 32 to void |
| 582 | for i ulong 32 |
| 583 | put out i 0 |
| 584 | end |
| 585 | end |
| 586 | fn mc_code code view uchar 16384 n ulong out edit uchar 32 to long |
| 587 | mc_clear edit out |
| 588 | if or eq n 0 or gt n 16384 ne rem n 16 0 |
| 589 | ret 1 |
| 590 | end |
| 591 | if ne kc_codesha code n edit out 0 |
| 592 | ret 6 |
| 593 | end |
| 594 | ret 0 |
| 595 | end |
| 596 | fn mc_submit m view ulong 32 s view ulong 16 to long |
| 597 | if or ne get s 0 1 or ne get s 1 159 ne get s 2 4 |
| 598 | ret 1 |
| 599 | end |
| 600 | if or eq get s 3 0 ne get s 3 get m 7 |
| 601 | ret 1 |
| 602 | end |
| 603 | if or gt get s 4 1 gt get s 5 4 |
| 604 | ret 2 |
| 605 | end |
| 606 | if or eq get s 6 0 gt get s 7 1000000 |
| 607 | ret 1 |
| 608 | end |
| 609 | if or gt get s 8 1 or ne get s 9 0 gt get s 10 1 |
| 610 | ret 2 |
| 611 | end |
| 612 | if or eq get s 11 0 or gt get s 11 4096 ge get m 6 get s 11 |
| 613 | ret 1 |
| 614 | end |
| 615 | for i ulong 4 |
| 616 | if ne get s add 12 i 0 |
| 617 | ret 1 |
| 618 | end |
| 619 | end |
| 620 | ret 0 |
| 621 | end |
| 622 | fn mc_qword q view uchar 1024 off ulong to ulong |
| 623 | v = ulong 0 |
| 624 | for i ulong 4 |
| 625 | v = or v shl ulong get q add off i mul i 8 |
| 626 | end |
| 627 | ret v |
| 628 | end |
| 629 | fn mc_qcode q view uchar 1024 to ulong |
| 630 | low = shl mc_qword q 128 4 |
| 631 | high = and mc_qword q 132 sub shl ulong 1 21 1 |
| 632 | ret or low shl high 36 |
| 633 | end |
| 634 | fn mc_lmeta m view ulong 32 qmd view uchar 1024 to long |
| 635 | if or ne get m 0 1 or ne get m 1 159 ne get m 2 1 |
| 636 | ret 1 |
| 637 | end |
| 638 | if or gt get m 3 5 or eq get m 4 0 gt get m 4 32 |
| 639 | ret 1 |
| 640 | end |
| 641 | n = get m 5 |
| 642 | if eq n 0 |
| 643 | ret 1 |
| 644 | end |
| 645 | if gt n 16384 |
| 646 | ret 1 |
| 647 | end |
| 648 | if ne rem n 16 0 |
| 649 | ret 1 |
| 650 | end |
| 651 | if or eq get m 7 0 gt get m 8 1 |
| 652 | ret 1 |
| 653 | end |
| 654 | if ne rem get m 9 8 0 |
| 655 | ret 3 |
| 656 | end |
| 657 | if eq get m 10 0 |
| 658 | ret 3 |
| 659 | end |
| 660 | if ne rem get m 10 16 0 |
| 661 | ret 3 |
| 662 | end |
| 663 | if ne mc_qcode qmd get m 10 |
| 664 | ret 3 |
| 665 | end |
| 666 | for i ulong 21 |
| 667 | if ne get m add 11 i 0 |
| 668 | ret 1 |
| 669 | end |
| 670 | end |
| 671 | ret 0 |
| 672 | end |
| 673 | fn mc_lbytes bank view uchar 1024 qmd view uchar 1024 n ulong b edit uchar 16384 to ulong |
| 674 | off = ulong 384 |
| 675 | for i ulong add 896 mul n 4 |
| 676 | put b add off i get bank i |
| 677 | end |
| 678 | off = add off add 896 mul n 4 |
| 679 | for i ulong 384 |
| 680 | put b add off i get qmd i |
| 681 | end |
| 682 | off = add off 384 |
| 683 | for i ulong 384 |
| 684 | put b add off i get qmd add 512 i |
| 685 | end |
| 686 | ret add off 384 |
| 687 | end |
| 688 | fn mc_launch m view ulong 32 bank view uchar 1024 qmd view uchar 1024 s view ulong 16 out edit uchar 32 to long |
| 689 | mc_clear edit out |
| 690 | st = mc_lmeta m qmd |
| 691 | if ne st 0 |
| 692 | ret st |
| 693 | end |
| 694 | st = mc_submit m s |
| 695 | if ne st 0 |
| 696 | ret st |
| 697 | end |
| 698 | b = new uchar 16384 0 |
| 699 | for i ulong 32 |
| 700 | mc_put edit b i get m i |
| 701 | end |
| 702 | for i ulong 16 |
| 703 | mc_put edit b add 32 i get s i |
| 704 | end |
| 705 | n = mc_lbytes bank qmd get m 4 edit b |
| 706 | if ne kc_codesha b n edit out 0 |
| 707 | ret 6 |
| 708 | end |
| 709 | ret 0 |
| 710 | end |
| 711 | fn mc_dir m view ulong 8 entries view ulong 1024 out edit uchar 32 to long |
| 712 | mc_clear edit out |
| 713 | if or ne get m 0 1 or ne get m 1 159 ne get m 2 2 |
| 714 | ret 1 |
| 715 | end |
| 716 | if or gt get m 3 1 or ne get m 4 257 eq get m 5 0 |
| 717 | ret 1 |
| 718 | end |
| 719 | if or gt get m 6 4294967295 ne get m 7 0 |
| 720 | ret 1 |
| 721 | end |
| 722 | b = new uchar 16384 0 |
| 723 | for i ulong 8 |
| 724 | mc_put edit b i get m i |
| 725 | end |
| 726 | for i ulong 1024 |
| 727 | if lt i 514 |
| 728 | if or eq get entries i 0 ne rem get entries i 8 0 |
| 729 | ret 3 |
| 730 | end |
| 731 | mc_put edit b add 8 i get entries i |
| 732 | else |
| 733 | if ne get entries i 0 |
| 734 | ret 1 |
| 735 | end |
| 736 | end |
| 737 | end |
| 738 | if ne kc_codesha b 4176 edit out 0 |
| 739 | ret 6 |
| 740 | end |
| 741 | ret 0 |
| 742 | end |
| 743 | fn mc_record r view ulong 1024 i ulong to long |
| 744 | p = mul i 16 |
| 745 | if ge get r p 64 |
| 746 | ret 1 |
| 747 | end |
| 748 | if ne i 0 |
| 749 | if le get r p get r sub p 16 |
| 750 | ret 1 |
| 751 | end |
| 752 | end |
| 753 | if or gt get r add p 1 4294967295 or eq get r add p 2 0 gt get r add p 2 4294967295 |
| 754 | ret 1 |
| 755 | end |
| 756 | if or lt get r add p 3 2 gt get r add p 3 4 |
| 757 | ret 1 |
| 758 | end |
| 759 | va = get r add p 4 |
| 760 | size = get r add p 5 |
| 761 | rv = get r add p 6 |
| 762 | avail = get r add p 7 |
| 763 | if or eq va 0 ne rem va 8 0 |
| 764 | ret 3 |
| 765 | end |
| 766 | if or eq size 0 gt va sub ulong 18446744073709551615 size |
| 767 | ret 3 |
| 768 | end |
| 769 | if or lt rv va ge rv add va size |
| 770 | ret 3 |
| 771 | end |
| 772 | if or eq avail 0 gt avail sub add va size rv |
| 773 | ret 3 |
| 774 | end |
| 775 | if or ne rem rv 8 0 eq get r add p 8 0 |
| 776 | ret 3 |
| 777 | end |
| 778 | for j ulong 7 |
| 779 | if ne get r add add p 9 j 0 |
| 780 | ret 1 |
| 781 | end |
| 782 | end |
| 783 | ret 0 |
| 784 | end |
| 785 | fn mc_backing r view ulong 1024 i ulong to long |
| 786 | p = mul i 16 |
| 787 | for j ulong i |
| 788 | q = mul j 16 |
| 789 | if eq get r add p 1 get r add q 1 |
| 790 | if ne get r add p 2 get r add q 2 |
| 791 | ret 3 |
| 792 | end |
| 793 | for k ulong 3 |
| 794 | if ne get r add add p 3 k get r add add q 3 k |
| 795 | ret 3 |
| 796 | end |
| 797 | end |
| 798 | end |
| 799 | end |
| 800 | ret 0 |
| 801 | end |
| 802 | fn mc_alloc m view ulong 8 r view ulong 1024 out edit uchar 32 to long |
| 803 | mc_clear edit out |
| 804 | if or ne get m 0 1 or ne get m 1 159 ne get m 2 3 |
| 805 | ret 1 |
| 806 | end |
| 807 | if or eq get m 3 0 gt get m 3 64 |
| 808 | ret 1 |
| 809 | end |
| 810 | for i ulong 3 |
| 811 | if eq get m add 4 i 0 |
| 812 | ret 1 |
| 813 | end |
| 814 | end |
| 815 | if ne get m 7 0 |
| 816 | ret 1 |
| 817 | end |
| 818 | for i ulong get m 3 |
| 819 | st = mc_record r i |
| 820 | if ne st 0 |
| 821 | ret st |
| 822 | end |
| 823 | st = mc_backing r i |
| 824 | if ne st 0 |
| 825 | ret st |
| 826 | end |
| 827 | end |
| 828 | base = mul get m 3 16 |
| 829 | for i ulong sub ulong 1024 base |
| 830 | if ne get r add base i 0 |
| 831 | ret 1 |
| 832 | end |
| 833 | end |
| 834 | b = new uchar 16384 0 |
| 835 | for i ulong 8 |
| 836 | mc_put edit b i get m i |
| 837 | end |
| 838 | for i ulong 1024 |
| 839 | mc_put edit b add 8 i get r i |
| 840 | end |
| 841 | if ne kc_codesha b 8256 edit out 0 |
| 842 | ret 6 |
| 843 | end |
| 844 | ret 0 |
| 845 | end |
| 846 | note Every occurrence is retained; code and launch series share the owner's actual-entry order. |
| 847 | fn mc_smeta m view ulong 8 ord view ulong 128 to long |
| 848 | if or ne get m 0 1 or ne get m 1 159 ne get m 2 5 |
| 849 | ret 1 |
| 850 | end |
| 851 | if or gt get m 3 5 gt get m 4 1 |
| 852 | ret 1 |
| 853 | end |
| 854 | if or eq get m 5 0 gt get m 5 128 |
| 855 | ret 1 |
| 856 | end |
| 857 | if eq get m 4 0 |
| 858 | if or ne get m 6 0 ne get m 7 0 |
| 859 | ret 1 |
| 860 | end |
| 861 | for i ulong 128 |
| 862 | if ne get ord i 0 |
| 863 | ret 1 |
| 864 | end |
| 865 | end |
| 866 | ret 0 |
| 867 | end |
| 868 | if or eq get m 6 0 or eq get m 7 0 gt get m 7 4096 |
| 869 | ret 1 |
| 870 | end |
| 871 | for i ulong 128 |
| 872 | if lt i get m 5 |
| 873 | if ge get ord i get m 7 |
| 874 | ret 1 |
| 875 | end |
| 876 | if gt i 0 |
| 877 | if le get ord i get ord sub i 1 |
| 878 | ret 1 |
| 879 | end |
| 880 | end |
| 881 | else |
| 882 | if ne get ord i 0 |
| 883 | ret 1 |
| 884 | end |
| 885 | end |
| 886 | end |
| 887 | ret 0 |
| 888 | end |
| 889 | fn mc_sdigs hashes view uchar 4096 n ulong to long |
| 890 | for i ulong 128 |
| 891 | v = uchar 0 |
| 892 | for j ulong 32 |
| 893 | if lt i n |
| 894 | v = or v get hashes add mul i 32 j |
| 895 | else |
| 896 | if ne get hashes add mul i 32 j 0 |
| 897 | ret 1 |
| 898 | end |
| 899 | end |
| 900 | end |
| 901 | if and lt i n eq v 0 |
| 902 | ret 3 |
| 903 | end |
| 904 | end |
| 905 | ret 0 |
| 906 | end |
| 907 | fn mc_series m view ulong 8 hashes view uchar 4096 ord view ulong 128 out edit uchar 32 to long |
| 908 | mc_clear edit out |
| 909 | if ne mc_smeta m ord 0 |
| 910 | ret 1 |
| 911 | end |
| 912 | st = mc_sdigs hashes get m 5 |
| 913 | if ne st 0 |
| 914 | ret st |
| 915 | end |
| 916 | b = new uchar 16384 0 |
| 917 | for i ulong 8 |
| 918 | mc_put edit b i get m i |
| 919 | end |
| 920 | off = ulong 64 |
| 921 | if eq get m 4 1 |
| 922 | for i ulong 128 |
| 923 | mc_put edit b add 8 i get ord i |
| 924 | end |
| 925 | off = ulong 1088 |
| 926 | end |
| 927 | for i ulong 4096 |
| 928 | put b add off i get hashes i |
| 929 | end |
| 930 | if ne kc_codesha b add off 4096 edit out 0 |
| 931 | mc_clear edit out |
| 932 | ret 6 |
| 933 | end |
| 934 | ret 0 |
| 935 | end |