aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / tests / ecosystem6 / mutate.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note Native source fault injector. Read one ASCII mode byte then affine.om. |
| 3 | note Exactly one match required; write a full modified source for actual compilation. |
| 4 | global Input uchar 65536 |
| 5 | global Mode ulong 1 |
| 6 | text SN "g = mul32 1073741824 r" |
| 7 | text SR "g = mul32 3221225472 r" |
| 8 | text DN "if or ne get ED 2 rank ne get ED 8 rows\nret -21\nend\nif ne get ED 16 cols\nret -21\nend\nif eq rank 2\nif or ne get ED 9 cols ne get ED 17 1\nret -21\nend\nend" |
| 9 | text DR "note MUTANT omits the dimension admission checks" |
| 10 | text UN "afput 1 i add32 afget 1 i xor delta 2147483648" |
| 11 | text UR "afput 1 i add32 afget 1 i delta" |
| 12 | |
| 13 | fn size to ulong |
| 14 | if eq get Mode 0 0 |
| 15 | ret len SN |
| 16 | end |
| 17 | if eq get Mode 0 1 |
| 18 | ret len DN |
| 19 | end |
| 20 | ret len UN |
| 21 | end |
| 22 | |
| 23 | fn patternbyte i ulong to uchar |
| 24 | if eq get Mode 0 0 |
| 25 | ret get SN i |
| 26 | end |
| 27 | if eq get Mode 0 1 |
| 28 | ret get DN i |
| 29 | end |
| 30 | ret get UN i |
| 31 | end |
| 32 | |
| 33 | fn replacement to void |
| 34 | if eq get Mode 0 0 |
| 35 | n = write 1 SR 0 len SR |
| 36 | if ne n long len SR |
| 37 | exit 74 |
| 38 | end |
| 39 | ret |
| 40 | end |
| 41 | if eq get Mode 0 1 |
| 42 | n = write 1 DR 0 len DR |
| 43 | if ne n long len DR |
| 44 | exit 74 |
| 45 | end |
| 46 | ret |
| 47 | end |
| 48 | n = write 1 UR 0 len UR |
| 49 | if ne n long len UR |
| 50 | exit 74 |
| 51 | end |
| 52 | end |
| 53 | |
| 54 | fn matches pos ulong to bool |
| 55 | for i ulong size |
| 56 | actual = get Input add pos i |
| 57 | wanted = patternbyte i |
| 58 | if ne actual wanted |
| 59 | ret false |
| 60 | end |
| 61 | end |
| 62 | ret true |
| 63 | end |
| 64 | |
| 65 | fn main to int |
| 66 | p = ulong 0 |
| 67 | reading = true |
| 68 | while reading |
| 69 | if eq p 65536 |
| 70 | ret 75 |
| 71 | end |
| 72 | n = read 0 Input p sub 65536 p |
| 73 | if eq n 0 |
| 74 | reading = false |
| 75 | else |
| 76 | if lt n 0 |
| 77 | ret 74 |
| 78 | end |
| 79 | p = add p ulong n |
| 80 | end |
| 81 | end |
| 82 | if lt p 2 |
| 83 | ret 75 |
| 84 | end |
| 85 | m = get Input 0 |
| 86 | if or lt m 48 gt m 50 |
| 87 | ret 75 |
| 88 | end |
| 89 | put Mode 0 ulong sub m 48 |
| 90 | length = size |
| 91 | found = ulong 0 |
| 92 | where = ulong 0 |
| 93 | if le p length |
| 94 | ret 75 |
| 95 | end |
| 96 | for start ulong sub p length |
| 97 | pos = add start 1 |
| 98 | if matches pos |
| 99 | found = add found 1 |
| 100 | where = pos |
| 101 | end |
| 102 | end |
| 103 | if ne found 1 |
| 104 | ret 76 |
| 105 | end |
| 106 | n = write 1 Input 1 sub where 1 |
| 107 | if ne n long sub where 1 |
| 108 | ret 74 |
| 109 | end |
| 110 | replacement |
| 111 | tail = add where length |
| 112 | n = write 1 Input tail sub p tail |
| 113 | if ne n long sub p tail |
| 114 | ret 74 |
| 115 | end |
| 116 | ret 0 |
| 117 | end |