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 / si / benchmarks / native / neuralese / nl1r / checkpoint.om
| 1 | note Standalone with io.om. Mode 0 packs C/P carrier; mode 1 checks actual binary then emits B/P. |
| 2 | note Full C/P/R/T campaign validation remains judge.om, not this conversion tool. |
| 3 | global BH ulong 8 |
| 4 | global BV ulong 83 |
| 5 | text BC "B," |
| 6 | text BP "P," |
| 7 | fn bread to ulong |
| 8 | v = ulong 0 |
| 9 | for k ulong 8 |
| 10 | c = jnext |
| 11 | if lt c 0 |
| 12 | jinvalid |
| 13 | end |
| 14 | v = or v shl ulong c mul k 8 |
| 15 | end |
| 16 | ret v |
| 17 | end |
| 18 | fn bwrite v ulong to void |
| 19 | for k ulong 8 |
| 20 | put JB k uchar and shr v mul k 8 255 |
| 21 | end |
| 22 | p = ulong 0 |
| 23 | while lt p 8 |
| 24 | n = write 1 JB p sub ulong 8 p |
| 25 | if le n 0 |
| 26 | exit 93 |
| 27 | end |
| 28 | p = add p ulong n |
| 29 | end |
| 30 | end |
| 31 | fn bvalid to void |
| 32 | if and ne get BH 0 1 ne get BH 0 2 |
| 33 | jinvalid |
| 34 | end |
| 35 | if ne get BH 7 0 |
| 36 | jinvalid |
| 37 | end |
| 38 | arm = get BH 1 |
| 39 | d = ulong 3 |
| 40 | n = ulong 31 |
| 41 | if eq arm 1 |
| 42 | d = 4 |
| 43 | n = 40 |
| 44 | end |
| 45 | if eq arm 2 |
| 46 | n = 83 |
| 47 | end |
| 48 | if eq arm 3 |
| 49 | d = 1 |
| 50 | n = 0 |
| 51 | end |
| 52 | if gt arm 3 |
| 53 | jinvalid |
| 54 | end |
| 55 | if eq get BH 0 2 |
| 56 | if gt arm 2 |
| 57 | jinvalid |
| 58 | end |
| 59 | d = 4 |
| 60 | n = 40 |
| 61 | end |
| 62 | if or ne get BH 2 d ne get BH 3 n |
| 63 | jinvalid |
| 64 | end |
| 65 | if or eq get BH 4 0 gt get BH 4 4294967295 |
| 66 | jinvalid |
| 67 | end |
| 68 | if or eq get BH 5 0 gt get BH 5 65535 |
| 69 | jinvalid |
| 70 | end |
| 71 | if gt get BH 6 32000 |
| 72 | jinvalid |
| 73 | end |
| 74 | end |
| 75 | fn bparams to void |
| 76 | for i ulong get BH 3 |
| 77 | if not le fabs bitcast f64 get BV i 1000000.0f64 |
| 78 | jinvalid |
| 79 | end |
| 80 | end |
| 81 | end |
| 82 | fn bpack to void |
| 83 | jexpect 67 |
| 84 | jexpect 44 |
| 85 | for k ulong 8 |
| 86 | delim = long 44 |
| 87 | if eq k 7 |
| 88 | delim = 10 |
| 89 | end |
| 90 | put JC k jvalue delim |
| 91 | end |
| 92 | put BH 0 get JC 0 |
| 93 | put BH 1 get JC 1 |
| 94 | put BH 2 get JC 4 |
| 95 | put BH 3 get JC 5 |
| 96 | put BH 4 get JC 2 |
| 97 | put BH 5 get JC 3 |
| 98 | put BH 6 get JC 6 |
| 99 | put BH 7 0 |
| 100 | bvalid |
| 101 | for i ulong get BH 3 |
| 102 | jexpect 80 |
| 103 | jexpect 44 |
| 104 | if ne jvalue 44 i |
| 105 | jinvalid |
| 106 | end |
| 107 | put BV i jvalue 10 |
| 108 | end |
| 109 | bparams |
| 110 | for i ulong 8 |
| 111 | bwrite get BH i |
| 112 | end |
| 113 | for i ulong get BH 3 |
| 114 | bwrite get BV i |
| 115 | end |
| 116 | end |
| 117 | fn bunpack to void |
| 118 | for i ulong 8 |
| 119 | put BH i bread |
| 120 | end |
| 121 | bvalid |
| 122 | for i ulong get BH 3 |
| 123 | put BV i bread |
| 124 | end |
| 125 | if ne jnext -1 |
| 126 | jinvalid |
| 127 | end |
| 128 | bparams |
| 129 | jout BC |
| 130 | for i ulong 8 |
| 131 | jnumber get BH i |
| 132 | if lt i 7 |
| 133 | jout JSEP |
| 134 | end |
| 135 | end |
| 136 | jout JLF |
| 137 | for i ulong get BH 3 |
| 138 | jout BP |
| 139 | jfield i |
| 140 | jnumber get BV i |
| 141 | jout JLF |
| 142 | end |
| 143 | end |
| 144 | fn main to int |
| 145 | if ne argcnt 2 |
| 146 | jinvalid |
| 147 | end |
| 148 | ab = new uchar 1 0 |
| 149 | n = argread 1 ab 0 1 |
| 150 | if ne n 1 |
| 151 | jinvalid |
| 152 | end |
| 153 | if eq get ab 0 48 |
| 154 | bpack |
| 155 | else |
| 156 | if ne get ab 0 49 |
| 157 | jinvalid |
| 158 | end |
| 159 | bunpack |
| 160 | end |
| 161 | ret 0 |
| 162 | end |