CodeQL / File created without restricting permissions
A file may be created here with mode 0666, which would make it world-writable.
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
A file may be created here with mode 0666, which would make it world-writable.
This argument to a file access function is derived from user input (value read by fscanf) and then passed to fopen(__filename).
curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/a3b2d2bacf7394eb.bundle -o a3b2d2bacf7394eb.bundle git fetch a3b2d2bacf7394eb.bundle refs/pull/752/head
github-import 1
aien-dev/omega-mv
752
93ba72a1432a15b570951928d74fcfc8ca20900b
{"kind":"github-import","owner":"aien-dev","repo":"omega-mv","number":752,"url":"https://github.com/aien-dev/omega-mv/pull/752","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:28Z","metadata":"unavailable","state_derived":true}
diff --git a/.crumb b/.crumb index 28f959081..a728d224e 100644 --- a/.crumb +++ b/.crumb @@ -48,7 +48,7 @@ }, { "digest": "f58c1a513a5dcae9490a8066e61c951c7b8c4c671a80ab7e4f5b6993c30f2d34", - "last_commit": "2cefd79c4", + "last_commit": "2d6ea129b", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -96,14 +96,14 @@ } ], "children_root": "sha256:2c6e3c6dccf812725f4eb0f55f9e946b3676b75bf5e09805764e9c3a774f78ad", - "compiled_at": "2026-10-25T23:21:49Z", + "compiled_at": "2026-10-26T04:48:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:a2c9ea556fc76c25b5aa9e05bc27cc3c673c6c5c091123499efa4f0b62283f5c", - "evidence_files": 12236, - "evidence_root": "sha256:a81617545b43a11490fc568dbceb04d61a5f5dd0692e34fd417f16f7ca85327e", - "files": 15915, - "generated_at_commit": "2cefd79c44aefa57593e59f611b39bd60121f4ad", - "source_tree": "sha256:c9be623d7681ebc191abea9b8da07c3af793a8b714b516771d4a9b60d0ff2365" + "digest": "sha256:f1e4f990b2104c629ee55defa841aaa4c093c66edbfcc562866963d7b3b02779", + "evidence_files": 12393, + "evidence_root": "sha256:4b2988be5512f8a2b1f03b8b30c5d50ae0241f233eba6c76dac3aef9ccddb51e", + "files": 16855, + "generated_at_commit": "86e4ea7f6d4a1c6f4b44720ba1a9d7b4cbb3fc7a", + "source_tree": "sha256:600f50e553a5eef43a9679bebdd665cd88d1bb3ee228098e0d1e878040a26b98" }, "owner_lane": "", "provenance": { diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index efbcf416c..db48552e0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -16,6 +16,7 @@ Every model below did real work. A model is listed only for work it did. The orc | Codex | C5 kernel-dump private exclusive creation, failure handling, and source-bound host safety checks | | Codex | C6 private kernel dumps and temporary listings, bounded dump filenames, descriptor-safe readback, and source-bound host safety checks | | Claude Opus 5.5 | Ionic-droplet reservoir (#440): pinned reference, CPU simulator and readout, `.mat` reader, Gate 2 comparison, benchmarks, timing and receipt | +| Claude Fable 5.1 | CodeQL high-severity fixes in the OM-2 oracles: 0600 image creation in offsetof.c, fixture-name allowlist and truncation check in sha_qual.c | This table starts with the numeric work on this branch. Earlier work in this repository is not yet attributed here; add rows only for work that can be traced to a model. diff --git a/seed/qualification/om2/MUTANTS.md b/seed/qualification/om2/MUTANTS.md new file mode 100644 index 000000000..68ea0abae --- /dev/null +++ b/seed/qualification/om2/MUTANTS.md @@ -0,0 +1,177 @@ +# OM-2 qualification: mutation plan and harness (#748, ledger L836) + +Status: Phase A was written before the OM-2 contract was frozen; the Phase B section at the end was written after it. +Rows marked **A: run** were executed in Phase A against the current baseline: omega main `acb3f15`, +`om/sha256/sha256.om`, pinned omc `734f0a39…6b61`. Rows marked **B: NOT_RUN** wait for the frozen +contract and the OM-2 SHA consumer. A Phase A kill is evidence about the baseline consumer and the +baseline compiler. It is not evidence about OM-2. + +## What the gate does + +`gate.om` is handwritten, seeded Omega and is the coordinator. It is modelled on +`security673/gate669.om`, and its header documents the case-list grammar. In short: + +- `gate OMC OMC_SHA256 CASES SCRATCH`. Before running anything, the gate hashes OMC itself + (FIPS 180-4 in `.om`, with K/IV read from the bc-derived fixtures) and compares the result with + the pinned digest. On a mismatch every case is NOT_RUN and the gate is INVALID. The pin itself + comes from `/usr/bin/sha256sum` (GNU coreutils 9.4), an external tool. The gate's own SHA-256 + and coreutils agreeing on `734f0a39…` is the cross-check. +- Each child (compiler, compiled program) runs with stdin, stdout and stderr redirected to files in + SCRATCH, under a deadline (default 30 s, `deadline` directive). The gate polls `waitpid` and + sends SIGKILL at the deadline. It prints every command with its redirects. +- Verdicts: + - **PASS**: exit, stdout and stderr equal the expectation. + - **FAIL**: deterministic wrong behaviour, reported with the first differing byte or the observed + exit or refusal code. + - **INVALID**: no evidence. Causes: signal, timeout, exec failure (child 127), malformed line, + unreadable input, scratch I/O, or a substitution that does not match exactly once. + - **NOT_RUN**: planned but not run. + + Final line and exit status: `OM2GATE PASS` 0, `FAIL` 1, `NOT_RUN` 2, `INVALID` 3. Any INVALID + case, an identity mismatch, or an empty list makes the run INVALID. +- Mutants are applied by the gate. `subst FROM TO` replaces the bytes of FROM by TO in the next + case's concatenated source. The source must contain FROM exactly once, else INVALID. The mutated + unit is written only to `SCRATCH/<line>.src`, and the offset is logged (`MUTATE … at byte N`). + `cc SRC` builds a compiler from a scratch-mutated `seed/omc/omc.om` with the pinned compiler and + prints its sha256. No tracked source is ever edited. `seed/omc/omc.om` is read only. + +## What counts as a kill + +A mutant is **killed** only when one of these holds against an independent oracle: + +1. **Vector kill** (`kill` mode). The mutant compiles (exit 0, ELF), runs to a clean exit with the + predicted status, and its stdout differs from the oracle digest. The gate reports the first + differing byte. +2. **Refusal kill** (`refuse` mode). The compiler exits with the contract's error code, writes no + output, and its diagnostic names `error CODE`. +3. **Trap kill** (`run` mode). A specified witness exits with the specified trap status (for + example 103 = trap 3) and no output, where the mutant shows a different predicted behaviour. + Both sides are cases: the correct side traps, and the mutant side prints its predicted line. + +These are never kills: a signal, a timeout, an exec failure, a compiler crash, or any exit other +than the predicted one. The gate turns the first three into INVALID and the rest into FAIL ("not a +meaningful kill"). A survivor (stdout equal to the oracle) is FAIL "mutant survived". A compiler +mutant must also compile the unmutated consumer correctly on a control vector, so that the kill +comes from the mutation and not from a broken compiler (guard.cases `sha-abc-guard-mutant`). + +## Oracles + +| id | oracle | identity | +|---|---|---| +| O1 | SHA-256 digests: 5 FIPS messages, seq lengths 0..130, 1000, 4095..4097, 8191..8193, 65536; rep:97 lengths 55, 56, 63..65, 4096; 8 seeded random messages | `/usr/bin/sha256sum` (coreutils 9.4) = Python hashlib (OpenSSL 3.0.13). abc, 448-bit and million-a also match the digests printed in NIST FIPS 180-2 Appendix B. | +| O2 | K[0..63], H(0)[0..7] | exact integer roots in bc 1.07.1; Python integer and Decimal(120) cross-check; FIPS 180-4 §4.2.2/§5.3.3 tables extracted by pdftotext | +| O3 | dup32 table: x, (2^32+1)x, low32, high32 for 0, 1, 2^31, 2^32-1 and 8 seeded values | bc + Python | +| O4 | slice table: wrapped vs exact bounds for 16 (n, o, k) triples; row 1 is the issue witness | bc + Python | +| O5 | refusal codes | the frozen OM-2 contract (Phase B); current language: OMEGESE §9 | +| O6 | identities: compiler, artifact, profile | `/usr/bin/sha256sum` pin plus gate.om's in-language SHA-256; the gate prints the sha256 of every compiler it builds | +| O7 | instruction encodings of compiler mutants | GNU objdump 2.42 (`-D -b binary -m aarch64`) | +| O8 | optional historical C (`git show acb3f15:src/sha256.c`, built by gcc outside the closure) | not used in Phase A | + +Provenance: `fixtures/PROVENANCE.txt`. The recipes that were run are in `fixtures/oracle/`. + +## Mutants + +| # | required mutant | application | detecting oracle and meaningful kill | status | +|---|---|---|---|---| +| M1 | wrong constant | `baseline/mutants/k0`: round 0 K 1116352408 to …409. `iv`: init H0 1779033703 to …704 | O1: `mut-k0-fips-abc` differs at byte 1; `mut-iv-fips-empty` differs at byte 0 | **A: run, killed** | +| M1b | wrong constant in the OM-2 source | the same one-digit change in the OM-2 constant table (K[0], K[63], H0), including a constant written with the #745 literal tooling | O1 vector kill; O2 must agree with the table | B: NOT_RUN | +| M2 | wrong rotation amount | `rot`: round 0 Σ1 rotate 25 to 24 | O1: `mut-rot-fips-abc` differs at byte 0 | **A: run, killed**; B: same on the OM-2 rotate | +| M3 | wrong round order | `order`: K[0] and K[1] exchanged between rounds 0 and 1 | O1: `mut-order-fips-abc` differs at byte 0 | **A: run, killed**; B: reversed or swapped round index in the compact loop | +| M4 | missing write / missing initialization | `nowrite`: delete the store of the 64-bit length in `final` | O1: `mut-nowrite-fips-abc` killed. Adequacy control: on the empty message the length is 0 and the mutant survives (`adequacy.cases`, expected FAIL) | **A: run, killed** | +| M4b | missing initialization under #746 | delete one initialization of a checked-initialized variable in the OM-2 SHA | O5: refusal kill with the contract's code. If the compiler accepts, O1 must still kill it, and the acceptance is recorded as a #746 FAIL | B: NOT_RUN | +| M5 | constructor bypass | build a representation-invariant value (dup32 cell, checked struct) without its constructor, or write one half only | O5 refusal kill; O3: constructor output for every table row must give low32 = high32 = x, checked as emitted values, not algebra | B: NOT_RUN | +| M6 | alias violation | the same array as both edit and view argument | current language: `baseline/alias.om` refused with error 19 (`language.cases`, PASS). OM-2: the #747 slice-alias rule with its contract code | **A: control run**; B: NOT_RUN | +| M7 | stale generation / artifact / profile identity | (a) compiler: wrong pin; (b) artifact: consumer built by a different compiler; (c) generation/profile identity of #745/#665: change the source or profile and keep the recorded identity | (a) O6: identity mismatch gives every case NOT_RUN and the gate INVALID (evidence `identity-mismatch.log`). (b) O6: built mutant compilers print sha256 `75297a57…` and `06f000e5…`, not `734f0a39…`. (c) O5 refusal or a specified loader status | (a), (b) **A: run**; (c) B: NOT_RUN | +| M8 | bad ABI length | the #747 slice ABI adapter passes n+1 (over capacity) or n-1 | n+1: trap kill (exit 103, no output) on a witness. n-1: O1 vector kill. The post-final context policy also gets a case | B: NOT_RUN (ABI v1 arrays are fixed 4096) | +| M9 | weakened guard (overflowing slice check) | `compiler-mutants/guard-wrapped`: omc.om `vs_chk` replaced by the wrapped check `ADD u = off + n; CMP u, len; B.HI trap` (scratch copy, built by `cc`) | O4 row 1 (o = 2^64-2, k = 4, len 4, wrapped 1 exact 0): the pinned compiler traps (`witness-pinned` exit 103); the mutant prints `WRAPPED_SLICE_ACCEPTED_4`, exit 0 (`witness-guard-mutant[-exact]`); the mutant still hashes abc correctly | **A: run, killed** | +| M9b | weakened guard in the OM-2 slice check | the same wrapped-sum substitution in the #747 slice-check emission | all 16 O4 rows as cases. wrapped=1 exact=0 rows are the kills; exact=1 rows pass under both compilers; wrapped=0 exact=0 rows trap under both | B: NOT_RUN | +| M10 | faulty optimization pass | `compiler-mutants/shr-imm-plus1`: omc.om `bo_shr` lowers shift-right-by-number with immr = s+1 (scratch copy) | O1: the mutant compiler's consumer build exits 0 and gives wrong digests for abc, empty, 448-bit and million-a (`transform.cases`) | **A: run, killed** | +| M10b | corrupted OM-2 transform (#665) | in a scratch omc.om: unroll factor off by one (drop or repeat one iteration), rotate fusion with the wrong amount (r±1 or 32-r), bounds-check elimination of a non-redundant check | O1 vector kill for unroll and rotate; O4 witness trap kill for check elimination; O7 objdump decode of the emitted instruction confirms the mutation took effect | B: NOT_RUN | +| M11 | separately compiled module boundary | build the SHA unit and its consumer separately (#625/#747); mutate only one side's interface (layout length, parameter order, ABI or generation identity) | O5/O6: the link or load identity check must refuse with the contract code. If accepted, O1 or a trap must kill it, and the acceptance is a module-guarantee FAIL | B: NOT_RUN | + +The issue also asks for split coverage. `baseline/sha256.cases` runs 16 vectors with piece sizes 1, +32, 63, 64, 65 and 4095 (96 cases). The `split` mutant (`if lt n lf` to `if le n lf` in `absorb` +loses a block that the buffer exactly completes) is killed with 32-byte pieces on seq-1000. It +survives with 4096-byte pieces (adequacy control). Split vectors therefore stay mandatory for the +OM-2 consumer. + +## Phase A evidence + +Run from the worktree root. The gate is built with the pinned compiler and the build is byte-for-byte +reproducible (two builds compared equal): + +```sh +seed/out/omc < seed/qualification/om2/gate.om > build/om2-qual/gate && chmod +x build/om2-qual/gate +build/om2-qual/gate seed/out/omc "$(cut -c1-64 seed/out/omc.sha256)" seed/qualification/om2/<list>.cases build/om2-qual/<new dir> +``` + +| list | expected | observed (`evidence/phaseA/*.log`) | +|---|---|---| +| selftest/pass | PASS | `OM2GATE PASS cases=4`, exit 0 | +| selftest/fail | FAIL: `cat-bad-seq` stdout differs at byte 5 | `OM2GATE FAIL pass=1 fail=1`, exit 1 (the second case is the adequacy control, PASS) | +| selftest/controls | each verdict fixed in the list's comments | 5 PASS, 5 FAIL, 8 INVALID (signal: wait byte 9; timeout: SIGKILL at the 1 s deadline; malformed; unreadable source and input; zero-match substitution; EXIT 127; trailing substitution), 1 NOT_RUN; `OM2GATE INVALID`, exit 3 | +| identity mismatch (pin of zeros) | INVALID | 4 NOT_RUN, `OM2GATE INVALID`, exit 3 | +| baseline/sha256 | PASS | 260 PASS: 158 vectors, 96 split cases, 6 mutant kills | +| baseline/adequacy | FAIL (survivors) | 2 FAIL "mutant survived", exit 1 | +| baseline/guard | PASS | 5 PASS (M9) | +| baseline/transform | PASS | 6 PASS (M10) | +| baseline/language | PASS | 1 PASS (alias refused, error 19) | + +`selftest/controls` also builds a compiler from the unmodified `seed/omc/omc.om` with `cc`. Its +sha256 equals the pin `734f0a39…`, which is self-reproduction through the gate. + +Limits: +- The gate is not a sandbox. Its deadline applies to direct children only. It shares the seed + compiler lineage with what it tests, which is why every oracle above is external to that lineage. +- The baseline driver `baseline/sha256-main.om` is test scaffolding around the consumer's `omsha` + and contains no hashing of its own. With piece size 1 it is limited to messages under 1,000,000 + bytes, because an unbounded `while` traps at 1,000,000 passes. +- The constant 2^64-2 in `baseline/slice-witness.om` is copied from `fixtures/obligations.txt`, + slice row 1. + +## Phase B (contract frozen: spec/omegese-om2.md 245bb74e…0881, errata E1-E8 on om2/contract) + +Phase B fixtures are written from the contract and errata alone. No CompilerLane, AbiLane or ShaLane +diff was read. Each compiler mutant below is defined by its behaviour and by the case that kills +it. The `subst FROM TO` patch for each one is written against the candidate `omc.om` (or bridge or +SHA source) only after the verdict on a pushed candidate head, then applied in a scratch copy +through `subst` + `cc` as in Phase A. Until then every row is **B: NOT_RUN (no candidate head)**. +The killing cases already exist, and they all parse and run under the pinned compiler with +invalid=0. + +A kill needs two things. The correct-side case must PASS under the unmutated candidate +(`sec/*/candidate.cases`). The mutant-side case must PASS under the mutant compiler +(`sec/s3s4/mutant-kills.cases` and `sec/s5s7/mutant-side.cases`: a `kill` with a clean exit and +stdout different from the oracle, or a predicted exact line). The mutant must also pass its +control rows. + +| # | Phase B mutant | killing case(s) | meaningful kill (predicted by oracle/*/oracle.py) | +|---|---|---|---| +| B1 | unroll emits K-1 copies | s3s4 `kill-unroll-sum` (K = 1, 4, 64, distinct weights), `kill-unroll-nest` | exit 0, stdout differs at byte 1 | +| B2 | unroll emits K+1 copies | s3s4 `kill-unroll-sum` (the extra copy writes `a[64]` of a 65-element array, so neither refusal nor crash) | exit 0, differs at byte 5 | +| B3 | rotate amount n+1 | s3s4 `kill-rot-values` (all four widths, every operand has w distinct rotations) | differs at byte 0 (ROR-immediate path), 29 (RORV path) | +| B4 | rotate amount w-n | s3s4 `kill-rot-values` | byte 4 (immediate), 33 (RORV) | +| B5 | ROR emitted for ROL | s3s4 `kill-rot-values` | byte 18 (immediate), 47 (RORV) | +| B6 | rotate range check dropped (n mod w) | s3s4 `kill-rot-trap-A..O` (n = w, n > w, constant and run-time) | prints a value, exit 0, where the correct output is empty with exit 107 | +| B7 | check eliminated on an unsized view | s3s4 `kill-ce-view-A/C/D/F` (a part/view of a larger caller array; the unchecked read returns a known neighbour) | A/C print 11111 (byte 14), D prints 1000000 (byte 0), F reads b[7] (byte 26); correct side traps 3 (exit 103) | +| B8 | trapping constant folded at compile time | s3s4 `kill-fold-trap-A..I`, `fold-guard` (guarded `if ne i 0` / `div 100 i`) | stdout differs (bytes A 4, B 22, C 8, D 40, E 11, F 0, G 4, H 4, I 3). A mutant that refuses instead fails the candidate run cases with `compile exit=N expected=0` | +| B9 | weakened part check `o + k <= len` (wrapped) | s5s7 `v6-part-wrap` (len 10, o = 2^64-2, k = 4) | correct: exit 103, empty stdout. Mutant: the part is formed and the callee prints its len "4", exit 0 (`mut-a-part-wrap`) | +| B9b | second part check dropped / first dropped / k evaluated before o | s5s7 `v6-part-tail` (o = len-2, k = 4), `v6-part-o`, `v6-part-order` | "4" / "0" printed instead of trap 3. Order: exit 105 instead of 102 (`mut-a2..a4`). `v6-part-empty` (o = len, k = 0) must be accepted by both | +| B9c | literal golden (2^64-1, 2^64-2, 4) inside a unit | — | **NOT_RUN: unreachable without a 2^64-1-element view** (coordinator decision). The bridge half is `abi-golden-wrap`, which expects status 32 (wrap) | +| B10 | fresh analysis with union instead of intersection at a join | s5s7 `f5-join-diff`, `f5-branch` (refused 27 at the get line, E8) | mutant compiles them: prints "99" and "7", exit 0 (`mut-b-*`) | +| B11 | constructor bypass allowed | s5s7 `a5-seal-main`, `a5-seal-other` (error 28 at the seal line, E8) | mutant compiles them, exit 0 (`mut-c-*`) | +| B12 | dup32 check erased for a non-exact constructor body | s5s7 `a5-kept` (trap 10, exit 110), `a5-kept-diag` (`omc-check 1 kept line=8 rule=-`) | mutant prints `0000000500000006`, exit 0; its diag says `erased … rule=dup32` | +| B13 | stale generation/profile identity accepted | s5s7 ABI driver `abi-ident-abiv/abiw` (the `omega2_ident_<unit>()` text = sha256 of the exact unit bytes, omc pin, `OM-2`; E1), plus `om/units.sh --check` on a stale unit, compiler or profile | a generator embedding a stale digest, pin or profile makes the driver print `FAIL abi-ident-*`, exit 1. A `--check` that skips identity exits 0 on the stale cases where the correct one refuses | +| B14 | bad ABI length accepted | s5s7 ABI driver status-32 rows: null with len > 0, misaligned, len*size overflow, ptr+len wrap (incl. golden extents), edit overlap | the mutant bridge returns status 0 / runs Omega code (`abi-null-len1` returns 0 with result 1); the correct one returns 32 with the result and out buffer untouched | +| B15 | SHA source: wrong constant (K[0], K[63], H0) | baseline/sha256.cases vectors retargeted to the OM-2 SHA driver (s5s7 `sha/sha_driver.c` digests, O1) | vector kill: digest differs (Phase A M1 kills at byte 1 / 0 carry over) | +| B16 | SHA source: wrong rotation (Σ/σ amount ±1, or rotr↔rotl) | same vectors | vector kill at byte 0 | +| B17 | SHA source: round order (K index swapped, or the round loop reversed) | same vectors | vector kill at byte 0 | +| B18 | SHA source: missing write (length store in final, or one state word in update) | same vectors plus split cases (piece sizes 1, 32, 63, 64, 65, 4095) | vector kill. Adequacy control: the empty message alone does not kill a missing length write (Phase A M4) | +| B19 | lexer accepts uppercase hex / 0X / 17 digits | s0s2 `s2-r6-upper*`, `s2-r6-mixed`, `s2-r6-17small`, `s1-d-hexupper(-plain)`, `s1-d-longtok` | `compile exit=0 expected=6` (or 8/0 for 17big) | +| B20 | fmt rewrites a note line or text bytes | s0s2 `s2-fmt-x1`, `-x3`, `-x5` and their `same`/run cases | `stdout differs` | +| B21 | diag span off | every exact s1 diag case (E4/E6) | `stderr differs at byte N` | +| B22 | OM-2 compiler changes an OM-1 unit's bytes or error | manifest-c2.txt (5720 entries) | **run**: the harness control with the Phase A shr-immediate mutant (06f000e5…) FAILs 175 entries (`evidence/phaseB/c2-shrmutant.log`). The pinned compiler PASSes 5720/5720 (`c2-pinned.log`) | + +Step for each candidate head: run manifest-c2.txt, every `sec/*/candidate.cases`, then each B row: +`subst` the mutation into a scratch copy of the candidate source, `cc` it, run the killing rows, and +finish with `cc pinned`. The candidate's own pin replaces 734f0a39 in the gate's command line. diff --git a/seed/qualification/om2/baseline/adequacy.cases b/seed/qualification/om2/baseline/adequacy.cases new file mode 100644 index 000000000..fdb61f02a --- /dev/null +++ b/seed/qualification/om2/baseline/adequacy.cases @@ -0,0 +1,7 @@ +# Adequacy controls (expected FAIL: mutant survived). A vector that never reaches the fault +# cannot kill it: the length is not padded into the block (empty message, bit length 0), or +# every piece is a whole number of blocks. +subst seed/qualification/om2/baseline/mutants/nowrite.from seed/qualification/om2/baseline/mutants/nowrite.to +mut-nowrite-fips-empty kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om - line:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 0 +subst seed/qualification/om2/baseline/mutants/split.from seed/qualification/om2/baseline/mutants/split.to +mut-split-seq-1000-p4096 kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 4096 diff --git a/seed/qualification/om2/baseline/alias.om b/seed/qualification/om2/baseline/alias.om new file mode 100644 index 000000000..7f1af1e8d --- /dev/null +++ b/seed/qualification/om2/baseline/alias.om @@ -0,0 +1,11 @@ +note SPDX-License-Identifier: Apache-2.0 +note Alias-violation control for the CURRENT language (OMEGESE 9.4): the arrays of one call must be +note distinct names, so passing one array as both an edit and a view argument is refused (error 19). +fn mix a edit uchar 4 b view uchar 4 to void +put a 0 get b 0 +end +fn main to int +x = new uchar 4 0 +mix x x +ret 0 +end diff --git a/seed/qualification/om2/baseline/guard.cases b/seed/qualification/om2/baseline/guard.cases new file mode 100644 index 000000000..406e032b8 --- /dev/null +++ b/seed/qualification/om2/baseline/guard.cases @@ -0,0 +1,11 @@ +# Weakened-guard mutant of the CURRENT compiler's read/write slice check (omc.om vs_chk), applied to +# a scratch copy only. The pinned compiler must trap the witness; the mutant compiler must let it +# through (a specific stdout line, exit 0) while still compiling the SHA consumer correctly. +witness-pinned run seed/qualification/om2/baseline/slice-witness.om - - - 103 +subst seed/qualification/om2/compiler-mutants/guard-wrapped.from seed/qualification/om2/compiler-mutants/guard-wrapped.to +cc seed/omc/omc.om +witness-guard-mutant kill seed/qualification/om2/baseline/slice-witness.om - - - 0 +witness-guard-mutant-exact run seed/qualification/om2/baseline/slice-witness.om - line:WRAPPED_SLICE_ACCEPTED_4 - 0 +sha-abc-guard-mutant run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +cc pinned +witness-pinned-again run seed/qualification/om2/baseline/slice-witness.om - - - 103 diff --git a/seed/qualification/om2/baseline/language.cases b/seed/qualification/om2/baseline/language.cases new file mode 100644 index 000000000..3406e9788 --- /dev/null +++ b/seed/qualification/om2/baseline/language.cases @@ -0,0 +1,2 @@ +# Current-language refusal controls (baseline acb3f15, pinned omc 734f0a39). +alias-same-array refuse seed/qualification/om2/baseline/alias.om 19 diff --git a/seed/qualification/om2/baseline/mutants/iv.from b/seed/qualification/om2/baseline/mutants/iv.from new file mode 100644 index 000000000..e9f117a6f --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/iv.from @@ -0,0 +1 @@ +putle c 0 4 1779033703 \ No newline at end of file diff --git a/seed/qualification/om2/baseline/mutants/iv.to b/seed/qualification/om2/baseline/mutants/iv.to new file mode 100644 index 000000000..d2ba7ea84 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/iv.to @@ -0,0 +1 @@ +putle c 0 4 1779033704 \ No newline at end of file diff --git a/seed/qualification/om2/baseline/mutants/k0.from b/seed/qualification/om2/baseline/mutants/k0.from new file mode 100644 index 000000000..b4f8b3a76 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/k0.from @@ -0,0 +1 @@ +get w 0 1116352408 \ No newline at end of file diff --git a/seed/qualification/om2/baseline/mutants/k0.to b/seed/qualification/om2/baseline/mutants/k0.to new file mode 100644 index 000000000..bc0b05746 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/k0.to @@ -0,0 +1 @@ +get w 0 1116352409 \ No newline at end of file diff --git a/seed/qualification/om2/baseline/mutants/nowrite.from b/seed/qualification/om2/baseline/mutants/nowrite.from new file mode 100644 index 000000000..dd6b5a117 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/nowrite.from @@ -0,0 +1 @@ +put c add 96 i uchar and shr bits sh 255 diff --git a/seed/qualification/om2/baseline/mutants/nowrite.to b/seed/qualification/om2/baseline/mutants/nowrite.to new file mode 100644 index 000000000..e69de29bb diff --git a/seed/qualification/om2/baseline/mutants/order.from b/seed/qualification/om2/baseline/mutants/order.from new file mode 100644 index 000000000..c6f7ff177 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/order.from @@ -0,0 +1,13 @@ +t = add x add get w 0 1116352408 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 1 1899447441 diff --git a/seed/qualification/om2/baseline/mutants/order.to b/seed/qualification/om2/baseline/mutants/order.to new file mode 100644 index 000000000..92b038da8 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/order.to @@ -0,0 +1,13 @@ +t = add x add get w 0 1899447441 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 1 1116352408 diff --git a/seed/qualification/om2/baseline/mutants/rot.from b/seed/qualification/om2/baseline/mutants/rot.from new file mode 100644 index 000000000..e7901462a --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/rot.from @@ -0,0 +1,4 @@ +t = add x add get w 0 1116352408 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 diff --git a/seed/qualification/om2/baseline/mutants/rot.to b/seed/qualification/om2/baseline/mutants/rot.to new file mode 100644 index 000000000..63d0bbc95 --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/rot.to @@ -0,0 +1,4 @@ +t = add x add get w 0 1116352408 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 24 diff --git a/seed/qualification/om2/baseline/mutants/split.from b/seed/qualification/om2/baseline/mutants/split.from new file mode 100644 index 000000000..4948a537d --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/split.from @@ -0,0 +1 @@ +if lt n lf \ No newline at end of file diff --git a/seed/qualification/om2/baseline/mutants/split.to b/seed/qualification/om2/baseline/mutants/split.to new file mode 100644 index 000000000..3eb88065e --- /dev/null +++ b/seed/qualification/om2/baseline/mutants/split.to @@ -0,0 +1 @@ +if le n lf \ No newline at end of file diff --git a/seed/qualification/om2/baseline/sha256-main.om b/seed/qualification/om2/baseline/sha256-main.om new file mode 100644 index 000000000..9d0bddd3a --- /dev/null +++ b/seed/qualification/om2/baseline/sha256-main.om @@ -0,0 +1,70 @@ +note SPDX-License-Identifier: Apache-2.0 +note OM-2 qualification driver for the CURRENT consumer om/sha256/sha256.om (baseline acb3f15). +note The gate concatenates this file with om/sha256/sha256.om into one program-mode unit. It is +note test scaffolding, not a SHA implementation: every hash operation is the consumer's omsha. +note stdin the message, read to end of file +note arg 1 optional piece size 1..4096 (default 4096): each read asks for at most that many bytes +note and every byte read is absorbed with op 1, so the split points are exercised +note stdout the digest as 64 lowercase hex digits and a newline; exit 0 +note Exit 90: bad argument; 91: read error; 92: short stdout write. +note digest byte j: the consumer packs the 32 digest bytes little endian into w[0..4) +fn dbyte w view ulong 64 j ulong to ulong +v = get w div j 8 +ret and shr v mul rem j 8 8 255 +end +text hexdig "0123456789abcdef" +fn piece to ulong +if eq argcnt 1 +ret 4096 +end +a = new uchar 8 0 +r = argread 1 a 0 8 +if or lt r 1 gt r 4 +exit 90 +end +v = ulong 0 +for i ulong ulong r +d = get a i +if or lt d 48 gt d 57 +exit 90 +end +v = add mul v 10 ulong sub d 48 +end +if or eq v 0 gt v 4096 +exit 90 +end +ret v +end +fn main to int +c = new uchar 104 0 +b = new uchar 4096 0 +w = new ulong 64 0 +b8 = new ulong 512 0 +o = new uchar 65 10 +k = piece +omsha c b 0 0 w b8 +go = true +while go +r = read 0 b 0 k +if lt r 0 +ret 91 +end +if eq r 0 +go = false +else +omsha c b ulong r 1 w b8 +end +end +omsha c b 0 2 w b8 +for j ulong 32 +x = dbyte w j +p = mul j 2 +put o p get hexdig shr x 4 +put o add p 1 get hexdig and x 15 +end +r = write 1 o 0 65 +if ne r 65 +ret 92 +end +ret 0 +end diff --git a/seed/qualification/om2/baseline/sha256.cases b/seed/qualification/om2/baseline/sha256.cases new file mode 100644 index 000000000..f5d2de222 --- /dev/null +++ b/seed/qualification/om2/baseline/sha256.cases @@ -0,0 +1,272 @@ +# Baseline: the CURRENT consumer om/sha256/sha256.om (acb3f15) through baseline/sha256-main.om. +# Generated from fixtures/sha256-vectors.txt by the awk commands in fixtures/PROVENANCE.txt. +# --- vectors, default piece size 4096 +fips-empty run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om - line:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 0 +fips-abc run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +fips-448 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m448.bin line:248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 - 0 +fips-896 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 +fips-million-a run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:1000000 line:cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 - 0 +seq-0 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:0 line:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 0 +seq-1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1 line:6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d - 0 +seq-2 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:2 line:b413f47d13ee2fe6c845b2ee141af81de858df4ec549a58b7970bb96645bc8d2 - 0 +seq-3 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:3 line:ae4b3280e56e2faf83f414a6e3dabe9d5fbe18976544c05fed121accb85b53fc - 0 +seq-4 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4 line:054edec1d0211f624fed0cbca9d4f9400b0e491c43742af2c5b0abebf0c990d8 - 0 +seq-5 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:5 line:08bb5e5d6eaac1049ede0893d30ed022b1a4d9b5b48db414871f51c9cb35283d - 0 +seq-6 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:6 line:17e88db187afd62c16e5debf3e6527cd006bc012bc90b51a810cd80c2d511f43 - 0 +seq-7 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:7 line:57355ac3303c148f11aef7cb179456b9232cde33a818dfda2c2fcb9325749a6b - 0 +seq-8 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8 line:8a851ff82ee7048ad09ec3847f1ddf44944104d2cbd17ef4e3db22c6785a0d45 - 0 +seq-9 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:9 line:f8348e0b1df00833cbbbd08f07abdecc10c0efb78829d7828c62a7f36d0cc549 - 0 +seq-10 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:10 line:1f825aa2f0020ef7cf91dfa30da4668d791c5d4824fc8e41354b89ec05795ab3 - 0 +seq-11 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:11 line:78a6273103d17c39a0b6126e226cec70e33337f4bc6a38067401b54a33e78ead - 0 +seq-12 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:12 line:fff3a9bcdd37363d703c1c4f9512533686157868f0d4f16a0f02d0f1da24f9a2 - 0 +seq-13 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:13 line:86eba947d50c2c01570fe1bb5ca552958dabbdbb59b0657f0f26e21ff011e5c7 - 0 +seq-14 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:14 line:ab107f1bd632d3c3f5c724a99d024f7faa033f33c07696384b604bfe78ac352d - 0 +seq-15 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:15 line:7071fc3188fde7e7e500d4768f1784bede1a22e991648dcab9dc3219acff1d4c - 0 +seq-16 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:16 line:be45cb2605bf36bebde684841a28f0fd43c69850a3dce5fedba69928ee3a8991 - 0 +seq-17 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:17 line:3e5718fea51a8f3f5baca61c77afab473c1810f8b9db330273b4011ce92c787e - 0 +seq-18 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:18 line:7a096cc12702bcfa647ee070d4f3ba4c2d1d715b484b55b825d0edba6545803b - 0 +seq-19 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:19 line:5f9a753613d87b8a17302373c4aee56faa310d3b24b6ae1862d673aa22e1790f - 0 +seq-20 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:20 line:e7aebf577f60412f0312d442c70a1fa6148c090bf5bab404caec29482ae779e8 - 0 +seq-21 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:21 line:75aee9dcc9fbe7ddc9394f5bc5d38d9f5ad361f0520f7ceab59616e38f5950b5 - 0 +seq-22 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:22 line:22cb4df00cddd6067ad5cfa2bba9857f21a06843e1a6e39ad1a68cb9a45ab8b7 - 0 +seq-23 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:23 line:f6a954a68555187d88cd9a026940d15ab2a7e24c7517d21ceeb028e93c96f318 - 0 +seq-24 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:24 line:1d64add2a6388367c9bc2d1f1b384b069a6ef382cdaaa89771dd103e28613a25 - 0 +seq-25 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:25 line:b729ce724d9a48d3884dbfcbee1d3793d922b29fa9d639e7290af4978263772b - 0 +seq-26 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:26 line:b858da80d8a57dc546905fd147612ebddd3c9188620405d058f9ee5ab1e6bc52 - 0 +seq-27 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:27 line:d78750726155a89c9131d0ecf2704b973b8710865bf9e831845de4f2dcbc19da - 0 +seq-28 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:28 line:dc27f8e8ee2d08a2bccbb2dbd6c8e07ffba194101fc3458c34ded55f72c0971a - 0 +seq-29 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:29 line:d09bea65dff48928a14b79741de3274b646f55ac898b71a66fa3eae2d9facd77 - 0 +seq-30 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:30 line:f2192584b67da35dfc26f743e5f53bb0376046f899dc6dabd5e7b541ae86c32f - 0 +seq-31 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:31 line:4f23c2ca8c5c962e50cd31e221bfb6d0adca19111dca8e0c62598ff146dd19c4 - 0 +seq-32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:32 line:630dcd2966c4336691125448bbb25b4ff412a49c732db2c8abc1b8581bd710dd - 0 +seq-33 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:33 line:5d8fcfefa9aeeb711fb8ed1e4b7d5c8a9bafa46e8e76e68aa18adce5a10df6ab - 0 +seq-34 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:34 line:14cdbf171499f86bd18b262243d669067efbdbb5431a48289cf02f2b5448b3d4 - 0 +seq-35 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:35 line:f12dd12340cb84e4d0d9958d62be7c59bb8f7243a7420fd043177ac542a26aaa - 0 +seq-36 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:36 line:5d7e2d9b1dcbc85e7c890036a2cf2f9fe7b66554f2df08cec6aa9c0a25c99c21 - 0 +seq-37 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:37 line:f4d285f47a1e4959a445ea6528e5df3efab041fa15aad94db1e2600b3f395518 - 0 +seq-38 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:38 line:a2fd0e15d72c9d18f383e40016f9ddc706673c54252084285aaa47a812552577 - 0 +seq-39 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:39 line:4aba23aea5e2a91b7807cf3026cdd10a1c38533ce55332683d4ccb88456e0703 - 0 +seq-40 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:40 line:5faa4eec3611556812c2d74b437c8c49add3f910f10063d801441f7d75cd5e3b - 0 +seq-41 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:41 line:753629a6117f5a25d338dff10f4dd3d07e63eecc2eaf8eabe773f6399706fe67 - 0 +seq-42 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:42 line:40a1ed73b46030c8d7e88682078c5ab1ae5a2e524e066e8c8743c484de0e21e5 - 0 +seq-43 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:43 line:c033843682818c475e187d260d5e2edf0469862dfa3bb0c116f6816a29edbf60 - 0 +seq-44 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:44 line:17619ec4250ef65f083e2314ef30af796b6f1198d0fddfbb0f272930bf9bb991 - 0 +seq-45 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:45 line:a8e960c769a9508d098451e3d74dd5a2ac6c861eb0341ae94e9fc273597278c9 - 0 +seq-46 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:46 line:8ebfeb2e3a159e9f39ad7cc040e6678dade70d4f59a67d529fa76af301ab2946 - 0 +seq-47 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:47 line:ef8a7781a95c32fa02ebf511eda3dc6e273be59cb0f9e20a4f84d54f41427791 - 0 +seq-48 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:48 line:4dbdc2b2b62cb00749785bc84202236dbc3777d74660611b8e58812f0cfde6c3 - 0 +seq-49 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:49 line:7509fe148e2c426ed16c990f22fe8116905c82c561756e723f63223ace0e147e - 0 +seq-50 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:50 line:a622e13829e488422ee72a5fc92cb11d25c3d0f185a1384b8138df5074c983bf - 0 +seq-51 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:51 line:3309847cee454b4f99dcfe8fdc5511a7ba168ce0b6e5684ef73f9030d009b8b5 - 0 +seq-52 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:52 line:c4c6540a15fc140a784056fe6d9e13566fb614ecb2d9ac0331e264c386442acd - 0 +seq-53 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:53 line:90962cc12ae9cdae32d7c33c4b93194b11fac835942ee41b98770c6141c66795 - 0 +seq-54 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:54 line:675f28acc0b90a72d1c3a570fe83ac565555db358cf01826dc8eefb2bf7ca0f3 - 0 +seq-55 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 +seq-56 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 +seq-57 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:57 line:2fe741af801cc238602ac0ec6a7b0c3a8a87c7fc7d7f02a3fe03d1c12eac4d8f - 0 +seq-58 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:58 line:e03b18640c635b338a92b82cce4ff072f9f1aba9ac5261ee1340f592f35c0499 - 0 +seq-59 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:59 line:bd2de8f5dd15c73f68dfd26a614080c2e323b2b51b1b5ed9d7933e535d223bda - 0 +seq-60 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:60 line:0ddde28e40838ef6f9853e887f597d6adb5f40eb35d5763c52e1e64d8ba3bfff - 0 +seq-61 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:61 line:4b5c2783c91ceccb7c839213bcbb6a902d7fe8c2ec866877a51f433ea17f3e85 - 0 +seq-62 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:62 line:c89da82cbcd76ddf220e4e9091019b9866ffda72bee30de1effe6c99701a2221 - 0 +seq-63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 +seq-64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 +seq-65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 +seq-66 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:66 line:b6dfd259f6e0d07deb658a88148f8253f9bbbb74ddd6db3edbe159a56bc35073 - 0 +seq-67 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:67 line:8fa5913b62847d42bb4b464e00a72c612d2ab0df2af0b9a96af8d323fa509077 - 0 +seq-68 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:68 line:7ded979c0153ebb9ef28a15a314d0b27b41c4f8eed700b54974b48eb3ecaf91c - 0 +seq-69 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:69 line:1cf3aa651dcf35dbfe296e770ad7ebc4e00bcccd0224db296183dc952d0008c9 - 0 +seq-70 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:70 line:5767d69a906d4860db9079eb7e90ab4a543e5cb032fce846554aef6ceb600e1d - 0 +seq-71 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:71 line:8189e3d54767d51e8d1942659a9e2905f9ec3ae72860c16a66e75b8cc9bd2087 - 0 +seq-72 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:72 line:107de2bc788e11029f7851f8e1b0b5afb4e34379c709fc840689ebd3d1f51b5b - 0 +seq-73 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:73 line:169f6f093a9be82febe1a6a4471425697ec25d5040b472c5b1822aeea2625988 - 0 +seq-74 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:74 line:2087ebd358ae3ea2a092fc19c2dfee57c5f0860296bc7b057c14e1227c5cb9d1 - 0 +seq-75 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:75 line:182ab56f7739e43cee0b9ba1e92c4b2a81b088705516a5243910159744f21be9 - 0 +seq-76 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:76 line:081f6c68899a48a1be455a55416104921d2fe4bdae696f4b72f9d9626a47915e - 0 +seq-77 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:77 line:5ce02376cc256861b78f87e34783814ba1aec6d09ab500d579ed8ee95c8afcc8 - 0 +seq-78 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:78 line:b93e407404e3e95f20fd647365e0e7f46afabe9af1ff083af996135e00d54009 - 0 +seq-79 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:79 line:e81fa832b37be8ed8f79da29987aa4d61310dcb14b2859dedf8fb1daa2541fd3 - 0 +seq-80 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:80 line:c56705fea5b110b8dc63688533ced21167e628017387c885423b835a55edd5ef - 0 +seq-81 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:81 line:c2226285d08a245a17058ed2d24ad095b714f608ae364fddf119e0a7df890540 - 0 +seq-82 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:82 line:f9c270da8793221a6809ac685fdd4f5387e0fe1ee6aaf01c74f1e0a719621614 - 0 +seq-83 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:83 line:e69befd6ef7f685c36e343ac1702d87ad6a0e4ac8c0d5c521d04aad4ef0b7458 - 0 +seq-84 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:84 line:4e3033562ad74a7d43eb5ff5fc2382622c6307cb10e245ad62da77c4c63cb178 - 0 +seq-85 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:85 line:2ea17629472564a59e5eb845a2cdd04f442df2ff26bcc866e400f77158d612a1 - 0 +seq-86 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:86 line:b90223df74dd49a8a1461f340f2d7a90f96903ccbb5bc3c74ea3658fc8948b20 - 0 +seq-87 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:87 line:e0209f42b927ec9c0f6d6a76007ed540e9bdd6e427b3368a1ea6c5e7565972dd - 0 +seq-88 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:88 line:10d9bd424114319c0999adf6288f74060cd8918ef1228827a6269b2bf0f0880c - 0 +seq-89 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:89 line:7d1978a65ac94dbbcdc62e3d81850299fe157dd9b7bd9e01b170156210d2815a - 0 +seq-90 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:90 line:e052dff9e1c94aaa49556f86fad55029a4875839fda57f5005f4c4403876b256 - 0 +seq-91 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:91 line:58d29459b2130a2e151252d408b95e6dac424c564062eb911cc76440cb926ca0 - 0 +seq-92 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:92 line:4e4530c392316f598e1bd07f32166380a8f712a33a48e9eb4247131ec5dc05d3 - 0 +seq-93 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:93 line:a09c9d3e42342c7dea44edb4aeb48cf6727cacd8032a12cf77a25829fc249d32 - 0 +seq-94 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:94 line:eb978d0f1ac03ce5c3510b5f4a16073a7a2bdc15c4ab7777dcf01030cc316667 - 0 +seq-95 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:95 line:7d1905a3ace827ea1ac51c4fa08c281ed3be87e7f4e928d696bfde35c8f2dc0f - 0 +seq-96 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:96 line:08359b108fa567f5dcf319fa3434da6abbc1d595f426372666447f09cc5a87dc - 0 +seq-97 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:97 line:a7b3830ffab0f2bbabbef6df0b169a7917008bf238880bbf8c20b8e000077312 - 0 +seq-98 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:98 line:b4f5d9b1555994c5ebaebd82918d560a3bf82962a171a1614e7551939e943366 - 0 +seq-99 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:99 line:014ecaea1b378900f1212898c6ddb01565d81af1d0ef78df5e28d46e9caf7cfc - 0 +seq-100 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:100 line:bce0aff19cf5aa6a7469a30d61d04e4376e4bbf6381052ee9e7f33925c954d52 - 0 +seq-101 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:101 line:4565d7b898ccea3139ad260f9273115f806b30079d7683218c4e3ecd43af3b33 - 0 +seq-102 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:102 line:ddadeb660fe8902c9fb2db9b6cf237c9ce5b31753398085c4367eb5910b9cc13 - 0 +seq-103 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:103 line:c15a8928131f6687dd10f3c115ddf8d7c8f2df7e18d12c08c4fd16f666ce60ba - 0 +seq-104 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:104 line:ae8e3d799b1353a39815f90eceebefa265cc448fe39faf2008cb20784cb2df9f - 0 +seq-105 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:105 line:98545371a3d9981abe5ab4a32a1d7b2fadd9801d89da52a94a4f78a42740d21c - 0 +seq-106 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:106 line:6323dce2f8b3a04dcea8d205602348c40403cb200c677eb1a1c0fe37edb6eb2f - 0 +seq-107 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:107 line:8150f7c5da910d709ff02ddf85dd293c6a2672633de8cda30f2e0aa58b14b0c4 - 0 +seq-108 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:108 line:44d21db70716bd7644cb0d819fa6791805ebc526ea32996a60e41dc753fcfafc - 0 +seq-109 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:109 line:b9b7c375cca45db19466ebd0fe7c9e147948cc42c1c90f0579728cfb2651956d - 0 +seq-110 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:110 line:a47a551b01e55aaaa015531a4fa26a666f1ebd4ba4573898de712b8b5e0ca7e9 - 0 +seq-111 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:111 line:60780e9451bdc43cf4530ffc95cbb0c4eb24dae2c39f55f334d679e076c08065 - 0 +seq-112 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:112 line:09373f127d34e61dbbaa8bc4499c87074f2ddb10e1b465f506d7d70a15011979 - 0 +seq-113 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:113 line:13aaa9b5fb739cdb0e2af99d9ac0a409390adc4d1cb9b41f1ef94f8552060e92 - 0 +seq-114 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:114 line:5b0a32f1219524f5d72b00ba1a1b1c09a05ff10c83bb7a86042e42988f2afc06 - 0 +seq-115 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:115 line:32796a0a246ea67eb785eda2e045192b9d6e40b9fe2047b21ef0cee929039651 - 0 +seq-116 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:116 line:da9ab8930992a9f65eccec4c310882cab428a708e6c899181046a8c73af00855 - 0 +seq-117 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:117 line:9c94557382c966753c8cab0957eaedbe1d737b5fcb35c56c220ddd36f8a2d351 - 0 +seq-118 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:118 line:d32ab00929cb935b79d44e74c5a745db460ff794dea3b79be40c1cc5cf5388ef - 0 +seq-119 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 +seq-120 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 +seq-121 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:121 line:335a461692b30bba1d647cc71604e88e676c90e4c22455d0b8c83f4bd7c8ac9b - 0 +seq-122 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:122 line:3d08c4d7bdda7ec922b0741df357de46e7bd102f9ab7a5c67624ab58da6d9d75 - 0 +seq-123 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:123 line:cc63be92e3a900cd067da89473b61b40579b54ef54f8305c2ffcc893743792e9 - 0 +seq-124 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:124 line:865447fc4fae01471f2fc973bfb448de00217521ef02e3214d5177ea89c3ef31 - 0 +seq-125 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:125 line:3daa582f9563601e290f3cd6d304bff7e25a9ee42a34ffbac5cf2bf40134e0d4 - 0 +seq-126 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:126 line:5dda7cb7c2282a55676f8ad5c448092f4a9ebd65338b07ed224fcd7b6c73f5ef - 0 +seq-127 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:127 line:92ca0fa6651ee2f97b884b7246a562fa71250fedefe5ebf270d31c546bfea976 - 0 +seq-128 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 +seq-129 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 +seq-130 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 +seq-1000 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 +seq-4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4095 line:45de2924756389e3ccab98bdaacbef8a81cdeb651b59f916a6d6385b4f7b999d - 0 +seq-4096 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4096 line:d67c656e01756650d77717b0839985a056ec28ffe174601d690fc407a2ceffca - 0 +seq-4097 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 +seq-8191 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8191 line:a7ff4cc384f150c0763c051418a0084ded32bfa5863717ab5f35d3f43a5ffe1c - 0 +seq-8192 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8192 line:25df2449b2e5a35fea14e02a7158e283801a1069c9f84631b9a9dacb2f809a7f - 0 +seq-8193 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 +seq-65536 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 +rep-a-55 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:55 line:9f4390f8d30c2dd92ec9f095b65e2b9ae9b0a925a5258e241c9f1e910f734318 - 0 +rep-a-56 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:56 line:b35439a4ac6f0948b6d6f9e3c6af0f5f590ce20f1bde7090ef7970686ec6738a - 0 +rep-a-63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:63 line:7d3e74a05d7db15bce4ad9ec0658ea98e3f06eeecf16b4c6fff2da457ddc2f34 - 0 +rep-a-64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:64 line:ffe054fe7ae0cb6dc65c3af9b61d5209f439851db43d0ba5997337df154668eb - 0 +rep-a-65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:65 line:635361c48bb9eab14198e76ea8ab7f1a41685d6ad62aa9146d301d4f17eb0ae0 - 0 +rep-a-4096 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:4096 line:c93eee2d0db02f10acc7460d9576e122dcf8cd53c4bf8dfcae1b3e74ebcfff5a - 0 +rnd-1-3 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:1:3 line:d46b892acb38e6d9d2f93fab2621df39929be969e7a6245e8f8828e1e224b122 - 0 +rnd-2-55 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:2:55 line:489354d7744738edcbc1228ca418ff7c0494df8e741686cf9092d364104bbe44 - 0 +rnd-3-56 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:3:56 line:a8126f4824235667aeede184b7dac301b41a5713caca7f972851f449a09d1520 - 0 +rnd-4-64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:4:64 line:df69de71c5b8b96befa275d42efa6feb59ffddf56501ae24db33ca419fa3afee - 0 +rnd-5-111 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:5:111 line:5fb527f8bc6556636300f5c4650021bd7c4f76b207b31ec13a9b64b9aeda2ad3 - 0 +rnd-6-4097 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:6:4097 line:4663feee0adebd8f54ad99f0a0e462d4f496613157a8a22d1ed0778a6b59cb4e - 0 +rnd-7-12345 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:7:12345 line:58257600665dc6151a6c00999f9a7a6474c66dd1910ddc4ce7660793504dd1f0 - 0 +rnd-8-100003 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 +# --- split points: piece sizes 1, 32, 63, 64, 65, 4095 +fips-896-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 1 +seq-55-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 1 +seq-56-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 1 +seq-63-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 1 +seq-64-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 1 +seq-65-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 1 +seq-119-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 1 +seq-120-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 1 +seq-128-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 1 +seq-129-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 1 +seq-130-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 1 +seq-1000-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 1 +seq-4097-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 1 +seq-8193-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 1 +seq-65536-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 1 +rnd-8-100003-p1 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 1 +fips-896-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 32 +seq-55-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 32 +seq-56-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 32 +seq-63-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 32 +seq-64-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 32 +seq-65-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 32 +seq-119-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 32 +seq-120-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 32 +seq-128-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 32 +seq-129-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 32 +seq-130-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 32 +seq-1000-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 32 +seq-4097-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 32 +seq-8193-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 32 +seq-65536-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 32 +rnd-8-100003-p32 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 32 +fips-896-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 63 +seq-55-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 63 +seq-56-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 63 +seq-63-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 63 +seq-64-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 63 +seq-65-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 63 +seq-119-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 63 +seq-120-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 63 +seq-128-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 63 +seq-129-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 63 +seq-130-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 63 +seq-1000-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 63 +seq-4097-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 63 +seq-8193-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 63 +seq-65536-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 63 +rnd-8-100003-p63 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 63 +fips-896-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 64 +seq-55-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 64 +seq-56-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 64 +seq-63-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 64 +seq-64-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 64 +seq-65-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 64 +seq-119-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 64 +seq-120-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 64 +seq-128-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 64 +seq-129-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 64 +seq-130-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 64 +seq-1000-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 64 +seq-4097-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 64 +seq-8193-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 64 +seq-65536-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 64 +rnd-8-100003-p64 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 64 +fips-896-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 65 +seq-55-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 65 +seq-56-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 65 +seq-63-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 65 +seq-64-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 65 +seq-65-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 65 +seq-119-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 65 +seq-120-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 65 +seq-128-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 65 +seq-129-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 65 +seq-130-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 65 +seq-1000-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 65 +seq-4097-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 65 +seq-8193-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 65 +seq-65536-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 65 +rnd-8-100003-p65 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 65 +fips-896-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m896.bin line:cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1 - 0 4095 +seq-55-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:55 line:463eb28e72f82e0a96c0a4cc53690c571281131f672aa229e0d45ae59b598b59 - 0 4095 +seq-56-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:56 line:da2ae4d6b36748f2a318f23e7ab1dfdf45acdc9d049bd80e59de82a60895f562 - 0 4095 +seq-63-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:63 line:29af2686fd53374a36b0846694cc342177e428d1647515f078784d69cdb9e488 - 0 4095 +seq-64-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:64 line:fdeab9acf3710362bd2658cdc9a29e8f9c757fcf9811603a8c447cd1d9151108 - 0 4095 +seq-65-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65 line:4bfd2c8b6f1eec7a2afeb48b934ee4b2694182027e6d0fc075074f2fabb31781 - 0 4095 +seq-119-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:119 line:da18797ed7c3a777f0847f429724a2d8cd5138e6ed2895c3fa1a6d39d18f7ec6 - 0 4095 +seq-120-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:120 line:f52b23db1fbb6ded89ef42a23ce0c8922c45f25c50b568a93bf1c075420bbb7c - 0 4095 +seq-128-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:128 line:471fb943aa23c511f6f72f8d1652d9c880cfa392ad80503120547703e56a2be5 - 0 4095 +seq-129-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:129 line:5099c6a56203f9687f7d33f4bfdf576d31dc91f6b695ecea38b2770c87631135 - 0 4095 +seq-130-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:130 line:8d39b60b9c767c58975b270c1d6b13c9b4507e5aee7ad496a3528e4c7f880721 - 0 4095 +seq-1000-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 4095 +seq-4097-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:4097 line:a16560d668b843fb3be99ace41dbd18471f342bd3255a1d21204b35e43f74436 - 0 4095 +seq-8193-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:8193 line:7e3691790cd64b19d4edb1a80e988214515abeb53aa0f34ffbfe4b4bf405d120 - 0 4095 +seq-65536-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:65536 line:4b640d85ab3ba30fd02c9fc9db4a8928f416322ad27022ea58a65aaee68a4df2 - 0 4095 +rnd-8-100003-p4095 run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rnd:8:100003 line:990929ebc8acf2ae2d7aa35428c6954f0320f5b48b969dec576f2070bb7afc31 - 0 4095 +# --- mutants of the consumer source (exact-once substitution); each must be killed by a +# digest mismatch on the named vector, with a clean exit 0 +subst seed/qualification/om2/baseline/mutants/k0.from seed/qualification/om2/baseline/mutants/k0.to +mut-k0-fips-abc kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +subst seed/qualification/om2/baseline/mutants/rot.from seed/qualification/om2/baseline/mutants/rot.to +mut-rot-fips-abc kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +subst seed/qualification/om2/baseline/mutants/order.from seed/qualification/om2/baseline/mutants/order.to +mut-order-fips-abc kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +subst seed/qualification/om2/baseline/mutants/iv.from seed/qualification/om2/baseline/mutants/iv.to +mut-iv-fips-empty kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om - line:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 0 +subst seed/qualification/om2/baseline/mutants/nowrite.from seed/qualification/om2/baseline/mutants/nowrite.to +mut-nowrite-fips-abc kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +subst seed/qualification/om2/baseline/mutants/split.from seed/qualification/om2/baseline/mutants/split.to +mut-split-seq-1000-p32 kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om seq:1000 line:4e4c294b331f7a2099a379bec34b9f9fc03dc46ab465d998f4d683da53487e6d - 0 32 diff --git a/seed/qualification/om2/baseline/slice-witness.om b/seed/qualification/om2/baseline/slice-witness.om new file mode 100644 index 000000000..85c1debba --- /dev/null +++ b/seed/qualification/om2/baseline/slice-witness.om @@ -0,0 +1,23 @@ +note SPDX-License-Identifier: Apache-2.0 +note Weakened-guard witness (#748): write 4 bytes from offset o = 2^64-2 of a 4-byte array to /dev/null. +note o and k = 4 are the issue's overflow pair (fixtures/obligations.txt, first slice row): the +note wrapped sum o+k = 2 <= len 4 is TRUE but k <= len - o is FALSE. A correct compiler traps 3 +note before the system call (exit 103, no output). A compiler whose check is the wrapped sum lets +note the call run; /dev/null accepts the bytes without reading them, so the mutant path is +note deterministic: it prints WRAPPED_SLICE_ACCEPTED_4 and a newline and exits 0. +text devnull "/dev/null" +text accepted "WRAPPED_SLICE_ACCEPTED_4\n" +fn main to int +a = new uchar 4 0 +f = fopen devnull 0 len devnull 1 0 +if lt f 0 +ret 90 +end +o = ulong 18446744073709551614 +r = write int f a o 4 +if eq r 4 +w = write 1 accepted 0 len accepted +ret 0 +end +ret 91 +end diff --git a/seed/qualification/om2/baseline/transform.cases b/seed/qualification/om2/baseline/transform.cases new file mode 100644 index 000000000..c33b923be --- /dev/null +++ b/seed/qualification/om2/baseline/transform.cases @@ -0,0 +1,13 @@ +# Faulty-transform mutant of the CURRENT compiler (scratch copy of omc.om only): shift right by a +# number is lowered with immr = s+1 instead of s (UBFM/SBFM, omc.om bo_shr). The pinned compiler's +# SHA must pass; the mutant compiler's build of the same consumer source must exit 0 and print a +# wrong digest for each FIPS vector (a clean, specific mismatch, never a crash or a refusal). +sha-abc-pinned run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +subst seed/qualification/om2/compiler-mutants/shr-imm-plus1.from seed/qualification/om2/compiler-mutants/shr-imm-plus1.to +cc seed/omc/omc.om +sha-abc-shr-mutant kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 +sha-empty-shr-mutant kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om - line:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - 0 +sha-448-shr-mutant kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/m448.bin line:248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1 - 0 +sha-million-shr-mutant kill seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om rep:97:1000000 line:cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0 - 0 +cc pinned +sha-abc-pinned-again run seed/qualification/om2/baseline/sha256-main.om+om/sha256/sha256.om file:seed/qualification/om2/fixtures/msg/abc.bin line:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad - 0 diff --git a/seed/qualification/om2/c2/corpus.pack b/seed/qualification/om2/c2/corpus.pack new file mode 100644 index 000000000..69b6d3619 --- /dev/null +++ b/seed/qualification/om2/c2/corpus.pack @@ -0,0 +1,184844 @@ + +#### c2-00001 sha256=124c19e6343133d45146e565eeb9307bbe7350a07fca01a736d6da8c3e5d4863 len=6318 +note SPDX-License-Identifier: Apache-2.0 +note b3unit.om: BLAKE3 (default unkeyed hash, 32-byte output) as one function-mode unit, bound +note through the omega-bridge native call ABI and exported as omega_omb3. It replaces the algorithm of +note src/omega_blake3.c, which keeps only omega_blake3_hash: that cuts the input into 1024-byte chunks. +note The tree logic follows om/blake3/blake3.om (the program form, kept for files and stdin). +note +note omb3 st b n fin o: +note st caller state, zeroed before the first call: rows 0..53 of 8 words are the chaining-value +note stack, word 440 its depth, word 441 the number of chunks absorbed +note fin 0 b holds a whole chunk that is not the last one (n must be 1024): its chaining value is +note merged into the stack +note fin 1 b[0..n) is the last chunk (n 0..1024): the tree is finished and the root hash goes to o +note A wrong n traps 3. +note +note Working words w (one array because globals are program-mode only): +note 0..15 state s, 16..31 message m, 32..47 permute scratch, 48..55 input chaining value, +note 56..71 compression output, 72 block length, 73 counter, 74 flags, 75..82 node chaining value, +note 83..90 IV, 91..106 message permutation + +fn initw w edit ulong 128 to void +put w 83 1779033703 +put w 84 3144134277 +put w 85 1013904242 +put w 86 2773480762 +put w 87 1359893119 +put w 88 2600822924 +put w 89 528734635 +put w 90 1541459225 +put w 91 2 +put w 92 6 +put w 93 3 +put w 94 10 +put w 95 7 +put w 96 0 +put w 97 4 +put w 98 13 +put w 99 1 +put w 100 11 +put w 101 12 +put w 102 5 +put w 103 9 +put w 104 14 +put w 105 15 +put w 106 8 +end + +note the G mixing function on state words a b c d with message words 2j and 2j+1 +fn g w edit ulong 128 a ulong b ulong c ulong d ulong j ulong to void +x = get w add 16 mul j 2 +t = add get w a get w b +put w a and add t x 4294967295 +t = xor get w d get w a +put w d and or shr t 16 shl t 16 4294967295 +put w c and add get w c get w d 4294967295 +t = xor get w b get w c +put w b and or shr t 12 shl t 20 4294967295 +x = get w add 17 mul j 2 +t = add get w a get w b +put w a and add t x 4294967295 +t = xor get w d get w a +put w d and or shr t 8 shl t 24 4294967295 +put w c and add get w c get w d 4294967295 +t = xor get w b get w c +put w b and or shr t 7 shl t 25 4294967295 +end + +fn round w edit ulong 128 to void +g w 0 4 8 12 0 +g w 1 5 9 13 1 +g w 2 6 10 14 2 +g w 3 7 11 15 3 +g w 0 5 10 15 4 +g w 1 6 11 12 5 +g w 2 7 8 13 6 +g w 3 4 9 14 7 +end + +fn permute w edit ulong 128 to void +for i ulong 16 +put w add 32 i get w add 16 get w add 91 i +end +for i ulong 16 +put w add 16 i get w add 32 i +end +end + +note the 16 little-endian words of blk into m +fn loadm w edit ulong 128 blk edit uchar 64 to void +for i ulong 16 +o = mul i 4 +v = ulong get blk add o 3 +v = or shl v 8 ulong get blk add o 2 +v = or shl v 8 ulong get blk add o 1 +v = or shl v 8 ulong get blk o +put w add 16 i v +end +end + +note compress (input chaining value, blk, block length, counter, flags) into the output words +fn compress w edit ulong 128 blk edit uchar 64 to void +loadm w blk +for i ulong 8 +put w i get w add 48 i +put w add i 8 get w add 83 i +end +put w 12 and get w 73 4294967295 +put w 13 and shr get w 73 32 4294967295 +put w 14 get w 72 +put w 15 get w 74 +for r ulong 7 +round w +permute w +end +for i ulong 8 +put w add 56 i xor get w i get w add i 8 +put w add 64 i xor get w add i 8 get w add 48 i +end +end + +note compress, then the node chaining value is the first 8 output words +fn nodecv w edit ulong 128 blk edit uchar 64 to void +compress w blk +for i ulong 8 +put w add 75 i get w add 56 i +end +end + +note copy cnt bytes of b from offset o into blk, zero the rest +fn loadblk blk edit uchar 64 b view uchar 1024 o ulong cnt ulong to void +for i ulong 64 +if lt i cnt +put blk i get b add o i +else +put blk i 0 +end +end +end + +fn setnb w edit ulong 128 bl ulong ctr ulong fl ulong to void +put w 72 bl +put w 73 ctr +put w 74 fl +end + +note chunk ctr holding b[0..cnt): every block but the last compressed, the last left set up +fn chunk w edit ulong 128 blk edit uchar 64 b view uchar 1024 cnt ulong ctr ulong to void +for i ulong 8 +put w add 48 i get w add 83 i +end +nblk = ulong 1 +if gt cnt 0 +nblk = div add cnt 63 64 +end +k = ulong 0 +while lt add k 1 nblk bound 16 +loadblk blk b mul k 64 64 +fl = ulong 0 +if eq k 0 +fl = 1 +end +setnb w 64 ctr fl +compress w blk +for i ulong 8 +put w add 48 i get w add 56 i +end +k = add k 1 +end +bo = mul sub nblk 1 64 +loadblk blk b bo sub cnt bo +fl = ulong 2 +if eq nblk 1 +fl = 3 +end +setnb w sub cnt bo ctr fl +end + +note parent node of stack row r (left) and the node chaining value (right), set up to compress +fn parentn w edit ulong 128 blk edit uchar 64 st edit ulong 448 r ulong to void +for i ulong 8 +put w add 48 i get w add 83 i +end +for i ulong 8 +l = get st add mul r 8 i +v = get w add 75 i +for k ulong 4 +sh = mul k 8 +q = add mul i 4 k +put blk q uchar and shr l sh 255 +put blk add 32 q uchar and shr v sh 255 +end +end +setnb w 64 0 4 +end + +fn push w edit ulong 128 st edit ulong 448 to void +p = get st 440 +for i ulong 8 +put st add mul p 8 i get w add 75 i +end +put st 440 add p 1 +end + +note a whole chunk that is not the last: merge completed subtrees, then push its chaining value +fn midchk w edit ulong 128 blk edit uchar 64 st edit ulong 448 b view uchar 1024 to void +ctr = get st 441 +chunk w blk b 1024 ctr +nodecv w blk +tot = add ctr 1 +while eq and tot 1 0 bound 64 +d = sub get st 440 1 +put st 440 d +parentn w blk st d +nodecv w blk +tot = shr tot 1 +end +push w st +put st 441 add ctr 1 +end + +note the last chunk: fold the stack into the root and write its 32 little-endian bytes into o +fn lastchk w edit ulong 128 blk edit uchar 64 st edit ulong 448 b view uchar 1024 n ulong o edit uchar 32 to void +chunk w blk b n get st 441 +while gt get st 440 0 bound 64 +nodecv w blk +d = sub get st 440 1 +put st 440 d +parentn w blk st d +end +put w 74 or get w 74 8 +compress w blk +outle w o +end + +note the first 8 output words, little endian, into o +fn outle w edit ulong 128 o edit uchar 32 to void +for i ulong 8 +v = get w add 56 i +for k ulong 4 +q = add mul i 4 k +put o q uchar and shr v mul k 8 255 +end +end +end + +fn omb3 st edit ulong 448 b view uchar 1024 n ulong fin ulong o edit uchar 32 to void +w = new ulong 128 0 +blk = new uchar 64 0 +initw w +if gt n 1024 +trap 3 +end +if eq fin 0 +if ne n 1024 +trap 3 +end +midchk w blk st b +ret +end +lastchk w blk st b n o +end + +#### c2-00002 sha256=79857ee82002d11d3df4c0c2a99523aa3419d18c5fc188a41efc778887b4baa3 len=5933 +note SPDX-License-Identifier: Apache-2.0 +note blake3: BLAKE3 default (unkeyed, 32-byte) hash of one file (or stdin when no argument), +note 64 hex digits + newline on stdout. Seeded native Omega port of src/omega_blake3.c. +note 32-bit words live in ulong cells and are masked after every add. +note 1024-byte chunks of 64-byte blocks, a binary tree of parents (stack depth <= 54 for 16 MiB), +note the ROOT flag on the last compression only. +note Capacity: 16 MiB of input (exit 66 beyond). Exit 65 when the file cannot be read. +note usage: blake3 [FILE] + +text tbad "blake3: cannot read input\n" +text tbig "blake3: input over 16 MiB\n" +text tnl "\n" + +global inp uchar 16777216 +global n ulong 1 +global iv ulong 8 +global perm ulong 16 +global m ulong 16 +global mt ulong 16 +global s ulong 16 +global co ulong 16 +global ncv ulong 8 +global blk uchar 64 +global nb ulong 3 +global cvr ulong 8 +global stk ulong 512 +global sp ulong 1 +global name uchar 4096 +global hex uchar 64 +global tiny uchar 1 + +const mask ulong 4294967295 +const cstart ulong 1 +const cend ulong 2 +const parent ulong 4 +const root ulong 8 + +fn initiv to void +put iv 0 1779033703 +put iv 1 3144134277 +put iv 2 1013904242 +put iv 3 2773480762 +put iv 4 1359893119 +put iv 5 2600822924 +put iv 6 528734635 +put iv 7 1541459225 +end + +fn initperm to void +put perm 0 2 +put perm 1 6 +put perm 2 3 +put perm 3 10 +put perm 4 7 +put perm 5 0 +put perm 6 4 +put perm 7 13 +put perm 8 1 +put perm 9 11 +put perm 10 12 +put perm 11 5 +put perm 12 9 +put perm 13 14 +put perm 14 15 +put perm 15 8 +end + +fn rotr x ulong r ulong to ulong +ret and or shr x r shl x sub 32 r mask +end + +note the G mixing function on state words a b c d with message words mx my +fn g a ulong b ulong c ulong d ulong mx ulong my ulong to void +t = add get s a get s b +put s a and add t mx mask +put s d rotr xor get s d get s a 16 +put s c and add get s c get s d mask +put s b rotr xor get s b get s c 12 +t = add get s a get s b +put s a and add t my mask +put s d rotr xor get s d get s a 8 +put s c and add get s c get s d mask +put s b rotr xor get s b get s c 7 +end + +fn round to void +g 0 4 8 12 get m 0 get m 1 +g 1 5 9 13 get m 2 get m 3 +g 2 6 10 14 get m 4 get m 5 +g 3 7 11 15 get m 6 get m 7 +g 0 5 10 15 get m 8 get m 9 +g 1 6 11 12 get m 10 get m 11 +g 2 7 8 13 get m 12 get m 13 +g 3 4 9 14 get m 14 get m 15 +end + +fn permute to void +for i ulong 16 +put mt i get m get perm i +end +for i ulong 16 +put m i get mt i +end +end + +note load the 16 little-endian words of blk into m +fn loadm to void +for i ulong 16 +o = mul i 4 +v = ulong get blk add o 3 +v = or shl v 8 ulong get blk add o 2 +v = or shl v 8 ulong get blk add o 1 +v = or shl v 8 ulong get blk o +put m i v +end +end + +note compress the node (ncv, blk, nb = block_len counter flags) into co (16 words); +note co 0..7 is the chaining value +fn compress to void +loadm +for i ulong 8 +put s i get ncv i +put s add i 8 get iv i +end +put s 12 and get nb 1 mask +put s 13 and shr get nb 1 32 mask +put s 14 get nb 0 +put s 15 get nb 2 +for r ulong 7 +round +permute +end +for i ulong 8 +put co i xor get s i get s add i 8 +put co add i 8 xor get s add i 8 get ncv i +end +end + +note chaining value of the node into cvr +fn nodecv to void +compress +for i ulong 8 +put cvr i get co i +end +end + +note copy cnt bytes of inp from offset o into blk, zero the rest +fn loadblk o ulong cnt ulong to void +for i ulong 64 +if lt i cnt +put blk i get inp add o i +else +put blk i 0 +end +end +end + +note the unfinished last compression of chunk number ctr holding inp[o .. o + cnt) +fn chunk o ulong cnt ulong ctr ulong to void +for i ulong 8 +put ncv i get iv i +end +nblk = ulong 1 +if gt cnt 0 +nblk = div add cnt 63 64 +end +b = ulong 0 +while lt add b 1 nblk bound 16 +loadblk add o mul b 64 64 +put nb 0 64 +put nb 1 ctr +put nb 2 0 +if eq b 0 +put nb 2 cstart +end +compress +for i ulong 8 +put ncv i get co i +end +b = add b 1 +end +bo = mul sub nblk 1 64 +rest = sub cnt bo +loadblk add o bo rest +put nb 0 rest +put nb 1 ctr +put nb 2 cend +if eq nblk 1 +put nb 2 or cend cstart +end +end + +note parent node of stk row r (left) and cvr (right) +fn parentn r ulong to void +for i ulong 8 +put ncv i get iv i +end +for i ulong 8 +l = get stk add mul r 8 i +v = get cvr i +for k ulong 4 +sh = mul k 8 +put blk add mul i 4 k uchar and shr l sh 255 +put blk add 32 add mul i 4 k uchar and shr v sh 255 +end +end +put nb 0 64 +put nb 1 0 +put nb 2 parent +end + +fn push to void +p = get sp 0 +for i ulong 8 +put stk add mul p 8 i get cvr i +end +put sp 0 add p 1 +end + +fn hexd v ulong to uchar +if lt v 10 +ret uchar add v 48 +end +ret uchar add v 87 +end + +note little-endian bytes of co 0..7 as 64 hex digits +fn emit to void +for i ulong 8 +v = get co i +for k ulong 4 +bt = and shr v mul k 8 255 +p = add mul i 8 mul k 2 +put hex p hexd shr bt 4 +put hex add p 1 hexd and bt 15 +end +end +r = write 1 hex 0 64 +r = write 1 tnl 0 1 +end + +note read the whole descriptor into inp; 0 ok, 65 read error, 66 over capacity +fn slurp fd int to int +t = ulong 0 +while true bound 999999 +room = sub len inp t +if eq room 0 +r = read fd tiny 0 1 +if lt r 0 +ret 65 +end +if gt r 0 +ret 66 +end +break +end +r = read fd inp t room +if lt r 0 +ret 65 +end +if eq r 0 +break +end +t = add t ulong r +end +put n 0 t +ret 0 +end + +fn hashall to void +sz = get n 0 +nch = ulong 1 +if gt sz 0 +nch = div add sz 1023 1024 +end +c = ulong 0 +while lt add c 1 nch bound 16385 +chunk mul c 1024 1024 c +nodecv +tot = add c 1 +while eq and tot 1 0 bound 64 +put sp 0 sub get sp 0 1 +parentn get sp 0 +nodecv +tot = shr tot 1 +end +push +c = add c 1 +end +lst = mul sub nch 1 1024 +chunk lst sub sz lst sub nch 1 +while gt get sp 0 0 bound 64 +nodecv +put sp 0 sub get sp 0 1 +parentn get sp 0 +end +put nb 2 or get nb 2 root +compress +end + +fn main to int +initiv +initperm +fd = int 0 +if ge argcnt 2 +l = argread 1 name 0 4095 +if lt l 1 +r = write 2 tbad 0 len tbad +ret 65 +end +fd = int fopen name 0 ulong l 0 0 +if lt fd 0 +r = write 2 tbad 0 len tbad +ret 65 +end +end +e = slurp fd +if eq e 65 +r = write 2 tbad 0 len tbad +ret 65 +end +if eq e 66 +r = write 2 tbig 0 len tbig +ret 66 +end +hashall +emit +ret 0 +end + +#### c2-00003 sha256=7f034814303a8a40b4bc56383ddd55ab2ae8460291f80793340bc3b0ac024e21 len=35333 +note SPDX-License-Identifier: Apache-2.0 +note sha256.om: FIPS 180-4 SHA-256 as one function-mode unit, bound through the omega-bridge native +note call ABI (docs/NATIVE-ABI.md) and exported as omega_omsha. It replaces the algorithm of +note src/sha256.c: the C file keeps only the sha256_* entry points that cut caller data into +note pieces of at most 4096 bytes. +note +note The whole hash state lives in the caller's sha256_ctx (104 bytes, src/sha256.h): +note bytes 0..31 state[8], uint32 little endian +note bytes 32..39 count, uint64 little endian (bytes absorbed so far) +note bytes 40..103 buffer, the pending partial block +note omsha c b n op w b8: +note op 0 init: count 0, FIPS initial hash value +note op 1 absorb b[0..n), n <= 4096, with src/sha256.c's buffering rules +note op 2 final: pad, absorb the bit length, the 32-byte digest packed into w[0..4) +note op 3 one shot: the digest of the n < 4096 bytes of b8 packed into w[0..4); c is not used +note w is the caller's scratch for the message schedule (64 words, contents ignored and overwritten): +note Omega writes every word before reading it, so the caller need not clear it. +note n > 4096 traps 3; any other op traps 9. + +note little-endian word of nb bytes at byte offset p of the context +fn getle c edit uchar 104 p ulong nb ulong to ulong +v = ulong 0 +i = nb +while gt i 0 bound 8 +i = sub i 1 +v = or shl v 8 ulong get c add p i +end +ret v +end + +fn putle c edit uchar 104 p ulong nb ulong v ulong to void +x = v +for i ulong nb +put c add p i uchar and x 255 +x = shr x 8 +end +end + +note the hash words of the context into h, and back +fn loadh c edit uchar 104 h edit uint 8 to void +for i ulong 8 +put h i uint getle c mul i 4 4 +end +end + +fn storeh c edit uchar 104 h edit uint 8 to void +for i ulong 8 +putle c mul i 4 4 ulong get h i +end +end + +note big-endian words of the block at byte o of b into w[0..16), then the schedule +fn schedb b view uchar 4096 o ulong w edit ulong 64 to void +for i ulong 16 +q = add o mul i 4 +v = ulong get b q +v = or shl v 8 ulong get b add q 1 +v = or shl v 8 ulong get b add q 2 +v = or shl v 8 ulong get b add q 3 +put w i or v shl v 32 +end +expand w +end + +note big-endian words of the block at byte 40 of b into w[0..16), then the schedule +fn schedc b edit uchar 104 w edit ulong 64 to void +for i ulong 16 +q = add 40 mul i 4 +v = ulong get b q +v = or shl v 8 ulong get b add q 1 +v = or shl v 8 ulong get b add q 2 +v = or shl v 8 ulong get b add q 3 +put w i or v shl v 32 +end +expand w +end + +note the 64 rounds, unrolled with the working words in locals (names rotate instead of moving). +note Same lazy low-32-bit cells and rotate trick as expand; K is an immediate; the eight words are +note reduced to 32 bits only when they are added back into h. +fn rounds h edit uint 8 w view ulong 64 to void +a = ulong get h 0 +b = ulong get h 1 +c = ulong get h 2 +d = ulong get h 3 +e = ulong get h 4 +f = ulong get h 5 +g = ulong get h 6 +x = ulong get h 7 +t = ulong 0 +u = ulong 0 +t = add x add get w 0 1116352408 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 1 1899447441 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 2 3049323471 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 3 3921009573 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 4 961987163 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 5 1508970993 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 6 2453635748 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 7 2870763221 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 8 3624381080 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 9 310598401 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 10 607225278 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 11 1426881987 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 12 1925078388 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 13 2162078206 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 14 2614888103 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 15 3248222580 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 16 3835390401 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 17 4022224774 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 18 264347078 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 19 604807628 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 20 770255983 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 21 1249150122 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 22 1555081692 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 23 1996064986 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 24 2554220882 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 25 2821834349 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 26 2952996808 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 27 3210313671 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 28 3336571891 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 29 3584528711 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 30 113926993 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 31 338241895 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 32 666307205 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 33 773529912 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 34 1294757372 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 35 1396182291 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 36 1695183700 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 37 1986661051 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 38 2177026350 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 39 2456956037 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 40 2730485921 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 41 2820302411 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 42 3259730800 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 43 3345764771 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 44 3516065817 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 45 3600352804 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 46 4094571909 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 47 275423344 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 48 430227734 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 49 506948616 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 50 659060556 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 51 883997877 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 52 958139571 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 53 1322822218 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 54 1537002063 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 55 1747873779 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add x add get w 56 1955562222 +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor g and e xor f g +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor b and xor a b xor b c +d = add d t +x = add t u +t = add g add get w 57 2024104815 +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor f and d xor e f +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor a and xor x a xor a b +c = add c t +g = add t u +t = add f add get w 58 2227730452 +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor e and c xor d e +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor x and xor g x xor x a +b = add b t +f = add t u +t = add e add get w 59 2361852424 +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor d and b xor c d +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor g and xor f g xor g x +a = add a t +e = add t u +t = add d add get w 60 2428436474 +u = shl a 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor c and a xor b c +u = shl e 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor f and xor e f xor f g +x = add x t +d = add t u +t = add c add get w 61 2756734187 +u = shl x 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor b and x xor a b +u = shl d 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor e and xor d e xor e f +g = add g t +c = add t u +t = add b add get w 62 3204031479 +u = shl g 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor a and g xor x a +u = shl c 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor d and xor c d xor d e +f = add f t +b = add t u +t = add a add get w 63 3329325298 +u = shl f 32 +u = or u shr u 32 +u = xor xor shr u 6 shr u 11 shr u 25 +t = add t u +t = add t xor x and f xor g x +u = shl b 32 +u = or u shr u 32 +u = xor xor shr u 2 shr u 13 shr u 22 +u = add u xor c and xor b c xor c d +e = add e t +a = add t u +t = add ulong get h 0 a +put h 0 uint and t 4294967295 +t = add ulong get h 1 b +put h 1 uint and t 4294967295 +t = add ulong get h 2 c +put h 2 uint and t 4294967295 +t = add ulong get h 3 d +put h 3 uint and t 4294967295 +t = add ulong get h 4 e +put h 4 uint and t 4294967295 +t = add ulong get h 5 f +put h 5 uint and t 4294967295 +t = add ulong get h 6 g +put h 6 uint and t 4294967295 +t = add ulong get h 7 x +put h 7 uint and t 4294967295 +end + +fn tobuf c edit uchar 104 bi ulong b view uchar 4096 bo ulong n ulong to void +for i ulong n +put c add 40 add bi i get b add bo i +end +end + +note absorb b[0..n), n <= 4096, exactly as src/sha256.c sha256_update does for that piece +fn absorb c edit uchar 104 b view uchar 4096 n ulong w edit ulong 64 to void +if gt n 4096 +trap 3 +end +h = new uint 8 0 +cnt = getle c 32 8 +bi = and cnt 63 +putle c 32 8 add cnt n +off = ulong 0 +if gt bi 0 +lf = sub 64 bi +if lt n lf +tobuf c bi b 0 n +ret +end +tobuf c bi b 0 lf +loadh c h +schedc c w +rounds h w +storeh c h +off = lf +end +if le add off 64 n +loadh c h +while le add off 64 n bound 65 +schedb b off w +rounds h w +off = add off 64 +end +storeh c h +end +tobuf c 0 b off sub n off +end + +fn init c edit uchar 104 to void +putle c 32 8 0 +putle c 0 4 1779033703 +putle c 4 4 3144134277 +putle c 8 4 1013904242 +putle c 12 4 2773480762 +putle c 16 4 1359893119 +putle c 20 4 2600822924 +putle c 24 4 528734635 +putle c 28 4 1541459225 +end + +note compress the context's own block buffer (bytes 40..103) into its hash words +fn compbuf c edit uchar 104 w edit ulong 64 to void +h = new uint 8 0 +loadh c h +schedc c w +rounds h w +storeh c h +end + +note zero buffer bytes s..e-1 (indices into the 64-byte block) +fn zbuf c edit uchar 104 s ulong e ulong to void +i = s +while lt i e bound 64 +put c add 40 i 0 +i = add i 1 +end +end + +note sha256_final of src/sha256.c, padding in place: 0x80, zeros to 56 mod 64 (one more block +note when the pending part is 56 bytes or more), the 64-bit big-endian bit count, then the digest. +note The count field is left as it was (src/sha256.c adds the padding to it; nothing reads it after). +fn final c edit uchar 104 w edit ulong 64 to void +cnt = getle c 32 8 +bi = and cnt 63 +put c add 40 bi 128 +zbuf c add bi 1 64 +if ge bi 56 +compbuf c w +zbuf c 0 56 +end +bits = mul cnt 8 +for i ulong 8 +sh = mul sub 7 i 8 +put c add 96 i uchar and shr bits sh 255 +end +compbuf c w +h = new uint 8 0 +loadh c h +digest8 h w +end + +note IV into h +fn initiv h edit uint 8 to void +put h 0 uint 1779033703 +put h 1 uint 3144134277 +put h 2 uint 1013904242 +put h 3 uint 2773480762 +put h 4 uint 1359893119 +put h 5 uint 2600822924 +put h 6 uint 528734635 +put h 7 uint 1541459225 +end + +note expand w[0..16) into the full 64-word schedule, unrolled (constant indices need no bounds checks). +note Every schedule word is stored duplicated, the 32-bit value in both halves (d = (x << 32) | x), so +note a rotate right by r is the low half of d >> r and a plain shift right by n is d >> (32 + n); sums +note are formed in the low 32 bits (add, and, xor, or need no masks) and duplicated once on store. +fn expand w edit ulong 64 to void +u = ulong 0 +v = ulong 0 +x = ulong 0 +x = get w 14 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 1 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 9 +u = add u get w 0 +u = shl u 32 +put w 16 or u shr u 32 +x = get w 15 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 2 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 10 +u = add u get w 1 +u = shl u 32 +put w 17 or u shr u 32 +x = get w 16 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 3 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 11 +u = add u get w 2 +u = shl u 32 +put w 18 or u shr u 32 +x = get w 17 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 4 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 12 +u = add u get w 3 +u = shl u 32 +put w 19 or u shr u 32 +x = get w 18 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 5 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 13 +u = add u get w 4 +u = shl u 32 +put w 20 or u shr u 32 +x = get w 19 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 6 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 14 +u = add u get w 5 +u = shl u 32 +put w 21 or u shr u 32 +x = get w 20 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 7 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 15 +u = add u get w 6 +u = shl u 32 +put w 22 or u shr u 32 +x = get w 21 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 8 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 16 +u = add u get w 7 +u = shl u 32 +put w 23 or u shr u 32 +x = get w 22 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 9 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 17 +u = add u get w 8 +u = shl u 32 +put w 24 or u shr u 32 +x = get w 23 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 10 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 18 +u = add u get w 9 +u = shl u 32 +put w 25 or u shr u 32 +x = get w 24 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 11 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 19 +u = add u get w 10 +u = shl u 32 +put w 26 or u shr u 32 +x = get w 25 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 12 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 20 +u = add u get w 11 +u = shl u 32 +put w 27 or u shr u 32 +x = get w 26 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 13 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 21 +u = add u get w 12 +u = shl u 32 +put w 28 or u shr u 32 +x = get w 27 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 14 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 22 +u = add u get w 13 +u = shl u 32 +put w 29 or u shr u 32 +x = get w 28 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 15 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 23 +u = add u get w 14 +u = shl u 32 +put w 30 or u shr u 32 +x = get w 29 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 16 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 24 +u = add u get w 15 +u = shl u 32 +put w 31 or u shr u 32 +x = get w 30 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 17 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 25 +u = add u get w 16 +u = shl u 32 +put w 32 or u shr u 32 +x = get w 31 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 18 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 26 +u = add u get w 17 +u = shl u 32 +put w 33 or u shr u 32 +x = get w 32 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 19 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 27 +u = add u get w 18 +u = shl u 32 +put w 34 or u shr u 32 +x = get w 33 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 20 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 28 +u = add u get w 19 +u = shl u 32 +put w 35 or u shr u 32 +x = get w 34 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 21 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 29 +u = add u get w 20 +u = shl u 32 +put w 36 or u shr u 32 +x = get w 35 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 22 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 30 +u = add u get w 21 +u = shl u 32 +put w 37 or u shr u 32 +x = get w 36 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 23 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 31 +u = add u get w 22 +u = shl u 32 +put w 38 or u shr u 32 +x = get w 37 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 24 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 32 +u = add u get w 23 +u = shl u 32 +put w 39 or u shr u 32 +x = get w 38 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 25 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 33 +u = add u get w 24 +u = shl u 32 +put w 40 or u shr u 32 +x = get w 39 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 26 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 34 +u = add u get w 25 +u = shl u 32 +put w 41 or u shr u 32 +x = get w 40 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 27 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 35 +u = add u get w 26 +u = shl u 32 +put w 42 or u shr u 32 +x = get w 41 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 28 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 36 +u = add u get w 27 +u = shl u 32 +put w 43 or u shr u 32 +x = get w 42 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 29 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 37 +u = add u get w 28 +u = shl u 32 +put w 44 or u shr u 32 +x = get w 43 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 30 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 38 +u = add u get w 29 +u = shl u 32 +put w 45 or u shr u 32 +x = get w 44 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 31 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 39 +u = add u get w 30 +u = shl u 32 +put w 46 or u shr u 32 +x = get w 45 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 32 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 40 +u = add u get w 31 +u = shl u 32 +put w 47 or u shr u 32 +x = get w 46 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 33 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 41 +u = add u get w 32 +u = shl u 32 +put w 48 or u shr u 32 +x = get w 47 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 34 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 42 +u = add u get w 33 +u = shl u 32 +put w 49 or u shr u 32 +x = get w 48 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 35 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 43 +u = add u get w 34 +u = shl u 32 +put w 50 or u shr u 32 +x = get w 49 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 36 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 44 +u = add u get w 35 +u = shl u 32 +put w 51 or u shr u 32 +x = get w 50 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 37 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 45 +u = add u get w 36 +u = shl u 32 +put w 52 or u shr u 32 +x = get w 51 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 38 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 46 +u = add u get w 37 +u = shl u 32 +put w 53 or u shr u 32 +x = get w 52 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 39 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 47 +u = add u get w 38 +u = shl u 32 +put w 54 or u shr u 32 +x = get w 53 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 40 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 48 +u = add u get w 39 +u = shl u 32 +put w 55 or u shr u 32 +x = get w 54 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 41 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 49 +u = add u get w 40 +u = shl u 32 +put w 56 or u shr u 32 +x = get w 55 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 42 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 50 +u = add u get w 41 +u = shl u 32 +put w 57 or u shr u 32 +x = get w 56 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 43 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 51 +u = add u get w 42 +u = shl u 32 +put w 58 or u shr u 32 +x = get w 57 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 44 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 52 +u = add u get w 43 +u = shl u 32 +put w 59 or u shr u 32 +x = get w 58 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 45 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 53 +u = add u get w 44 +u = shl u 32 +put w 60 or u shr u 32 +x = get w 59 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 46 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 54 +u = add u get w 45 +u = shl u 32 +put w 61 or u shr u 32 +x = get w 60 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 47 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 55 +u = add u get w 46 +u = shl u 32 +put w 62 or u shr u 32 +x = get w 61 +u = xor xor shr x 17 shr x 19 shr x 42 +x = get w 48 +v = xor xor shr x 7 shr x 18 shr x 35 +u = add u v +u = add u get w 56 +u = add u get w 47 +u = shl u 32 +put w 63 or u shr u 32 +end + +note Word access for the aligned paths. b8 is the caller's 8-byte-aligned copy of the input lent a +note second time as ulong cells (b views the same bytes), so one load brings 8 bytes. Swapping the +note bytes inside each 32-bit half (two mask-and-shift steps; the constants stay in registers) turns +note little-endian bytes b0..b7 into the big-endian words b0..b3 (low half) and b4..b7 (high half). +note Each word is stored duplicated, as expand requires. +fn blk8 b8 view ulong 512 q ulong w edit ulong 64 to void +for i ulong 8 +x = get b8 add q i +y = or shl and x 71777214294589695 8 and shr x 8 71777214294589695 +y = or shl and y 281470681808895 16 and shr y 16 281470681808895 +j = mul i 2 +t = shl y 32 +put w j or t shr t 32 +put w add j 1 or and y 18446744069414584320 shr y 32 +end +end + +note the padded tail b[off..n) (less than 64 bytes), read as words through b8 (the bytes past n +note are inside the caller's 4096-byte copy and are masked off here): the word holding byte n keeps +note its k valid bytes and gets 0x80 after them, later words are zero, the 64-bit bit count goes in +note words 14 and 15; a second block when the tail is 56 bytes or more +fn tail8 h edit uint 8 b8 view ulong 512 off ulong n ulong w edit ulong 64 to void +blk8 b8 shr off 3 w +r = sub n off +fw = shr r 2 +k = and r 3 +sh = mul k 8 +v = get w fw +v = and v shl 4294967295 sub 32 sh +v = and v 4294967295 +v = or v shl 128 sub 24 sh +put w fw or v shl v 32 +i = add fw 1 +while lt i 16 bound 16 +put w i 0 +i = add i 1 +end +if ge r 56 +expand w +rounds h w +for j ulong 14 +put w j 0 +end +end +bits = mul n 8 +v = shr bits 32 +put w 14 or v shl v 32 +v = and bits 4294967295 +put w 15 or v shl v 32 +expand w +rounds h w +end + +note the digest of h as 32 bytes packed little endian into w[0..4): word i holds the big-endian +note bytes of h[2i] then h[2i+1], so the caller copies the digest out of w with memcpy +fn digest8 h edit uint 8 w edit ulong 64 to void +for i ulong 4 +j = mul i 2 +x = or ulong get h j shl ulong get h add j 1 32 +y = or shl and x 71777214294589695 8 and shr x 8 71777214294589695 +y = or shl and y 281470681808895 16 and shr y 16 281470681808895 +put w i y +end +end + +note SHA-256 of the n < 4096 bytes in b8, state in locals only (sha256_hash's short path) +fn oneshot b8 view ulong 512 n ulong w edit ulong 64 to void +if ge n 4096 +trap 3 +end +h = new uint 8 0 +initiv h +off = ulong 0 +while le add off 64 n bound 64 +blk8 b8 shr off 3 w +expand w +rounds h w +off = add off 64 +end +tail8 h b8 off n w +digest8 h w +end + +fn omsha c edit uchar 104 b view uchar 4096 n ulong op ulong w edit ulong 64 b8 view ulong 512 to void +if eq op 0 +init c +ret +end +if eq op 1 +absorb c b n w +ret +end +if eq op 2 +final c w +ret +end +if eq op 3 +oneshot b8 n w +ret +end +trap 9 +end + +#### c2-00004 sha256=0e6bdbfb63ef9e52028682ddbecb1e9b4d81a3326b2e63848be570a775c31e6e len=456 +text want "two words" +global buf uchar 32 +fn main to int +if ne argcnt 4 +ret 1 +end +n = argread 1 buf 0 len buf +if ne n 0 +ret 2 +end +n = argread 2 buf 3 29 +if ne n long len want +ret 3 +end +for i ulong len want +if ne get buf add i 3 get want i +ret 4 +end +end +put buf 0 42 +n = argread 2 buf 0 1 +if ne n neg long 105 +ret 5 +end +if ne get buf 0 42 +ret 6 +end +n = argread 3 buf 0 len buf +if ne n 2 +ret 7 +end +if or ne get buf 0 207 ne get buf 1 128 +ret 8 +end +ret 0 +end + +#### c2-00005 sha256=33f64d79ae5655a020d795f8f31b7e4cff9f8c176534e4474216a2709b04f759 len=480 +note chdir: create a directory, enter it, create a relative file there, return, and refuse a missing path. +text dsub "sub" +text dfile "inside" +text dup ".." +text dno "nope" +fn main to int +r = makedir dsub 0 len dsub 493 +if ne r 0 +ret 1 +end +r = chdir dsub 0 len dsub +if ne r 0 +ret 2 +end +fd = int fopen dfile 0 len dfile 577 420 +if lt fd 0 +ret 3 +end +r = fclose fd +if ne r 0 +ret 4 +end +r = chdir dup 0 len dup +if ne r 0 +ret 5 +end +r = chdir dno 0 len dno +if ge r 0 +ret 6 +end +ret 0 +end + +#### c2-00006 sha256=21ee5f82d67f2b286cbcd3c5e1242199f0b7b66f020caa98f5a53212d4245532 len=635 +note chmod: path permissions through fchmodat; mode 0600 is 384, checked in st_mode at byte 16. +text p "mode.tmp" +text miss "no.such.file" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +r = fclose fd +if ne r 0 +ret 2 +end +r = chmod p 0 len p 384 +if ne r 0 +ret 3 +end +buf = new uchar 128 0 +r = stat p 0 len p buf 0 128 +if ne r 0 +ret 4 +end +m = add ulong get buf 16 shl ulong get buf 17 ulong 8 +m = add m shl ulong get buf 18 ulong 16 +m = add m shl ulong get buf 19 ulong 24 +if ne and m ulong 4095 ulong 384 +ret 5 +end +r = chmod miss 0 len miss 384 +if ge r 0 +ret 6 +end +r = unlink p 0 len p +if ne r 0 +ret 7 +end +ret 0 +end + +#### c2-00007 sha256=9e5d8e7f2fd5678c63ed95bbde66f9d6f753b42791701d45311bfe20dd7f4d17 len=517 +note chown: fchownat to the current uid (gid unchanged); st_uid low byte at 24, missing path errno. +text p "own.tmp" +text miss "no.such.file" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +r = fclose fd +u = getuid +r = chown p 0 len p int u int -1 +if ne r 0 +ret 2 +end +st = new uchar 128 0 +r = stat p 0 len p st 0 128 +if ne r 0 +ret 3 +end +if ne int get st 24 int and u long 255 +ret 4 +end +r = chown miss 0 len miss int u int -1 +if ge r 0 +ret 5 +end +r = unlink p 0 len p +if ne r 0 +ret 6 +end +ret 0 +end + +#### c2-00008 sha256=ca76010ea6cf2ab7acd8b8fab36234dcaad8f2cede057e01a52e840842a2e8ed len=1589 +note Parameter binding checks use invalid descriptors, never a GPU device. +global header uchar 48 +global params uchar 32 +global large uchar 16384 +global status uchar 4 +text msg "PASS native device parameter binding\n" +fn ck yes bool to void +if not yes +exit int 80 +end +end +fn fault k int to int +if eq k 0 +r = devcall neg int 1 uint 3223340587 header 0 31 params 0 0 +ret int r +end +if eq k 1 +r = devcall neg int 1 uint 3223340587 header 17 32 params 0 0 +ret int r +end +if eq k 2 +r = devcall neg int 1 uint 3223340587 header 0 32 params 31 2 +ret int r +end +if eq k 3 +put header 16 1 +r = devcall neg int 1 uint 3223340587 header 0 32 params 0 1 +ret int r +end +if eq k 4 +r = devcall neg int 1 uint 3223340587 header 0 32 large 0 16384 +ret int r +end +r = devcall neg int 1 uint 3223340587 header 0 32 params 18446744073709551615 1 +ret int r +end +fn main to int +for i ulong 48 +put header i 171 +end +for i ulong 8 +put header add i 24 0 +end +for n ulong 33 +ck eq devcall neg int 1 uint 3223340587 header 8 32 params 0 n neg long 9 +for i ulong 48 +if and ge i 24 lt i 32 +ck eq get header i 0 +else +if eq i 32 +ck eq get header i uchar n +else +if and gt i 32 lt i 36 +ck eq get header i 0 +else +ck eq get header i 171 +end +end +end +end +end +ck eq add devcall neg int 1 uint 3223340586 header 8 32 params 4 12 10 1 +for i ulong 48 +put header i 0 +end +ck eq devcall neg int 1 uint 3223340587 header 0 32 large 1 16383 neg long 9 +for k int 6 +p = fork +ck ge p 0 +if eq p 0 +exit fault k +end +ck eq waitpid int p status 0 4 0 p +ck eq get status 0 0 +ck eq get status 1 103 +end +ck eq write 1 msg 0 len msg long len msg +ret 0 +end + +#### c2-00009 sha256=375898c6ac071af5ab50bb41fce6aa93ee5796302916cac65df70831c52d3d67 len=1641 +note Host/device composition. No GPU opened. FIONREAD observes real native pipes. +global ends uchar 8 +global count uchar 12 +global status uchar 4 +text msg "Omega device boundary" +text zero "/dev/zero" +fn word32 off ulong to int +v = uint 0 +for i ulong 4 +v = or v shl uint get ends add off i mul i 8 +end +ret int v +end +fn fault kind int to int +if eq kind 0 +r = devctl neg int 1 uint 21531 count 0 3 +ret int r +end +if eq kind 1 +r = devctl neg int 1 uint 21531 count 0 5 +ret int r +end +if eq kind 2 +r = devctl neg int 1 uint 21531 count 9 4 +ret int r +end +if eq kind 3 +r = devctl neg int 1 uint 21531 count 18446744073709551615 4 +ret int r +end +r = devctl neg int 1 uint 21531 count 0 18446744073709551615 +ret int r +end +fn main to int +if ne pipefds ends 0 8 0 0 +ret 1 +end +rd = word32 0 +wr = word32 4 +if ne write wr msg 0 len msg long len msg +ret 2 +end +for i ulong 12 +put count i 171 +end +if ne devctl rd uint 21531 count 4 4 0 +ret 3 +end +if ne get count 4 uchar len msg +ret 4 +end +for i ulong 12 +if or lt i 4 ge i 8 +if ne get count i 171 +ret 5 +end +else +if and gt i 4 ne get count i 0 +ret 6 +end +end +end +if ne devctl neg int 1 uint 21531 count 4 4 neg long 9 +ret 7 +end +note Normal file operations and nested native calls retain live values. +fd = fopen zero 0 len zero 0 0 +if lt fd 0 +ret 8 +end +if ne add devctl int fd uint 21531 count 4 4 25 0 +ret 9 +end +if ne fclose int fd 0 +ret 10 +end +if ne fclose rd 0 +ret 11 +end +if ne fclose wr 0 +ret 12 +end +for kind int 5 +pid = fork +if lt pid 0 +ret 13 +end +if eq pid 0 +exit fault kind +end +if ne waitpid int pid status 0 4 0 pid +ret 14 +end +if ne get status 0 0 +ret 15 +end +if ne get status 1 103 +ret 16 +end +end +ret 0 +end + +#### c2-00010 sha256=c25fcaeb5e6fc0331b31d7f4af5aa5d00c87c5df6d99c8d2fa42456268e0124c len=1116 +text dir "adir" +text old "before" +text fresh "after" +global bytes uchar 4096 +global packet uchar 64 +fn main to int +r = makedir dir 0 len dir 448 +if ne r 0 +ret 1 +end +note Linux ARM64 overrides O_DIRECTORY to 040000 octal in asm/fcntl.h. +fd = fopen dir 0 len dir 16384 0 +if lt fd 0 +ret 2 +end +r = getdnts int fd bytes 0 len bytes +if le r 0 +ret 3 +end +r = fclose int fd +r = rmdir dir 0 len dir +if ne r 0 +ret 4 +end +fd = fopen old 0 len old 194 384 +if lt fd 0 +ret 5 +end +r = write int fd fresh 0 len fresh +if ne r long len fresh +ret 6 +end +r = fstat int fd bytes 0 128 +if ne r 0 +ret 7 +end +if ne get bytes 48 uchar len fresh +ret 8 +end +r = fclose int fd +put packet 0 2 +put packet 2 uchar len old +for i ulong len old +put packet add i 4 get old i +end +n = add len old 4 +put packet n uchar len fresh +n = add n 2 +for i ulong len fresh +put packet add n i get fresh i +end +n = add n len fresh +r = renames packet 0 n 1 +if ne r 0 +ret 9 +end +fd = fopen old 0 len old 194 384 +if lt fd 0 +ret 10 +end +r = fclose int fd +r = renames packet 0 n 1 +if ne r neg long 17 +ret 11 +end +r = unlink old 0 len old +r = unlink fresh 0 len fresh +ret int r +end + +#### c2-00011 sha256=d798e64c66d39fa9cf6df29ed67026e747a8cff2e4c4f95f84ccc2ea8d01bff6 len=484 +note envcnt/envread: find OMTEST=hello in the process environment, and refuse a short buffer with -105. +text want "OMTEST=hello" +global buf uchar 128 +fn main to int +c = ulong envcnt +if eq c 0 +ret 1 +end +n0 = envread 0 buf 0 1 +if ne n0 -105 +ret 3 +end +i = ulong 0 +while lt i c +n = envread i buf 0 len buf +if eq n long len want +j = long 0 +same = ulong 1 +while lt j n +if ne get buf j get want j +same = ulong 0 +break +end +j = add j 1 +end +if eq same 1 +ret 0 +end +end +i = add i 1 +end +ret 2 +end + +#### c2-00012 sha256=93043b312007ee2dedce62d8a7a5d4601c34c80a4f142ce471270b585ce7dc66 len=157 +note an environment index equal to the count must trap 3 (program exit 103). +fn main to int +c = ulong envcnt +a = new uchar 8 0 +n = envread c a 0 8 +ret 0 +end + +#### c2-00013 sha256=a6fcf6e1ede30da15f4ad75ea11173cd4d5001613ae424cd0b30eff62f96898a len=848 +global buf uchar 256 +fn main to int +if ne fclose neg int 1 neg long 9 +ret 1 +end +if ne fsync neg int 1 neg long 9 +ret 2 +end +if ne fchmod neg int 1 384 neg long 9 +ret 3 +end +if ne fseek neg int 1 0 0 neg long 9 +ret 4 +end +if ne getdnts neg int 1 buf 0 256 neg long 9 +ret 5 +end +if ne fstat neg int 1 buf 0 128 neg long 9 +ret 6 +end +if ne bind neg int 1 buf 0 16 neg long 9 +ret 7 +end +if ne connect neg int 1 buf 0 16 neg long 9 +ret 8 +end +if ne listen neg int 1 1 neg long 9 +ret 9 +end +if ne accept neg int 1 0 neg long 9 +ret 10 +end +if ne send neg int 1 buf 0 1 0 neg long 9 +ret 11 +end +if ne recv neg int 1 buf 0 1 0 neg long 9 +ret 12 +end +if ne sockname neg int 1 buf 0 16 neg long 9 +ret 13 +end +if ne waitpid neg int 1 buf 0 4 1 neg long 10 +ret 14 +end +if ne pipefds buf 0 8 neg int 1 neg long 22 +ret 15 +end +if ne killpid int getpid 0 0 +ret 16 +end +ret 0 +end + +#### c2-00014 sha256=e4aec179deea0ab97c88ab0a274bba8fab2f1f0ca6d54b9829d8b724967e4087 len=384 +note faccess: F_OK (0) on an existing path succeeds; a missing path returns a negative error. +text p "acc.tmp" +text miss "no.such.file" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +r = fclose fd +if ne r 0 +ret 2 +end +r = faccess p 0 len p 0 +if ne r 0 +ret 3 +end +r = faccess miss 0 len miss 0 +if ge r 0 +ret 4 +end +r = unlink p 0 len p +if ne r 0 +ret 5 +end +ret 0 +end + +#### c2-00015 sha256=7bce001ac35fee18b0205df59aeeaea62b1d2eea68e336c0262ad3741f40028e len=784 +note fchdir/getppid/umask: directory fd, mask 0 with a 0777 file, parent id. +text subd "subdir" +text inside "inside" +text p "mode2.tmp" +fn main to int +pp = getppid +if eq pp long 0 +ret 1 +end +me = getpid +if eq pp long me +ret 2 +end +old = umask 0 +fd = int fopen p 0 len p 578 511 +if lt fd 0 +ret 3 +end +r = fclose fd +st = new uchar 128 0 +r = stat p 0 len p st 0 128 +if ne r 0 +ret 4 +end +m = add ulong get st 16 shl ulong get st 17 ulong 8 +if ne and m ulong 4095 ulong 511 +ret 5 +end +z = umask int old +r = unlink p 0 len p +if ne r 0 +ret 6 +end +r = makedir subd 0 len subd 448 +if ne r 0 +ret 7 +end +dfd = int fopen subd 0 len subd 16384 0 +if lt dfd 0 +ret 8 +end +r = fchdir dfd +if ne r 0 +ret 9 +end +f = int fopen inside 0 len inside 578 511 +if lt f 0 +ret 10 +end +z = fclose f +z = fclose dfd +ret 0 +end + +#### c2-00016 sha256=4a7bc7d82979b05511a5ea2cd8a7c51ebce6e36a52a3fc929b0e9db1f99e3733 len=607 +text p "dsync.tmp" +text body "abcd" +text name "mfd" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +w = write fd body 0 len body +if ne w long len body +ret 2 +end +r = fdsync fd +if ne r 0 +ret 3 +end +r = fclose fd +if ne r 0 +ret 4 +end +r = fdsync fd +if ge r 0 +ret 5 +end +r = unlink p 0 len p +if ne r 0 +ret 6 +end +m = int memfd name 0 len name 0 +if lt m 0 +ret 7 +end +w = write m body 0 len body +if ne w long len body +ret 8 +end +r = fseek m 0 0 +if ne r 0 +ret 9 +end +buf = new uchar 4 0 +n = read m buf 0 4 +if ne n 4 +ret 10 +end +if ne get buf 0 97 +ret 11 +end +r = fclose m +if ne r 0 +ret 12 +end +ret 0 +end + +#### c2-00017 sha256=7599eaaa3936a7342b4825965f6fd0a0a2517075f12168b5bc54d4d06ddc5a4b len=1034 +note Native host file and monotonic clock checks. Paths belong to the gate's isolated working directory. +text path "probe.bin" +text data "Omega host test\n" +global bytes uchar 32 +fn main to int +if lt realns 1700000000000000000 +ret 16 +end +start = monons +if lt start 0 +ret 1 +end +fd = fopen path 0 len path 194 384 +if lt fd 0 +ret 2 +end +dup = fopen path 0 len path 194 384 +if ne dup neg long 17 +ret 3 +end +n = write int fd data 0 len data +if ne n long len data +ret 4 +end +r = fsync int fd +if ne r 0 +ret 5 +end +r = fchmod int fd 256 +if ne r 0 +ret 6 +end +r = fseek int fd 0 0 +if ne r 0 +ret 7 +end +n = read int fd bytes 0 len bytes +if ne n long len data +ret 8 +end +for i ulong len data +if ne get bytes i get data i +ret 9 +end +end +r = fclose int fd +if ne r 0 +ret 10 +end +r = fclose int fd +if ne r neg long 9 +ret 11 +end +r = unlink path 0 len path +if ne r 0 +ret 12 +end +r = fopen path 0 len path 0 0 +if ne r neg long 2 +ret 13 +end +last = start +for i ulong 10000 +now = monons +if lt now last +ret 14 +end +last = now +end +if le last start +ret 15 +end +ret 0 +end + +#### c2-00018 sha256=ea4f544b49878f5532f75b0ac7e8fa42e6926d5b57ea002e748679922859ad48 len=568 +note White-box boundary fixture: compiler's generation ceiling replaced with 3 for this test only. +note Uses the same emitted vacancy/retirement branch as the real 55-bit ceiling. +text passed "PASS generation ceiling, retirement and final exhaustion\n" +fn main to int +for slot long 128 +for gen long 3 +h = mapnew neg int 1 0 4096 3 34 +expected = add mul add gen 1 256 add slot 1 +if ne h expected +ret 1 +end +if ne mapdrop h 0 +ret 2 +end +end +end +if ne mapnew neg int 1 0 4096 3 34 neg long 24 +ret 3 +end +if ne write 1 passed 0 len passed long len passed +ret 4 +end +ret 0 +end + +#### c2-00019 sha256=9fa1710075bf9ce64bf57d3f0c6ffe8deac39a294bb8242c64ba185e8cb7cd3a len=1149 +note link/symlnk take a packed two-path list: u16 count 2, then each u16 length + bytes. +text a "pl1.tmp" +text b "pl2.tmp" +text c "pl3.tmp" +text body "abcd" +fn main to int +fd = int fopen a 0 len a 578 420 +if lt fd 0 +ret 1 +end +w = write fd body 0 len body +if ne w long len body +ret 2 +end +r = fclose fd +if ne r 0 +ret 3 +end +list = new uchar 64 0 +put list 0 2 +put list 1 0 +put list 2 uchar len a +put list 3 0 +i = ulong 0 +while lt i len a bound 64 +put list add 4 i get a i +i = add i 1 +end +off = add 4 len a +put list off uchar len b +put list add off 1 0 +i = ulong 0 +while lt i len b bound 64 +put list add add off 2 i get b i +i = add i 1 +end +total = add add off 2 len b +r = link list 0 total +if ne r 0 +ret 4 +end +st = new uchar 128 0 +r = stat b 0 len b st 0 128 +if ne r 0 +ret 5 +end +if ne get st 20 2 +ret 6 +end +i = ulong 0 +while lt i len c bound 64 +put list add add off 2 i get c i +i = add i 1 +end +r = symlnk list 0 total +if ne r 0 +ret 7 +end +buf = new uchar 64 0 +n = readlnk c 0 len c buf 0 64 +if ne n long len a +ret 8 +end +r = unlink c 0 len c +if ne r 0 +ret 9 +end +r = unlink b 0 len b +if ne r 0 +ret 10 +end +r = unlink a 0 len a +if ne r 0 +ret 11 +end +ret 0 +end + +#### c2-00020 sha256=5cf587ad20927ccf7c2873f58d332623f1a2e60adac8efa2e3877d74647cdc98 len=225 +note a one-record packed list must be refused before any kernel call: link needs exactly two. +fn main to int +list = new uchar 16 0 +put list 0 1 +put list 1 0 +put list 2 1 +put list 3 0 +put list 4 97 +r = link list 0 5 +ret 0 +end + +#### c2-00021 sha256=691bc9c2903c9c269ded9a55596ce1cb08adc693fe3e08ffcbf274b3e523a944 len=2457 +note cwd includes its trailing zero in the count; readlnk returns raw bytes without a terminator. +global here uchar 4096 +global target uchar 4096 +text procwd "/proc/self/cwd" +text padded "_/proc/self/cwd_" +text procexe "/proc/self/exe" +text suffix "/location" +text absent "missing-link-target" +text regular "regular-file" +fn localcwd result edit uchar 4096 to long +ret add long 7 cwd result 3 4000 +end +fn locallnk path view uchar 16 result edit uchar 4096 to long +ret add long 11 readlnk path 1 14 result 7 4000 +end +fn main to int +local = new uchar 4096 85 +pathcopy = new uchar 16 0 +n = sub localcwd local 7 +if or le n 1 gt n 4000 +ret 1 +end +if or ne get local 2 85 ne get local add 3 ulong n 85 +ret 2 +end +if or ne get local 3 47 ne get local add 2 ulong n 0 +ret 3 +end +m = cwd here 0 ulong n +if ne m n +ret 4 +end +for i ulong ulong n +if ne get here i get local add 3 i +ret 5 +end +end +if ne cwd here 0 sub ulong n 1 neg long 34 +ret 6 +end +if ne cwd here 0 0 neg long 34 +ret 7 +end +for i ulong len target +put target i 85 +end +m = readlnk procwd 0 len procwd target 5 4000 +if ne m sub n 1 +ret 8 +end +for i ulong ulong m +if ne get target add 5 i get local add 3 i +ret 9 +end +end +if or ne get target 4 85 ne get target add 5 ulong m 85 +ret 10 +end +m = readlnk procwd 0 len procwd target 0 1 +if or ne m 1 ne get target 0 47 +ret 11 +end +if ne readlnk procwd 0 len procwd target 0 0 neg long 22 +ret 12 +end +m = readlnk procexe 0 len procexe target 0 len target +if ne m long add sub ulong n 1 len suffix +ret 13 +end +for i ulong sub ulong n 1 +if ne get target i get local add 3 i +ret 14 +end +end +for i ulong len suffix +if ne get target add sub ulong n 1 i get suffix i +ret 15 +end +end +if ne readlnk absent 0 len absent target 0 len target neg long 2 +ret 16 +end +fd = fopen regular 0 len regular 194 384 +if lt fd 0 +ret 17 +end +r = fclose int fd +if ne r 0 +ret 18 +end +r = readlnk regular 0 len regular target 0 len target +if ne r neg long 22 +ret 19 +end +r = unlink regular 0 len regular +if ne r 0 +ret 20 +end +for i ulong len padded +put pathcopy i get padded i +end +m = sub locallnk pathcopy local 11 +if ne m sub n 1 +ret 21 +end +for i ulong ulong m +if ne get local add 7 i get here i +ret 22 +end +end +note The private path copy permits the output slice to overlap the input path safely. +for i ulong len procwd +put target i get procwd i +end +m = readlnk target 0 len procwd target 0 len target +if ne m sub n 1 +ret 23 +end +for i ulong ulong m +if ne get target i get here i +ret 24 +end +end +ret 0 +end + +#### c2-00022 sha256=544cf17cf26ab54eb71e42030027a6a171faccc084294e235c76c8df419a8a6f len=976 +note stat follows the final symlink (size 4); lstat reports S_IFLNK in st_mode at byte 16. +text a "ls1.tmp" +text c "ls2.tmp" +text body "abcd" +fn main to int +fd = int fopen a 0 len a 578 420 +if lt fd 0 +ret 1 +end +w = write fd body 0 len body +r = fclose fd +list = new uchar 64 0 +put list 0 2 +put list 1 0 +put list 2 uchar len a +put list 3 0 +i = ulong 0 +while lt i len a bound 64 +put list add 4 i get a i +i = add i 1 +end +off = add 4 len a +put list off uchar len c +put list add off 1 0 +i = ulong 0 +while lt i len c bound 64 +put list add add off 2 i get c i +i = add i 1 +end +total = add add off 2 len c +r = symlnk list 0 total +if ne r 0 +ret 2 +end +st = new uchar 128 0 +r = stat c 0 len c st 0 128 +if ne r 0 +ret 3 +end +if ne get st 48 4 +ret 4 +end +r = lstat c 0 len c st 0 128 +if ne r 0 +ret 5 +end +m = add ulong get st 16 shl ulong get st 17 ulong 8 +if ne and m ulong 61440 ulong 40960 +ret 6 +end +r = unlink c 0 len c +if ne r 0 +ret 7 +end +r = unlink a 0 len a +if ne r 0 +ret 8 +end +ret 0 +end + +#### c2-00023 sha256=f657ff3daa44b070608178834b46f1f83ade03e65b73c00e05a1c2e2a9356267 len=1771 +note Exact word access through managed mappings. No GPU or device opens. +global bytes uchar 16 +global status uchar 4 +text msg "PASS managed addresses and ordered mapped words\n" +fn ck yes bool to void +if not yes +exit int 80 +end +end +fn bad k int to void +h = mapnew neg int 1 0 4096 3 34 +ck gt h 0 +if eq k 0 +ck eq mapdrop h 0 +r = mapaddr h +ret +end +if eq k 1 +ck eq mapdrop h 0 +r = mapget h 0 4 +ret +end +if eq k 2 +r = mapget h 4096 4 +ret +end +if eq k 3 +r = mapset h 4092 8 0 +ret +end +if eq k 4 +r = mapget h 1 4 +ret +end +if eq k 5 +r = mapset h 4 8 0 +ret +end +if eq k 6 +ro = mapnew neg int 1 0 4096 1 34 +r = mapset ro 0 4 0 +ret +end +if eq k 7 +r = mapset h 0 4 4294967296 +ret +end +r = mapget h 18446744073709551615 8 +end +fn held h long a ulong b ulong c ulong d ulong e ulong to void +ck gt mapaddr h 4096 +ck eq mapset h 0 8 18446744073709551615 0 +ck eq mapget h 0 8 18446744073709551615 +ck eq a 101 +ck eq b 202 +ck eq c 303 +ck eq d 404 +ck eq e 505 +end +fn main to int +h = mapnew neg int 1 0 4096 3 33 +ck gt h 0 +ck eq and mapaddr h 4095 0 +held h 101 202 303 404 505 +ck eq mapset h 8 4 4294967295 0 +ck eq mapget h 8 4 4294967295 +ck eq mapset h 12 4 305419896 0 +ck eq mapread h 0 bytes 0 16 16 +for i ulong 12 +ck eq get bytes i 255 +end +ck eq get bytes 12 120 +ck eq get bytes 13 86 +ck eq get bytes 14 52 +ck eq get bytes 15 18 +ck eq mapset h 4088 8 81985529216486895 0 +ck eq mapget h 4088 8 81985529216486895 +p = fork +ck ge p 0 +if eq p 0 +ck eq mapset h 0 8 42 0 +exit int 0 +end +ck eq waitpid int p status 0 4 0 p +ck and eq get status 0 0 eq get status 1 0 +ck eq mapget h 0 8 42 +ck eq mapdrop h 0 +for k int 9 +p = fork +ck ge p 0 +if eq p 0 +bad k +exit int 80 +end +ck eq waitpid int p status 0 4 0 p +ck and eq get status 0 0 eq get status 1 103 +end +ck eq write 1 msg 0 len msg long len msg +ret 0 +end + +#### c2-00024 sha256=b42c477a43862018dc0cb1f1c4f06374d1413130eeb112b6fd6b81132360c607 len=3965 +note Native memory ownership, shared/private files, bounds, stale handles and resource limits. +text path "mapped.bin" +text payload "native Omega mapped memory" +text ok "PASS native mapping\n" +global buf uchar 8192 +global caps long 128 +global wstat uchar 4 +global fdnum int 1 +fn expect yes bool to void +if not yes +exit int 80 +end +end +note Keep five distinct caller values live across each native mapping operation. +fn held h long a ulong b ulong c ulong d ulong e ulong to void +expect eq mapwrite h 31 payload 0 len payload long len payload +expect eq a 101 +expect eq b 202 +expect eq c 303 +expect eq d 404 +expect eq e 505 +expect eq mapread h 31 buf 1 len payload long len payload +expect eq a 101 +expect eq b 202 +expect eq c 303 +expect eq d 404 +expect eq e 505 +expect eq mapdrop h 0 +expect eq a 101 +expect eq b 202 +expect eq c 303 +expect eq d 404 +expect eq e 505 +end +fn fault kind int to int +h = mapnew neg int 1 0 4096 3 34 +expect gt h 0 +if eq kind 0 +expect eq mapdrop h 0 +r = mapread h 0 buf 0 1 +ret int r +end +if eq kind 1 +expect eq mapdrop h 0 +next = mapnew neg int 1 0 4096 3 34 +expect ne next h +r = mapwrite h 0 payload 0 1 +ret int r +end +if eq kind 2 +r = mapread h 4096 buf 0 1 +ret int r +end +if eq kind 3 +r = mapwrite h 18446744073709551615 payload 0 1 +ret int r +end +if eq kind 4 +ro = mapnew get fdnum 0 0 4096 1 2 +r = mapwrite ro 0 payload 0 1 +ret int r +end +if eq kind 5 +r = mapdrop long 0 +ret int r +end +if eq kind 6 +r = mapdrop long 129 +ret int r +end +if eq kind 7 +r = mapnew neg int 1 0 0 3 34 +ret int r +end +if eq kind 8 +r = mapnew neg int 1 0 68719476737 3 34 +ret int r +end +if eq kind 9 +r = mapnew neg int 1 1 4096 3 34 +ret int r +end +if eq kind 10 +r = mapread h 0 buf 8192 1 +ret int r +end +if eq kind 11 +r = mapread h 0 buf 0 18446744073709551615 +ret int r +end +if eq kind 12 +r = mapdrop neg long 1 +ret int r +end +if eq kind 13 +r = mapnew int 0 0 4096 3 34 +ret int r +end +ret 99 +end +fn main to int +fd = fopen path 0 len path 194 384 +expect ge fd 0 +put fdnum 0 int fd +expect eq write int fd buf 0 8192 8192 +shared = mapnew int fd 0 8192 3 1 +expect gt shared 0 +expect eq mapwrite shared 4099 payload 0 len payload long len payload +expect eq fseek int fd 4099 0 4099 +expect eq read int fd buf 0 len payload long len payload +for i ulong len payload +expect eq get buf i get payload i +end +private = mapnew int fd 4096 4096 3 2 +expect gt private 0 +expect ne private shared +expect eq mapread private 3 buf 100 len payload long len payload +for i ulong len payload +expect eq get buf add i 100 get payload i +end +put buf 0 222 +expect eq mapwrite private 3 buf 0 1 1 +expect eq mapread private 3 buf 1 1 1 +expect eq get buf 1 222 +expect eq mapread shared 4099 buf 2 1 1 +expect eq get buf 2 get payload 0 +expect eq mapdrop shared 0 +expect eq mapdrop private 0 +ro = mapnew int fd 0 8192 1 2 +expect gt ro 0 +expect eq mapread ro 4099 buf 0 len payload long len payload +expect eq mapdrop ro 0 +expect eq mapnew neg int 1 0 4096 1 2 neg long 9 +expect eq mapnew int fd 1 4096 1 2 neg long 22 +live = mapnew neg int 1 0 4096 3 34 +held live 101 202 303 404 505 +note A failed kernel mapping must not consume a slot. +for i ulong 128 +h = mapnew neg int 1 0 4096 3 34 +expect gt h 0 +put caps i h +expect eq mapread h 4095 buf 0 1 1 +expect eq get buf 0 0 +expect eq mapwrite h 4096 payload len payload 0 0 +end +expect eq mapnew neg int 1 0 4096 3 34 neg long 24 +for i ulong 128 +expect eq mapdrop get caps i 0 +end +for i ulong 1024 +h = mapnew neg int 1 0 4096 3 34 +expect gt h get caps 0 +expect eq mapwrite h 13 payload 0 len payload long len payload +expect eq mapread h 13 buf 1 len payload long len payload +for j ulong len payload +expect eq get buf add j 1 get payload j +end +expect eq mapdrop h 0 +put caps 0 h +end +for kind int 14 +pid = fork +expect ge pid 0 +if eq pid 0 +exit fault kind +end +expect eq waitpid int pid wstat 0 4 0 pid +expect eq get wstat 0 0 +expect eq get wstat 1 103 +end +expect eq fclose int fd 0 +expect eq unlink path 0 len path 0 +expect eq write 1 ok 0 len ok long len ok +ret 0 +end + +#### c2-00025 sha256=652a4bc9455251bb51d01a75fc5be0ad008ae5e022e4835e43959f073c82413d len=6428 +note Native compiler refusal driver. argv[1] names the exact compiler under test. +text infile "case.om" +text outfile "case.elf" +text errfile "case.err" +text passed "PASS 36 device/mapping compiler refusals\n" +text a "global b uint 4\nfn main to int\nr = devctl int 0 uint 21531 b 0 4\nret 0\nend\n" +text b "global b uchar 4\nfn main to int\nq = uint 21531\nr = devctl int 0 q b 0 4\nret 0\nend\n" +text c "global b uchar 4\nfn main to int\nr = devctl int 0 uint 1 b 0 4\nret 0\nend\n" +text d "text b \"four\"\nfn main to int\nr = devctl int 0 uint 21531 b 0 4\nret 0\nend\n" +text e "global b uchar 4\nfn main to int\nr = devctl long 0 uint 21531 b 0 4\nret 0\nend\n" +text f "global b uchar 4\nfn main to int\nr = devctl int 0 ulong 21531 b 0 4\nret 0\nend\n" +text g "fn main to int\nr = mapnew neg int 1 0 4096 7 34\nret 0\nend\n" +text h "fn main to int\nr = mapnew neg int 1 0 4096 3 50\nret 0\nend\n" +text j "fn main to int\nm = int 34\nr = mapnew neg int 1 0 4096 3 m\nret 0\nend\n" +text k "fn main to int\na = int 3\nr = mapnew neg int 1 0 4096 a 34\nret 0\nend\n" +text m "fn main to int\nr = mapdrop ulong 257\nret 0\nend\n" +text n "text a \"four\"\nfn main to int\nr = mapread long 257 0 a 0 4\nret 0\nend\n" +text p "global a uint 4\nfn main to int\nr = mapwrite long 257 0 a 0 4\nret 0\nend\n" +text q "fn test to long\nret mapnew neg int 1 0 4096 3 34\nend\n" +text s "global b uchar 4\nfn main to int\nr = devctl int 0 uint 3221243393 b 0 4\nret 0\nend\n" +text t "fn main to int\nr = mapnew long 0 0 4096 1 2\nret 0\nend\n" +text u "global a uchar 32\nglobal b uchar 32\nfn main to int\nr = devcall neg int 1 uint 21531 a 0 32 b 0 32\nret 0\nend\n" +text v "global a uchar 32\nglobal b uchar 32\nfn main to int\nq = uint 3223340587\nr = devcall neg int 1 q a 0 32 b 0 32\nret 0\nend\n" +text w "global a uchar 32\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 a 0 32\nret 0\nend\n" +text x "text a \"readonly\"\nglobal b uchar 32\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 b 0 32\nret 0\nend\n" +text y "global a uchar 32\ntext b \"readonly\"\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 b 0 8\nret 0\nend\n" +text z "global a uchar 32\nglobal b uint 32\nfn main to int\nr = devcall neg int 1 uint 3223340587 a 0 32 b 0 32\nret 0\nend\n" +text aa "global a uchar 32\nfn main to int\nr = uvmctl neg int 1 uint 1 a 0 32\nret 0\nend\n" +text ab "global a uchar 32\nfn main to int\nq = uint 25\nr = uvmctl neg int 1 q a 0 32\nret 0\nend\n" +text ac "text a \"readonly\"\nfn main to int\nr = uvmctl neg int 1 uint 75 a 0 8\nret 0\nend\n" +text ad "global a uint 32\nfn main to int\nr = uvmctl neg int 1 uint 25 a 0 32\nret 0\nend\n" +text ae "fn test a edit uchar 32 b edit uchar 32 to long\nret devcall neg int 1 uint 3223340587 a 0 32 b 0 32\nend\n" +text af "fn test a edit uchar 32 to long\nret uvmctl neg int 1 uint 25 a 0 32\nend\n" +text ag "fn main to int\nr = mapget long 257 0 2\nret 0\nend\n" +text ah "fn main to int\nw = int 4\nr = mapset long 257 0 w 0\nret 0\nend\n" +text aj "fn main to int\nr = mapaddr ulong 257\nret 0\nend\n" +text ak "fn main to int\nr = maphold long 68719476736 4096\nret 0\nend\n" +text am "fn main to int\nr = mapbind long 257 int 3 0 7\nret 0\nend\n" +text an "fn main to int\nr = mapbind long 257 long 3 0 3\nret 0\nend\n" +text ap "fn test to ulong\nret mapaddr long 257\nend\n" +text aq "fn test to long\nret maphold 68719476736 4096\nend\n" +global packet uchar 4096 +global status uchar 4 +global tmp uchar 1 +fn expect yes bool to void +if not yes +exit int 80 +end +end +fn source num int fd int to int +r = long 0 +want = int 9 +if eq num 0 +r = write fd a 0 len a +want = 7 +end +if eq num 1 +r = write fd b 0 len b +end +if eq num 2 +r = write fd c 0 len c +end +if eq num 3 +r = write fd d 0 len d +want = 20 +end +if eq num 4 +r = write fd e 0 len e +want = 7 +end +if eq num 5 +r = write fd f 0 len f +want = 7 +end +if eq num 6 +r = write fd g 0 len g +end +if eq num 7 +r = write fd h 0 len h +end +if eq num 8 +r = write fd j 0 len j +end +if eq num 9 +r = write fd k 0 len k +end +if eq num 10 +r = write fd m 0 len m +want = 7 +end +if eq num 11 +r = write fd n 0 len n +want = 20 +end +if eq num 12 +r = write fd p 0 len p +want = 7 +end +if eq num 13 +r = write fd q 0 len q +end +if eq num 14 +r = write fd s 0 len s +end +if eq num 15 +r = write fd t 0 len t +want = 7 +end +if eq num 16 +r = write fd u 0 len u +end +if eq num 17 +r = write fd v 0 len v +end +if eq num 18 +r = write fd w 0 len w +want = 19 +end +if eq num 19 +r = write fd x 0 len x +want = 20 +end +if eq num 20 +r = write fd y 0 len y +want = 20 +end +if eq num 21 +r = write fd z 0 len z +want = 7 +end +if eq num 22 +r = write fd aa 0 len aa +end +if eq num 23 +r = write fd ab 0 len ab +end +if eq num 24 +r = write fd ac 0 len ac +want = 20 +end +if eq num 25 +r = write fd ad 0 len ad +want = 7 +end +if eq num 26 +r = write fd ae 0 len ae +end +if eq num 27 +r = write fd af 0 len af +end +if eq num 28 +r = write fd ag 0 len ag +end +if eq num 29 +r = write fd ah 0 len ah +end +if eq num 30 +r = write fd aj 0 len aj +want = 7 +end +if eq num 31 +r = write fd ak 0 len ak +want = 7 +end +if eq num 32 +r = write fd am 0 len am +end +if eq num 33 +r = write fd an 0 len an +want = 7 +end +if eq num 34 +r = write fd ap 0 len ap +end +if eq num 35 +r = write fd aq 0 len aq +end +expect gt r 0 +ret want +end +fn main to int +expect eq argcnt 2 +size = argread 1 packet 4 4092 +expect and gt size 0 le size 4092 +put packet 0 1 +put packet 2 uchar and size 255 +put packet 3 uchar shr size 8 +for num int 36 +input = fopen infile 0 len infile 524482 384 +output = fopen outfile 0 len outfile 524482 384 +errors = fopen errfile 0 len errfile 524482 384 +expect ge input 0 +expect ge output 0 +expect ge errors 0 +want = source num int input +expect eq fseek int input 0 0 0 +pid = fork +expect ge pid 0 +if eq pid 0 +expect eq dupfd int input 0 0 0 +expect eq dupfd int output 1 0 1 +expect eq dupfd int errors 2 0 2 +r = execprog packet 0 add ulong size 4 +exit int 81 +end +expect eq waitpid int pid status 0 4 0 pid +if ne get status 0 0 +ret add num 1 +end +if ne get status 1 uchar want +ret add num 1 +end +expect eq fseek int output 0 0 0 +expect eq read int output tmp 0 1 0 +expect eq fseek int errors 0 0 0 +expect eq read int errors tmp 0 1 1 +expect eq fclose int input 0 +expect eq fclose int output 0 +expect eq fclose int errors 0 +expect eq unlink infile 0 len infile 0 +expect eq unlink outfile 0 len outfile 0 +expect eq unlink errfile 0 len errfile 0 +end +expect eq write 1 passed 0 len passed long len passed +ret 0 +end + +#### c2-00026 sha256=a8b16320610b79bd0a3e96e303d631c1a9a00b6464d963f3d79c5b4e1ff2d514 len=1943 +note An isolated local socket. The server and client are both native Omega in this program. +text path "native.sock" +text msg "native ping" +global addr uchar 110 +global buf uchar 32 +global status uchar 4 +global family int 1 +global alen ulong 1 +fn client to int +fd = socknew get family 0 1 0 +if lt fd 0 +ret 21 +end +r = connect int fd addr 0 get alen 0 +if ne r 0 +ret 22 +end +r = send int fd msg 0 len msg 0 +if ne r long len msg +ret 23 +end +r = waitio int fd 1 1000000000 +if or lt r 0 eq and r 1 0 +ret 24 +end +r = recv int fd buf 0 len buf 0 +if ne r long len msg +ret 25 +end +for i ulong len msg +if ne get buf i get msg i +ret 26 +end +end +r = fclose int fd +ret int r +end +fn serve fd int to int +r = waitio fd 1 1000000000 +if or lt r 0 eq and r 1 0 +ret 31 +end +conn = accept fd 0 +if lt conn 0 +ret 32 +end +r = waitio int conn 1 1000000000 +if or lt r 0 eq and r 1 0 +ret 33 +end +r = recv int conn buf 0 len buf 0 +if ne r long len msg +ret 34 +end +for i ulong len msg +if ne get buf i get msg i +ret 35 +end +end +r = send int conn buf 0 len msg 0 +if ne r long len msg +ret 36 +end +r = fclose int conn +ret int r +end +fn main to int +put family 0 1 +put alen 0 110 +if eq argcnt 2 +put family 0 2 +put alen 0 16 +put addr 0 2 +put addr 4 127 +put addr 7 1 +else +put addr 0 1 +for i ulong len path +put addr add i 2 get path i +end +end +fd = socknew get family 0 1 0 +if lt fd 0 +ret 1 +end +r = bind int fd addr 0 get alen 0 +if ne r 0 +ret 2 +end +if eq get family 0 2 +r = sockname int fd addr 0 get alen 0 +if ne r 16 +ret 8 +end +if and eq get addr 2 0 eq get addr 3 0 +ret 9 +end +end +r = listen int fd 1 +if ne r 0 +ret 3 +end +r = waitio int fd 1 1000000 +if ne r 0 +ret 4 +end +pid = fork +if lt pid 0 +ret 5 +end +if eq pid 0 +r = fclose int fd +ret client +end +result = serve int fd +r = waitpid int pid status 0 len status 0 +if ne r pid +ret 6 +end +if ne get status 0 0 +ret 7 +end +if ne get status 1 0 +ret int get status 1 +end +r = fclose int fd +if eq get family 0 1 +r = unlink path 0 len path +end +ret result +end + +#### c2-00027 sha256=97cee434be0cc7dc8c27b2786747e2ecdd9dc31a33c558e5c54c20f787a19ece len=436 +note process groups: setsid succeeds or returns EPERM when already a leader; on success the new +note group id must be the pid. setpgid(0,0) may succeed or return EPERM depending on that state. +fn main to int +i = getpgid 0 +if le i long 0 +ret 1 +end +s = setsid +if and lt s 0 ne s long -1 +ret 2 +end +q = getpgid 0 +if le q long 0 +ret 3 +end +if ge s 0 +if ne q getpid +ret 4 +end +end +r = setpgid 0 0 +if and ne r 0 ne r long -1 +ret 5 +end +ret 0 +end + +#### c2-00028 sha256=d36aec6170344d4c3126212a092bc021e671c24ab3bc31871562847429767c80 len=488 +text p "pio.tmp" +text body "abcdefgh" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +w = write fd body 0 len body +if ne w long len body +ret 2 +end +src = new uchar 2 0 +put src 0 88 +put src 1 89 +r = pwrite fd src 0 2 4 +if ne r 2 +ret 3 +end +buf = new uchar 8 0 +n = pread fd buf 0 8 0 +if ne n 8 +ret 4 +end +if ne get buf 4 88 +ret 5 +end +if ne get buf 5 89 +ret 6 +end +r = fclose fd +r = pwrite fd src 0 2 0 +if ge r 0 +ret 7 +end +r = unlink p 0 len p +if ne r 0 +ret 8 +end +ret 0 +end + +#### c2-00029 sha256=0c1292a905cb1263a733e26f2e026a2915089d6d6959d16b617c05f446452964 len=1996 +text child "./exec-child" +text words "two words" +text data "Omega pipe" +global packet uchar 4096 +global status uchar 4 +global fds uchar 8 +global buf uchar 32 +fn fdword off ulong to int +x = ulong 0 +for i ulong 4 +v = ulong get fds add off i +x = or x shl v mul i 8 +end +ret int x +end +fn exectest to int +put packet 0 4 +put packet 2 uchar len child +for i ulong len child +put packet add i 4 get child i +end +n = add len child 6 +put packet n uchar len words +n = add n 2 +for i ulong len words +put packet add n i get words i +end +n = add n len words +put packet n 2 +put packet add n 2 207 +put packet add n 3 128 +n = add n 4 +pid = fork +if lt pid 0 +ret 1 +end +if eq pid 0 +r = execprog packet 0 n +ret 2 +end +r = waitpid int pid status 0 len status 0 +if ne r pid +ret 3 +end +if or ne get status 0 0 ne get status 1 0 +ret 4 +end +put packet 0 1 +put packet 2 4 +put packet 4 103 +put packet 5 111 +put packet 6 110 +put packet 7 101 +r = execprog packet 0 8 +if ne r neg long 2 +ret 5 +end +ret 0 +end +fn pipetest to int +r = pipefds fds 0 len fds 524288 +if ne r 0 +ret 11 +end +rd = fdword 0 +wr = fdword 4 +r = dupfd wr 96 524288 +if ne r 96 +ret 12 +end +r = write 96 data 0 len data +if ne r long len data +ret 13 +end +r = waitio rd 1 1000000000 +if or lt r 0 eq and r 1 0 +ret 14 +end +r = read rd buf 0 len buf +if ne r long len data +ret 15 +end +for i ulong len data +if ne get data i get buf i +ret 16 +end +end +r = fclose 96 +r = fclose wr +r = fclose rd +ret 0 +end +fn stoptest to int +if le getpid 0 +ret 21 +end +start = monons +r = sleepns 1000000 +if ne r 0 +ret 22 +end +elapsed = sub monons start +if lt elapsed 1000000 +ret 23 +end +pid = fork +if lt pid 0 +ret 24 +end +if eq pid 0 +r = sleepns 5000000000 +ret 25 +end +r = killpid int pid 15 +if ne r 0 +ret 26 +end +r = waitpid int pid status 0 len status 0 +if ne r pid +ret 27 +end +if ne get status 0 15 +ret 28 +end +ret 0 +end +fn main to int +if ne add getpid getpid mul getpid 2 +ret 41 +end +if ne fclose int socknew 1 1 0 0 +ret 42 +end +r = exectest +if ne r 0 +ret r +end +r = pipetest +if ne r 0 +ret r +end +ret stoptest +end + +#### c2-00030 sha256=8355680fe35976dc5fd3621c3dc9b2ff8f6cc8b210ec90915d2044a4de133473 len=280 +text p "hs.tmp" +fn main to int +s = getsid 0 +if le s long 0 +ret 1 +end +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 2 +end +r = syncfs fd +if ne r 0 +ret 3 +end +r = shutdown fd 2 +if ge r 0 +ret 4 +end +r = fclose fd +if ne r 0 +ret 5 +end +r = unlink p 0 len p +if ne r 0 +ret 6 +end +ret 0 +end + +#### c2-00031 sha256=cf1eff4a9e12ff42141d76dd0a2eb136ca345e9cbf9f4e3ee73d70abdd7e16fb len=504 +note random A off n flags: exact byte count, not all zero, two calls differ, invalid flags negative. +fn main to int +a = new uchar 8 0 +r = random a 0 8 0 +if ne r 8 +ret 1 +end +i = ulong 0 +z = ulong 1 +while lt i 8 +if ne get a i 0 +z = ulong 0 +end +i = add i 1 +end +if eq z 1 +ret 2 +end +b = new uchar 8 0 +r = random b 0 8 0 +if ne r 8 +ret 3 +end +i = ulong 0 +same = ulong 1 +while lt i 8 +if ne get a i get b i +same = ulong 0 +end +i = add i 1 +end +if eq same 1 +ret 4 +end +r = random a 0 8 8 +if ge r 0 +ret 5 +end +ret 0 +end + +#### c2-00032 sha256=8498b995e3ee7a2d9ac86085af1674af7c14b57da5778051fc5e7a15406768dc len=1869 +note Owned low-address reservations and complete-span file binding. Host only. +text path "reserve.bin" +text mark "Z" +text msg "PASS owned reservations, collision refusal and failed-bind retirement\n" +global buf uchar 4 +global status uchar 4 +global fds int 2 +fn ck yes bool to void +if not yes +exit int 80 +end +end +fn bad k int to void +if eq k 0 +r = maphold 4096 4096 +ret +end +if eq k 1 +r = maphold 1099511627776 4096 +ret +end +if eq k 2 +r = maphold 68719476737 4096 +ret +end +if eq k 3 +r = maphold 68719476736 4097 +ret +end +if eq k 4 +r = maphold 18446744073709551615 4096 +ret +end +h = maphold 68719542272 4096 +ck gt h 0 +if eq k 5 +r = mapread h 0 buf 0 1 +ret +end +if eq k 6 +r = mapwrite h 0 mark 0 1 +ret +end +if eq k 7 +r = mapget h 0 4 +ret +end +if eq k 8 +r = mapset h 0 4 0 +ret +end +if eq k 9 +ck eq mapbind h neg int 1 0 3 neg long 9 +r = mapaddr h +ret +end +ck eq mapbind h get fds 0 0 3 0 +r = mapbind h get fds 0 0 3 +end +fn main to int +fd = fopen path 0 len path 524482 384 +ck ge fd 0 +put fds 0 int fd +ck eq fseek int fd 4095 0 4095 +ck eq write int fd mark 0 1 1 +ro = fopen path 0 len path 524288 0 +ck ge ro 0 +put fds 1 int ro +for i ulong 16 +h = maphold 68719476736 4096 +ck gt h 0 +ck eq mapaddr h 68719476736 +ck eq maphold 68719476736 4096 neg long 17 +ck eq mapbind h int fd 0 3 0 +ck eq mapread h 4095 buf 0 1 1 +ck eq get buf 0 90 +ck eq mapset h 0 4 add 123 i 0 +ck eq mapget h 0 4 add 123 i +ck eq mapdrop h 0 +end +h = maphold 68719476736 4096 +ck gt h 0 +ck eq mapbind h int ro 0 3 neg long 13 +j = maphold 68719476736 4096 +ck gt j 0 +ck ne j h +ck eq mapbind j int ro 0 1 0 +ck eq mapget j 0 4 138 +ck eq mapdrop j 0 +for k int 11 +p = fork +ck ge p 0 +if eq p 0 +bad k +exit int 80 +end +ck eq waitpid int p status 0 4 0 p +ck and eq get status 0 0 eq get status 1 103 +end +ck eq fclose int fd 0 +ck eq fclose int ro 0 +ck eq unlink path 0 len path 0 +ck eq write 1 msg 0 len msg long len msg +ret 0 +end + +#### c2-00033 sha256=0ee354c31e3e33c63da7cd8ade18cdf3f98d6d742adeedbffa506d746b5ff0c1 len=1009 +note Verify socket option effect with an independent bind outcome on an ephemeral loopback UDP port. +global addr uchar 16 +text enabled "abcd" +fn setreuse fd int option view uchar 8 to long +ret add long 9 sockopt fd 1 2 option 2 4 +end +fn main to int +option = new uchar 8 0 +put option 2 1 +put addr 0 2 +put addr 4 127 +put addr 7 1 +a = socknew 2 2 0 +if lt a 0 +ret 1 +end +b = socknew 2 2 0 +if lt b 0 +ret 2 +end +if ne setreuse int a option 9 +ret 3 +end +if ne bind int a addr 0 len addr 0 +ret 4 +end +if ne sockname int a addr 0 len addr 16 +ret 5 +end +if and eq get addr 2 0 eq get addr 3 0 +ret 6 +end +if ne bind int b addr 0 len addr neg long 98 +ret 7 +end +if ne sockopt int b 1 2 enabled 0 len enabled 0 +ret 8 +end +if ne bind int b addr 0 len addr 0 +ret 9 +end +if ne sockopt neg int 1 1 2 enabled 0 4 neg long 9 +ret 10 +end +if ne sockopt int b 1 2 enabled 0 0 neg long 22 +ret 11 +end +if ne sockopt int b 1 2147483647 enabled 0 4 neg long 92 +ret 12 +end +if ne fclose int a 0 +ret 13 +end +if ne fclose int b 0 +ret 14 +end +ret 0 +end + +#### c2-00034 sha256=6ff1b76d4fd35599e67684e706a5d66eec84584f51326c74a1fc35bec023ab60 len=621 +note stat: path-based metadata without opening the file. st_size is at byte 48 of the ARM64 stat structure. +text p "stat.tmp" +text body "abcdefgh" +text miss "no.such.file" +fn main to int +fd = int fopen p 0 len p 577 420 +if lt fd 0 +ret 1 +end +w = write fd body 0 len body +if ne w long len body +ret 2 +end +r = fclose fd +if ne r 0 +ret 3 +end +buf = new uchar 128 0 +r = stat p 0 len p buf 0 128 +if ne r 0 +ret 4 +end +if ne get buf 48 8 +ret 5 +end +k = ulong 49 +while lt k 56 bound 8 +if ne get buf k 0 +ret 6 +end +k = add k 1 +end +r = stat miss 0 len miss buf 0 128 +if ge r 0 +ret 7 +end +r = unlink p 0 len p +if ne r 0 +ret 8 +end +ret 0 +end + +#### c2-00035 sha256=628c9696acb656943ad68a4137a81fbfafdc1a1aafb59e0fe4a09332957b2600 len=233 +note stat with a 64-byte output must trap 3 before the kernel writes the 128-byte structure. +text p "short.tmp" +fn main to int +fd = int fopen p 0 len p 577 420 +z = fclose fd +buf = new uchar 64 0 +r = stat p 0 len p buf 0 64 +ret 0 +end + +#### c2-00036 sha256=8a861930643b73590772a575f62985389eb6c1daf77820d37e88a8c648171505 len=497 +note SPDX-License-Identifier: AGPL-3.0-only +note Combined gate: a struct value drives a native file operation in one program. +struct H x uint y ulong end +text path "structfile.tmp" +text body "ok\n" +fn main to int +h = new H 7 9 +put h y 42 +fd = int fopen path 0 len path 577 420 +if lt fd 0 +ret 1 +end +n = write fd body 0 len body +r = fclose fd +u = unlink path 0 len path +if ne n long len body +ret 2 +end +if ne r 0 +ret 3 +end +if ne u 0 +ret 4 +end +if eq get h x 7 +if eq get h y 42 +ret 0 +end +end +ret 5 +end + +#### c2-00037 sha256=6a48633d31aa718ca9bd543a3c0ec134318d74005b31e6424bd4b0f920963764 len=563 +note ftrunc: write 8 bytes, shorten to 4, rewind, read 4 then EOF; a closed descriptor is refused. +text p "trunc.tmp" +text body "abcdefgh" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +n = write fd body 0 len body +if ne n long len body +ret 2 +end +r = ftrunc fd 4 +if ne r 0 +ret 3 +end +r = fseek fd 0 0 +if ne r 0 +ret 4 +end +buf = new uchar 8 0 +n = read fd buf 0 8 +if ne n 4 +ret 5 +end +m = read fd buf 0 8 +if ne m 0 +ret 6 +end +r = fclose fd +if ne r 0 +ret 7 +end +r = ftrunc fd 0 +if ge r 0 +ret 8 +end +r = unlink p 0 len p +if ne r 0 +ret 9 +end +ret 0 +end + +#### c2-00038 sha256=53dab870239429150e88616fe5173a0ad8637719cc15eac7bbf955f0e5662b3d len=517 +note truncate: path form of ftrunc; st_size at byte 48 becomes 4, a missing path returns negative. +text p "tr.tmp" +text body "abcdefgh" +text miss "no.such.file" +fn main to int +fd = int fopen p 0 len p 578 420 +if lt fd 0 +ret 1 +end +w = write fd body 0 len body +r = fclose fd +r = truncate p 0 len p 4 +if ne r 0 +ret 2 +end +st = new uchar 128 0 +r = stat p 0 len p st 0 128 +if ne r 0 +ret 3 +end +if ne get st 48 4 +ret 4 +end +r = truncate miss 0 len miss 4 +if ge r 0 +ret 5 +end +r = unlink p 0 len p +if ne r 0 +ret 6 +end +ret 0 +end + +#### c2-00039 sha256=1e7b46b9d0fb44f5c97768f92daa7599e9b36e6d5cbc6553ac755a7c02047b5f len=1262 +note Host only: every allowed UVM request uses an invalid fd, never a GPU. +global data uchar 9280 +global status uchar 4 +text msg "PASS bounded native UVM requests\n" +fn ck yes bool to void +if not yes +exit int 80 +end +end +fn bad k int to long +if eq k 0 +ret uvmctl neg int 1 uint 33 data 0 9263 +end +if eq k 1 +ret uvmctl neg int 1 uint 33 data 0 9265 +end +if eq k 2 +ret uvmctl neg int 1 uint 33 data 17 9264 +end +ret uvmctl neg int 1 uint 75 data 18446744073709551615 8 +end +fn main to int +ck eq uvmctl neg int 1 uint 805306369 data 8 16 neg long 9 +ck eq uvmctl neg int 1 uint 75 data 8 8 neg long 9 +ck eq uvmctl neg int 1 uint 37 data 8 40 neg long 9 +ck eq uvmctl neg int 1 uint 38 data 8 20 neg long 9 +ck eq uvmctl neg int 1 uint 25 data 8 32 neg long 9 +ck eq uvmctl neg int 1 uint 26 data 8 20 neg long 9 +ck eq uvmctl neg int 1 uint 27 data 8 56 neg long 9 +ck eq uvmctl neg int 1 uint 28 data 8 28 neg long 9 +ck eq uvmctl neg int 1 uint 33 data 8 9264 neg long 9 +ck eq uvmctl neg int 1 uint 34 data 8 24 neg long 9 +ck eq add uvmctl neg int 1 uint 73 data 8 24 10 1 +for k int 4 +p = fork +ck ge p 0 +if eq p 0 +r = bad k +exit int 80 +end +ck eq waitpid int p status 0 4 0 p +ck eq get status 0 0 +ck eq get status 1 103 +end +ck eq write 1 msg 0 len msg long len msg +ret 0 +end + +#### c2-00040 sha256=74620988c967f18f9757807fc1d6f713c3120513c2a4a4aaba671e3019e8865e len=68349 +note omc: the Omega compiler written in Omega (the om4 subset). Reads Omegese on stdin, writes a runnable +note AArch64 Linux program (or bare function words) on stdout. Built first by om4; its codegen matches om4 +note byte for byte on the original subset (seed chain rung 5, ledger L408). Native host operations +note extend that subset; om4 still builds this compiler, and the compiler rebuilds itself identically. +note All compiler state lives in fixed global pools (decision 24: no heap). Every working value is a ulong +note (raw 64 bits) so the language's checked conversions never fire on om4's untyped-register logic. + +note ---- input, output, token ---- +global inp uchar 8388608 +global inlen ulong 1 +global cur ulong 1 +global line ulong 1 +global tk ulong 1 +global tw ulong 1 +global tl ulong 1 +global ts ulong 1 +global tbig ulong 1 +global out uchar 8388608 +global oc ulong 1 + +note ---- name table (1024 names in scope): packed name, register, type, length, kind, address ---- +global nm_name ulong 1024 +global nm_reg uchar 1024 +global nm_type uchar 1024 +global nm_len ulong 1024 +global nm_kind uchar 1024 +global nm_addr ulong 1024 +global nn ulong 1 + +note ---- function table (512): name, address (byte offset in out), return type, parameter count, +note per-parameter type/length/kind (6 each), name length, name offset in the input ---- +global fn_name ulong 512 +global fn_addr ulong 512 +global fn_ret uchar 512 +global fn_np uchar 512 +global fn_pt uchar 3072 +global fn_pl ulong 3072 +global fn_pk uchar 3072 +global fn_nmlen ulong 512 +global fn_off ulong 512 +global nf ulong 1 +global lastfn ulong 1 +global scanning ulong 1 +global ncalls ulong 1 +global callsite ulong 65536 +global callfrom ulong 65536 +global callto ulong 65536 +global settled uchar 512 + + +note ---- compiler state ---- +global npar ulong 1 +global held ulong 1 +global nslot ulong 1 +global curret ulong 1 +global progmode ulong 1 +global nglob ulong 1 +global hostargs ulong 1 +global stkbytes ulong 1 +global dead ulong 1 +global poolb ulong 1 + +note ======== leaf helpers ======== + +note poolc: the i-th register of the pool x0..x6, x8..x15, x17 (x7 is the runtime, x16 scratch) +fn poolc i ulong to ulong +if lt i 7 +ret i +end +if lt i 15 +ret add i 1 +end +ret 17 +end + +note ---- error reporting ---- +global msg uchar 64 +global mc ulong 1 + +fn mputb b uchar to void +m = get mc 0 +put msg m b +put mc 0 add m 1 +end + +fn mputn v ulong to void +d = new uchar 20 0 +i = ulong 0 +x = v +put d 0 uchar add rem x 10 48 +x = div x 10 +i = add i 1 +while gt x 0 +put d i uchar add rem x 10 48 +x = div x 10 +i = add i 1 +end +j = i +while gt j 0 +j = sub j 1 +mputb get d j +end +end + +note fail: write "omc: line N: error E" to stderr (fd 2) and exit with the code +fn fail code ulong to void +put mc 0 0 +mputb 111 +mputb 109 +mputb 99 +mputb 58 +mputb 32 +mputb 108 +mputb 105 +mputb 110 +mputb 101 +mputb 32 +mputn get line 0 +mputb 58 +mputb 32 +mputb 101 +mputb 114 +mputb 114 +mputb 111 +mputb 114 +mputb 32 +mputn code +mputb 10 +w = write 2 msg 0 get mc 0 +exit int code +end + +note emitb / emit: one byte / one 32-bit word (little-endian) to the output; error 14 when it is full +note (om4 EMIT, EMITB: the 8 MiB output area) +fn emitb b uchar to void +o = get oc 0 +if ge o 8388608 +fail 14 +end +put out o b +put oc 0 add o 1 +end + +fn emit w ulong to void +if ge get oc 0 8388608 +fail 14 +end +emitb uchar and w 255 +emitb uchar and shr w 8 255 +emitb uchar and shr w 16 255 +emitb uchar and shr w 24 255 +end + +note tok_num: the word at [ts,cur) is [-]decimal, at most 20 digits, from -2^63 to 2^64 - 1 (error 6 +note bad number, 8 out of range). tw = its raw 64 bits (a negative one as two's complement); tbig = 1 +note when it is 2^63 or more (only a ulong holds it), else 0. As om4's TK_NUM. +fn tok_num to void +p = get ts 0 +e = get cur 0 +minus = false +if eq get inp p 45 +minus = true +p = add p 1 +end +ndig = sub e p +if eq ndig 0 +fail 6 +end +if gt ndig 20 +fail 6 +end +v = ulong 0 +lim = ulong 1844674407370955161 +i = p +while lt i e +d = sub ulong get inp i 48 +if gt d 9 +fail 6 +end +if gt v lim +fail 8 +end +if and eq v lim gt d 5 +fail 8 +end +v = add mul v 10 d +i = add i 1 +end +half = shl ulong 1 63 +put tbig 0 0 +if minus +if gt v half +fail 8 +end +put tw 0 sub ulong 0 v +else +if ge v half +put tbig 0 1 +end +put tw 0 v +end +put tk 0 2 +end + +note tok_text: a text literal starting at the opening quote. tw = first byte offset, tl = source length +note (escapes not yet decoded). Ends at an unescaped '"' on the same line, followed by a blank/end. Err 22. +note (Loops over the input are two loops, the inner under 1000000 passes: om4 has no pass limit.) +fn tok_text to void +put cur 0 add get cur 0 1 +put tw 0 get cur 0 +go = true +while go +n = ulong 0 +while and go lt n 999999 +if ge get cur 0 get inlen 0 +fail 22 +end +b = get inp get cur 0 +if eq b 10 +fail 22 +end +if eq b 34 +go = false +else +put cur 0 add get cur 0 1 +if eq b 92 +if ge get cur 0 get inlen 0 +fail 22 +end +if eq get inp get cur 0 10 +fail 22 +end +put cur 0 add get cur 0 1 +end +end +n = add n 1 +end +end +put tl 0 sub get cur 0 get tw 0 +put cur 0 add get cur 0 1 +put tk 0 4 +if lt get cur 0 get inlen 0 +if gt get inp get cur 0 32 +fail 22 +end +end +end + +note tok2: a word at cur with first byte c; packs 8 bytes into tw, sets tl and ts. A '"' is a text; a +note first byte '-' or a digit is a number. +fn tok2 c uchar to void +if eq c 34 +tok_text +ret +end +put ts 0 get cur 0 +w = ulong 0 +sh = ulong 0 +n = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge get cur 0 get inlen 0 +go = false +else +b = get inp get cur 0 +if le b 32 +go = false +else +if lt n 8 +w = or w shl ulong b sh +sh = add sh 8 +end +n = add n 1 +put cur 0 add get cur 0 1 +end +end +m = add m 1 +end +end +put tw 0 w +put tl 0 n +f = get inp get ts 0 +isnum = false +if eq f 45 +isnum = true +end +if and ge f 48 le f 57 +isnum = true +end +if isnum +tok_num +else +put tk 0 1 +end +end + +note tok: next word, skipping blanks (space, tab, carriage return); newline is end of line (kind 0) and +note bumps the line number; another byte below 32 is error 16; the end of the input is kind 3. om4 TOK. +fn tok to void +go = true +while go +n = ulong 0 +while and go lt n 999999 +if ge get cur 0 get inlen 0 +go = false +else +c = get inp get cur 0 +if or or eq c 32 eq c 9 eq c 13 +put cur 0 add get cur 0 1 +else +if eq c 10 +put cur 0 add get cur 0 1 +put line 0 add get line 0 1 +put tk 0 0 +ret +end +if lt c 32 +fail 16 +end +tok2 c +ret +end +end +n = add n 1 +end +end +put tk 0 3 +end + +note ======== keyword lookup (original om4 KWTAB plus hand-maintained native host words 100..134) ======== +note genkw.awk describes the original om4 table only; retain the native host extension on regeneration. +fn kw w ulong to ulong +if eq w 6584163 +ret 132 +end +packed = or ulong 114 shl ulong 101 8 +packed = or packed shl ulong 97 16 +packed = or packed shl ulong 100 24 +packed = or packed shl ulong 108 32 +packed = or packed shl ulong 110 40 +packed = or packed shl ulong 107 48 +if eq w packed +ret 133 +end +packed = or ulong 115 shl ulong 111 8 +packed = or packed shl ulong 99 16 +packed = or packed shl ulong 107 24 +packed = or packed shl ulong 111 32 +packed = or packed shl ulong 112 40 +packed = or packed shl ulong 116 48 +if eq w packed +ret 134 +end +if eq w 1819242338 +ret 1 +end +if eq w 491260502901 +ret 2 +end +if eq w 14453 +ret 2 +end +if eq w 128034844210037 +ret 3 +end +if eq w 3551605 +ret 3 +end +if eq w 1953393013 +ret 4 +end +if eq w 3289973 +ret 4 +end +if eq w 444234427509 +ret 5 +end +if eq w 3421813 +ret 5 +end +if eq w 1702132066 +ret 6 +end +if eq w 14441 +ret 6 +end +if eq w 500136110195 +ret 7 +end +if eq w 3551593 +ret 7 +end +if eq w 7630441 +ret 8 +end +if eq w 3289961 +ret 8 +end +if eq w 1735290732 +ret 9 +end +if eq w 3421801 +ret 9 +end +if eq w 6579297 +ret 33 +end +if eq w 6452595 +ret 34 +end +if eq w 7107949 +ret 35 +end +if eq w 7760228 +ret 36 +end +if eq w 7169394 +ret 37 +end +if eq w 6581857 +ret 38 +end +if eq w 29295 +ret 39 +end +if eq w 7499640 +ret 40 +end +if eq w 7104627 +ret 41 +end +if eq w 7497843 +ret 42 +end +if eq w 29029 +ret 43 +end +if eq w 25966 +ret 44 +end +if eq w 29804 +ret 45 +end +if eq w 25964 +ret 46 +end +if eq w 29799 +ret 47 +end +if eq w 25959 +ret 48 +end +if eq w 6776174 +ret 49 +end +if eq w 7630702 +ret 50 +end +if eq w 7628135 +ret 51 +end +if eq w 7234924 +ret 52 +end +if eq w 1684104562 +ret 53 +end +if eq w 435744764535 +ret 54 +end +if eq w 1702195828 +ret 55 +end +if eq w 435728179558 +ret 56 +end +if eq w 2003134838 +ret 57 +end +if eq w 1953064037 +ret 58 +end +if eq w 28262 +ret 64 +end +if eq w 28532 +ret 65 +end +if eq w 6581861 +ret 66 +end +if eq w 26217 +ret 67 +end +if eq w 1702063205 +ret 68 +end +if eq w 435610544247 +ret 69 +end +if eq w 431349919586 +ret 70 +end +if eq w 7499622 +ret 71 +end +if eq w 7628146 +ret 72 +end +if eq w 61 +ret 73 +end +if eq w 40 +ret 74 +end +if eq w 41 +ret 75 +end +if eq w 1684631414 +ret 76 +end +if eq w 119165519096935 +ret 78 +end +if eq w 1954047348 +ret 79 +end +if eq w 7632240 +ret 80 +end +if eq w 1701147238 +ret 81 +end +if eq w 1953069157 +ret 82 +end +if eq w 1702129518 +ret 83 +end +if eq w 7824750 +ret 84 +end +if eq w 461195539042 +ret 77 +end +if eq w 1885434484 +ret 77 +end +if eq w 7239535 +ret 77 +end +if eq w 7308604897168158579 +ret 131 +end +if eq w 126918101919090 +ret 130 +end +if eq w 7453301735350958181 +ret 124 +end +if eq w 32481142782190962 +ret 125 +end +if eq w 491394461042 +ret 126 +end +if eq w 28263429247363435 +ret 127 +end +if eq w 32480013273033072 +ret 128 +end +if eq w 110404021020007 +ret 129 +end +if eq w 122498715312503 +ret 123 +end +if eq w 32497639802299751 +ret 113 +end +if eq w 32760384594014051 +ret 114 +end +if eq w 1684957538 +ret 115 +end +if eq w 28263429381382519 +ret 116 +end +if eq w 499851228006 +ret 117 +end +if eq w 1986225522 +ret 118 +end +if eq w 1684956531 +ret 119 +end +if eq w 32491051338263667 +ret 120 +end +if eq w 128017462948449 +ret 121 +end +if eq w 28254586010038881 +ret 122 +end +if eq w 111546465018726 +ret 100 +end +if eq w 427055215462 +ret 101 +end +if eq w 110429739705190 +ret 102 +end +if eq w 461262648166 +ret 103 +end +if eq w 33607047151054707 +ret 104 +end +if eq w 121382024472940 +ret 105 +end +if eq w 128026086171489 +ret 106 +end +if eq w 1802661734 +ret 107 +end +if eq w 431215375716 +ret 108 +end +if eq w 126918153105261 +ret 109 +end +if eq w 474148269926 +ret 110 +end +if eq w 118121959288437 +ret 111 +end +if eq w 32204027264196973 +ret 112 +end +ret 0 +end + +note ======== om4's small tables, as functions ======== +note twid: width in bits by type 0..9 (bool 1; uchar ushort uint ulong; byte short int long) +fn twid t ulong to ulong +if eq t 1 +ret 1 +end +if or eq t 2 eq t 6 +ret 8 +end +if or eq t 3 eq t 7 +ret 16 +end +if or eq t 4 eq t 8 +ret 32 +end +if or eq t 5 eq t 9 +ret 64 +end +ret 0 +end + +note tlog: log2 of the element size by type +fn tlog t ulong to ulong +if or eq t 3 eq t 7 +ret 1 +end +if or eq t 4 eq t 8 +ret 2 +end +if or eq t 5 eq t 9 +ret 3 +end +ret 0 +end + +note regidx: the pool index of register r (the inverse of poolc; 255 for x7 and x16) +fn regidx r ulong to ulong +if lt r 7 +ret r +end +if eq r 7 +ret 255 +end +if lt r 16 +ret sub r 1 +end +if eq r 16 +ret 255 +end +ret 15 +end + +note conds: the condition for eq ne lt le gt ge (i = 2 (op - 43) + 1 when signed): EQ 0, NE 1, LO 3 / LT 11, +note LS 9 / LE 13, HI 8 / GT 12, HS 2 / GE 10 (Arm ARM Table C1-1). The opposite condition is cond xor 1. +fn conds i ulong to ulong +if lt i 2 +ret 0 +end +if lt i 4 +ret 1 +end +if eq i 4 +ret 3 +end +if eq i 5 +ret 11 +end +if eq i 6 +ret 9 +end +if eq i 7 +ret 13 +end +if eq i 8 +ret 8 +end +if eq i 9 +ret 12 +end +if eq i 10 +ret 2 +end +ret 10 +end + +note ldop / stop: register-offset load / store by element type (om4 LDOP, STOP tables) +fn ldop t ulong to ulong +note LDRB 0x38606800, LDRH 0x78607800, LDR w 0xb8607800, LDR x 0xf8607800, LDRSB 0x38a06800, +note LDRSH 0x78a07800, LDRSW 0xb8a07800 +if eq t 2 +ret 945842176 +end +if eq t 3 +ret 2019588096 +end +if eq t 4 +ret 3093329920 +end +if or eq t 5 eq t 9 +ret 4167071744 +end +if eq t 6 +ret 950036480 +end +if eq t 7 +ret 2023782400 +end +if eq t 8 +ret 3097524224 +end +ret 0 +end + +fn stop t ulong to ulong +note STRB 0x38206800, STRH 0x78207800, STR w 0xb8207800, STR x 0xf8207800 +if or eq t 2 eq t 6 +ret 941647872 +end +if or eq t 3 eq t 7 +ret 2015393792 +end +if or eq t 4 eq t 8 +ret 3089135616 +end +if or eq t 5 eq t 9 +ret 4162877440 +end +ret 0 +end + +note ---- trap list (8192 sites per function): output offset of the branch, trap code ---- +global tsite ulong 8192 +global tcode ulong 8192 +global nt ulong 1 +note ---- block stack (512): kind (1 if, 2 else, 3 while, 4 for), branch to patch, loop head, loop +note register, its type, names and held pool slots to restore at end, then-part ended (for else) ---- +global bkind ulong 512 +global bbr ulong 512 +global bhead ulong 512 +global breg ulong 512 +global btyp ulong 512 +global bnames ulong 512 +global bheld ulong 512 +global bdead ulong 512 +global nb ulong 1 +global curfn ulong 1 + +note ======== names and functions ======== +note findname: packed name -> its index + 1 among the names in scope (0 none). om4 FINDNAME. +fn findname w ulong to ulong +i = ulong 0 +n = get nn 0 +while lt i n +if eq get nm_name i w +ret add i 1 +end +i = add i 1 +end +ret 0 +end + +note findfn: packed name w (first 8 bytes), length l (any value up to 8 for a short name), start s in the +note input (read only for a name over 8 bytes) -> function index + 1 (0 none). om4 FINDFN. +fn findfn w ulong l ulong s ulong to ulong +j = ulong 0 +while lt j get nf 0 +if eq get fn_name j w +fl = get fn_nmlen j +if le l 8 +if le fl 8 +ret add j 1 +end +else +if eq fl l +o = get fn_off j +k = ulong 8 +same = true +while and same lt k l +a = get inp add o k +if ne a get inp add s k +same = false +end +k = add k 1 +end +if same +ret add j 1 +end +end +end +end +j = add j 1 +end +ret 0 +end + +note newname: the name must not be in use (a name in scope when 8 bytes or fewer, or a function): error 10 +fn newname w ulong l ulong s ulong to void +if le l 8 +if ne findname w 0 +fail 10 +end +end +if ne findfn w l s 0 +fail 10 +end +end + +note addname: packed name, register, type, length, kind, address. om4 ADDNAME. +fn addname w ulong r ulong t ulong ln ulong k ulong a ulong to void +n = get nn 0 +if ge n 1024 +fail 14 +end +put nm_name n w +put nm_reg n uchar r +put nm_type n uchar t +put nm_len n ln +put nm_kind n uchar k +put nm_addr n a +put nn 0 add n 1 +end + +note ======== registers and words ======== +note alloc: the next free register of the pool (after the parameters); error 12 when none is left +fn alloc to ulong +i = add get npar 0 get nslot 0 +if ge i 16 +fail 12 +end +put nslot 0 add get nslot 0 1 +ret poolc i +end + +note destreg: d, or a new temporary when d is 255 +fn destreg d ulong to ulong +if eq d 255 +ret alloc +end +ret d +end + +note e3: emit op | d | n << 5 | m << 16 +fn e3 op ulong d ulong n ulong m ulong to void +emit or or or op d shl n 5 shl m 16 +end + +note trapsite: note the place and code of a branch to the trap stub, then emit it. trapc: B.cond, as om4. +fn trapsite w ulong code ulong to void +n = get nt 0 +if ge n 8192 +fail 14 +end +put tsite n get oc 0 +put tcode n code +put nt 0 add n 1 +emit w +end + +fn trapc cc ulong code ulong to void +trapsite or 1409286144 cc code +end + +fn rdword at ulong to ulong +a = ulong get out at +b = shl ulong get out add at 1 8 +c = shl ulong get out add at 2 16 +d = shl ulong get out add at 3 24 +ret or or or a b c d +end + +fn wrword at ulong w ulong to void +put out at uchar and w 255 +put out add at 1 uchar and shr w 8 255 +put out add at 2 uchar and shr w 16 255 +put out add at 3 uchar and shr w 24 255 +end + +note patch19: the word distance from a B.cond / CBZ / CBNZ at `at` to `target`, into bits 5..23 +fn patch19 at ulong target ulong to void +d = and shr sub target at 2 524287 +wrword at or rdword at shl d 5 +end + +note patch26: the word distance from a B at `at` to `target`, into bits 0..25 +fn patch26 at ulong target ulong to void +d = and shr sub target at 2 67108863 +wrword at or rdword at d +end + +note back: emit B to an earlier place (C6.2.35) +fn back addr ulong to void +emit or 335544320 and shr sub addr get oc 0 2 67108863 +end + +note matconst: put a 64-bit value in register r: MOVZ (C6.2.285) or, for a value with the top bit set, +note MOVN (C6.2.284) with the first halfword that differs from the fill, then MOVK (C6.2.283) for each +note other such halfword. om4 MATCONST. +fn matconst r ulong v ulong to void +fill = ulong 0 +mop = ulong 3531603968 +if ne shr v 63 0 +fill = ulong 65535 +mop = ulong 2457862144 +end +started = false +hw = ulong 0 +while lt hw 4 +h = and shr v shl hw 4 65535 +if ne h fill +if started +emit or or or 4068474880 shl h 5 shl hw 21 r +else +emit or or or mop shl xor h fill 5 shl hw 21 r +started = true +end +end +hw = add hw 1 +end +if not started +emit or mop r +end +end + +note canon: u8/u16/u32 UBFM Xr, Xr, #0, #w-1 (C6.2.487); i8/i16/i32 SBFM (C6.2.355); else nothing +fn canon r ulong t ulong to void +if lt t 2 +ret +end +if eq t 5 +ret +end +if eq t 9 +ret +end +base = ulong 3544186880 +if gt t 5 +base = ulong 2470445056 +end +emit or or or base shl sub twid t 1 10 r shl r 5 +end + +note chkext: CMP Xr, Wr, SXTB/SXTH/SXTW (SUBS extended, C6.2.463), then B.NE trap code +fn chkext r ulong t ulong code ulong to void +emit or or or 3944742943 shl sub t 2 13 shl r 16 shl r 5 +trapc 1 code +end + +note range: error 8 unless v is a value of type t; big = the number was written as 2^63 or more +fn range v ulong t ulong big ulong to void +w = twid t +if eq w 64 +if eq t 9 +if ne big 0 +fail 8 +end +ret +end +if ne big 0 +ret +end +if ne shr v 63 0 +fail 8 +end +ret +end +if ne big 0 +fail 8 +end +lim = shl ulong 1 w +if lt t 6 +if ge v lim +fail 8 +end +ret +end +half = shr lim 1 +if ge add v half lim +fail 8 +end +end + +note cset: CSET Xr, cond = CSINC Xr, XZR, XZR, opposite cond (C6.2.141) +fn cset r ulong cc ulong to void +emit or or 2594113504 r shl xor cc 1 12 +end + +note force: put a value (kind 1 register, 3 number, 4 flags) in register r; a bare number is error 11 +fn force k ulong v ulong t ulong r ulong to void +if eq k 1 +if ne v r +emit or or 2852127712 r shl v 16 +end +ret +end +if eq k 3 +matconst r v +ret +end +if eq k 4 +cset r v +ret +end +fail 11 +end + +note matreg: a register holding the value +fn matreg k ulong v ulong t ulong to ulong +if eq k 1 +ret v +end +r = alloc +force k v t r +ret r +end + +note spop: ADD (C6.2.5) / SUB (C6.2.457) SP, SP by a multiple of 16 below 2^24: low 12 bits, then the +note high 12 bits LSL 12; nothing for a zero part +fn spop base ulong bytes ulong to void +lo = and bytes 4095 +if ne lo 0 +emit or or base 1023 shl lo 10 +end +hi = and shr bytes 12 4095 +if ne hi 0 +emit or or base 4195327 shl hi 10 +end +end + +fn spadd bytes ulong to void +spop 2432696320 bytes +end + +fn spsub bytes ulong to void +spop 3506438144 bytes +end + +note stkchk: program mode only: CMP SP, X28 (C6.2.463); B.LO trap 6 +fn stkchk to void +if ne get progmode 0 0 +emit 3946603519 +trapc 3 6 +end +end + +note epi: give back the stack of the local arrays, then RET (C6.2.338) +fn epi to void +spadd get stkbytes 0 +emit 3596551104 +end + +fn dead1 to void +put dead 0 1 +end + +note pushb / pushnh: open a block (om4 PUSHB, split in two because a call takes at most 6 values) +fn pushb br ulong k ulong head ulong reg ulong ty ulong to void +n = get nb 0 +if ge n 512 +fail 14 +end +put bkind n k +put bbr n br +put bhead n head +put breg n reg +put btyp n ty +put bdead n 0 +put nb 0 add n 1 +end + +fn pushnh names ulong hd ulong to void +n = sub get nb 0 1 +put bnames n names +put bheld n hd +end + +note ======== small readers ======== +fn elemtype t ulong to void +if lt t 2 +fail 9 +end +end + +note arrlen: an array length 1 .. 16777216 (error 8 below, 23 above, 23 when written as 2^63 or more) +fn arrlen v ulong to void +if ne get tbig 0 0 +fail 23 +end +if or eq v 0 ne shr v 63 0 +fail 8 +end +if gt v 16777216 +fail 23 +end +end + +note typeword: read a type name -> 1..9 +fn typeword to ulong +tok +k = get tk 0 +if eq k 0 +fail 4 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +c = kw get tw 0 +if eq c 76 +fail 9 +end +if gt sub c 1 8 +fail 16 +end +ret c +end + +note eol: the line must end here +fn eol to void +tok +k = get tk 0 +if and ne k 0 ne k 3 +fail 5 +end +end + +note arrname: read an array name -> its index + 1 +fn arrname to ulong +tok +k = get tk 0 +if eq k 0 +fail 4 +end +if eq k 3 +fail 4 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +e = findname get tw 0 +if eq e 0 +fail 3 +end +if eq get nm_kind sub e 1 0 +fail 7 +end +ret e +end + +note topname: read a new name for a global or a text -> its packed word +fn topname to ulong +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +ret w +end + +note ---- value results (om4 x0 kind 1 register / 2 bare number / 3 typed number / 4 flags, x1 register, +note number or condition, x2 type). fr: 32 cells per value nesting depth 0..1024: 0..5 the two operands of +note a binary op (kind, value, type each), 8..25 a call's arguments (kind, value, array name each) ---- +global rk ulong 1 +global rv ulong 1 +global rt ulong 1 +global fr ulong 32800 +global depth ulong 1 + +note ======== BINOP (om4 BINOP and its BO_* parts): two values already read, types settled ======== +note bo_w3: emit fx | rd | ra << 5 | (imm12 << 10, or rb << 16) +fn bo_w3 fx ulong rd ulong ra ulong rb ulong imm ulong to void +if ne imm 0 +emit or or or fx rd shl ra 5 shl rb 10 +else +emit or or or fx rd shl ra 5 shl rb 16 +end +end + +note bo_fix: after a 64-bit op on rd: u8/u16/u32 wrap (canon), i8/i16/i32 overflow check (trap 1) +fn bo_fix rd ulong ty ulong to void +if lt ty 6 +canon rd ty +ret +end +if eq ty 9 +ret +end +chkext rd ty 1 +end + +note bo_schk: a shift amount in a register must be below the width: CMP Xb, #w; B.HS trap 7 +fn bo_schk ty ulong rb ulong to void +emit or or 4043309087 shl twid ty 10 shl rb 5 +trapc 2 7 +end + +note add, sub: u32 the 32-bit form; i64 ADDS/SUBS + B.VS trap 1; others 64-bit then bo_fix (om4 BO_ADD) +fn bo_add op ulong ty ulong ra ulong rb ulong imm ulong rd ulong to void +fx = ulong 2332033024 +if eq op 34 +fx = ulong 3405774848 +end +if ne imm 0 +fx = ulong 2432696320 +if eq op 34 +fx = ulong 3506438144 +end +end +if eq ty 4 +bo_w3 xor fx 2147483648 rd ra rb imm +ret +end +if eq ty 9 +bo_w3 or fx 536870912 rd ra rb imm +trapc 6 1 +ret +end +bo_w3 fx rd ra rb imm +bo_fix rd ty +end + +note mul: i64 SMULH t, MUL, CMP t, rd, ASR #63, B.NE trap 1 (om4 BO_MUL) +fn bo_mul ty ulong ra ulong rb ulong rd ulong to void +if eq ty 9 +t = alloc +e3 2604694528 t ra rb +bo_w3 2600500224 rd ra rb 0 +e3 3951098911 0 t rd +trapc 1 1 +ret +end +if eq ty 4 +bo_w3 453016576 rd ra rb 0 +ret +end +bo_w3 2600500224 rd ra rb 0 +bo_fix rd ty +end + +note div, rem (om4 BO_DIV, BO_SDIV): CBZ Xb trap 2 unless fl bit 1 (b a number other than 0); UDIV or +note SDIV; rem: t = a / b, rd = a - t * b (MSUB); i64 div: CMN Xb, #1; B.NE +3; NEGS XZR, Xa; B.VS trap 1, +note unless fl bit 2 (b a number other than -1) +fn bo_div op ulong ty ulong ra ulong rb ulong rd ulong fl ulong to void +if eq and fl 1 0 +trapsite or 3019898880 rb 2 +end +if eq op 37 +t = alloc +if ge ty 6 +e3 2596277248 t ra rb +else +e3 2596276224 t ra rb +end +e3 or 2600501248 shl ra 10 rd t rb +ret +end +if lt ty 6 +bo_w3 2596276224 rd ra rb 0 +ret +end +if eq ty 9 +if eq and fl 2 0 +emit or 2969568287 shl rb 5 +emit 1409286241 +emit or 3942646783 shl ra 16 +trapc 6 1 +end +end +bo_w3 2596277248 rd ra rb 0 +if ne ty 9 +bo_fix rd ty +end +end + +note and, or, xor (om4 BO_LOG) +fn bo_log op ulong ra ulong rb ulong rd ulong to void +fx = ulong 2315255808 +if eq op 39 +fx = ulong 2852126720 +end +if eq op 40 +fx = ulong 3388997632 +end +bo_w3 fx rd ra rb 0 +end + +note bo_lsl: LSL Xd, Xn, #s as UBFM Xd, Xn, #(64-s) mod 64, #63-s +fn bo_lsl ra ulong s ulong rd ulong to void +r = shl and sub 64 s 63 16 +r = or r shl sub 63 s 10 +r = or r shl ra 5 +emit or or 3544186880 r rd +end + +note shl (om4 BO_SHL, BS_64): by a number s: UBFM Xd, Xn, #(64-s) mod 64, #63-s; by a register: the amount +note check, LSLV; i64: t = a << s, X16 = t >> s arithmetic, CMP X16, Xa, B.NE trap 1, MOV Xd, Xt +fn bo_shl ty ulong ra ulong rb ulong imm ulong rd ulong to void +if eq ty 9 +t = alloc +if ne imm 0 +bo_lsl ra rb t +emit or or 2470509584 shl rb 16 shl t 5 +else +bo_schk ty rb +e3 2596282368 t ra rb +e3 2596284432 0 t rb +end +emit or 3942646303 shl ra 16 +trapc 1 1 +emit or or 2852127712 rd shl t 16 +ret +end +if ne imm 0 +bo_lsl ra rb rd +bo_fix rd ty +ret +end +bo_schk ty rb +if eq ty 4 +bo_w3 448798720 rd ra rb 0 +ret +end +bo_w3 2596282368 rd ra rb 0 +bo_fix rd ty +end + +note shr: unsigned LSR, signed ASR; by a number UBFM / SBFM Xd, Xn, #s, #63; by a register the amount check +note then LSRV / ASRV (om4 BO_SHR) +fn bo_shr ty ulong ra ulong rb ulong imm ulong rd ulong to void +if ne imm 0 +fi = ulong 3544251392 +if ge ty 6 +fi = ulong 2470509568 +end +emit or or or fi shl rb 16 shl ra 5 rd +ret +end +bo_schk ty rb +fx = ulong 2596283392 +if ge ty 6 +fx = ulong 2596284416 +end +bo_w3 fx rd ra rb 0 +end + +note comparisons: CMP Xa, #imm or CMP Xa, Xb; the result is the flags and a condition (om4 BO_CMP) +fn bo_cmp op ulong ty ulong ra ulong rb ulong imm ulong to void +if ne imm 0 +emit or or 4043309087 shl rb 10 shl ra 5 +else +emit or or 3942645791 shl rb 16 shl ra 5 +end +i = mul sub op 43 2 +if ge ty 6 +i = add i 1 +end +put rk 0 4 +put rv 0 conds i +put rt 0 1 +end + +note binop: op 33..48, destination (255 none), ix the fr slot of a (kind, number/register, type) then b. +note Result in rk/rv/rt. om4 BINOP. +fn binop op ulong dst ulong ix ulong to void +ty = get fr add ix 2 +ra = matreg get fr ix get fr add ix 1 ty +imm = ulong 0 +bk = get fr add ix 3 +bn = get fr add ix 4 +rb = ulong 0 +useimm = false +if eq bk 3 +if or eq op 41 eq op 42 +if lt bn twid ty +useimm = true +end +else +if or lt op 35 ge op 43 +if le bn 4095 +useimm = true +end +end +end +end +if useimm +rb = bn +imm = ulong 1 +else +rb = matreg bk bn get fr add ix 5 +end +if ge op 43 +bo_cmp op ty ra rb imm +ret +end +if eq ty 1 +if gt sub op 38 2 +fail 7 +end +end +rd = destreg dst +if lt op 35 +bo_add op ty ra rb imm rd +else +if eq op 35 +bo_mul ty ra rb rd +else +if lt op 38 +fl = ulong 0 +if and eq bk 3 ne bn 0 +fl = or fl 1 +end +if and eq bk 3 ne bn 18446744073709551615 +fl = or fl 2 +end +bo_div op ty ra rb rd fl +else +if lt op 41 +bo_log op ra rb rd +else +if eq op 41 +bo_shl ty ra rb imm rd +else +bo_shr ty ra rb imm rd +end +end +end +end +end +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note ======== calls: registers saved around a call and loaded back ======== +global svn ulong 1 +global sva ulong 1 +note save: n = registers in use (parameters + pool slots), A = 8 (n + 1) rounded up to 16: SUB SP, SP, #A +note (C6.2.457); the stack check; STR Xr, [SP, #8j] for each (C6.2.415); STR X30, [SP, #8n]. Out: svn n, +note sva A. om4 SAVE. +fn save to void +n = add get npar 0 get nslot 0 +a = shl shr add n 2 1 4 +put svn 0 n +put sva 0 a +spsub a +stkchk +j = ulong 0 +while lt j n +emit or or 4177527776 poolc j shl j 10 +j = add j 1 +end +emit or 4177527806 shl n 10 +end + +note loadarg: register t from an argument: kind 1 or 5 a register v, read back from its save slot (LDR Xt, +note [SP, #8 slot], C6.2.216); kind 3 or 6 the number or address v. om4 LOADARG. +fn loadarg t ulong k ulong v ulong to void +if or eq k 3 eq k 6 +matconst t v +ret +end +emit or or 4181722080 t shl regidx v 10 +end + +note basearg: register t = the base of array name e (index + 1): its register from the save area, or its +note address. om4 BASEARG. +fn basearg t ulong e ulong to void +i = sub e 1 +if ge get nm_kind i 4 +matconst t get nm_addr i +ret +end +loadarg t 1 ulong get nm_reg i +end + +note restore: d destination (255: a new temporary at pool slot `slot`), slot the pool slot before the +note arguments, n saved count, a save bytes, res 1 if there is a result in X0. MOV Xd, X0 (C6.2.282); LDR +note each register in use before the arguments except Xd (C6.2.216); LDR X30; ADD SP, SP, #A (C6.2.5). +note Returns Xd (255 when no result). om4 RESTORE. +fn restore d ulong slot ulong n ulong a ulong res ulong to ulong +put nslot 0 slot +rd = ulong 255 +if ne res 0 +rd = d +if eq d 255 +rd = alloc +end +if ne rd 0 +emit or 2852127712 rd +end +end +m = add get npar 0 slot +j = ulong 0 +while lt j m +r = poolc j +if ne r rd +emit or or 4181722080 r shl j 10 +end +j = add j 1 +end +emit or 4181722110 shl n 10 +spadd a +ret rd +end + +note ca_bl: BL to function f (index + 1), C6.2.43 +fn ca_bl f ulong to void +n = get ncalls 0 +if ge n 65536 +fail 14 +end +put callsite n get oc 0 +put callfrom n get curfn 0 +put callto n f +put ncalls 0 add n 1 + +emit or 2483027968 and shr sub get fn_addr sub f 1 get oc 0 2 67108863 +end + +note ======== element addresses and array arguments ======== +global ea_b ulong 1 +global ea_i ulong 1 +note elemaddr: array name e (index + 1), index value (kind, number or register, type). A number index must +note be inside the array (error 21) and needs no check; a register index: CMP Xi, #len (C6.2.96) or CMP Xi, +note Xt (C6.2.97), B.HS trap 3 (unsigned, so a negative signed index traps too). Out: ea_b base register +note (the array's register, or a new one holding its address), ea_i index register. om4 ELEMADDR. +fn elemaddr e ulong k ulong v ulong t ulong to void +if eq t 1 +fail 7 +end +i = sub e 1 +ln = get nm_len i +x = v +if eq k 3 +if ge v ln +fail 21 +end +x = alloc +matconst x v +else +if le ln 4095 +emit or or 4043309087 shl ln 10 shl v 5 +else +y = alloc +matconst y ln +emit or or 3942645791 shl y 16 shl v 5 +end +trapc 2 3 +end +put ea_i 0 x +if ge get nm_kind i 4 +b = alloc +matconst b get nm_addr i +put ea_b 0 b +else +put ea_b 0 ulong get nm_reg i +end +end + +note aa_word: the next word of an array argument must be a name of at most 8 bytes +fn aa_word to void +tok +k = get tk 0 +if eq k 0 +fail 4 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +end + +note arrarg: an array argument for parameter pi of function f (index + 1): [view | edit] NAME. Its type and +note length must equal the parameter's; an edit parameter needs a writable array (local or edit, error 20; +note a view passed to it is error 20, OMEGESE.md 9.4); a global is never passed (error 19). Out: rk 5 +note (register rv) or 6 (address rv, a text), rt the name entry. om4 ARRARG. +fn arrarg f ulong pi ulong to void +md = ulong 0 +aa_word +w = get tw 0 +c = kw w +if ne c 0 +if or lt c 57 gt c 58 +fail 16 +end +md = c +aa_word +w = get tw 0 +end +e = findname w +if eq e 0 +fail 3 +end +i = sub e 1 +k = ulong get nm_kind i +if eq k 0 +fail 7 +end +if eq k 4 +fail 19 +end +p = add mul sub f 1 6 pi +if eq get fn_pk p 3 +if eq md 57 +fail 20 +end +if and ne k 1 ne k 3 +fail 20 +end +else +if eq md 58 +fail 7 +end +end +if ne get nm_type i get fn_pt p +fail 7 +end +if ne get nm_len i get fn_pl p +fail 7 +end +put rt 0 e +if eq k 5 +put rk 0 6 +put rv 0 get nm_addr i +else +put rk 0 5 +put rv 0 ulong get nm_reg i +end +end + +note ======== the parts of the value reader that read no further value ======== +fn vdec to void +put depth 0 sub get depth 0 1 +end + +note vdone: a value's result, and one nesting level less (om4 VT_RET) +fn vdone k ulong v ulong t ulong to void +put rk 0 k +put rv 0 v +put rt 0 t +vdec +end + +note vt_un: neg / not of the value in rk/rv/rt (a bare number already refused). neg: NEG Xd, Xm (SUB from +note XZR, C6.2.458; the 32-bit form for u32), i64 NEGS + B.VS trap 1 (C6.2.465), then the wrap or the +note sign check; not: bool EOR Xd, Xn, #1 (C6.2.155), else MVN (ORN from XZR, C6.2.300), then the wrap. +note om4 VU1 .. VU_E. +fn vt_un c ulong dst ulong to void +ty = get rt 0 +ra = matreg get rk 0 get rv 0 ty +rd = destreg dst +if eq c 50 +if eq ty 1 +e3 3527409664 rd ra 0 +else +if eq ty 4 +e3 706741216 rd 0 ra +else +e3 2854224864 rd 0 ra +if lt ty 6 +canon rd ty +end +end +end +else +if eq ty 1 +fail 7 +end +if eq ty 9 +e3 3942646752 rd 0 ra +trapc 6 1 +else +if eq ty 4 +e3 1258292192 rd 0 ra +else +e3 3405775840 rd 0 ra +if lt ty 6 +canon rd ty +else +chkext rd ty 1 +end +end +end +end +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note vt_conv: the value in rk/rv/rt converted to type tt (neither bool, error 9). Out of range when any bit +note at or above s is set: LSR Xt, Xa, #s (UBFM, C6.2.487); CBNZ Xt trap 5 (C6.2.77); signed to a narrower +note signed type: the sign-extension check, trap 5. om4 VTT1 .. VC_OK. +fn vt_conv tt ulong to void +ft = get rt 0 +ra = matreg get rk 0 get rv 0 ft +if eq ft 1 +fail 9 +end +if eq tt 1 +fail 9 +end +wf = twid ft +wt = twid tt +s = ulong 99 +if lt ft 6 +if ge tt 6 +if ge wf wt +s = sub wt 1 +end +else +if gt wf wt +s = wt +end +end +else +if lt tt 6 +s = wt +if gt s 63 +s = ulong 63 +end +else +if gt wf wt +chkext ra tt 5 +end +end +end +if ne s 99 +t = alloc +emit or or or 3544251392 t shl s 16 shl ra 5 +trapsite or 3036676096 t 5 +end +put rk 0 1 +put rv 0 ra +put rt 0 tt +end + +note vt_get: get A i with the index value in rk/rv/rt: the element address, then the load of the element +note type, register offset (LDOP table). om4 VT_GET. +fn vt_get e ulong dst ulong to void +elemaddr e get rk 0 get rv 0 get rt 0 +rd = destreg dst +ty = ulong get nm_type sub e 1 +w = or ldop ty rd +emit or or w shl get ea_b 0 5 shl get ea_i 0 16 +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note vs_chk: read / write bounds: n <= len A and off <= len A - n, else trap 3 (CMP C6.2.97, B.HI C6.2.34, +note SUB C6.2.458). om4 VT_SYS. +fn vs_chk e ulong ro ulong rn ulong to void +t = alloc +matconst t get nm_len sub e 1 +emit or or 3942645791 shl rn 5 shl t 16 +trapc 8 3 +e3 3405774848 t t rn +emit or or 3942645791 shl ro 5 shl t 16 +trapc 8 3 +end + +note vs_call: save the registers in use, X0 = fd, X1 = A + off (ADD through X16, C6.2.6), X2 = n, X8 = 63 +note (read) or 64 (write) (MOVZ C6.2.285), SVC #0 (C6.2.466). om4 VT_SYS. +fn vs_call c ulong fk ulong fv ulong e ulong ro ulong rn ulong to void +save +loadarg 0 fk fv +basearg 1 e +loadarg 16 1 ro +emit 2333081633 +loadarg 2 1 rn +emit or 3531603976 shl add c 10 5 +emit 3556769793 +end + +note ca_scal: a scalar argument just read (rk/rv/rt) for parameter p: flags into a register; its type +note must be the parameter's; stored at fr[q..q+2]. om4 CA1 .. CA_PUT. +fn ca_scal p ulong q ulong to void +if eq get rk 0 4 +put rv 0 matreg 4 get rv 0 get rt 0 +put rk 0 1 +put rt 0 1 +end +if ne get rt 0 ulong get fn_pt p +fail 7 +end +put fr q get rk 0 +put fr add q 1 get rv 0 +put fr add q 2 0 +end + +note ca_arr: an array argument i of function f, call frame cb: one array passed twice is error 19. +note om4 CA_ARR .. CA_PUT. +fn ca_arr f ulong i ulong cb ulong to void +arrarg f i +j = ulong 0 +while lt j i +if eq get fr add add cb mul j 3 2 get rt 0 +fail 19 +end +j = add j 1 +end +q = add cb mul i 3 +put fr q get rk 0 +put fr add q 1 get rv 0 +put fr add q 2 get rt 0 +end + +note ca_end: all arguments read: save, the arguments into X0.., BL, restore. Frame cb: 3 per argument, +note then cb+18 the parameter count, cb+19 the pool slot before the arguments. om4 CA_DONE .. CA5. +fn ca_end f ulong dst ulong cb ulong to void +save +np = get fr add cb 18 +i = ulong 0 +while lt i np +q = add cb mul i 3 +loadarg i get fr q get fr add q 1 +i = add i 1 +end +ca_bl f +hr = ulong 1 +if eq get fn_ret sub f 1 10 +hr = ulong 0 +end +n = get svn 0 +a = get sva 0 +sl = get fr add cb 19 +r = restore dst sl n a hr +put rk 0 1 +put rv 0 r +put rt 0 ulong get fn_ret sub f 1 +end + +note vs_fd, vs_arr, vs_off, vs_end: the steps of read / write between the values it reads, with the fd +note (kind, value), the offset register and the pool slot before kept in fr[x+8..x+11] (om4's VT_SYS +note frame slots 4, 5, 7 and 14) +fn vs_fd x ulong to void +if ne get rt 0 8 +fail 7 +end +put fr add x 9 get rk 0 +put fr add x 10 get rv 0 +end + +fn vs_arr c ulong e ulong to void +if eq c 53 +k = get nm_kind sub e 1 +if or eq k 2 eq k 5 +fail 20 +end +end +end + +fn vs_off x ulong to void +if ne get rt 0 5 +fail 7 +end +put fr add x 11 matreg get rk 0 get rv 0 get rt 0 +end + +fn vs_end c ulong e ulong dst ulong x ulong to void +if ne get rt 0 5 +fail 7 +end +rn = matreg get rk 0 get rv 0 get rt 0 +ro = get fr add x 11 +vs_chk e ro rn +fk = get fr add x 9 +fv = get fr add x 10 +vs_call c fk fv e ro rn +sl = get fr add x 8 +n = get svn 0 +a = get sva 0 +r = restore dst sl n a 1 +vdone 1 r 9 +end + +note Native Linux ARM64 host operations. Encoding forms are those in seed/rung2/table.s2. +note Syscall numbers and layouts: Linux asm-generic/unistd.h, fcntl.h and time.h. +note No raw address or arbitrary syscall is exposed to an Omega program. +fn hargc c ulong to ulong +if or or eq c 107 eq c 109 eq c 129 +ret 0 +end +if or eq c 100 eq c 101 +ret 1 +end +if or or or eq c 102 eq c 105 eq c 106 eq c 127 +ret 2 +end +ret 3 +end +fn hsysno c ulong to ulong +if eq c 127 +ret 129 +end +if eq c 129 +ret 172 +end +if eq c 100 +ret 57 +end +if eq c 101 +ret 82 +end +if eq c 102 +ret 52 +end +if eq c 103 +ret 62 +end +if eq c 104 +ret 198 +end +if eq c 105 +ret 201 +end +if eq c 106 +ret 242 +end +if eq c 107 +ret 220 +end +ret 24 +end +fn harg x ulong i ulong ty ulong to void +rdval 0 ty 255 0 +if ne get rt 0 ty +fail 7 +end +q = add add x 8 mul i 2 +put fr q get rk 0 +put fr add q 1 get rv 0 +end +fn hload x ulong i ulong reg ulong to void +q = add add x 8 mul i 2 +loadarg reg get fr q get fr add q 1 +end +fn hsys n ulong to void +matconst 8 n +emit 3556769793 +end +fn hreturn dst ulong x ulong to void +sl = get fr add x 7 +n = get svn 0 +a = get sva 0 +r = restore dst sl n a 1 +vdone 1 r 9 +end +fn hscalar c ulong dst ulong x ulong to void +np = hargc c +for i ulong np +ty = ulong 8 +if and eq c 103 eq i 1 +ty = ulong 9 +end +harg x i ty +end +save +for i ulong np +hload x i i +end +if eq c 106 +hload x 1 3 +matconst 1 0 +matconst 2 0 +end +if eq c 107 +matconst 0 17 +for i ulong 5 +matconst add i 1 0 +end +end +hsys hsysno c +hreturn dst x +end +fn hclock c ulong dst ulong x ulong to void +save +spsub 16 +stkchk +matconst 0 1 +if eq c 130 +matconst 0 0 +end +emit 2432697313 +hsys 113 +emit 4043309087 +bad = get oc 0 +emit 1409286155 +emit 4181722081 +emit 4181723106 +note Reject overflow before seconds are multiplied; clock result is a signed nanosecond count. +matconst 3 9223372036 +e3 3942645760 31 1 3 +trapc 8 1 +matconst 3 1000000000 +e3 2600500224 1 1 3 +e3 2868903936 0 1 2 +trapc 6 1 +patch19 bad get oc 0 +spadd 16 +hreturn dst x +end +fn harray x ulong writable ulong to ulong +e = arrname +if ne get nm_type sub e 1 2 +fail 7 +end +if ne writable 0 +vs_arr 53 e +end +put fr add x 20 e +harg x 0 5 +harg x 1 5 +ro = matreg get fr add x 8 get fr add x 9 5 +rn = matreg get fr add x 10 get fr add x 11 5 +put fr add x 21 ro +put fr add x 22 rn +vs_chk e ro rn +ret e +end +note Copy a checked path to a private 4096-byte stack buffer. Reject embedded zero bytes. +note Public paths remain length-delimited; only the kernel-facing private copy has a terminator. +fn hpathcp x ulong to void +e = get fr add x 20 +save +basearg 4 e +loadarg 16 1 get fr add x 21 +e3 2332033024 4 4 16 +loadarg 5 1 get fr add x 22 +matconst 6 4095 +e3 3942645760 31 5 6 +trapc 8 3 +end +fn hcopy to void +spsub 4096 +stkchk +emit 2432697313 +head = get oc 0 +emit 4043309247 +done = get oc 0 +emit 1409286144 +emit 960495750 +emit 4043309279 +trapc 0 3 +emit 956301350 +emit 2432697476 +emit 2432697377 +emit 3506439333 +back head +patch19 done get oc 0 +emit 956301375 +emit 2432697313 +matconst 0 18446744073709551516 +end +fn hpath c ulong dst ulong x ulong to void +e = harray x 0 +if eq c 110 +harg x 2 8 +harg x 3 8 +end +if eq c 112 +harg x 2 8 +end +hpathcp x +if eq c 110 +hload x 2 2 +hload x 3 3 +end +if eq c 111 +matconst 2 0 +end +if eq c 126 +matconst 2 512 +end +if eq c 112 +hload x 2 2 +end +hcopy +nr = ulong 56 +if or eq c 111 eq c 126 +nr = ulong 35 +end +if eq c 112 +nr = ulong 34 +end +hsys nr +spadd 4096 +hreturn dst x +end +fn hbuffer c ulong dst ulong x ulong to void +harg x 4 8 +wr = ulong 0 +if or or or or eq c 113 eq c 116 eq c 117 eq c 118 eq c 131 +wr = ulong 1 +end +e = harray x wr +if or or eq c 116 eq c 118 eq c 119 +harg x 2 8 +end +if or eq c 116 eq c 117 +need = ulong 4 +if eq c 117 +need = ulong 128 +end +tmp = alloc +matconst tmp need +e3 3942645760 31 get fr add x 22 tmp +trapc 3 3 +end +save +hload x 4 0 +basearg 1 e +loadarg 16 1 get fr add x 21 +e3 2332033024 1 1 16 +loadarg 2 1 get fr add x 22 +nr = ulong 61 +if eq c 114 +nr = ulong 203 +end +if eq c 115 +nr = ulong 200 +end +if eq c 116 +nr = ulong 260 +hload x 2 2 +matconst 3 0 +end +if eq c 117 +nr = ulong 80 +end +if or eq c 118 eq c 119 +nr = ulong 207 +hload x 2 3 +matconst 4 0 +matconst 5 0 +if eq c 119 +nr = ulong 206 +matconst 16 16384 +e3 2852126720 3 3 16 +end +end + +if eq c 131 +note getsockname uses a private 32-bit socklen. Success returns the full address length. +spsub 16 +stkchk +emit 3103785954 +emit 2432697314 +hsys 204 +emit 4043309087 +failed = get oc 0 +emit 1409286155 +emit 3107980256 +patch19 failed get oc 0 +spadd 16 +else +hsys nr +end +hreturn dst x +end +fn hsleep dst ulong x ulong to void +harg x 0 9 +save +hload x 0 2 +emit 4043309151 +trapc 11 3 +spsub 16 +stkchk +matconst 3 1000000000 +e3 2596276224 4 2 3 +note MSUB x5,x4,x3,x2 gives the subsecond remainder. +emit 2600700037 +emit 4177527780 +emit 4177528805 +emit 2432697312 +matconst 1 0 +hsys 101 +spadd 16 +hreturn dst x +end +fn hargs c ulong dst ulong x ulong to void +if eq c 121 +save +emit 4181721952 +hreturn dst x +ret +end +harg x 4 5 +e = harray x 1 +save +hload x 4 0 +emit 4181721953 +e3 3942645760 31 0 1 +trapc 2 3 +emit 2432697344 +matconst 16 8 +e3 2600500224 0 0 16 +e3 2332033024 3 27 0 +emit 4181721187 +e3 2852126720 4 31 3 +matconst 5 0 +scan = get oc 0 +emit 960495750 +emit 4043309279 +done = get oc 0 +emit 1409286144 +emit 2432697476 +emit 2432697509 +matconst 16 1048576 +e3 3942645760 31 5 16 +trapc 2 3 +back scan +patch19 done get oc 0 +loadarg 2 1 get fr add x 22 +e3 3942645760 31 5 2 +small = get oc 0 +emit 1409286152 +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +e3 2852126720 2 31 5 +copy = get oc 0 +emit 4043309247 +endcp = get oc 0 +emit 1409286144 +emit 960495718 +emit 956301318 +emit 2432697443 +emit 2432697344 +emit 3506439333 +back copy +patch19 endcp get oc 0 +e3 2852126720 0 31 2 +endbr = get oc 0 +emit 335544320 +patch19 small get oc 0 +matconst 0 18446744073709551511 +patch26 endbr get oc 0 +hreturn dst x +end + +note waitio(fd int, events int, timeout_ns long): revents, 0 timeout, or negative errno. +note ppoll uses one private pollfd and one private timespec. Negative timeout is infinite. +fn hwaitio dst ulong x ulong to void +harg x 0 8 +harg x 1 8 +harg x 2 9 +save +hload x 0 0 +hload x 1 1 +hload x 2 2 +note pollfd.events is 16 bits; refuse truncation of the public int argument. +emit 4043309119 +trapc 11 3 +matconst 16 65535 +e3 3942645760 31 1 16 +trapc 8 3 +spsub 32 +stkchk +emit 4177527807 +emit 3103785952 +emit 2030046177 +matconst 3 1000000000 +emit 4043309151 +forever = get oc 0 +emit 1409286155 +e3 2596276224 4 2 3 +emit 2600700037 +emit 4177528804 +emit 4177529829 +emit 2432705506 +jump = get oc 0 +emit 335544320 +patch19 forever get oc 0 +matconst 2 0 +patch26 jump get oc 0 +emit 2432697312 +matconst 1 1 +matconst 3 0 +matconst 4 8 +hsys 73 +emit 4043309087 +failed = get oc 0 +emit 1409286157 +emit 2034241504 +patch19 failed get oc 0 +spadd 32 +hreturn dst x +end + +note A packed argument list is u16 count followed by count (u16 length, bytes) records. +note Byte order is little-endian. The packet is at most 4096 bytes and 64 records. +note The decoder constructs kernel pointers only in private stack memory. +fn hpack c ulong dst ulong x ulong to void +e = harray x 0 +if eq c 125 +harg x 2 8 +end +save +basearg 4 e +loadarg 16 1 get fr add x 21 +e3 2332033024 4 4 16 +loadarg 5 1 get fr add x 22 +matconst 16 4096 +e3 3942645760 31 5 16 +trapc 8 3 +emit 4043311295 +trapc 3 3 +if eq c 125 +hload x 2 14 +end +spsub 8192 +stkchk +emit 2034237574 +emit 2432698500 +emit 3506440357 +emit 4043309279 +trapc 0 3 +matconst 16 64 +e3 3942645760 31 6 16 +trapc 8 3 +if eq c 125 +emit 4043311327 +trapc 1 3 +end +matconst 9 0 +emit 2432697322 +emit 2436892651 +outer = get oc 0 +e3 3942645760 31 9 6 +done = get oc 0 +emit 1409286146 +emit 4043311295 +trapc 3 3 +emit 2034237580 +emit 2432698500 +emit 3506440357 +e3 3942645760 31 12 5 +trapc 8 3 +note A program path and both rename paths must be nonempty. +if eq c 124 +emit 4043309375 +notfirst = get oc 0 +emit 1409286145 +emit 4043309471 +trapc 0 3 +patch19 notfirst get oc 0 +else +emit 4043309471 +trapc 0 3 +end +emit 4177527146 +emit 2432704875 +inner = get oc 0 +emit 4043309471 +endstr = get oc 0 +emit 1409286144 +emit 960495757 +emit 4043309503 +trapc 0 3 +emit 956301645 +emit 2432697476 +emit 2432697674 +emit 3506439333 +emit 3506439564 +back inner +patch19 endstr get oc 0 +emit 956301663 +emit 2432697674 +emit 2432697641 +back outer +patch19 done get oc 0 +emit 4043309247 +trapc 1 3 +emit 4177527167 +if eq c 124 +emit 2432697312 +emit 2436892641 +e3 2852126720 2 31 11 +hsys 221 +else +emit 2436892656 +emit 4181721601 +emit 4181722627 +matconst 0 18446744073709551516 +matconst 2 18446744073709551516 +e3 2852126720 4 31 14 +hsys 276 +end +spadd 8192 +hreturn dst x +end +fn hpipe dst ulong x ulong to void +e = harray x 1 +harg x 2 8 +tmp = alloc +matconst tmp 8 +e3 3942645760 31 get fr add x 22 tmp +trapc 3 3 +save +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +hload x 2 1 +hsys 59 +hreturn dst x +end + +fn hcwd dst ulong x ulong to void +e = harray x 1 +save +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +loadarg 1 1 get fr add x 22 +hsys 17 +hreturn dst x +end +fn hreadlnk dst ulong x ulong to void +e = harray x 0 +put fr add x 23 e +put fr add x 24 get fr add x 21 +put fr add x 25 get fr add x 22 +e = harray x 1 +put fr add x 26 e +put fr add x 27 get fr add x 21 +put fr add x 28 get fr add x 22 +put fr add x 20 get fr add x 23 +put fr add x 21 get fr add x 24 +put fr add x 22 get fr add x 25 +hpathcp x +note readlnk refuses an empty path before the kernel call. +emit 4043309247 +trapc 0 3 +basearg 2 get fr add x 26 +loadarg 16 1 get fr add x 27 +e3 2332033024 2 2 16 +loadarg 3 1 get fr add x 28 +hcopy +hsys 78 +spadd 4096 +hreturn dst x +end +fn hsockopt dst ulong x ulong to void +harg x 2 8 +harg x 3 8 +harg x 4 8 +e = harray x 0 +save +hload x 2 0 +hload x 3 1 +hload x 4 2 +basearg 3 e +loadarg 16 1 get fr add x 21 +e3 2332033024 3 3 16 +loadarg 4 1 get fr add x 22 +hsys 208 +hreturn dst x +end + +fn hostval c ulong dst ulong to void +if eq get progmode 0 0 +fail 9 +end +x = mul get depth 0 32 +put fr add x 7 get nslot 0 +if eq c 132 +hcwd dst x +ret +end +if eq c 133 +hreadlnk dst x +ret +end +if eq c 134 +hsockopt dst x +ret +end +if or eq c 109 eq c 130 +hclock c dst x +ret +end +if or and ge c 113 le c 119 eq c 131 +hbuffer c dst x +ret +end +if eq c 120 +hsleep dst x +ret +end +if eq c 123 +hwaitio dst x +ret +end +if or eq c 124 eq c 125 +hpack c dst x +ret +end +if eq c 126 +hpath c dst x +ret +end +if or eq c 127 eq c 129 +hscalar c dst x +ret +end +if eq c 128 +hpipe dst x +ret +end +if ge c 121 +put hostargs 0 1 +hargs c dst x +ret +end +if ge c 110 +hpath c dst x +ret +end +hscalar c dst x +end + +note ======== rdval: read one value (om4 VAL, VALTOK, CALL and the VT_ parts, one self-recursive +note function because a function calls only earlier functions or itself) ======== +note mode 0: read the first word; 1: the first word is the current token; 2: a call of function fe (index +note + 1), its arguments still to read. exp the expected type (0 none), dst the destination register (255 +note none). Out: rk kind (1 register, 2 bare number, 3 typed number, 4 flags), rv register / number / +note condition, rt type (for a bare number: 1 when written as 2^63 or more). Only the outermost op writes the +note destination. Every value nests one level deeper (at most 1024, error 14); a call does not. +fn rdval mode ulong exp ulong dst ulong fe ulong to void +if eq mode 2 +cb = add mul get depth 0 32 8 +put fr add cb 18 ulong get fn_np sub fe 1 +put fr add cb 19 get nslot 0 +if eq get progmode 0 0 +if eq get curfn 0 fe +fail 9 +end +end +i = ulong 0 +while lt i get fr add cb 18 +p = add mul sub fe 1 6 i +if eq get fn_pk p 0 +rdval 0 ulong get fn_pt p 255 0 +ca_scal p add cb mul i 3 +else +ca_arr fe i cb +end +i = add i 1 +end +ca_end fe dst cb +ret +end +if eq mode 0 +tok +end +put depth 0 add get depth 0 1 +if gt get depth 0 1024 +fail 14 +end +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if eq get tk 0 4 +fail 16 +end +if eq get tk 0 2 +if eq exp 0 +vdone 2 get tw 0 get tbig 0 +ret +end +range get tw 0 exp get tbig 0 +vdone 3 get tw 0 exp +ret +end +if gt get tl 0 8 +f = findfn get tw 0 get tl 0 get ts 0 +if eq f 0 +fail 13 +end +if eq get fn_ret sub f 1 10 +fail 7 +end +rdval 2 0 dst f +vdec +ret +end +c = kw get tw 0 +if eq c 0 +e = findname get tw 0 +if ne e 0 +if ne get nm_kind sub e 1 0 +fail 7 +end +vdone 1 ulong get nm_reg sub e 1 ulong get nm_type sub e 1 +ret +end +f = findfn get tw 0 0 0 +if eq f 0 +fail 3 +end +if eq get fn_ret sub f 1 10 +fail 7 +end +rdval 2 0 dst f +vdec +ret +end +if le sub c 1 8 +tok +if eq get tk 0 2 +range get tw 0 c get tbig 0 +vdone 3 get tw 0 c +ret +end +rdval 1 0 255 0 +if eq get rk 0 2 +fail 11 +end +vt_conv c +vdec +ret +end +if eq c 74 +rdval 0 exp dst 0 +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +if ne kw get tw 0 75 +fail 16 +end +vdec +ret +end +if eq c 77 +fail 9 +end +if and ge c 100 le c 134 +hostval c dst +ret +end +if eq c 51 +e = arrname +rdval 0 5 255 0 +vt_get e dst +vdec +ret +end +if eq c 52 +e = arrname +vdone 3 get nm_len sub e 1 5 +ret +end +if or eq c 53 eq c 54 +x = mul get depth 0 32 +put fr add x 8 get nslot 0 +rdval 0 8 255 0 +vs_fd x +e = arrname +vs_arr c e +rdval 0 5 255 0 +vs_off x +rdval 0 5 255 0 +vs_end c e dst x +ret +end +if eq c 55 +vdone 3 1 1 +ret +end +if eq c 56 +vdone 3 0 1 +ret +end +if gt sub c 33 17 +fail 16 +end +if ge c 49 +rdval 0 exp 255 0 +if and eq c 50 eq get rk 0 4 +put rv 0 xor get rv 0 1 +vdec +ret +end +if eq get rk 0 2 +fail 11 +end +vt_un c dst +vdec +ret +end +rdval 0 0 255 0 +ak = get rk 0 +av = get rv 0 +at = get rt 0 +if eq ak 4 +av = matreg 4 av at +ak = ulong 1 +at = ulong 1 +end +rdval 0 0 255 0 +bk = get rk 0 +bv = get rv 0 +bt = get rt 0 +if eq bk 4 +bv = matreg 4 bv bt +bk = ulong 1 +bt = ulong 1 +end +if eq ak 2 +if eq bk 2 +fail 11 +end +range av bt at +at = bt +ak = ulong 3 +end +if eq bk 2 +range bv at bt +bt = at +bk = ulong 3 +end +if and ne c 41 ne c 42 +if ne at bt +fail 7 +end +end +x = mul get depth 0 32 +put fr x ak +put fr add x 1 av +put fr add x 2 at +put fr add x 3 bk +put fr add x 4 bv +put fr add x 5 bt +binop c dst x +vdec +end + +note cond: read a condition (a bool value); emit a branch taken when it is false: B.cond with the opposite +note condition (C6.2.34), or CBZ Xr (C6.2.78). Returns that branch's place. om4 COND. +fn cond to ulong +rdval 0 1 255 0 +if ne get rt 0 1 +fail 7 +end +if eq get rk 0 4 +at = get oc 0 +emit or 1409286144 xor get rv 0 1 +ret at +end +r = matreg get rk 0 get rv 0 get rt 0 +at = get oc 0 +emit or 3019898880 r +ret at +end + +note ======== statements, one per line (om4 STMT and the S_ parts) ======== +note skipnl: note ...: the rest of the line is not read (up to the newline, which tok reads). om4 S_NOTE. +fn skipnl to void +go = true +while go +n = ulong 0 +while and go lt n 999999 +if ge get cur 0 get inlen 0 +go = false +else +if eq get inp get cur 0 10 +go = false +else +put cur 0 add get cur 0 1 +end +end +n = add n 1 +end +end +end + +note s_long: a word over 8 characters at the start of a line: only a call of a void function. om4 S_LONG. +fn s_long to void +if eq get curret 0 0 +fail 13 +end +if ne get dead 0 0 +fail 17 +end +f = findfn get tw 0 get tl 0 get ts 0 +if eq f 0 +fail 13 +end +if ne get fn_ret sub f 1 10 +fail 7 +end +rdval 2 0 255 f +eol +end + +note blo: B.LO back to an earlier place (C6.2.34) +fn blo at ulong to void +d = and shr sub at get oc 0 2 524287 +emit or 1409286147 shl d 5 +end + +note sa_arr: x = new T N v: N elements of type T on the stack, each set to v; only in the function's +note outermost block, so the stack held by local arrays is known at every ret. SUB SP (C6.2.457); program +note mode: the stack check; MOV Xb, SP (ADD immediate, C6.2.5); then the fill loop: STR v, [Xb, Xi, LSL]; +note ADD Xi, Xi, #1; CMP Xi, #N or Xn; B.LO back (C6.2.34). om4 SA_ARR. +fn sa_arr w ulong to void +if ne get nb 0 0 +fail 9 +end +t = typeword +elemtype t +tok +if ne get tk 0 2 +fail 16 +end +n = get tw 0 +arrlen n +by = shl shr add shl n tlog t 15 4 4 +s = add get stkbytes 0 by +if gt s 4194304 +fail 23 +end +put stkbytes 0 s +r = alloc +put held 0 get nslot 0 +rdval 0 t 255 0 +if ne get rt 0 t +fail 7 +end +v = matreg get rk 0 get rv 0 get rt 0 +spsub by +stkchk +emit or 2432697312 r +i = alloc +emit or 3531603968 i +m = ulong 0 +if gt n 4095 +m = alloc +matconst m n +end +lp = get oc 0 +emit or or or stop t v shl r 5 shl i 16 +emit or or 2432697344 i shl i 5 +if le n 4095 +emit or or 4043309087 shl n 10 shl i 5 +else +emit or or 3942645791 shl m 16 shl i 5 +end +blo lp +addname w r t n 1 0 +end + +note s_assign: name [=] value (an existing scalar, or a new one), or name = new T N v. om4 S_ASSIGN. +fn s_assign w ulong to void +tok +if eq get tk 0 1 +if le get tl 0 8 +if eq kw get tw 0 73 +tok +end +end +end +e = findname w +if ne e 0 +i = sub e 1 +if ne get nm_kind i 0 +fail 7 +end +r = ulong get nm_reg i +t = ulong get nm_type i +rdval 1 t r 0 +if ne get rt 0 t +fail 7 +end +force get rk 0 get rv 0 get rt 0 r +eol +ret +end +if ne findfn w 0 0 0 +fail 10 +end +if eq get tk 0 1 +if le get tl 0 8 +if eq kw get tw 0 84 +sa_arr w +eol +ret +end +end +end +r = alloc +put held 0 get nslot 0 +rdval 1 0 r 0 +if eq get rk 0 2 +fail 11 +end +t = get rt 0 +force get rk 0 get rv 0 t r +addname w r t 0 0 0 +eol +end + +note s_name: a name at the start of a line: a call of a void function, or name [=] value. om4 S_NAME. +fn s_name w ulong to void +if ne findname w 0 +s_assign w +ret +end +f = findfn w get tl 0 0 +if eq f 0 +s_assign w +ret +end +if ne get fn_ret sub f 1 10 +fail 7 +end +rdval 2 0 255 f +eol +end + +note fn_p: the type of parameter np (name pw) of function f (index): T, or view / edit T N (an array: +note kind 2 / 3, element type, length 1 .. 2^24). om4 FN_P .. FN_ADD. +fn fn_p f ulong np ulong pw ulong to void +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +c = kw get tw 0 +t = ulong 0 +ln = ulong 0 +k = ulong 0 +if or eq c 57 eq c 58 +k = sub c 55 +t = typeword +elemtype t +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 2 +fail 16 +end +ln = get tw 0 +arrlen ln +else +if gt sub c 1 8 +fail 16 +end +t = c +end +addname pw poolc np t ln k 0 +p = add mul f 6 np +put fn_pt p uchar t +put fn_pl p ln +put fn_pk p uchar k +end + +note fn_to: to T | to void at the end of a fn line; the function's state starts. om4 FN_TO .. FN_T2. +fn fn_to f ulong np ulong to void +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +c = kw get tw 0 +r = c +if eq c 76 +r = ulong 10 +else +if gt sub c 1 8 +fail 16 +end +end +put curret 0 r +put fn_ret f uchar r +put fn_np f uchar np +put stkbytes 0 0 +put dead 0 0 +put npar 0 np +put nslot 0 0 +put held 0 0 +put nb 0 0 +put nt 0 0 +eol +end + +note s_fn: fn name (param type | param view T N | param edit T N)* to type | void. om4 S_FN. +fn s_fn to void +if ne get curret 0 0 +fail 15 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 63 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +l = get tl 0 +s = get ts 0 +f = ulong 0 +if eq get scanning 0 1 +newname w l s +f = get nf 0 +if ge f 512 +fail 14 +end +put nf 0 add f 1 +put curfn 0 add f 1 +put lastfn 0 add f 1 +put fn_name f w +put fn_addr f get oc 0 +put fn_ret f 0 +put fn_np f 0 +put fn_nmlen f l +put fn_off f s +else +f = sub findfn w l s 1 +put curfn 0 add f 1 +put lastfn 0 add f 1 +put fn_addr f get oc 0 +end +put nn 0 get nglob 0 +np = ulong 0 +go = true +while go +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +pw = get tw 0 +c = kw pw +if eq c 65 +go = false +else +if ne c 0 +fail 16 +end +newname pw get tl 0 get ts 0 +if ge np 6 +fail 9 +end +fn_p f np pw +np = add np 1 +end +end +fn_to f np +if eq get scanning 0 1 +put curret 0 0 +put nn 0 0 +end +end + +note s_ret: ret [value]: the value into X0, give back the local arrays' stack, RET. om4 S_RET. +fn s_ret to void +r = get curret 0 +if eq r 10 +eol +epi +dead1 +ret +end +rdval 0 r 0 0 +if ne get rt 0 r +fail 7 +end +force get rk 0 get rv 0 get rt 0 0 +epi +dead1 +eol +end + +note s_exit: exit value (int): Linux exit (system call 93: MOVZ X8, #93, C6.2.285; SVC #0, C6.2.466); the +note path ends. om4 S_EXIT. +fn s_exit to void +rdval 0 8 255 0 +if ne get rt 0 8 +fail 7 +end +force get rk 0 get rv 0 get rt 0 0 +emit 3531606952 +emit 3556769793 +dead1 +eol +end + +note stel: the checked store of v (type t) at ea_b / ea_i (the STOP table: register offset, scaled) +fn stel t ulong v ulong to void +b = shl get ea_b 0 5 +i = shl get ea_i 0 16 +emit or or or stop t v b i +end + +note s_put: put A i v: index, then value, then the checked store (STOP table). om4 S_PUT. +fn s_put to void +e = arrname +k = get nm_kind sub e 1 +if or eq k 2 eq k 5 +fail 20 +end +rdval 0 5 255 0 +ik = get rk 0 +iv = get rv 0 +it = get rt 0 +t = ulong get nm_type sub e 1 +rdval 0 t 255 0 +if ne get rt 0 t +fail 7 +end +v = matreg get rk 0 get rv 0 get rt 0 +elemaddr e ik iv it +stel t v +eol +end + +note s_global: global NAME T N: a fixed pool of N elements, zero at start, in the read/write part of the +note program image after the 8 MiB stack pool (address 0x10800000 + pool bytes so far); at most 1 GiB of +note pools (error 23). om4 S_GLOBAL. +fn s_global to void +w = topname +t = typeword +elemtype t +tok +if ne get tk 0 2 +fail 16 +end +n = get tw 0 +arrlen n +by = shl shr add shl n tlog t 15 4 4 +pb = get poolb 0 +a = add 276824064 pb +s = add pb by +if gt s 1073741824 +fail 23 +end +put poolb 0 s +addname w 0 t n 4 a +put nglob 0 get nn 0 +eol +end + +note s_text: text NAME "...": read-only bytes in the program image (escapes \n \t \\ \", any other is error +note 22), padded to a word, with their length; address 0x400000 + its place. om4 S_TEXT. +fn s_text to void +w = topname +tok +if ne get tk 0 4 +fail 16 +end +a = add get oc 0 4194304 +p = get tw 0 +e = add p get tl 0 +n = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +b = get inp p +p = add p 1 +if eq b 92 +b = get inp p +p = add p 1 +if eq b 110 +b = uchar 10 +else +if eq b 116 +b = uchar 9 +else +if and ne b 92 ne b 34 +fail 22 +end +end +end +end +emitb b +n = add n 1 +end +m = add m 1 +end +end +while ne and get oc 0 3 0 +emitb 0 +end +addname w 0 2 n 5 a +put nglob 0 get nn 0 +eol +end + +note s_if: if cond: the false branch is patched at else / end. om4 S_IF. +fn s_if to void +at = cond +pushb at 1 0 0 0 +pushnh get nn 0 get held 0 +eol +end + +note s_else: jump over the else part (B, C6.2.35); the if's false branch lands after that jump. om4 S_ELSE. +fn s_else to void +n = get nb 0 +if eq n 0 +fail 15 +end +i = sub n 1 +if ne get bkind i 1 +fail 15 +end +b = get oc 0 +emit 335544320 +patch19 get bbr i get oc 0 +put bkind i 2 +put bbr i b +put nn 0 get bnames i +put held 0 get bheld i +put bdead i get dead 0 +put dead 0 0 +eol +end + +note lpcnt: the hidden counter check of a loop: CMP Xc, #N (C6.2.96) or CMP Xc, Xn (C6.2.97); B.HS trap +note 4; ADD Xc, Xc, #1 (C6.2.5). om4 SW_NOB .. SW_G and the same in S_FOR. +fn lpcnt c ulong n ulong to void +if le n 4095 +emit or or 4043309087 shl n 10 shl c 5 +else +m = alloc +matconst m n +emit or or 3942645791 shl c 5 shl m 16 +end +trapc 2 4 +emit or or 2432697344 c shl c 5 +end + +note s_while: while cond [bound N]: hidden counter = 0; head: cond false -> exit; counter >= N -> trap 4; +note counter = counter + 1; body; B head. N is 1 .. 999999 (error 8), 1000000 with no bound. om4 S_WHILE. +fn s_while to void +sn = get nn 0 +sh = get held 0 +c = alloc +put held 0 get nslot 0 +emit or 3531603968 c +hd = get oc 0 +br = cond +n = ulong 1000000 +tok +k = get tk 0 +if and ne k 0 ne k 3 +if ne k 1 +fail 5 +end +if gt get tl 0 8 +fail 5 +end +if ne kw get tw 0 70 +fail 5 +end +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 2 +fail 16 +end +if ge sub get tw 0 1 999999 +fail 8 +end +n = get tw 0 +eol +end +lpcnt c n +pushb br 3 hd c 0 +pushnh sn sh +end + +note sf_br: B.HS (unsigned) or B.GE (signed) to the loop exit, C6.2.34 (distance filled at end); returns +note its place. om4 SF_BR. +fn sf_br t ulong to ulong +at = get oc 0 +if lt t 6 +emit 1409286146 +else +emit 1409286154 +end +ret at +end + +note sf_num: for i T K with K a number: i = 0 (MOVZ, C6.2.285); head: CMP Xi, #K or Xk; B.HS/B.GE exit. +note om4 SF_NUM .. SF_PUSH. +fn sf_num w ulong t ulong kk ulong sn ulong sh ulong to void +eol +i = alloc +put held 0 get nslot 0 +addname w i t 0 0 0 +emit or 3531603968 i +hd = get oc 0 +if le kk 4095 +emit or or 4043309087 shl kk 10 shl i 5 +else +k = alloc +matconst k kk +emit or or 3942645791 shl i 5 shl k 16 +end +br = sf_br t +pushb br 4 hd i t +pushnh sn sh +end + +note sf_val: for i T K with K a value of type T in register kr: i = 0; the hidden counter c = 0; head: CMP +note Xi, Xk; B.HS/B.GE exit; the counter guard of a while with no bound. om4 SF_VAL. +fn sf_val w ulong t ulong kr ulong sn ulong sh ulong to void +eol +i = alloc +put held 0 get nslot 0 +addname w i t 0 0 0 +emit or 3531603968 i +c = alloc +put held 0 get nslot 0 +emit or 3531603968 c +hd = get oc 0 +emit or or 3942645791 shl kr 16 shl i 5 +br = sf_br t +m = alloc +matconst m 1000000 +emit or or 3942645791 shl c 5 shl m 16 +trapc 2 4 +emit or or 2432697344 c shl c 5 +pushb br 4 hd i t +pushnh sn sh +end + +note s_for: for i T K: i = 0; head: not i < K -> exit; body; latch i = add i 1; B head. K a number, or a +note value of type T: a name is read at every pass, another value once before the loop. om4 S_FOR. +fn s_for to void +sn = get nn 0 +sh = get held 0 +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +t = typeword +if eq t 1 +fail 7 +end +tok +if eq get tk 0 0 +fail 4 +end +if eq get tk 0 2 +range get tw 0 t get tbig 0 +sf_num w t get tw 0 sn sh +ret +end +rdval 1 t 255 0 +if ne get rt 0 t +fail 7 +end +if eq get rk 0 3 +sf_num w t get rv 0 sn sh +ret +end +kr = matreg get rk 0 get rv 0 get rt 0 +sf_val w t kr sn sh +end + +note finish: end of a function: a function that needs a value must not reach its end (error 18), a void +note one returns; then the trap stubs: shared tail, function mode MOV X0, X7; LDR X16, [X7, #16]; BR X16 +note (C6.2.282, C6.2.216, C6.2.46: OscRt.trap); program mode ADD X0, X1, #100; MOVZ X8, #93; SVC #0 (exit +note 100 + code). Per trap code used: MOVZ X1, #code (C6.2.285); B tail. om4 FINISH. +fn finish to void +eol +if eq get dead 0 0 +if ne get curret 0 10 +fail 18 +end +epi +end +nt0 = get nt 0 +if ne nt0 0 +tail = get oc 0 +if eq get progmode 0 0 +emit 2852586464 +emit 4181723376 +emit 3592356352 +else +emit 2432798752 +emit 3531606952 +emit 3556769793 +end +code = ulong 1 +while le code 14 +st = ulong 0 +j = ulong 0 +while lt j nt0 +if eq get tcode j code +if eq st 0 +st = get oc 0 +emit or 3531603969 shl code 5 +back tail +end +patch19 get tsite j st +end +j = add j 1 +end +code = add code 1 +end +end +put curret 0 0 +put nn 0 get nglob 0 +put curfn 0 0 +end + +note s_end: close the innermost block (if: patch its branch; else: patch its jump; while: B head; for: i = +note add i 1, B head), or the function. om4 S_END. +fn s_end to void +n = get nb 0 +if eq n 0 +finish +ret +end +i = sub n 1 +put nb 0 i +k = get bkind i +if eq k 2 +put dead 0 and get dead 0 get bdead i +else +put dead 0 0 +end +if eq k 4 +put fr 0 1 +put fr 1 get breg i +put fr 2 get btyp i +put fr 3 3 +put fr 4 1 +put fr 5 get btyp i +binop 33 get breg i 0 +end +if ge k 3 +back get bhead i +end +if eq k 2 +patch26 get bbr i get oc 0 +else +patch19 get bbr i get oc 0 +end +put nn 0 get bnames i +put held 0 get bheld i +eol +end + +note ======== the end of the input: the output ======== +note writeout: the output from byte st to the end, to stdout (error 2), then exit 0. om4 WRITEOUT. +fn writeout st ulong to void +p = st +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p get oc 0 +go = false +else +n = write 1 out p sub get oc 0 p +if le n 0 +fail 2 +end +p = add p ulong n +end +m = add m 1 +end +end +exit int 0 +end + +note elfhdr: the 176-byte file header (om4 ELFHDR, 44 words): ELF64 little-endian, executable, AArch64, +note entry 0x4000b0 (the word after the header), 2 program headers: code read+execute from 0x400000, and +note the read/write pools from 0x10000000. Only the words that are not 0 (the output starts at 0). +fn elfhdr to void +wrword 0 1179403647 +wrword 4 65794 +wrword 16 11993090 +wrword 20 1 +wrword 24 4194480 +wrword 32 64 +wrword 52 3670080 +wrword 56 2 +wrword 64 1 +wrword 68 5 +wrword 80 4194304 +wrword 88 4194304 +wrword 112 4096 +wrword 120 1 +wrword 124 6 +wrword 136 268435456 +wrword 144 268435456 +wrword 168 4096 +end + +note eof_prog: program mode: start code = MOVZ X28, #0x1000, LSL 16 (stack pool floor); MOVZ X16, #0x1080, +note LSL 16; MOV SP, X16 (ADD immediate, C6.2.5); BL main (C6.2.43); [MOVZ X0, #0 for a void main]; MOVZ X8, +note #93; SVC #0. The entry word after the header is a B to it; the header gets the file and pool sizes. +note om4 EOF_PROG. +fn eof_prog to void +f = findfn 1852399981 4 0 +if eq f 0 +fail 16 +end +if ne get fn_np sub f 1 0 +fail 9 +end +wrword 176 or 335544320 and shr sub get oc 0 176 2 67108863 +if ne get hostargs 0 0 +note Preserve Linux's initial argument stack privately before installing Omega's bounded stack. +emit 2432697339 +end +emit 3533832220 +emit 3533836304 +emit 2432696863 +emit or 2483027968 and shr sub get fn_addr sub f 1 get oc 0 2 67108863 +if eq get fn_ret sub f 1 10 +emit 3531603968 +end +emit 3531606952 +emit 3556769793 +elfhdr +wrword 96 get oc 0 +wrword 104 get oc 0 +wrword 160 add get poolb 0 8388608 +writeout 0 +end + +note s_eof: end of input: no open function (error 15), some function (16); function mode: no globals or +note texts (9); one function: its bare words; more: the entry word, a B to the last function. om4 S_EOF. +note Resolve every call after all addresses are known. In function mode remove leaves of the call +note graph; any functions left after nf rounds form or reach a cycle (error 9). +fn resolve to void +n = get ncalls 0 +i = ulong 0 +while lt i n +s = get callsite i +f = sub get callto i 1 +wrword s or 2483027968 and shr sub get fn_addr f s 2 67108863 +i = add i 1 +end +if eq get progmode 0 0 +pass = ulong 0 +while lt pass get nf 0 +f = ulong 0 +while lt f get nf 0 +if eq get settled f 0 +ok = true +i = ulong 0 +while and ok lt i n +if eq get callfrom i add f 1 +if eq get settled sub get callto i 1 0 +ok = false +end +end +i = add i 1 +end +if ok +put settled f 1 +end +end +f = add f 1 +end +pass = add pass 1 +end +f = ulong 0 +while lt f get nf 0 +if eq get settled f 0 +fail 9 +end +f = add f 1 +end +end +end + +fn s_eof to void + +if ne get curret 0 0 +fail 15 +end +if eq get nf 0 0 +fail 16 +end +resolve +if ne get progmode 0 0 +eof_prog +end +if ne get nglob 0 0 +fail 9 +end +if eq get nf 0 1 +writeout 180 +end +a = get fn_addr sub get lastfn 0 1 +wrword 176 or 335544320 and shr sub a 176 2 67108863 +writeout 176 +end + +note stmt: one line. Returns 1 at the end of the input. om4 STMT. +fn stmt to ulong +put nslot 0 get held 0 +tok +k = get tk 0 +if eq k 0 +ret 0 +end +if eq k 3 +s_eof +ret 1 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +s_long +ret 0 +end +w = get tw 0 +c = kw w +if eq c 83 +skipnl +ret 0 +end +if eq c 64 +s_fn +ret 0 +end +if eq get curret 0 0 +if eq c 78 +s_global +ret 0 +end +if eq c 79 +s_text +ret 0 +end +fail 16 +end +if eq c 66 +s_end +ret 0 +end +if eq c 68 +s_else +ret 0 +end +if ne get dead 0 0 +fail 17 +end +if eq c 0 +s_name w +ret 0 +end +if eq c 67 +s_if +ret 0 +end +if eq c 69 +s_while +ret 0 +end +if eq c 71 +s_for +ret 0 +end +if eq c 72 +s_ret +ret 0 +end +if eq c 80 +s_put +ret 0 +end +if eq c 82 +s_exit +ret 0 +end +if or or or eq c 77 eq c 78 eq c 79 eq c 81 +fail 9 +end +fail 16 +ret 0 +end + +note ======== program mode: some line is `fn main` (blanks, fn, blanks, main, then a blank or the end) ======== +note skipbl: the first place at or after q that is not a space or tab (or the end) +fn skipbl q ulong to ulong +e = get inlen 0 +p = q +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +b = get inp p +if or eq b 32 eq b 9 +p = add p 1 +else +go = false +end +end +m = add m 1 +end +end +ret p +end + +note skipln: the place after the next newline at or after q (or the end) +fn skipln q ulong to ulong +e = get inlen 0 +p = q +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +b = get inp p +p = add p 1 +if eq b 10 +go = false +end +end +m = add m 1 +end +end +ret p +end + +note ps_at: the line's first byte that is not blank is at p: 1 when the line is `fn main`, 2 when the input +note ends while deciding, else 0. om4 PS_LINE .. PS_YES. +fn ps_at p ulong to ulong +e = get inlen 0 +if ne get inp p 102 +ret 0 +end +q = add p 1 +if ge q e +ret 2 +end +if ne get inp q 110 +ret 0 +end +r = add q 1 +q = skipbl r +if ge q e +ret 2 +end +if eq q r +ret 0 +end +if gt add q 4 e +ret 0 +end +if ne get inp q 109 +ret 0 +end +if ne get inp add q 1 97 +ret 0 +end +if ne get inp add q 2 105 +ret 0 +end +if ne get inp add q 3 110 +ret 0 +end +if ge add q 4 e +ret 1 +end +if gt get inp add q 4 32 +ret 0 +end +ret 1 +end + +fn prescan to void +e = get inlen 0 +p = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +p = skipbl p +if ge p e +go = false +else +r = ps_at p +if eq r 1 +put progmode 0 1 +go = false +end +if eq r 2 +go = false +end +if go +p = skipln p +if ge p e +go = false +end +end +end +m = add m 1 +end +end +end + +note First collect signatures. Only fn headers are parsed here; other lines are read in the body pass. +fn namescan to void +put scanning 0 1 +put line 0 1 +go = true +while go +n = ulong 0 +while and go lt n 999999 +tok +if eq get tk 0 3 +go = false +else +if ne get tk 0 0 +if and eq get tk 0 1 eq get tw 0 28262 +s_fn +else +skipnl +end +end +end +n = add n 1 +end +end +put scanning 0 0 +put cur 0 0 +put line 0 1 +put nn 0 0 +put curfn 0 0 +put curret 0 0 +put npar 0 0 +put nslot 0 0 +put held 0 0 +end + +note main: read all of stdin +note (8 MiB at most, error 14; a read error is 1), find the mode, then one +note statement per line from output byte 180 (om4 START .. STMT) +fn main to int +off = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge off len inp +fail 14 +end +n = read 0 inp off sub len inp off +if eq n 0 +go = false +else +if lt n 0 +fail 1 +end +off = add off ulong n +end +m = add m 1 +end +end +put inlen 0 off +prescan +namescan +put oc 0 180 +put line 0 1 +done = false +while not done +m = ulong 0 +while and not done lt m 999999 +if ne stmt 0 +done = true +end +m = add m 1 +end +end +ret 0 +end + +#### c2-00041 sha256=6c13fcebf3ceedca5821363538ee7264f43113f72b8f26075de29ef185436294 len=371 +note add, sub, mul, div and neg on f64 and f32; truncating conversions make the results observable. +fn main to int +if ne int add 1.5f64 2.25f64 3 +ret 1 +end +if ne int mul 1.5f64 2.25f64 3 +ret 2 +end +if ne int sub 5.5f64 2.25f64 3 +ret 3 +end +if ne int div 10.0f64 4.0f64 2 +ret 4 +end +if ne int neg 2.5f64 -2 +ret 5 +end +if ne int mul f32 1.5f32 f32 4.0f32 6 +ret 6 +end +ret 0 +end + +#### c2-00042 sha256=7f2851060cd2cd8ddf63fc465564861da118c3532f8dac194ac78a81137ccbc1 len=256 +note f64 and f32 elements in local arrays keep their exact bits. +fn main to int +a = new f64 4 1.5 +put a 2 2.5 +b = bitcast ulong get a 2 +if ne b 4612811918334230528 +ret 1 +end +c = new f32 4 1.5 +d = bitcast uint get c 1 +if ne d 1069547520 +ret 2 +end +ret 0 +end + +#### c2-00043 sha256=fa4da2d9339ab85578398e4021e9ce601613559b324f649c467781d462777dbc len=490 +note comparisons follow IEEE: unordered (NaN) makes every ordered comparison false and != true. +fn main to int +if not lt 1.5f64 2.0f64 +ret 1 +end +if lt 2.5f64 2.0f64 +ret 2 +end +if not le 2.0f64 2.0f64 +ret 3 +end +if not gt 3.0f64 2.0f64 +ret 4 +end +if not ge 3.0f64 3.0f64 +ret 5 +end +if not eq 2.0f64 2.0f64 +ret 6 +end +n = div 0.0f64 0.0f64 +if eq n n +ret 7 +end +if not ne n n +ret 8 +end +if lt n 1.0f64 +ret 9 +end +if le n 1.0f64 +ret 10 +end +if gt n 1.0f64 +ret 11 +end +if ge n 1.0f64 +ret 12 +end +ret 0 +end + +#### c2-00044 sha256=65ae75e90b5b42a4ce0f783307442ee40772ca1959260ab138ae7294a90743e4 len=406 +note int<->float, f32<->f64: truncate, saturate, NaN to 0, round to nearest even. +fn main to int +if ne int f64 -3.7 -3 +ret 1 +end +if ne int f64 3.9 3 +ret 2 +end +if ne int f64 3e9 2147483647 +ret 3 +end +n = div 0.0f64 0.0f64 +if ne int n 0 +ret 4 +end +if ne int f64 1.5 1 +ret 5 +end +x = f32 0.1 +y = f64 x +if ne int mul y 10.0f64 1 +ret 6 +end +z = f64 0.1 +w = f32 z +if ne bitcast uint w 1036831949 +ret 7 +end +ret 0 +end + +#### c2-00045 sha256=7acfa9723193e6c2f6fddd7e3bad650b5674caece785426a09d021bad89d5ad8 len=626 +note f32 literals are rounded once, to binary32: expected bits computed outside this compiler. +fn main to int +a = bitcast uint f32 1.5 +if ne a 1069547520 +ret 1 +end +b = bitcast uint f32 0.1 +if ne b 1036831949 +ret 2 +end +c = bitcast uint f32 3.14159265 +if ne c 1078530011 +ret 3 +end +d = bitcast uint f32 1e-3 +if ne d 981668463 +ret 4 +end +e = bitcast uint f32 3.4028235e38 +if ne e 2139095039 +ret 5 +end +f = bitcast uint f32 1e-45 +if ne f 1 +ret 6 +end +g = bitcast uint f32 1e-46 +if ne g 0 +ret 7 +end +h = bitcast uint f32 6.02214076e23 +if ne h 1727990830 +ret 8 +end +i = bitcast uint f32 1.17549435e-38 +if ne i 8388608 +ret 9 +end +ret 0 +end + +#### c2-00046 sha256=69f1f50da597f8be29894cf1f66d2c4a50bf2a67b9cddc2430540793d9792762 len=863 +note literals convert exactly: every constant here was computed outside this compiler (IEEE-754 bits). +fn main to int +a = bitcast ulong f64 1.5 +if ne a 4609434218613702656 +ret 1 +end +b = bitcast ulong f64 0.1 +if ne b 4591870180066957722 +ret 2 +end +c = bitcast ulong f64 3.141592653589793 +if ne c 4614256656552045848 +ret 3 +end +d = bitcast ulong f64 1e-3 +if ne d 4562254508917369340 +ret 4 +end +e = bitcast ulong f64 -0.0 +if ne e 9223372036854775808 +ret 5 +end +f = bitcast ulong f64 6.02214076e23 +if ne f 4962933279127225623 +ret 6 +end +g = bitcast ulong f64 1.602176634e-19 +if ne g 4325607224011134547 +ret 7 +end +h = bitcast ulong f64 1e308 +if ne h 9214871658872686752 +ret 8 +end +i = bitcast ulong f64 5e-324 +if ne i 1 +ret 9 +end +j = bitcast ulong f64 1e-324 +if ne j 0 +ret 10 +end +k = bitcast ulong f64 1.7976931348623158e308 +if ne k 9218868437227405311 +ret 11 +end +ret 0 +end + +#### c2-00047 sha256=d486ac3eeca262f2935fa9051dec8f158ed469597c6cedb614aed53248a9c6e8 len=281 +note a float pool holds the same 8-byte (f64) or 4-byte (f32) patterns as an array. +global g f64 4 +global h f32 4 +fn main to int +put g 1 0.5 +b = bitcast ulong get g 1 +if ne b 4602678819172646912 +ret 1 +end +put h 3 1.5 +c = bitcast uint get h 3 +if ne c 1069547520 +ret 2 +end +ret 0 +end + +#### c2-00048 sha256=aad37ba8942c0d97ef96053a6942ef55e497df1add274540df0117bc42cff66a len=565 +note fsqrt, fabs, fmin, fmax: one scalar FP instruction each; fmin/fmax are the IEEE minNum/maxNum rule. +fn main to int +a = fsqrt 4.0f64 +if ne int a 2 +ret 1 +end +b = fabs -2.5f64 +if ne bitcast ulong b 4612811918334230528 +ret 2 +end +n = div 0.0f64 0.0f64 +c = fmin n 1.5f64 +if ne bitcast ulong c 4609434218613702656 +ret 3 +end +d = fmax -0.0f64 0.0f64 +if ne bitcast ulong d 0 +ret 4 +end +e = fsqrt f32 4.0f32 +if ne int e 2 +ret 5 +end +f = f32 0.5 +g = fabs f +if ne bitcast uint g 1056964608 +ret 6 +end +h = fmax f32 -0.0f32 f32 0.0f32 +if ne bitcast uint h 0 +ret 7 +end +ret 0 +end + +#### c2-00049 sha256=430c1371717b4ad5763398bcfcb730acde9e71f34664e908674f34b7cfc970b0 len=33 +fn main to int +x = 1.5 +ret 0 +end + +#### c2-00050 sha256=2d59d4a6c4bf9dc502a896fe68b07f664431e3b7de0d4006bb40a753d584e3ac len=36 +fn main to int +x = f64 1. +ret 0 +end + +#### c2-00051 sha256=402c66c99adca7a65b827c4d4a18e9758b1a7e9708988761cd9300decb2683f5 len=47 +fn main to int +for i f64 3 +ret 0 +end +ret 1 +end + +#### c2-00052 sha256=2e5cbda1867a07054f5a5312fd33a8e62f03ed3ec0b5919750c06eeea0dcd0ad len=65 +fn main to int +a = new uchar 4 0 +i = f64 1.0 +ret int get a i +end + +#### c2-00053 sha256=b50ba249e20f89fb7021a0a71b2a3f35cb2609151b7378945669f19189a08607 len=39 +fn main to int +x = fsqrt 2.0 +ret 0 +end + +#### c2-00054 sha256=2863a00fc02623302b2115b3489f84ee99f9b65186b906b50c033373b30fa8b8 len=37 +fn main to int +x = fsqrt 1 +ret 0 +end + +#### c2-00055 sha256=46f5021c7d57eb432797a638b1cd1a9b6388448edeb5329ed27bf751c2f1e86e len=56 +fn main to int +x = fmin f32 1.0f32 f64 2.0f64 +ret 0 +end + +#### c2-00056 sha256=f7d9fc8ad8f8f6cc3072581c322f73b93851cea4f3e1b27b2cd9492521afa487 len=40 +ir +fn main to int +x = f64 1.0 +ret 0 +end + +#### c2-00057 sha256=20960e628cfc44d4c8a67a135b6409437e97aef05d92d5ef07fe078ca1a7f181 len=47 +fn main to int +ret int add f32 1.0 f64 2.0 +end + +#### c2-00058 sha256=7448823e772e887342acc3ab2cf5c1ec5943ab2ad5be40f689d29d308b4ce545 len=39 +fn main to int +x = f64 1e999 +ret 0 +end + +#### c2-00059 sha256=7e0e48611e74eeedba03e27d52e8b39ffefb36add6a88a8e72cf8cc942e90553 len=39 +fn main to int +x = f64 1e309 +ret 0 +end + +#### c2-00060 sha256=03060d58137417dcb85e384b3ebf09294d2205c2a700e1bc03cbd4f9e3f0108a len=40 +fn main to int +x = f32 3.5e38 +ret 0 +end + +#### c2-00061 sha256=7abc1d436207f5db136a845bc90226597e36aa68159be037127c8c1b4530b871 len=60 +fn main to int +a = new f64 4 0.0 +n = read 0 a 0 8 +ret 0 +end + +#### c2-00062 sha256=82ec9c2b6048fd2afbe7775b71235364dc625a2ad35817566e01f51063011cf8 len=291 +note float parameters and return values use the same register convention as integers internally. +fn addf x f64 y f64 to f64 +ret add x y +end +fn half x f64 to f64 +ret div x 2.0 +end +fn main to int +r = addf 1.5 2.5 +if ne int r 4 +ret 1 +end +q = half 5.0 +if ne int mul q 4.0 10 +ret 2 +end +ret 0 +end + +#### c2-00063 sha256=567d36b99d47a9e407581a63aa758caef9b7b799405b2c9fa9bf84a68fa51490 len=451 +note a struct field may be f64 or f32 (an f32 field still uses an 8-byte cell); a view receives it. +struct S a f64 b f32 c f32 2 end +fn total s view S to f64 +ret add get s a f64 get s b +end +fn main to int +x = new S 1.5 2.5 0.5 +put x c 1 3.5 +if ne bitcast ulong get x a 4609434218613702656 +ret 1 +end +if ne bitcast uint get x b 1075838976 +ret 2 +end +if ne bitcast uint get x c 1 1080033280 +ret 3 +end +r = total x +if ne int mul r 2.0 8 +ret 4 +end +ret 0 +end + +#### c2-00064 sha256=ebe3a28b5fe6e5e9dc06d7760dec27f6be2f8eec73382c096b277a86e7550f90 len=264 +note existing .om code uses bits, min, max, abs and sqrt as ordinary names; none may become a keyword. +fn min a ulong b ulong to ulong +ret add a b +end +fn main to ulong +bits = ulong 1 +max = ulong 2 +abs = ulong 3 +sqrt = ulong 4 +ret min bits add max add abs sqrt +end + +#### c2-00065 sha256=16c462b70f493a4f416c066334ebd3062d908d2b27287278f98c0ba4ab9b28e0 len=43 +fn main to int +bitcast = ulong 1 +ret 0 +end + +#### c2-00066 sha256=73a40d7ea270b6c9b9012f62493b63ecdb2ff7987a4fadef057c5babd473f164 len=64 +struct S a uchar end +fn main to int +x = offsetof S zz +ret 0 +end + +#### c2-00067 sha256=ebf14dc2af667808b209d9cdbd23b54d5db9aa5d2f3a225d2a0f72c9752eed4c len=45 +fn main to int +x = offsetof Nope a +ret 0 +end + +#### c2-00068 sha256=c2b409e82e1a38e4ae9de0318ee2f1f53ba2f25dc8ad1ccd30a9e6e06754a510 len=43 +fn main to int +x = sizeof nosuch +ret 0 +end + +#### c2-00069 sha256=4a0cb7e9baefc97ee40ab6c381cb773ec5bb4f17bcd385f15e9263a122a47f6a len=41 +fn main to int +x = sizeof void +ret 0 +end + +#### c2-00070 sha256=f4592fdc60365bd430683daa6d6fcfbba4ffe0b3bee95297232b3e08ecf529cf len=610 +note sizeof and offsetof are compile-time constants of type ulong; struct fields live in 8-byte cells. +struct S a uchar b ulong c uchar 3 end +fn main to int +if ne sizeof bool 1 +ret 1 +end +if ne sizeof uchar 1 +ret 2 +end +if ne sizeof ushort 2 +ret 3 +end +if ne sizeof uint 4 +ret 4 +end +if ne sizeof ulong 8 +ret 5 +end +if ne sizeof int 4 +ret 6 +end +if ne sizeof long 8 +ret 7 +end +if ne sizeof f32 4 +ret 8 +end +if ne sizeof f64 8 +ret 9 +end +if ne sizeof S 40 +ret 10 +end +if ne offsetof S a 0 +ret 11 +end +if ne offsetof S b 8 +ret 12 +end +if ne offsetof S c 16 +ret 13 +end +if ne add sizeof S offsetof S b 48 +ret 14 +end +ret 0 +end + +#### c2-00071 sha256=81c099f6194f6e2729fe1eb75e5d6fdf2f00ef6878822b8037a4ecef6aeb7ce1 len=66 +fn main to int +k = ulong 0 +while lt k 1 +break +ret 1 +end +ret 0 +end + +#### c2-00072 sha256=a4ddae58e0cab53f8f2feb28a171f9dcd8b0964ce2bfb29fa72c65f0d04685fe len=69 +fn main to int +k = ulong 0 +while lt k 1 +continue +ret 1 +end +ret 0 +end + +#### c2-00073 sha256=8b6b5c169089f858f4d42badca3fe545d72dd079d09671d8984c104590ad778e len=28 +fn main to int +continue +end + +#### c2-00074 sha256=2f5242b6d64b4c9ef5e8454631450056a0df8e3810fe25e8a00e68393be47b0c len=25 +fn main to int +break +end + +#### c2-00075 sha256=8763b05ba65de8d503f326c96f16a8345204243f69e18e2ee8449364145b4657 len=26 +fn main to int +trap 0 +end + +#### c2-00076 sha256=af081438536daa393acebe8f5031a7293397898235d1ecaa1a10d7fae90d614b len=27 +fn main to int +trap 15 +end + +#### c2-00077 sha256=dd19f2b1be45c381db256571a5d48d13c926c06e864bd256b10eeb83e4579693 len=182 +note continue in a while jumps to the head: 1 + 2 + 4 + 5 + 6 = 18 +fn main to ulong +i = ulong 0 +s = ulong 0 +while lt i 6 +i = add i 1 +if eq i 3 +continue +end +s = add s i +end +ret s +end + +#### c2-00078 sha256=b4f64b0fce985d9a5f51d78d031212db57db667edcea9f4f8af911de4e201215 len=182 +note continue in a for jumps to the increment, so the loop still advances: 0+1+2+4+5 = 12 +fn main to ulong +s = ulong 0 +for i ulong 6 +if eq i 3 +continue +end +s = add s i +end +ret s +end + +#### c2-00079 sha256=9cd732ba8a9460b301b349580caab8817e1b949b654b0f98f0068ec37e1c2c79 len=210 +note continue leaves only the inner iteration: 2 successes per outer pass, 3 x 12 = 36 +fn main to ulong +n = ulong 0 +for i ulong 3 +for j ulong 3 +if eq j 1 +continue +end +n = add n 1 +end +n = add n 10 +end +ret n +end + +#### c2-00080 sha256=d485922515a8324f47930a7184c2f8da9efcf3f61192b058f1fc81ac6f6c966f len=133 +note continue as the whole body must still advance the for counter and terminate +fn main to int +for i ulong 3 +continue +end +ret 0 +end + +#### c2-00081 sha256=64d0cdd05e2f5a1a8fa2ff84caca3530f6caedd76fe8a8ece0a7b12b58203353 len=164 +note the while bound still counts when every pass continues: trap 4 after 3 passes, exit 104 +fn main to int +i = ulong 0 +while lt i 3 bound 3 +continue +end +ret 0 +end + +#### c2-00082 sha256=50c545731b4991ffaf416779b2fefdfeaaefd808ee2e6d6449d973ee9747b81a len=138 +note for with a conditional break: 0 + 1 + 2 = 3 +fn main to ulong +s = ulong 0 +for i ulong 5 +if eq i 3 +break +end +s = add s i +end +ret s +end + +#### c2-00083 sha256=ba8e33652ba800ea6ae9716fedc2fb8b7d574db47ad244dc43ecf6917129d699 len=194 +note break leaves only the inner loop: 1 + 10 per outer pass, 3 x 11 = 33 +fn main to ulong +n = ulong 0 +for i ulong 3 +for j ulong 3 +if eq j 1 +break +end +n = add n 1 +end +n = add n 10 +end +ret n +end + +#### c2-00084 sha256=9c84795693cc28dd38333af5376d5bf4def29878083b98667d7eaf442ce9d74b len=177 +note a break outside the inner loop targets the outer loop: 2 + 2 = 4 +fn main to ulong +n = ulong 0 +for i ulong 3 +for j ulong 2 +n = add n 1 +end +if eq i 1 +break +end +end +ret n +end + +#### c2-00085 sha256=c516894ebc1597c36935a06ae504d5ff9f5f6c26ce8e7a9bfad40e7553f181ca len=213 +note two loops reuse a block slot; the first break must not be patched by the second loop +fn main to ulong +n = ulong 0 +while lt n 1 +break +end +n = add n 1 +while lt n 5 +n = add n 1 +if eq n 3 +break +end +end +ret n +end + +#### c2-00086 sha256=cfb1ad20093af061bd111b3b20861c9bace86ee4d367d0ac904960910231569f len=68 +note trap 5 in program mode exits 100 + 5 +fn main to int +trap 5 +end + +#### c2-00087 sha256=9c692c8b82fe5c32c2ecb652d06602dedbf08ce14357b8c727f9294e200b20cd len=149 +note a trap inside if exits 107; the path after the if stays live through the other branch +fn main to int +x = ulong 1 +if eq x 1 +trap 7 +end +ret 0 +end + +#### c2-00088 sha256=4a945f2c5e02388247338c878ca76910ea1ee3d70e6a8d04be642d3b22ce7808 len=164 +note while with a conditional break: 1 + 2 + 3 = 6 +fn main to ulong +i = ulong 0 +s = ulong 0 +while lt i 10 +i = add i 1 +if eq i 4 +break +end +s = add s i +end +ret s +end + +#### c2-00089 sha256=9a2dacafd0a2a543c767af1ec5680ef00e9e0bcc86b24db1befd614f6ded87c4 len=244 +note parentheses are separate words even when written next to a value; they only group. +fn main to int +a = (int 2) +b = ((int 3)) +if ne add a b 5 +ret 1 +end +if ne add (mul (int 2) (int 3)) (int 4) 10 +ret 2 +end +if ne (int 7) 7 +ret 3 +end +ret 0 +end + +#### c2-00090 sha256=38908ab20dd18f470a67942b70a0175484f5f96674d412753cf8f57a9d0c4f6a len=51 +fn main to int +ret int add (f64 1.5) (f64 2.5) +end + +#### c2-00091 sha256=633e3e6512303828bffe2f0bc7a25eac0f86b22b8eadd2bc24216ce95fdfc588 len=33 +fn main to int +x = (5) +ret 0 +end + +#### c2-00092 sha256=ad0849253d2b57503c46d533e79c5d1d23ba98c56193e016a5ef869c8a2193a3 len=26 +fn main to int +ret (5 +end + +#### c2-00093 sha256=5c969447c48b55923d9c3ffb815ed033d270af89e8cbfbc3125f2315ce6be6f6 len=46 +fn main to uint +ret 1 +end +struct P x uint end + +#### c2-00094 sha256=a19f92a0af3ac7238cd7daad5da64d30018a2c305fd380caab99d482bd85a73c len=64 +struct P x uint end +fn main to uint +p = new P 1 +ret get p z +end + +#### c2-00095 sha256=ced0b92a5942d5a5eee2b34bc930e5015e569f98de385c6632eab0130b34f70b len=53 +struct P x uint x uint end +fn main to uint +ret 1 +end + +#### c2-00096 sha256=a01c28b62473796f94823e03c4f8082507c1d98552e87ec4463fd256788869fb len=66 +struct P x uint end +struct P y uint end +fn main to uint +ret 1 +end + +#### c2-00097 sha256=4cce201133535e070c32c1625759e502ab82622851fd61388bed06172392fb31 len=39 +struct P end +fn main to uint +ret 1 +end + +#### c2-00098 sha256=a68d3114b31036f7394296f91cb2f7ca7bc96c3d38f1701f5815626f36b1955d len=46 +struct P P uint end +fn main to uint +ret 1 +end + +#### c2-00099 sha256=100a3f7158c8b082bb2b325eb65146c7f7d24c3263b6277a10b25a3fa25b5e76 len=158 +struct P a uint b uint c uint d uint e uint f uint g uint h uint i uint j uint k uint l uint m uint n uint o uint p uint q uint end +fn main to uint +ret 1 +end + +#### c2-00100 sha256=bbe8f47dcd869bbdd69c1bf5a73fb2741c6e29230f7678ca068c9524104c52e1 len=68 +struct H v uint 4 end +fn main to uint +h = new H 1 +ret get h v 4 +end + +#### c2-00101 sha256=38174e5b4994c8f6f584a9bfbb6556d7b13f6ab41bb14118715fdd578fb63416 len=56 +struct P x uint end +fn main to uint +p = new P +ret 1 +end + +#### c2-00102 sha256=afb7e8a384a3df511e6c080befe32bcaa6532e5cf88319d7061a9526e8c6f642 len=70 +struct P x uint end +fn main to uint +if true +p = new P 1 +end +ret 1 +end + +#### c2-00103 sha256=b9da9ec1eb6d4710dad23b1cd76b4424a69775c629e22fe771766ba12805e6cc len=42 +struct P x uint +fn main to uint +ret 1 +end + +#### c2-00104 sha256=67c021c3a4f4c58449e6c0f9bfa3f554014da853c6ad574973b10e125790197c len=102 +struct P x uint end +fn bad v view P to void +put v x 1 +end +fn main to uint +p = new P 1 +bad p +ret 1 +end + +#### c2-00105 sha256=d9fa9e7eff138630081c4a5dd649347f2ad61a1910d3a14f71174b56f1213ef9 len=65 +struct P x uint end +fn main to uint +p = new P 1 +free p +ret 1 +end + +#### c2-00106 sha256=c076ef26f041417a543b291437881291d2b0899b1d2c81ddd5bc2d2984aa027f len=87 +struct P x uint y uint end +fn main to uint +p = new P 20 22 +ret add get p x get p y +end + +#### c2-00107 sha256=fd78d1b9bf5e5c5bc1d5e1a0318853fe4bc15c54b3289c4a29ef840d2e7da3c6 len=75 +struct P x uint y uint end +fn main to uint +p = new P 20 22 +ret get p x +end + +#### c2-00108 sha256=39271665c00b200d73bb7d0925e53e053e11055ea6bc6ac1ffbf5179ff845c02 len=75 +struct P x uint y uint end +fn main to uint +p = new P 20 22 +ret get p y +end + +#### c2-00109 sha256=68a1efe3f203bf166430c748c53f4affe55101b52fb0b211cdf1ef02af371573 len=109 +struct H n uint v uint 4 end +fn main to uint +h = new H 3 3 +put h v 1 add get h n get h v 1 +ret get h v 1 +end + +#### c2-00110 sha256=3f0680abdd48b9b1d472f0bcc6b70d848a3dea88375d9a48b6f477a81b537854 len=141 +struct A x int end +struct B y int z int end +fn main to int +p = new A 5 +q = new B 4 5 +put q z mul get p x get q y +ret sub get q z get p x +end + +#### c2-00111 sha256=ca3f280447fab7ad542a0aac78d2e477a92d1d8a12b2d29f55552bdc04f9b1e3 len=132 +struct V a ulong b ulong end +fn total v view V to ulong +ret add get v a get v b +end +fn main to ulong +s = new V 10 7 +ret total s +end + +#### c2-00112 sha256=2ed0931c02af8178a428592f526fd4a32a1ea796d1c3c58510212abb234ae9e3 len=171 +struct C n uint last uint end +fn bump c edit C v uint to void +put c n add get c n v +put c last v +end +fn main to uint +c = new C 4 4 +bump c 3 +ret add get c n get c last +end + +#### c2-00113 sha256=5dd4ea9d05d622c6f7955dd77b77125dd5aeb1e85e0a7abdaec573fb2273f942 len=160 +struct Acc sum long v long 4 end +fn main to long +s = new Acc 3 3 +for i long 4 +put s v i add get s v i i +put s sum add get s sum get s v i +end +ret get s sum +end + +#### c2-00114 sha256=3784978d2eb13e49fe822930b173d08179e66a4d8cc145507cfa1bf29d0c66dd len=84 +struct M a uint b uchar end +fn main to uint +p = new M 1 2 +put p b 9 +ret get p a +end + +#### c2-00115 sha256=5080d43e83ab8629ce6279b9c4ec71f6c047304d2ef1ec98578d74843793b984 len=89 +struct M a uint b uchar end +fn main to uint +p = new M 1 2 +put p b 9 +ret uint get p b +end + +#### c2-00116 sha256=a6fc7ace001b2656b87e0540199936dc5f46a6f7f4dec14910f6a42fbd136cbd len=114 +struct N a uchar b uint c uchar d uchar e uchar end +fn main to uint +p = new N 0 1 0 0 0 +put p e 9 +ret get p b +end + +#### c2-00117 sha256=63a54e3b414f10ecb6655c46781901a99e7c0a024be134a89d505afa8e2ee325 len=88 +struct H v uint 2 t uchar end +fn main to uint +p = new H 1 1 +put p t 9 +ret get p v 0 +end + +#### c2-00118 sha256=90a3990c6576da4f0e31f18aa5112ea74cda548348264749eca695f6f3685989 len=243 +note text bytes with every escape are written to stdout and read back with get and len +text t "a\tb\\c\"d\ne" +global g uchar 16 +fn main to int +n = write int 1 t ulong 0 len t +put g 0 get t 2 +ret add int get t 0 int add len t ulong get g 0 +end + +#### c2-00119 sha256=eb4b7fdbc09894f22eeca00930010dbf90e98e4c32b8836730b0049853b6fd9d len=555 +note SPDX-License-Identifier: Apache-2.0 +note Binary request adapter for the native stream consumer, also exercised by unit.om. +global rngreq uchar 265 +global rngout uchar 64 + +fn rngreqok n ulong to int +if or lt n 8 gt n 264 +ret 2 +end +seed = ulong 0 +for i ulong 8 +seed = or seed shl ulong get rngreq i mul i 8 +end +size = sub n 8 +for i ulong size +put rngtag i get rngreq add i 8 +end +ret rnginit seed size +end + +fn rngpack to void +for word ulong 8 +v = rngnext +for octet ulong 8 +put rngout add mul word 8 octet uchar and shr v mul octet 8 255 +end +end +ret +end + +#### c2-00120 sha256=9e33c77230da8cfa898f43503656556112f2a4b4c2f52320a4f7e349949ebf34 len=1653 +note SPDX-License-Identifier: Apache-2.0 +note Handwritten PD0 stream primitive. See README.md for the bounded byte-tag API. +note Single stream, explicit global storage; no allocator, C call or implicit wrapping. +global rngtag uchar 256 +global rngstate ulong 1 + +note Low 64 bits of addition: each intermediate is less than 2^34. +fn rngadd a ulong b ulong to ulong +lo = add and a 4294967295 and b 4294967295 +hi = add add shr a 32 shr b 32 shr lo 32 +ret or shl and hi 4294967295 32 and lo 4294967295 +end + +note Low 64 bits of multiplication in base 65536. +note Each column has at most four 16-bit products plus carry, below 2^35. +note Only the masked digit is shifted, so every shift fits ulong exactly. +fn rngmul a ulong b ulong to ulong +out = ulong 0 +carry = ulong 0 +for k ulong 4 +sum = carry +for j ulong add k 1 +av = and shr a mul j 16 65535 +bv = and shr b mul sub k j 16 65535 +sum = add sum mul av bv +end +out = or out shl and sum 65535 mul k 16 +carry = shr sum 16 +end +ret out +end + +note Return 2 for capacity or embedded NUL, preserving state on refusal. +note Valid tags are exactly n nonzero bytes, equivalent to a C tag plus terminator. +fn rnginit seed ulong n ulong to int +if gt n len rngtag +ret 2 +end +hash = ulong 14695981039346656037 +for i ulong n +c = get rngtag i +if eq c uchar 0 +ret 2 +end +hash = rngmul xor hash ulong c 1099511628211 +end +put rngstate 0 xor seed hash +ret 0 +end + +fn rngnext to ulong +state = rngadd get rngstate 0 11400714819323198485 +put rngstate 0 state +z = rngmul xor state shr state 30 13787848793156543929 +z = rngmul xor z shr z 27 10723151780598845931 +ret xor z shr z 31 +end + +fn rnguniform to ulong +ret rem rngnext 1000001 +end + +#### c2-00121 sha256=52196ac35631bdb2ba3e887acc2deabf871e379ba51143518ba82a1c804aca91 len=763 +note SPDX-License-Identifier: Apache-2.0 +note Concatenate rng.om, request.om then this consumer before compilation. +note Request: 8-byte little-endian seed, then 0..256 nonzero tag bytes, then EOF. +note Response: eight successive little-endian 64-bit words, exactly 64 bytes. +note Exit 2 malformed/capacity, 4 I/O failure; no output before validation. +fn main to int +used = ulong 0 +reading = true +while and reading lt used len rngreq +n = read 0 rngreq used sub len rngreq used +if lt n 0 +ret 4 +end +if eq n 0 +reading = false +else +used = add used ulong n +end +end +status = rngreqok used +if ne status 0 +ret status +end +rngpack +sent = ulong 0 +while lt sent len rngout +n = write 1 rngout sent sub len rngout sent +if le n 0 +ret 4 +end +sent = add sent ulong n +end +ret 0 +end + +#### c2-00122 sha256=329dd2e21b38335f14aee27e6b572cc3427eb17ea072b0b02da8856c651eac59 len=5778 +note SPDX-License-Identifier: Apache-2.0 +note Concatenate rng.om, request.om, unit.om. Exit 0 only if all checks pass. +note Expected values from the unmodified C baseline at d863780eb42bd940349eba61a3d1c78b0b819941. +text world "world" +fn main to int +note Modular arithmetic carries and maximum products. +if ne rngadd 18446744073709551615 1 0 +ret 1 +end +if ne rngadd 18446744073709551615 18446744073709551615 18446744073709551614 +ret 2 +end +if ne rngmul 18446744073709551615 18446744073709551615 1 +ret 3 +end +if ne rngmul 4294967296 4294967296 0 +ret 4 +end +if ne rngmul 18446744073709551615 65536 18446744073709486080 +ret 5 +end +note Raw SplitMix state extremes, including increment wraparound. +put rngstate 0 0 +if ne rngnext 16294208416658607535 +ret 6 +end +if ne get rngstate 0 11400714819323198485 +ret 7 +end +put rngstate 0 18446744073709551615 +if ne rngnext 16490336266968443936 +ret 8 +end +if ne get rngstate 0 11400714819323198484 +ret 9 +end +note Empty tag, zero seed, eight consecutive outputs and post-draw state. +if ne rnginit 0 0 0 +ret 10 +end +if ne get rngstate 0 14695981039346656037 +ret 11 +end +if ne rngnext 14087677454934409008 +ret 12 +end +if ne rngnext 1156539639830188822 +ret 13 +end +if ne rngnext 6107907394010225435 +ret 14 +end +if ne rngnext 3199123669689638002 +ret 15 +end +if ne rngnext 7288325018142838421 +ret 16 +end +if ne rngnext 17866453389242143151 +ret 17 +end +if ne rngnext 8177402106386418192 +ret 18 +end +if ne rngnext 7327937117123367831 +ret 19 +end +if ne get rngstate 0 13667979225384485837 +ret 20 +end +if ne rnginit 18446744073709551615 0 0 +ret 21 +end +if ne rngnext 3526150024844925518 +ret 22 +end +if ne rngnext 11731478886250893314 +ret 23 +end +note One byte and multibyte ASCII, both seed extremes. +put rngtag 0 97 +if ne rnginit 0 1 0 +ret 24 +end +if ne get rngstate 0 12638187200555641996 +ret 25 +end +if ne rngnext 6857225946766476583 +ret 26 +end +if ne rngnext 18412106973715859535 +ret 27 +end +if ne rnginit 18446744073709551615 1 0 +ret 28 +end +if ne rngnext 15365624696913284058 +ret 29 +end +if ne rngnext 14384683269263029524 +ret 30 +end +for i ulong len world +put rngtag i get world i +end +if ne rnginit 0 len world 0 +ret 31 +end +if ne get rngstate 0 5717881983045765875 +ret 32 +end +if ne rngnext 17513863605490730988 +ret 33 +end +if ne rngnext 9401024372741141497 +ret 34 +end +if ne rnginit 18446744073709551615 len world 0 +ret 35 +end +if ne rngnext 5751318989716258026 +ret 36 +end +if ne rngnext 12984362597069512417 +ret 37 +end +note High-bit bytes are unsigned, not sign-extended. +put rngtag 0 128 +put rngtag 1 255 +if ne rnginit 0 2 0 +ret 40 +end +if ne get rngstate 0 713197150969623264 +ret 41 +end +if ne rngnext 11707748180763584890 +ret 42 +end +if ne rngnext 14667845794806978071 +ret 43 +end +if ne rngnext 7581507163619784878 +ret 44 +end +if ne rngnext 6812334620058058772 +ret 45 +end +if ne rngnext 793927904360208106 +ret 46 +end +if ne rngnext 1256370476000318575 +ret 47 +end +if ne rngnext 14222632400573449213 +ret 48 +end +if ne rngnext 4532184365850327507 +ret 49 +end +if ne get rngstate 0 18131939410717004680 +ret 50 +end +if ne rnginit 18446744073709551615 2 0 +ret 51 +end +if ne rngnext 15903987064210817861 +ret 52 +end +if ne rngnext 7962989993763865288 +ret 53 +end +note Capacity boundary, last byte included, and both seed extremes. +for i ulong len rngtag +put rngtag i 97 +end +if ne rnginit 0 256 0 +ret 60 +end +if ne get rngstate 0 18242136092491110437 +ret 61 +end +if ne rngnext 1543074406968970713 +ret 62 +end +if ne rngnext 16439775865296349378 +ret 63 +end +if ne rnginit 18446744073709551615 256 0 +ret 64 +end +if ne rngnext 6955825034878021046 +ret 65 +end +if ne rngnext 8540932145809807677 +ret 66 +end +note Uniform consumes exactly one draw, preserving the following word. +if ne rnginit 0 0 0 +ret 70 +end +if ne rnguniform 41737 +ret 71 +end +if ne rngnext 1156539639830188822 +ret 72 +end +note Invalid tags must refuse before changing the prior stream state. +old = get rngstate 0 +if ne rnginit 0 257 2 +ret 80 +end +if ne rnginit 0 18446744073709551615 2 +ret 81 +end +put rngtag 0 0 +if ne rnginit 0 1 2 +ret 82 +end +put rngtag 0 97 +put rngtag 255 0 +if ne rnginit 0 256 2 +ret 83 +end +if ne get rngstate 0 old +ret 84 +end +note Request framing rejects short and oversized lengths without indexing. +if ne rngreqok 0 2 +ret 90 +end +if ne rngreqok 7 2 +ret 91 +end +if ne rngreqok 265 2 +ret 92 +end +if ne rngreqok 18446744073709551615 2 +ret 93 +end +if ne get rngstate 0 old +ret 94 +end +for i ulong 8 +put rngreq i 0 +end +put rngreq 8 0 +if ne rngreqok 9 2 +ret 95 +end +if ne get rngstate 0 old +ret 96 +end +note Valid request, full response packing, repeated-call determinism. +if ne rngreqok 8 0 +ret 100 +end +rngpack +if ne get rngstate 0 13667979225384485837 +ret 101 +end +note Independently fixed byte order for the first response word. +if ne get rngout 0 48 +ret 109 +end +if ne get rngout 1 255 +ret 110 +end +if ne get rngout 2 164 +ret 111 +end +if ne get rngout 3 107 +ret 112 +end +if ne get rngout 4 1 +ret 113 +end +if ne get rngout 5 124 +ret 114 +end +if ne get rngout 6 129 +ret 115 +end +if ne get rngout 7 195 +ret 116 +end +if ne rnginit 0 0 0 +ret 102 +end +for word ulong 8 +v = rngnext +for octet ulong 8 +if ne get rngout add mul word 8 octet uchar and shr v mul octet 8 255 +ret 103 +end +end +end +for i ulong 8 +put rngreq i 255 +end +put rngreq 8 128 +put rngreq 9 255 +if ne rngreqok 10 0 +ret 104 +end +if ne get rngstate 0 17733546922739928351 +ret 105 +end +if ne rngnext 15903987064210817861 +ret 106 +end +for i ulong 256 +put rngreq add i 8 97 +end +if ne rngreqok 264 0 +ret 107 +end +if ne rngnext 6955825034878021046 +ret 108 +end +note Mixed seed bytes detect reversed or permuted seed decoding. +put rngreq 0 1 +put rngreq 1 35 +put rngreq 2 69 +put rngreq 3 103 +put rngreq 4 137 +put rngreq 5 171 +put rngreq 6 205 +put rngreq 7 239 +if ne rngreqok 8 0 +ret 117 +end +if ne get rngstate 0 2611867254004318244 +ret 118 +end +if ne rngnext 7292048037619145208 +ret 119 +end +ret 0 +end + +#### c2-00123 sha256=bcfb200a48291c27d4a700ea074e02616a881767c8838a52ad2dfd7b83b52d33 len=175 +note Exercise the actual backward B.LO caller for local-array initialization. +fn main to int +a = new ulong 64 12345 +for i ulong 64 +if ne get a i 12345 +ret 1 +end +end +ret 0 +end + +#### c2-00124 sha256=3165c09cb7ed7523355ccaa1acbdc89be55c2882fbb61fc7f25594bd68deeca3 len=2602 +note Consume independently decoded GNU objdump output, not machine words from the compiler. +note Exit61 target mismatch;62 invalid input. Only the first b.ne and unique mov marker are selected. +global linebuf uchar 512 +global chunk uchar 4096 +global cursor ulong 1 +global branch ulong 1 +global marker ulong 1 +global bcount ulong 1 +global mcount ulong 1 +text mn "b.ne" +text label "mov\tx1, #0x3039" +fn hexval b uchar to ulong +if and ge b 48 le b 57 +ret sub ulong b 48 +end +if and ge b 97 le b 102 +ret add sub ulong b 97 10 +end +ret 16 +end +fn number start ulong n ulong to ulong +p = start +value = ulong 0 +while lt p n +v = hexval get linebuf p +if eq v 16 +if eq p start +exit 62 +end +put cursor 0 p +ret value +end +if ge sub p start 16 +exit 62 +end +value = or shl value 4 v +p = add p 1 +end +if eq p start +exit 62 +end +put cursor 0 p +ret value +end +fn hasmn i ulong n ulong to bool +if or eq i 0 ge add i len mn n +ret false +end +if and ne get linebuf sub i 1 9 ne get linebuf sub i 1 32 +ret false +end +for j ulong len mn +if ne get linebuf add i j get mn j +ret false +end +end +v = get linebuf add i len mn +ret or eq v 9 eq v 32 +end +fn hasmark i ulong n ulong to bool +if or eq i 0 gt add i len label n +ret false +end +if and ne get linebuf sub i 1 9 ne get linebuf sub i 1 32 +ret false +end +for j ulong len label +if ne get linebuf add i j get label j +ret false +end +end +if lt add i len label n +v = get linebuf add i len label +if and ne v 32 ne v 9 +ret false +end +end +ret true +end +fn target i ulong n ulong to ulong +p = add i len mn +while lt p n +v = get linebuf p +if and ne v 32 ne v 9 +if gt add p 2 n +exit 62 +end +if or ne v 48 ne get linebuf add p 1 120 +exit 62 +end +value = number add p 2 n +q = get cursor 0 +if lt q n +v = get linebuf q +if and ne v 32 ne v 9 +exit 62 +end +end +ret value +end +p = add p 1 +end +exit 62 +end +fn inspect n ulong to void +p = ulong 0 +while lt p n +if ne get linebuf p 32 +if eq hexval get linebuf p 16 +ret +end +addr = number p n +q = get cursor 0 +if ge q n +ret +end +if or ne get linebuf q 58 lt addr 176 +ret +end +for i ulong n +if eq get bcount 0 0 +if hasmn i n +put branch 0 target i n +put bcount 0 1 +end +end +if hasmark i n +put marker 0 addr +put mcount 0 add get mcount 0 1 +end +end +ret +end +p = add p 1 +end +end +fn main to int +n = ulong 0 +go = true +while go +r = read 0 chunk 0 len chunk +if lt r 0 +ret 62 +end +if eq r 0 +go = false +else +for k ulong ulong r +if eq get chunk k 10 +inspect n +n = ulong 0 +else +if ge n len linebuf +ret 62 +end +put linebuf n get chunk k +n = add n 1 +end +end +end +end +if ne n 0 +inspect n +end +if or ne get bcount 0 1 ne get mcount 0 1 +ret 62 +end +if ne get branch 0 get marker 0 +ret 61 +end +ret 0 +end + +#### c2-00125 sha256=a2672e4d018ca2ded61044af19bcde0ad7f8a3990429067aa2d5086ee681a413 len=2037 +note Synthetic source generator for issue669. Reads one mode byte and a 4-byte little-endian repetition +note count on stdin, then writes one program. Mode0 if over the body, mode1 nested if, mode2 while over +note the body, mode3 a trap followed by the body. Every program ends with a unique mov x1, 12345 marker +note whose address is the expected branch target. Only synthetic source is produced. +global arg uchar 5 +global extra uchar 1 +text pre0 "fn main to int\nx = ulong 0\ny = ulong 0\nif eq x 1\n" +text pre1 "fn main to int\nx = ulong 0\ny = ulong 0\nif eq x 1\nif eq x 2\n" +text pre2 "fn main to int\nx = ulong 0\ny = ulong 0\nwhile eq x 1\n" +text pre3 "fn main to int\nx = ulong 1\ny = ulong 0\nz = div x 0\n" +text stmt "x = add x 1\n" +text post0 "end\ny = ulong 12345\nret int x\nend\n" +text post1 "end\nend\ny = ulong 12345\nret int x\nend\n" +text post2 "end\ny = ulong 12345\nret int x\nend\n" +text post3 "y = ulong 12345\nret int x\nend\n" +fn main to int +pos = ulong 0 +while lt pos 5 +r = read 0 arg pos sub 5 pos +if le r 0 +ret 90 +end +pos = add pos ulong r +end +mode = ulong get arg 0 +if gt mode 3 +ret 90 +end +if ne read 0 extra 0 1 0 +ret 90 +end +n = ulong 0 +i = ulong 0 +while lt i 4 +b = ulong get arg add i 1 +n = or n shl b mul i 8 +i = add i 1 +end +if gt n 600000 +ret 90 +end +if eq mode 0 +r = write 1 pre0 0 len pre0 +if ne r long len pre0 +ret 91 +end +else +if eq mode 1 +r = write 1 pre1 0 len pre1 +if ne r long len pre1 +ret 91 +end +else +if eq mode 2 +r = write 1 pre2 0 len pre2 +if ne r long len pre2 +ret 91 +end +else +r = write 1 pre3 0 len pre3 +if ne r long len pre3 +ret 91 +end +end +end +end +i = ulong 0 +while lt i n +r = write 1 stmt 0 len stmt +if ne r long len stmt +ret 91 +end +i = add i 1 +end +r = long 0 +expected = ulong 0 +if eq mode 0 +r = write 1 post0 0 len post0 +expected = len post0 +else +if eq mode 1 +r = write 1 post1 0 len post1 +expected = len post1 +else +if eq mode 2 +r = write 1 post2 0 len post2 +expected = len post2 +else +r = write 1 post3 0 len post3 +expected = len post3 +end +end +end +if ne r long expected +ret 91 +end +ret 0 +end + +#### c2-00126 sha256=4bc9e252ca68ba185c284b9b9aed09dee83526abae9913db6c6b592700db76e1 len=2045 +note Exact-source qualification transform. Mode0 exposes the real disp19 through a new main. +note Mode1 weakens the forward limit by two instructions. No transformed artifact is a production compiler. +global src uchar 262144 +global used ulong 1 +global mode uchar 8 +global needle uchar 64 +global repl uchar 64 +text entry "fn main to int" +text renamed "fn prev to int" +text limit "gt diff 1048572" +text weak "gt diff 1048580" +text probe "\nfn main to int\nn = read 0 msg 0 1\nif ne n 1\nret 90\nend\nm = get msg 0\na = ulong 0\nt = ulong 0\ne = ulong 0\nif eq m 0\nt = ulong 1048572\ne = ulong 262143\nend\nif eq m 1\na = ulong 1048576\ne = ulong 262144\nend\nif eq m 2\na = ulong 1024\ne = ulong 524032\nend\nif eq m 3\na = ulong 1028\ne = ulong 524031\nend\nif eq m 4\nt = ulong 1048576\nend\nif eq m 5\na = ulong 1048580\nend\nif eq m 6\nt = ulong 2\nend\nif eq m 7\na = ulong 2\nend\nv = disp19 a t\nif ge m 4\nret 81\nend\nif ne v e\nret 82\nend\nret 0\nend\n" +fn matches i ulong to bool +for j ulong get used 0 +if ne get src add i j get needle j +ret false +end +end +ret true +end +fn replace i ulong to void +for j ulong get used 0 +put src add i j get repl j +end +end +fn main to int +if ne argcnt 2 +ret 90 +end +r = argread 1 mode 0 len mode +if ne r 1 +ret 90 +end +m = get mode 0 +if and ne m 48 ne m 49 +ret 90 +end +if eq m 48 +put used 0 len entry +for i ulong len entry +put needle i get entry i +put repl i get renamed i +end +else +put used 0 len limit +for i ulong len limit +put needle i get limit i +put repl i get weak i +end +end +n = ulong 0 +go = true +while go +if eq n len src +ret 91 +end +r = read 0 src n sub len src n +if lt r 0 +ret 92 +end +if eq r 0 +go = false +else +n = add n ulong r +end +end +found = ulong 0 +for i ulong n +if le get used 0 sub n i +if matches i +found = add found 1 +replace i +end +end +end +if ne found 1 +ret 93 +end +p = ulong 0 +while lt p n +r = write 1 src p sub n p +if le r 0 +ret 94 +end +p = add p ulong r +end +if eq m 48 +p = ulong 0 +while lt p len probe +r = write 1 probe p sub len probe p +if le r 0 +ret 94 +end +p = add p ulong r +end +end +ret 0 +end + +#### c2-00127 sha256=459a60da8e660ee1f433a9679bb41467074fda45997e5168e23e92ebad0d570b len=291 +note Supervisor negative controls: known wrong exit, self-signal, deadline overrun. +global mode uchar 1 +fn main to int +if ne read 0 mode 0 1 1 +ret 90 +end +m = get mode 0 +if eq m 0 +ret 7 +end +if eq m 1 +r = killpid int getpid 9 +ret 98 +end +if eq m 2 +r = sleepns 45000000000 +ret 98 +end +ret 90 +end + +#### c2-00128 sha256=07bc11a69f0d629e0c262056061789114d8710505a308e3e2a5ac42ae73dee94 len=7593 +note Native issue669 qualification coordinator. Run from repository root; scratch must not exist. +note All child exits are observed; signal, timeout, failed build, malformed oracle output fail closed. +note GNU objdump is an independent decoder. Hashes identify artifacts and do not prove correctness. +text scratch "build/security673-native" +text prefix "build/security673-native/" +text names "seed/omc/omc.om\nseed/qualification/security673/branch-corpus.om\nseed/qualification/security673/branch-mutate.om\nseed/qualification/security673/branch-check.om\n/usr/bin/objdump\n-D\n-b\nbinary\n-m\naarch64\n0\n1\n/dev/null\nseed/rung4/om4.bin\nseed/qualification/security673/array-fill.om\nseed/qualification/security673/oracle-corpus.om\nseed/qualification/security673/gate-child.om\n" +text input " < " +text output " > " +text errors " 2> " +text nl "\n" +text statusm "exit=" +text expect " expected=" +text signalm "INVALID child wait low-byte=" +text timeoutm "INVALID child deadline exceeded; sent SIGKILL; wait low-byte=" +text passed "GATE669 PASS bounded Linux AArch64 execution and independent decoding only\n" +text failed "GATE669 FAIL; retain all scratch files and command output\n" +global pathbuf uchar 4096 +global plen ulong 1 +global serial ulong 1 +global argv uchar 4096 +global argc ulong 1 +global apos ulong 1 +global statbuf uchar 4 +global buf uchar 4096 +global other uchar 4096 +global digits uchar 32 +fn stop to void +r = write 2 failed 0 len failed +exit 99 +end +fn decimal v ulong to ulong +x = v +n = ulong 0 +while ge x 10 +put digits n uchar add 48 rem x 10 +x = div x 10 +n = add n 1 +end +put digits n uchar add 48 x +ret add n 1 +end +fn num v ulong to void +n = decimal v +for i ulong n +r = write 1 digits sub sub n i 1 1 +if ne r 1 +stop +end +end +end +fn setpath id ulong to void +if ge id 1000 +for i ulong len prefix +put pathbuf i get prefix i +end +n = decimal id +for i ulong n +put pathbuf add len prefix i get digits sub sub n i 1 +end +put plen 0 add len prefix n +ret +end +index = ulong 1 +p = ulong 0 +for i ulong len names +b = get names i +if eq b 10 +if eq index id +put plen 0 p +ret +end +index = add index 1 +else +if eq index id +put pathbuf p b +p = add p 1 +end +end +end +stop +end +fn showpath id ulong to void +setpath id +r = write 1 pathbuf 0 get plen 0 +if ne r long get plen 0 +stop +end +end +fn openfile id ulong flags int to int +setpath id +r = fopen pathbuf 0 get plen 0 flags 384 +if lt r 0 +stop +end +ret int r +end +fn fresh to ulong +n = add get serial 0 1 +if ge n 400000 +stop +end +put serial 0 n +ret add 1000 n +end +fn arg id ulong to void +setpath id +p = get apos 0 +n = get plen 0 +if gt add add p n 2 len argv +stop +end +put argv p uchar and n 255 +put argv add p 1 uchar shr n 8 +p = add p 2 +for i ulong n +put argv add p i get pathbuf i +end +put apos 0 add p n +put argc 0 add get argc 0 1 +end +fn command exe ulong to void +put argc 0 0 +put apos 0 2 +arg exe +showpath exe +end +fn argument id ulong to void +put digits 0 32 +r = write 1 digits 0 1 +showpath id +arg id +end +fn close fd int to void +if ne fclose fd 0 +stop +end +end +fn redirect source int dest int to void +if ne source dest +if ne dupfd source dest 0 long dest +stop +end +end +end +fn reap pid int to ulong +start = monons +if lt start 0 +stop +end +while true +r = waitpid pid statbuf 0 len statbuf 1 +if eq r long pid +if ne get statbuf 0 0 +r = write 1 signalm 0 len signalm +num ulong get statbuf 0 +r = write 1 nl 0 1 +stop +end +ret ulong get statbuf 1 +end +if lt r 0 +stop +end +now = monons +if or lt now start gt sub now start 30000000000 +r = killpid pid 9 +r = waitpid pid statbuf 0 len statbuf 0 +r = write 1 timeoutm 0 len timeoutm +num ulong get statbuf 0 +r = write 1 nl 0 1 +stop +end +if ne sleepns 1000000 0 +stop +end +end +exit 99 +end +fn run source ulong wanted ulong to ulong +outid = fresh +errid = add outid 500000 +r = write 1 input 0 len input +showpath source +r = write 1 output 0 len output +showpath outid +r = write 1 errors 0 len errors +showpath errid +r = write 1 nl 0 1 +rd = openfile source 524288 +wr = openfile outid 524481 +er = openfile errid 524481 +put argv 0 uchar get argc 0 +put argv 1 uchar shr get argc 0 8 +pid = fork +if lt pid 0 +stop +end +if eq pid 0 +redirect rd 0 +redirect wr 1 +redirect er 2 +r = execprog argv 0 get apos 0 +exit 98 +end +close rd +close wr +close er +actual = reap int pid +r = write 1 statusm 0 len statusm +num actual +r = write 1 expect 0 len expect +num wanted +r = write 1 nl 0 1 +if ne actual wanted +stop +end +ret outid +end +fn enable id ulong to void +fd = openfile id 524288 +r = read fd buf 0 4 +if ne r 4 +stop +end +if or ne get buf 0 127 ne get buf 1 69 +stop +end +if or ne get buf 2 76 ne get buf 3 70 +stop +end +if ne fchmod fd 448 0 +stop +end +close fd +end +fn empty id ulong to void +fd = openfile id 524288 +r = read fd buf 0 1 +close fd +if ne r 0 +stop +end +end +fn compile cc ulong src ulong wanted ulong to ulong +command cc +outid = run src wanted +if eq wanted 0 +enable outid +else +empty outid +end +ret outid +end +fn equal a ulong b ulong to void +fa = openfile a 524288 +fb = openfile b 524288 +while true +ra = read fa buf 0 len buf +rb = read fb other 0 len other +if or lt ra 0 ne ra rb +stop +end +if eq ra 0 +close fa +close fb +ret +end +for i ulong ulong ra +if ne get buf i get other i +stop +end +end +end +end +fn params mode uchar count ulong size ulong to ulong +id = fresh +fd = openfile id 524481 +put buf 0 mode +for i ulong 4 +put buf add i 1 uchar and shr count mul i 8 255 +end +if ne write fd buf 0 size long size +stop +end +close fd +ret id +end +fn decode checker ulong elf ulong wanted ulong to void +command 5 +argument 6 +argument 7 +argument 8 +argument 9 +argument 10 +argument elf +decoded = run 13 0 +command checker +result = run decoded wanted +end +fn fixture gen ulong mode uchar count ulong to ulong +p = params mode count 5 +command gen +ret run p 0 +end +fn positive cc ulong gen ulong checker ulong count ulong to void +src = fixture gen 0 count +elf = compile cc src 0 +decode checker elf 0 +command elf +outid = run 13 0 +empty outid +end +fn negative cc ulong gen ulong mode uchar count ulong to void +src = fixture gen mode count +elf = compile cc src 24 +end +fn boundaries cc ulong mut ulong to void +command mut +argument 11 +src = run 1 0 +probe = compile cc src 0 +for i ulong 8 +p = params uchar i 0 1 +command probe +want = ulong 0 +if ge i 4 +want = ulong 24 +end +result = run p want +end +end +fn mutant cc ulong gen ulong mut ulong checker ulong to void +command mut +argument 12 +src = run 1 0 +badcc = compile cc src 0 +sample = fixture gen 0 262144 +elf = compile badcc sample 0 +decode checker elf 61 +refused = compile cc sample 24 +end +fn oracle cc ulong checker ulong to void +gen = compile cc 16 0 +for i ulong 7 +p = params uchar i 0 1 +command gen +sample = run p 0 +command checker +wanted = ulong 62 +if eq i 0 +wanted = ulong 0 +end +if eq i 5 +wanted = ulong 61 +end +result = run sample wanted +end +end +fn control cc ulong to void +if ne argread 1 buf 0 1 1 +stop +end +m = get buf 0 +if or lt m 48 gt m 50 +stop +end +p = params sub m 48 0 1 +child = compile cc 17 0 +command child +result = run p 0 +stop +end +fn main to int +if or lt argcnt 1 gt argcnt 2 +ret 90 +end +if ne makedir scratch 0 len scratch 448 0 +ret 91 +end +cc1 = compile 14 1 0 +cc2 = compile cc1 1 0 +equal cc1 cc2 +if eq argcnt 2 +control cc2 +ret 99 +end +gen = compile cc2 2 0 +mut = compile cc2 3 0 +checker = compile cc2 4 0 +boundaries cc2 mut +array = compile cc2 15 0 +command array +result = run 13 0 +oracle cc2 checker +positive cc2 gen checker 16 +positive cc2 gen checker 262142 +negative cc2 gen 0 262143 +negative cc2 gen 0 524287 +negative cc2 gen 1 300000 +negative cc2 gen 2 300000 +negative cc2 gen 3 300000 +mutant cc2 gen mut checker +command checker +result = run 13 62 +r = write 1 passed 0 len passed +if ne r long len passed +ret 99 +end +ret 0 +end + +#### c2-00129 sha256=41118388d232dd6897bebf9b239f4174a2e5054cdd07a4753c4ce60bf7c022fa len=1163 +note Deliberately synthetic decoder outputs. These test parser refusal, not compiler correctness. +global mode uchar 1 +global textbuf uchar 256 +text good "b0: b.ne 0xb4\nb4: mov\tx1, #0x3039\n" +text token "b0: b.ne 0xb4garbage\nb4: bogus #12345oops\n" +text reg "b0: b.ne 0xb4\nb4: mov\tx8, #0x3039\n" +text dupl "b0: b.ne 0xb4\nb4: mov\tx1, #0x3039\nb8: mov\tx1, #0x3039\n" +text missing "b0: b.ne 0xb4\n" +text wrong "b0: b.ne 0xb8\nb4: mov\tx1, #0x3039\n" +text prefix "b0: b.ne 0xb4\nb4: notmov\tx1, #0x3039\n" +fn main to int +if ne read 0 mode 0 1 1 +ret 90 +end +m = get mode 0 +if gt m 6 +ret 90 +end +n = ulong 0 +if eq m 0 +n = len good +for i ulong n +put textbuf i get good i +end +end +if eq m 1 +n = len token +for i ulong n +put textbuf i get token i +end +end +if eq m 2 +n = len reg +for i ulong n +put textbuf i get reg i +end +end +if eq m 3 +n = len dupl +for i ulong n +put textbuf i get dupl i +end +end +if eq m 4 +n = len missing +for i ulong n +put textbuf i get missing i +end +end +if eq m 5 +n = len wrong +for i ulong n +put textbuf i get wrong i +end +end +if eq m 6 +n = len prefix +for i ulong n +put textbuf i get prefix i +end +end +if ne write 1 textbuf 0 n long n +ret 91 +end +ret 0 +end + +#### c2-00130 sha256=d5bd24b9fa592ee626786770d1d29140175dcb7f0dd2b3a7f6b4982e91a9a1e1 len=412 +note byte copy: read up to 65536 bytes, copy them byte by byte into a second pool reversed, write it +global src uchar 65536 +global dst uchar 65536 +fn fill to ulong +t = ulong 0 +k = read 0 src 0 len src +while gt k 0 +t = add t ulong k +k = long 0 +if lt t len src +k = read 0 src t sub len src t +end +end +ret t +end +fn main to int +n = fill +for i ulong n +put dst sub sub n i 1 get src i +end +w = write 1 dst 0 n +ret 0 +end + +#### c2-00131 sha256=0867238aa1d3964dae6ab963cb06590ea69d554aeec587867a74a665f0138ed7 len=257 +note echo: copy stdin to stdout through a 4096-byte pool, until read gives 0 +global buf uchar 4096 +fn main to int +n = read 0 buf 0 len buf +while gt n 0 +w = write 1 buf 0 ulong n +if ne w n +ret 1 +end +n = read 0 buf 0 len buf +end +if lt n 0 +ret 2 +end +ret 0 +end + +#### c2-00132 sha256=2a0049656ed75165d0af38a8b9b912c480b85c313d471a52696d349712996c57 len=429 +note recursive fib(n) for n = 0 .. 25, one number per line +global out uchar 32 +fn fib n ulong to ulong +if lt n 2 +ret n +end +a = fib sub n 1 +b = fib sub n 2 +ret add a b +end +fn putnum v ulong to void +put out 31 10 +p = ulong 31 +x = v +while gt x 9 +p = sub p 1 +put out p uchar add rem x 10 48 +x = div x 10 +end +p = sub p 1 +put out p uchar add x 48 +w = write 1 out p sub 32 p +end +fn main to int +for i ulong 26 +putnum fib i +end +ret 0 +end + +#### c2-00133 sha256=5ff3b6cddb9f66971ecb7b58da2d2f07e3df9e7176dd1ba50a2c3a36f2447e81 len=80 +fn sdivr a long b long to long +q = div a b +r = rem a b +ret add mul q 1000 r +end + +#### c2-00134 sha256=02b9d845454e7379d4d55f3c78af7e9ddd9f87f15d196765b338ee5ae6416965 len=66 +fn d32 a int b int to int +q = div a b +r = rem a b +ret sub q r +end + +#### c2-00135 sha256=3323f23ff905d4915ced5c83d97d772c5b4e4e1347ba738ae3752ef74d99cc0e len=44 +fn sh a long s uint to long +ret shl a s +end + +#### c2-00136 sha256=06149063fb825604227f54d226fbce04afe48b755f6ccbe2690ef35afe1c5a65 len=68 +fn shi a int s uchar to int +x = shl a s +y = shl a 2 +ret sub x y +end + +#### c2-00137 sha256=3b0acd8ea8b0a46d3131378ae447ffd337e15e0b92da1c45ba2c1a2383dc4b54 len=120 +fn sq a ulong to ulong +ret mul a a +end +fn hyp a ulong b ulong to ulong +x = add sq a sq b +y = sq x +ret sub y sq sq a +end + +#### c2-00138 sha256=cf0a8200ec4341d1c4634bceb6bab5e7cca15bae510ca4d6f41982fe1ad70a9c len=72 +fn tri n uint to uint +s = uint 0 +for i uint n +s = add s i +end +ret s +end + +#### c2-00139 sha256=ccbdc5fd0b1005df6bbd17dee7d8679f7d5fbc0355ca1cca9a5c4e32cc1c352a len=194 +fn sum4 v view uint 4 to uint +s = uint 0 +for i uint 4 +s = add s get v i +end +ret s +end +fn f a uint b uint to uint +x = new uint 4 0 +put x 0 a +put x 3 b +put x 1 add a 1 +r = sum4 x +free x +ret r +end + +#### c2-00140 sha256=1cb48989143498ec44e1cbc9ed9bfd11082b9426d937c1ebae5ac02a2c171f93 len=76 +fn g a uint to uint +x = new uint 4 7 +put x 2 a +r = get x a +free x +ret r +end + +#### c2-00141 sha256=e9548779048e3d97b48f7d9904fa832aa47c8a6158c9355d2b88eefa50c87589 len=82 +fn m a short b short to short +c = div a b +d = rem a b +e = shl c 1 +ret add e d +end + +#### c2-00142 sha256=7eef44a3969f470d9044ba2cc2c03e60b36bd890f8e1a9bfd787afff38113135 len=61 +fn main to int +later = 2 +ret 0 +end +fn later to int +ret 1 +end + +#### c2-00143 sha256=feee7fe73a8d916ec5ca2a6435dd2867356b2d81420e2c87177e58355b9527b4 len=44 +fn a to int +ret b +end +fn b to int +ret a +end + +#### c2-00144 sha256=20b9cc05c2fe02200d9e0693023ab32d057cf7ae92f64b93bec9985f3209d2bb len=55 +fn main to int +ret later +end +fn later to int +ret 7 +end + +#### c2-00145 sha256=6c703b6f9362707125bf2304ef2aa2688dc82fce304d36ad7ee8876528c233a6 len=80 +fn mid to int +ret late +end +fn late to int +ret 7 +end +fn entry to int +ret mid +end + +#### c2-00146 sha256=2a7409688787bf957d1a08328c5459675ad971720dd85860f2c99fbb9312b158 len=186 +fn even n ulong to ulong +if eq n 0 +ret 1 +end +ret odd sub n 1 +end +fn odd n ulong to ulong +if eq n 0 +ret 0 +end +ret even sub n 1 +end +fn main to int +r = even 8 +if eq r 1 +ret 0 +end +ret 1 +end + +#### c2-00147 sha256=7c5e1c43aec3fd8fe8005e43426291a01ca50ad4a97fe6477fdf9d6cfbdfaccb len=1049 +note sort 1000 numbers: a local array filled by a fixed generator, sorted by insertion through calls +note with an edit array, then a checksum line and a sorted-or-not line +global out uchar 32 +fn gen a edit ulong 1000 to void +x = ulong 12345 +for i ulong 1000 +x = rem add mul x 1103515245 12345 2147483648 +put a i rem x 100000 +end +end +fn isort a edit ulong 1000 to void +for j ulong 1000 +v = get a j +k = j +moving = true +while and moving gt k 0 +p = get a sub k 1 +if gt p v +put a k p +k = sub k 1 +else +moving = false +end +end +put a k v +end +end +fn putnum v ulong to void +put out 31 10 +p = ulong 31 +x = v +while gt x 9 +p = sub p 1 +put out p uchar add rem x 10 48 +x = div x 10 +end +p = sub p 1 +put out p uchar add x 48 +w = write 1 out p sub 32 p +end +fn sorted a view ulong 1000 to ulong +bad = ulong 0 +for i ulong 999 +if gt get a i get a add i 1 +bad = add bad 1 +end +end +ret bad +end +fn main to int +a = new ulong 1000 0 +gen a +isort a +s = ulong 0 +for i ulong 1000 +s = add s mul get a i add i 1 +end +putnum s +putnum sorted a +putnum get a 0 +putnum get a 999 +ret 0 +end + +#### c2-00148 sha256=33d3500571f3044c0fc567d41f6e624c3d14a5d1b7199b0531cdba46305b03d1 len=64 +global g uchar 4 +fn main to int +i = ulong 7 +ret int get g i +end + +#### c2-00149 sha256=a1aef67f44677193d396d940f423dd2bf1e943309109d8583856392f03a8986d len=157 +note L412 probe cmp_unsigned: 2^64 - 1 is a ulong and is not below 1 +fn main to int +x = ulong 18446744073709551615 +y = ulong 1 +if lt x y +ret 1 +end +ret 0 +end + +#### c2-00150 sha256=fd5cf7817b0f763696617dd61b7ba4f99947f7f6dacaad902493214e116dc5d5 len=50 +fn main to int +x = ulong 3000000000 +ret int x +end + +#### c2-00151 sha256=bb5252eb87caec42ce645b239eee630954cc68a7c58b507c9e8c24c20afc0f15 len=140 +note L412 probe conv_sign: 2^63 is a ulong; converting it to long traps 5 +fn main to int +x = ulong 9223372036854775808 +y = long x +ret 0 +end + +#### c2-00152 sha256=75a90ce14dfe45501fb8f9fb111b24e752be8ddcbf7ef3ede048cca607afdf2e len=51 +fn main to int +x = long 0 +ret int div long 5 x +end + +#### c2-00153 sha256=10921e8e63b6eb7981ddcada50438a4a347023e93ad4481f912a14391cb6824d len=27 +fn main to int +exit 42 +end + +#### c2-00154 sha256=bb7aa36ca5f755812d7a254257e425c206b2306bc30b484aa9b6dbce5e47f9e8 len=72 +fn main to int +i = uint 0 +while true bound 10 +i = add i 1 +end +ret 0 +end + +#### c2-00155 sha256=f3e7a6e2bc0ea4d028defa6101d79627eb90ae7dcb9ff28af33f321e3eef754b len=56 +fn main to int +x = int 2147483647 +y = add x 1 +ret y +end + +#### c2-00156 sha256=5ebd71896c81edb2df63a85f1f416eb642df67cda731b30ce69ccd056a6196c0 len=59 +global g uchar 4 +fn main to int +n = read 0 g 2 3 +ret 0 +end + +#### c2-00157 sha256=ebb72434cc0d04972086cb871c918907084615fcd645dc8d2212c5688d793de5 len=79 +fn r n ulong to ulong +ret add r add n 1 1 +end +fn main to int +x = r 0 +ret 0 +end + +#### c2-00158 sha256=5fee958162492adddf2d14252e09724600e7a0334c6cae9c916cf0c638e01e03 len=154 +note 2^63 read as a ulong, in an op with a ulong name: its top 4 bits are 8 +fn main to int +z = ulong 0 +x = add z 9223372036854775808 +ret int shr x 60 +end + +#### c2-00159 sha256=438d046b50714fc58faeaa61a77b560a61fe310c6f5fa91ad91b8b565e24b172 len=120 +note 2^64 - 1 read as a ulong: its top 5 bits are 31 +fn main to int +x = ulong 18446744073709551615 +ret int shr x 59 +end + +#### c2-00160 sha256=2fa63a0964493b7e8fdfafb06f828b00d2eb20d3f6706ec4f3e9ccb4f802f4e8 len=96 +global g uchar 1 +fn set v uchar to void +put g 0 v +end +fn main to int +set 77 +ret int get g 0 +end + +#### c2-00161 sha256=0581b7f3aa387cff66ee9c3ee6199f1b026ff6e0e963cdf5920acbb3297507ee len=177 +note L412 probe write_wrap: an offset of 2^64 - 1 is outside the array (trap 3), it does not wrap +global g uchar 4 +fn main to int +w = write 1 g 18446744073709551615 2 +ret 0 +end + +#### c2-00162 sha256=f744e3ec012deac392e62d6a8d4133efb7681887d31675d6ff516d4aead07e64 len=116 +fn clamp_add a uchar b uchar to uchar +x = ushort a +y = ushort b +s = add x y +if gt s 255 +ret 255 +end +ret uchar s +end + +#### c2-00163 sha256=fe772bcf3433b1ea0daa0fda78b877790bbf2eacf251ce05f64f0f77dede0e51 len=99 +fn absdiff a int b int to long +x = long a +y = long b +d = sub x y +if lt d 0 +ret neg d +end +ret d +end + +#### c2-00164 sha256=e0382bdae6aabd733c7eb4ba314c9feca55242a8fa25360a6442cde40820a8f0 len=119 +fn popcount x ulong to uchar +n = uchar 0 +for i uint 64 +b = and x 1 +if eq b 1 +n = add n 1 +end +x = shr x 1 +end +ret n +end + +#### c2-00165 sha256=0481442ea45287b9a1a2c5b9116aea6b36dafd0a2d7d89019aa923b3a7d4a356 len=90 +fn gcd a uint b uint to uint +while ne b 0 bound 100 +t = rem a b +a = b +b = t +end +ret a +end + +#### c2-00166 sha256=9b6e72361efce2dbdf209e05a74b89d3a0bf2491818db684d6aa110f3159243c len=56 +fn checked_mul a short b short to short +ret mul a b +end + +#### c2-00167 sha256=5b09682d993bbb9afb96fdbc0f7a75c8e2cf14fc094b5b6c6e1ecf7fcd6ee374 len=50 +fn safe_div a uint b uint to uint +ret div a b +end + +#### c2-00168 sha256=93d8728c52bfad927150d0e08d74a1eca29256489dd3f3acc48c1ad4034f6823 len=158 +fn isqrt x uint to uint +v = ulong x +r = ulong 0 +for i ulong 16 +sh = sub 15 i +bit = shl 1 sh +c = or r bit +sq = mul c c +if le sq v +r = c +end +end +ret uint r +end + +#### c2-00169 sha256=3c78cf83258748b829d8248670f7b46d69351f8e389b9ddecb3ccbfb6548e1da len=188 +fn collatz_steps n uint to uint +x = ulong n +steps = uint 0 +while ne x 1 bound 1000 +r = rem x 2 +if eq r 0 +x = div x 2 +else +t = mul x 3 +x = add t 1 +end +steps = add steps 1 +end +ret steps +end + +#### c2-00170 sha256=93fa5e1cce0ea59252fbb8203d1a7fe15b40ebcb82cf7d4090d62fa1abe4d477 len=114 +fn bitrev8 x uchar to uchar +r = uchar 0 +for i uint 8 +r = shl r 1 +b = and x 1 +r = or r b +x = shr x 1 +end +ret r +end + +#### c2-00171 sha256=2efe0c6e3663a40562589b98f4229f0ac2a43ab264c53b4fbca40d11c76edbfd len=38 +fn to_i8 x int to byte +ret byte x +end + +#### c2-00172 sha256=b078ae26e824ad0cb671108a896862ee033c90c6f4394637684b15bd90e95322 len=87 +fn absdiff a int b int to long +d = sub long a long b +if lt d 0 +ret neg d +end +ret d +end + +#### c2-00173 sha256=52a9a88352cc3e9c60832187586fafe0d05748693ce55141844a9d5030229a6e len=105 +fn popcount x ulong to uchar +n = uchar 0 +for i uint 64 +n = add n uchar and x 1 +x = shr x 1 +end +ret n +end + +#### c2-00174 sha256=ac0eb5306b4233a8c49dc9db8d503ec343b76c0bac0b3681c22b3d0d866a99f3 len=120 +fn checked_mul a short b short to short +p = mul int a int b +if or (lt p -32768) (gt p 32767) +trap 1 +end +ret short p +end + +#### c2-00175 sha256=aca09a84add052ccf4416bc8f7b0d01a71d9fe0b6de8957322b90a88a3597f88 len=132 +fn isqrt x uint to uint +v = ulong x +r = ulong 0 +for i ulong 16 +c = or r shl 1 sub 15 i +if le mul c c v +r = c +end +end +ret uint r +end + +#### c2-00176 sha256=4260833a70ad7a0a858a0b7910b0364a426580e9aba1c622565fc140a42b58ae len=176 +fn collatz_steps n uint to uint +x = ulong n +steps = uint 0 +while ne x 1 bound 1000 +if eq rem x 2 0 +x = div x 2 +else +x = add mul x 3 1 +end +steps = add steps 1 +end +ret steps +end + +#### c2-00177 sha256=38d8b37e5878695b29d5308a8b43ac2dc9877908106528515104423027cff52b len=97 +fn bitrev8 x uchar to uchar +r = uchar 0 +for i uchar 8 +r = or shl r 1 and shr x i 1 +end +ret r +end + +#### c2-00178 sha256=55b567b2c43c115ec5cfafd9ec7d0085feef7ca688da5a63c34203224b27e35e len=113 +fn absdiff a i32 b i32 to i64 +diff = i64 a +diff = sub diff (i64 b) +if lt diff 0 +diff = neg diff +end +ret diff +end + +#### c2-00179 sha256=6a56da67212db3956af91e36a2b680b9c78f98bb8d9f0e76a49eaac7ee8cffd1 len=136 +fn popcount x u64 to u8 +count = u8 0 +for i u8 64 +bit = and x (shl u64 1 i) +if ne bit u64 0 +count = add count u8 1 +end +end +ret count +end + +#### c2-00180 sha256=184e9efad7fccc9b147f4813b2434ae1a5cb9122a0ce423b3b7356be18849874 len=129 +fn checked_mul a i16 b i16 to i16 +p = mul a b +if lt p short 32767 +if ge p short -32768 +ret p +else +trap 1 +end +else +trap 1 +end +end + +#### c2-00181 sha256=d051dd6a0d98c805ef6c6421872f6e99781f756772a528f7fd104b580d2d49ee len=100 +fn isqrt x u32 to u32 +r = u32 0 +while le add mul r r 4 r x bound 32 +r = add r 1 +end +ret sub r 1 +end + +#### c2-00182 sha256=4098c21c8e3ef82a9d6bc61012537a3b30ef89568cb1bbe3b2cf3f33cad6595a len=184 +fn collatz_steps n u32 to u32 +steps = u32 0 +while ne n 1 bound 1000 +even = eq (rem n 2) 0 +if even +n = div n 2 +else +n = add (mul (uint 3) n) 1 +end +steps = add steps 1 +end +ret steps +end + +#### c2-00183 sha256=895c35cbfdfc9d94103790214e47f5409af1b0d87788b4925b25fccb59d4e02c len=109 +fn bitrev8 x u8 to u8 +r = u8 0 +for i u8 8 +b = and x (shl u8 1 i) +r = or r (shl b (sub u8 7 i)) +end +ret r +end + +#### c2-00184 sha256=b5624972ed3b4394027eca96d94b670f7a8846af51d3083940e63c079c8649e4 len=71 +fn clamp_sub a uint b uint to uint +if ge a b +ret sub a b +end +ret 0 +end + +#### c2-00185 sha256=0bfe80ea229071421efd1418bbf09db219acf1c303d4c8a80025d1033744759d len=254 +fn above v view int 4 t int to uchar +k = uchar 0 +for i uint 4 +if gt get v i t +k = add k 1 +end +end +ret k +end +fn count_above a int b int c int d int t int to uchar +v = new int 4 0 +put v 0 a +put v 1 b +put v 2 c +put v 3 d +k = above view v t +free v +ret k +end + +#### c2-00186 sha256=14439646d9db8ec1c40b7646b3ec177d21ce8178a1e7c6c001134339cd8fab76 len=107 +fn count_digits n ulong to uchar +k = uchar 1 +while ge n 10 bound 20 +n = div n 10 +k = add k 1 +end +ret k +end + +#### c2-00187 sha256=83b4aad4f657f489ac7a7b9eee847118bc8d37c452a83efd3d5135af4f2e69dd len=166 +fn cube_xor_pair n uchar to ushort +t = new ushort 16 0 +for i uint 16 +v = ushort i +put t i mul mul v v v +end +j = uint n +r = xor get t j get t add j 1 +free t +ret r +end + +#### c2-00188 sha256=1974598d956017c608019ebd9a8b5af42dc34c5eae20809b47940337c14f2349 len=345 +fn dot u view long 3 w view long 3 to long +s = long 0 +for i uint 3 +s = add s mul get u i get w i +end +ret s +end +fn dot3 a short b short c short x short y short z short to long +u = new long 3 0 +w = new long 3 0 +put u 0 long a +put u 1 long b +put u 2 long c +put w 0 long x +put w 1 long y +put w 2 long z +s = dot view u view w +free u +free w +ret s +end + +#### c2-00189 sha256=95a41a420eb97cac77023a066936cc4c9673e3224489d118834edd076232ab59 len=145 +fn halve_or_dec_steps n uint to uint +k = uint 0 +while gt n 1 bound 64 +if eq rem n 2 0 +n = div n 2 +else +n = sub n 1 +end +k = add k 1 +end +ret k +end + +#### c2-00190 sha256=bd88c1daeb2c9f2bde005d46172b7b7e0b4ed2c95081ea106dd62f8caafb16a0 len=157 +fn has_digit n uint d uchar to bool +t = uint d +found = eq rem n 10 t +while ge n 10 bound 10 +n = div n 10 +if eq rem n 10 t +found = true +end +end +ret found +end + +#### c2-00191 sha256=fe9f95b097d0137a3ddb4a62246c5e6875fbc19aded228c2f23c4679b84c2ccf len=64 +fn hash_step h uint c uchar to uint +ret add mul h 31 uint c +end + +#### c2-00192 sha256=4335f62c4d839f7a7d0addd992208b6107249d7620d840080a81076b3800bc26 len=59 +fn narrow_sum a short b short to byte +ret byte add a b +end + +#### c2-00193 sha256=23026d2191616675acd10e798835bcb290ecd259c1e17935019bb2f97021d9fd len=124 +fn nibble_mirror x ushort to bool +a = and x 15 +b = and shr x 4 15 +c = and shr x 8 15 +d = shr x 12 +ret and eq a d eq b c +end + +#### c2-00194 sha256=a55747b9894b8a8c07f33e6678b8f5482eee35096c97ff686be7ec7b7784d9c1 len=258 +fn mod a ulong b ulong m ulong to ulong +ret rem mul a b m +end +fn power_mod b uint e uint m uint to uint +mm = ulong m +r = rem ulong 1 mm +x = rem ulong b mm +while gt e 0 bound 40 +if eq rem e 2 1 +r = mod r x mm +end +x = mod x x mm +e = div e 2 +end +ret uint r +end + +#### c2-00195 sha256=d8196e4bdfe690afeed43f7a52aefbb76f13ca42a6caa51fc61e70a585165213 len=99 +fn rotl8 x uchar k uchar to uchar +s = rem k 8 +if eq s 0 +ret x +end +ret or shl x s shr x sub 8 s +end + +#### c2-00196 sha256=9acda5f3fd9ddc1dc01923fa76a30a4667f2d0e8d460ba2a60c5d6d5fc27807c len=123 +fn sum_range lo int hi int to long +s = long 0 +i = lo +while le i hi bound 300000 +s = add s long i +i = add i 1 +end +ret s +end + +#### c2-00197 sha256=17b76ece94d8d691b3339b4d3f58443814c81d897a6e3f746981263674d32257 len=89 +fn sum_squares3 a short b short c short to short +ret add add mul a a mul b b mul c c +end + +#### c2-00198 sha256=8ecfa30de1ec78883a3c4c40fc5a11aeb2646a38df403a8bf61da47d99017e1d len=230 +fn tri_kind a ushort b ushort c ushort to uchar +x = uint a +y = uint b +z = uint c +if or or le add x y z le add x z y le add y z x +ret 0 +else +if and eq a b eq b c +ret 1 +else +if or or eq a b eq b c eq a c +ret 2 +end +end +end +ret 3 +end + +#### c2-00199 sha256=a50c02817f492a2390f613aa5f7554ef6ef08b9a41d6ce73fa1eb1fa53191af1 len=341 +fn total a view ulong 4 to ulong +s = ulong 0 +for i ulong 4 +s = add s get a i +end +ret s +end +fn bump a edit uchar 4 to void +for i ulong 4 +put a i add get a i 1 +end +end +fn narrow x ulong to uchar +ret uchar x +end +fn divide a long b long to long +ret div a b +end +fn copy a edit ulong 4 b view ulong 4 to void +for i ulong 4 +put a i get b i +end +end + +#### c2-00200 sha256=aeb6c82de5ce15b821f1a153fc87e55b87d4b49e1e45fc7e4c2c1f4559fbcd9c len=11986 +note Omega Bridge GPU adapter, protocol omega-bridge-gpu-adapter/1. +note Pure boundary: no device, no driver, no encoder, no launch. It decides +note whether a declared consumer may attach to a declared adapter, and it +note refuses every request it cannot prove from the fields below. A refusal +note never falls back to CPU or to another backend. +note Handwritten native Omega (seed omc); SHA-256 adapted from the Apache-2.0 WITH LLVM-exception +note Omega implementation in benchmarks-mv/build/base/om-sha256.om. + +global src uchar 32768 +global slen ulong 1 +global lstart ulong 64 +global llen ulong 64 +global nlines ulong 1 +global koff ulong 1 +global klen ulong 1 +global voff ulong 1 +global vlen ulong 1 +global coff ulong 1 +global code ulong 1 +global mode ulong 1 +global adap ulong 1 +global cons ulong 1 +global pp ulong 1 +global bad ulong 1 +global wr ulong 1 + +note ---- protocol dictionaries ---- +text keys "mode\nadapter\nconsumer\nbackend\nisa\ndriver\nabi\ndtypes\ncapabilities\nrights\nsync\ntelemetry\ncontract_id\nartifact_id\nkernel_format\nqmd_template\nreceipt\nownership\nalias\n" +global ko ulong 19 +global kl ulong 19 +text vals "omega-bridge-gpu-adapter/1\nnegotiate\nadmit\nfake-gpu\ngb10-native-cubin\nomega\nmax\nnvidia\nfake\nsm_121\nfake-1\nomega-gpu-platform/1.2\nbf16,f32\ncubin-load,launch-template,memory-handoff\nread,execute\nexplicit\noff\n580.173.02\nnvidia-cubin-elf64\nzero-va-v1\nvalid\nstale\nmissing\nproducer\nconsumer\nnone\nalias\n" +global vo ulong 27 +global vl ulong 27 +text codes "E_VERSION\nE_ORDER\nE_MODE\nE_ADAPTER\nE_BACKEND\nE_ISA\nE_DRIVER\nE_ABI\nE_DTYPES\nE_CAPABILITY\nE_RIGHTS\nE_SYNC\nE_TELEMETRY\nE_CONTRACT\nE_ARTIFACT\nE_FORMAT\nE_RELOC\nE_RECEIPT\nE_OWNERSHIP\nE_ALIAS\nE_LIMIT\nE_IO\n" +global co ulong 22 +global cl ulong 22 + +text lver "verdict=" +text lcode "code=" +text lada "adapter=" +text lcon "consumer=" +text lisa "isa=" +text lcid "contract_id=" +text lsha "request_sha256=" +text lacc "ACCEPT" +text lref "REFUSE" +text lf "\n" + +note ---- SHA-256 state (AGPL, adapted) ---- +global hk uint 64 +global hs uint 8 +global hm uint 64 +global hb uchar 64 +global hd uchar 64 +global hmeta ulong 3 +text hconst "428a2f9871374491b5c0fbcfe9b5dba53956c25b59f111f1923f82a4ab1c5ed5d807aa9812835b01243185be550c7dc372be5d7480deb1fe9bdc06a7c19bf174e49b69c1efbe47860fc19dc6240ca1cc2de92c6f4a7484aa5cb0a9dc76f988da983e5152a831c66db00327c8bf597fc7c6e00bf3d5a7914706ca63511429296727b70a852e1b21384d2c6dfc53380d13650a7354766a0abb81c2c92e92722c85a2bfe8a1a81a664bc24b8b70c76c51a3d192e819d6990624f40e3585106aa07019a4c1161e376c082748774c34b0bcb5391c0cb34ed8aa4a5b9cca4f682e6ff3748f82ee78a5636f84c878148cc7020890befffaa4506cebbef9a3f7c67178f2" +text hseed "6a09e667bb67ae853c6ef372a54ff53a510e527f9b05688c1f83d9ab5be0cd19" +text hhex "0123456789abcdef" + +fn hnib c uchar to uint +if le c 57 +ret uint sub c 48 +end +ret uint sub c 87 +end + +fn hreset to void +for i ulong 64 +v = uint 0 +for j ulong 8 +v = or shl v 4 hnib get hconst add mul i 8 j +end +put hk i v +end +for i ulong 8 +v = uint 0 +for j ulong 8 +v = or shl v 4 hnib get hseed add mul i 8 j +end +put hs i v +end +for i ulong 3 +put hmeta i 0 +end +end + +fn hrot x uint n uint to uint +ret or shr x n shl x sub 32 n +end + +fn hsmall0 x uint to uint +ret xor xor hrot x 7 hrot x 18 shr x 3 +end + +fn hsmall1 x uint to uint +ret xor xor hrot x 17 hrot x 19 shr x 10 +end + +fn hbig0 x uint to uint +ret xor xor hrot x 2 hrot x 13 hrot x 22 +end + +fn hbig1 x uint to uint +ret xor xor hrot x 6 hrot x 11 hrot x 25 +end + +fn hblock to void +for i ulong 16 +v = uint 0 +for j ulong 4 +v = or shl v 8 uint get hb add mul i 4 j +end +put hm i v +end +for j ulong 48 +i = add j 16 +v = add hsmall1 get hm sub i 2 get hm sub i 7 +v = add v hsmall0 get hm sub i 15 +put hm i add v get hm sub i 16 +end +a = get hs 0 +b = get hs 1 +c = get hs 2 +d = get hs 3 +e = get hs 4 +f = get hs 5 +g = get hs 6 +h = get hs 7 +for i ulong 64 +t1 = add h hbig1 e +t1 = add t1 xor and e f and not e g +t1 = add t1 get hk i +t1 = add t1 get hm i +t2 = hbig0 a +t2 = add t2 xor xor and a b and a c and b c +h = g +g = f +f = e +e = add d t1 +d = c +c = b +b = a +a = add t1 t2 +end +put hs 0 add get hs 0 a +put hs 1 add get hs 1 b +put hs 2 add get hs 2 c +put hs 3 add get hs 3 d +put hs 4 add get hs 4 e +put hs 5 add get hs 5 f +put hs 6 add get hs 6 g +put hs 7 add get hs 7 h +end + +fn hraw c uchar to void +n = get hmeta 0 +put hb n c +n = add n 1 +if eq n 64 +hblock +n = ulong 0 +end +put hmeta 0 n +end + +fn hpush c uchar to bool +if ne get hmeta 2 0 +ret false +end +if eq get hmeta 1 2305843009213693951 +put hmeta 2 2 +ret false +end +hraw c +put hmeta 1 add get hmeta 1 1 +ret true +end + +fn hfinal to bool +if ne get hmeta 2 0 +ret false +end +bits = mul get hmeta 1 8 +hraw 128 +while ne get hmeta 0 56 +hraw 0 +end +for i ulong 8 +shift = mul sub 7 i 8 +hraw uchar and shr bits shift 255 +end +for i ulong 8 +v = get hs i +for j ulong 8 +shift = uint mul sub 7 j 4 +digit = ulong and shr v shift 15 +put hd add mul i 8 j get hhex digit +end +end +put hmeta 2 1 +ret true +end + +note ---- static tables ---- +fn init to void +put co 0 0 +put cl 0 9 +put co 1 10 +put cl 1 7 +put co 2 18 +put cl 2 6 +put co 3 25 +put cl 3 9 +put co 4 35 +put cl 4 9 +put co 5 45 +put cl 5 5 +put co 6 51 +put cl 6 8 +put co 7 60 +put cl 7 5 +put co 8 66 +put cl 8 8 +put co 9 75 +put cl 9 12 +put co 10 88 +put cl 10 8 +put co 11 97 +put cl 11 6 +put co 12 104 +put cl 12 11 +put co 13 116 +put cl 13 10 +put co 14 127 +put cl 14 10 +put co 15 138 +put cl 15 8 +put co 16 147 +put cl 16 7 +put co 17 155 +put cl 17 9 +put co 18 165 +put cl 18 11 +put co 19 177 +put cl 19 7 +put co 20 185 +put cl 20 7 +put co 21 193 +put cl 21 4 +put ko 0 0 +put kl 0 4 +put ko 1 5 +put kl 1 7 +put ko 2 13 +put kl 2 8 +put ko 3 22 +put kl 3 7 +put ko 4 30 +put kl 4 3 +put ko 5 34 +put kl 5 6 +put ko 6 41 +put kl 6 3 +put ko 7 45 +put kl 7 6 +put ko 8 52 +put kl 8 12 +put ko 9 65 +put kl 9 6 +put ko 10 72 +put kl 10 4 +put ko 11 77 +put kl 11 9 +put ko 12 87 +put kl 12 11 +put ko 13 99 +put kl 13 11 +put ko 14 111 +put kl 14 13 +put ko 15 125 +put kl 15 12 +put ko 16 138 +put kl 16 7 +put ko 17 146 +put kl 17 9 +put ko 18 156 +put kl 18 5 +put vo 0 0 +put vl 0 26 +put vo 1 27 +put vl 1 9 +put vo 2 37 +put vl 2 5 +put vo 3 43 +put vl 3 8 +put vo 4 52 +put vl 4 17 +put vo 5 70 +put vl 5 5 +put vo 6 76 +put vl 6 3 +put vo 7 80 +put vl 7 6 +put vo 8 87 +put vl 8 4 +put vo 9 92 +put vl 9 6 +put vo 10 99 +put vl 10 6 +put vo 11 106 +put vl 11 22 +put vo 12 129 +put vl 12 8 +put vo 13 138 +put vl 13 41 +put vo 14 180 +put vl 14 12 +put vo 15 193 +put vl 15 8 +put vo 16 202 +put vl 16 3 +put vo 17 206 +put vl 17 10 +put vo 18 217 +put vl 18 18 +put vo 19 236 +put vl 19 10 +put vo 20 247 +put vl 20 5 +put vo 21 253 +put vl 21 5 +put vo 22 259 +put vl 22 7 +put vo 23 267 +put vl 23 8 +put vo 24 276 +put vl 24 8 +put vo 25 285 +put vl 25 4 +put vo 26 290 +put vl 26 5 +end + +note ---- parsing ---- +fn eqkey off ulong ln2 ulong id ulong to bool +if ne ln2 get kl id +ret false +end +for i ulong ln2 +if ne get src add off i get keys add get ko id i +ret false +end +end +ret true +end + +fn eqval off ulong ln2 ulong id ulong to bool +if ne ln2 get vl id +ret false +end +for i ulong ln2 +if ne get src add off i get vals add get vo id i +ret false +end +end +ret true +end + +fn lineis id ulong to bool +ret eqval get lstart 0 get llen 0 id +end + +fn keyis id ulong to bool +ret eqkey get koff 0 get klen 0 id +end + +fn valis id ulong to bool +ret eqval get voff 0 get vlen 0 id +end + +fn kv i ulong to void +ln = get lstart i +ll = get llen i +j = ln +stop = add ln ll +while and lt j stop ne get src j 61 +j = add j 1 +end +put koff 0 ln +put klen 0 sub j ln +if eq j stop +put voff 0 stop +put vlen 0 0 +else +put voff 0 add j 1 +put vlen 0 sub stop add j 1 +end +end + +fn vline i ulong kid ulong vid ulong to bool +kv i +if not keyis kid +ret false +end +if not valis vid +ret false +end +ret true +end + +fn split to void +n = ulong 0 +p = ulong 0 +total = get slen 0 +while lt p total +q = p +while and lt q total ne get src q 10 +q = add q 1 +end +put lstart n p +put llen n sub q p +n = add n 1 +p = add q 1 +end +put nlines 0 n +end + +fn hex64 off ulong ln2 ulong to bool +if ne ln2 64 +ret false +end +for i ulong 64 +c = get src add off i +if or lt c 48 gt c 102 +ret false +end +if and gt c 57 lt c 97 +ret false +end +end +ret true +end + +fn pnum to ulong +v = ulong 0 +n = ulong 0 +going = true +while and going lt get pp 0 get vlen 0 +c = get src add get voff 0 get pp 0 +if or lt c 48 gt c 57 +going = false +else +v = add mul v 10 ulong sub c 48 +n = add n 1 +put pp 0 add get pp 0 1 +end +end +if eq n 0 +put bad 0 1 +end +if lt get pp 0 get vlen 0 +c = get src add get voff 0 get pp 0 +if eq c 46 +put pp 0 add get pp 0 1 +else +put bad 0 1 +end +end +ret v +end + +fn drvok to bool +put pp 0 0 +put bad 0 0 +a = pnum +b = pnum +c = pnum +if ne get pp 0 get vlen 0 +put bad 0 1 +end +if ne get bad 0 0 +ret false +end +if gt a 580 +ret true +end +if lt a 580 +ret false +end +if gt b 173 +ret true +end +if lt b 173 +ret false +end +ret ge c 2 +end + +fn hashreq to bool +hreset +for i ulong get slen 0 +if not hpush get src i +ret false +end +end +ret hfinal +end + +fn readin to int +put slen 0 0 +more = true +while more +room = sub 32768 get slen 0 +if eq room 0 +ret 65 +end +n = read 0 src get slen 0 room +if eq n 0 +more = false +else +if lt n 0 +ret 74 +end +put slen 0 add get slen 0 ulong n +end +end +ret 0 +end + +note ---- output ---- +fn putstr id ulong to void +put wr 0 ulong write 1 vals add get vo id 0 get vl id +end + +fn putc id ulong to void +put wr 0 ulong write 1 codes add get co id 0 get cl id +end + +fn emit acc ulong to void +put wr 0 ulong write 1 vals 0 26 +put wr 0 ulong write 1 lf 0 1 +put wr 0 ulong write 1 lver 0 len lver +if eq acc 1 +put wr 0 ulong write 1 lacc 0 len lacc +else +put wr 0 ulong write 1 lref 0 len lref +end +put wr 0 ulong write 1 lf 0 1 +if eq acc 1 +put wr 0 ulong write 1 lada 0 len lada +putstr get adap 0 +put wr 0 ulong write 1 lf 0 1 +put wr 0 ulong write 1 lcon 0 len lcon +putstr get cons 0 +put wr 0 ulong write 1 lf 0 1 +put wr 0 ulong write 1 lisa 0 len lisa +if eq get adap 0 3 +putstr 10 +else +putstr 9 +end +put wr 0 ulong write 1 lf 0 1 +put wr 0 ulong write 1 lcid 0 len lcid +put wr 0 ulong write 1 src get coff 0 64 +put wr 0 ulong write 1 lf 0 1 +else +put wr 0 ulong write 1 lcode 0 len lcode +putc get code 0 +put wr 0 ulong write 1 lf 0 1 +end +put wr 0 ulong write 1 lsha 0 len lsha +put wr 0 ulong write 1 hd 0 64 +put wr 0 ulong write 1 lf 0 1 +end + +fn fail c ulong to int +put code 0 c +ok = hashreq +if not ok +put code 0 21 +end +emit 0 +ret 3 +end + +note ---- policy ---- +fn common to int +if vline 3 2 5 +put cons 0 5 +else +if vline 3 2 6 +put cons 0 6 +else +ret fail 9 +end +end +if not vline 7 6 11 +ret fail 7 +end +if not vline 8 7 12 +ret fail 8 +end +if not vline 9 8 13 +ret fail 9 +end +if not vline 10 9 14 +ret fail 10 +end +if not vline 11 10 15 +ret fail 11 +end +if not vline 12 11 16 +ret fail 12 +end +kv 13 +if not keyis 12 +ret fail 1 +end +if not hex64 get voff 0 get vlen 0 +ret fail 13 +end +put coff 0 get voff 0 +ret 0 +end + +fn main to int +init +rc = readin +if ne rc 0 +ret fail 21 +end +split +if lt get nlines 0 1 +ret fail 1 +end +if not lineis 0 +ret fail 1 +end +kv 1 +if not keyis 0 +ret fail 1 +end +if valis 1 +put mode 0 1 +else +if valis 2 +put mode 0 2 +else +ret fail 2 +end +end +if eq get mode 0 1 +if ne get nlines 0 14 +ret fail 1 +end +kv 2 +if not keyis 1 +ret fail 1 +end +if valis 3 +put adap 0 3 +if not vline 4 3 8 +ret fail 4 +end +if not vline 5 4 10 +ret fail 5 +end +kv 6 +if not keyis 5 +ret fail 1 +end +else +if valis 4 +put adap 0 4 +if not vline 4 3 7 +ret fail 4 +end +if not vline 5 4 9 +ret fail 5 +end +kv 6 +if not keyis 5 +ret fail 1 +end +if not drvok +ret fail 6 +end +else +ret fail 3 +end +end +else +if ne get nlines 0 20 +ret fail 1 +end +kv 2 +if not keyis 1 +ret fail 1 +end +if not valis 4 +ret fail 3 +end +put adap 0 4 +if not vline 4 3 7 +ret fail 4 +end +if not vline 5 4 9 +ret fail 5 +end +kv 6 +if not keyis 5 +ret fail 1 +end +if not drvok +ret fail 6 +end +end +c = common +if ne c 0 +ret c +end +if eq get mode 0 2 +kv 14 +if not keyis 13 +ret fail 1 +end +if not hex64 get voff 0 get vlen 0 +ret fail 14 +end +if not vline 15 14 18 +ret fail 15 +end +if not vline 16 15 19 +ret fail 16 +end +kv 17 +if not keyis 16 +ret fail 1 +end +if not valis 20 +ret fail 17 +end +if not vline 18 17 23 +ret fail 18 +end +if not vline 19 18 25 +ret fail 19 +end +end +ok = hashreq +if not ok +ret fail 21 +end +emit 1 +ret 0 +end + +#### c2-00201 sha256=2c2c53f61d4ab302f1a2092c3c32189335dd53f6cf2b388f47a475f99f2c3940 len=15376 +note native.om: omega-bridge native call ABI v1 binding generator (docs/NATIVE-ABI.md). +note Input on stdin, one or more units: the unit's .om source, a 0 byte, its code length as 8 decimal +note digits, then the function-mode machine code the seeded compiler wrote for that source. +note Output on stdout, only after every unit is accepted: one C file that embeds each code unchanged +note and exports uint32_t omega_<name>(uint64_t *result, ...) per unit. The bound function is the +note unit's last one, which is where the compiler enters function-mode code (word 0 branches to it); +note earlier functions are private helpers with any types. The bound function's parameters are ulong +note or long scalars, or edit/view arrays of ulong or uchar; its result is ulong, long or void. +note Anything else is refused: trap 10 (exit 110) and no output. +global inb uchar 1048576 +global outb uchar 4194304 +global st ulong 8 +global tks ulong 40 +global tke ulong 40 +global pk ulong 6 +global pl ulong 6 +global ps ulong 6 +global pe ulong 6 +global dg uchar 24 +global us ulong 256 +global ue ulong 256 +text hx "0123456789abcdef" +text kw "toeditviewulonglongucharvoidmain" +text fr "__asm__(\".section .text.omega_bridge,\\\"ax\\\",@progbits\\n.balign 4\\n.globl ombr_code_~\\n.hidden ombr_code_~\\nombr_code_~:\\n.byte ~\\n.previous\\n\");\nextern const unsigned char ombr_entry_~[] __attribute__((visibility(\"hidden\")));\n__attribute__((visibility(\"default\"))) uint32_t omega_~(uint64_t *result~, uint64_t o_~, void *o_~, const void *o_~_len~)\n{\n ombr_span sp[7];\n unsigned ns = 0;\n uint64_t a[6] = {0};\n if (ombr_span_add(sp, &ns, result, 1u, 1u, 8u, 1))\n return OMEGA_BAD_ARG;\n~ if (ombr_span_add(sp, &ns, o_~, o_~_len, ~u, ~))\n return OMEGA_BAD_ARG;\n a[~] = (uint64_t)(uintptr_t)o_~;\n~ a[~] = o_~ if (ombr_overlap(sp, ns))\n return OMEGA_BAD_ARG;\n return ombr_run(ombr_entry_~, a, result, ~);\n}\n~\\n.globl ombr_entry_~\\n.hidden ombr_entry_~\\nombr_entry_~:\\nhint #34\\nb ombr_code_" +text pre "/* Generated by omega-bridge src/native.om: native call ABI v1 (docs/NATIVE-ABI.md).\n * The Omega machine code below is embedded byte for byte as the seeded compiler wrote it.\n * This file only adapts the C calling convention to it. Regenerate it; do not edit it. */\n#include <pthread.h>\n#include <signal.h>\n#include <stdint.h>\n#include <sys/mman.h>\n#define OMEGA_OK 0u\n#define OMEGA_BAD_ARG 32u\n#define OMEGA_REENTRY 33u\n#define OMEGA_BAD_RT 34u\n#define OMEGA_NO_STACK 35u\n#define OMBR_STACK (8u << 20)\n#define OMBR_GUARD (8u << 20)\n/* entry[2] is the trap entry (OSC-1 section 7). */\ntypedef struct ombr_rt { const void *entry[32]; } ombr_rt;\ntypedef struct ombr_span { uintptr_t lo, hi; int w; } ombr_span;\nstatic _Thread_local volatile sig_atomic_t ombr_active;\nstatic _Thread_local unsigned char *ombr_stk;\nstatic pthread_key_t ombr_key;\nstatic int ombr_keyok;\nstatic pthread_once_t ombr_once = PTHREAD_ONCE_INIT;\nuint32_t ombr_enter(const void *code, const uint64_t *args, const ombr_rt *rt, uint64_t *out, void *top)\n __attribute__((visibility(\"hidden\")));\nextern const unsigned char ombr_trap[] __attribute__((visibility(\"hidden\")));\nextern const unsigned char ombr_no_entry[] __attribute__((visibility(\"hidden\")));\n/* ombr_enter saves the callee-saved registers on the caller's stack, keeps that stack pointer in x19 and\n * runs the code on the binding's own stack. A normal return stores x0 through out and\n * returns 0. A runtime entry restores the stack pointer from x19 and returns a status; out is not\n * written. The seeded compiler never writes x19..x28. Runtime entries are reached by blr/br, so they\n * start with bti jc. */\n__asm__(\".text\\n.balign 4\\n.globl ombr_enter\\n.hidden ombr_enter\\n.type ombr_enter,%function\\nombr_enter:\\n\"\n \"hint #34\\nstp x29,x30,[sp,#-176]!\\nmov x29,sp\\nstp x19,x20,[sp,#16]\\nstp x21,x22,[sp,#32]\\n\"\n \"stp x23,x24,[sp,#48]\\nstp x25,x26,[sp,#64]\\nstp x27,x28,[sp,#80]\\nstp d8,d9,[sp,#96]\\n\"\n \"stp d10,d11,[sp,#112]\\nstp d12,d13,[sp,#128]\\nstp d14,d15,[sp,#144]\\nstr x3,[sp,#160]\\n\"\n \"mov x19,sp\\nmov x16,x0\\nmov x17,x1\\nmov x7,x2\\nmov sp,x4\\n\"\n \"ldp x0,x1,[x17]\\nldp x2,x3,[x17,#16]\\nldp x4,x5,[x17,#32]\\nblr x16\\n\"\n \"mov sp,x19\\nldr x9,[sp,#160]\\nstr x0,[x9]\\nmov w0,#0\\n\"\n \"ombr_leave:\\nldp d14,d15,[sp,#144]\\nldp d12,d13,[sp,#128]\\nldp d10,d11,[sp,#112]\\n\"\n \"ldp d8,d9,[sp,#96]\\nldp x27,x28,[sp,#80]\\nldp x25,x26,[sp,#64]\\nldp x23,x24,[sp,#48]\\n\"\n \"ldp x21,x22,[sp,#32]\\nldp x19,x20,[sp,#16]\\nldp x29,x30,[sp],#176\\nret\\n.size ombr_enter,.-ombr_enter\\n\"\n \".globl ombr_trap\\n.hidden ombr_trap\\n.type ombr_trap,%function\\nombr_trap:\\nhint #38\\n\"\n \"mov sp,x19\\nsub x2,x1,#1\\nmov w3,#34\\ncmp x2,#13\\ncsel w0,w1,w3,ls\\nb ombr_leave\\n\"\n \".size ombr_trap,.-ombr_trap\\n\"\n \".globl ombr_no_entry\\n.hidden ombr_no_entry\\n.type ombr_no_entry,%function\\nombr_no_entry:\\nhint #38\\n\"\n \"mov sp,x19\\nmov w0,#34\\nb ombr_leave\\n.size ombr_no_entry,.-ombr_no_entry\\n\");\nstatic void ombr_free(void *p)\n{\n munmap(p, OMBR_STACK + OMBR_GUARD);\n}\nstatic void ombr_init(void)\n{\n ombr_keyok = pthread_key_create(&ombr_key, ombr_free) == 0;\n}\n/* The thread's Omega stack: OMBR_STACK usable bytes above an OMBR_GUARD no-access region. A function-mode\n * unit has no call cycles and at most 4 MiB of local arrays per function (OMEGESE, local arrays), so a frame that\n * would pass the bottom starts inside the guard and faults there; nothing below the guard is touched. */\nstatic unsigned char *ombr_stack(void)\n{\n if (ombr_stk)\n return ombr_stk;\n pthread_once(&ombr_once, ombr_init);\n if (!ombr_keyok)\n return 0;\n unsigned char *p = mmap(0, OMBR_STACK + OMBR_GUARD, PROT_READ | PROT_WRITE,\n MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);\n if (p == MAP_FAILED)\n return 0;\n if (mprotect(p, OMBR_GUARD, PROT_NONE) != 0 || pthread_setspecific(ombr_key, p) != 0) {\n munmap(p, OMBR_STACK + OMBR_GUARD);\n return 0;\n }\n ombr_stk = p + OMBR_GUARD + OMBR_STACK;\n return ombr_stk;\n}\nstatic int ombr_span_add(ombr_span *sp, unsigned *ns, const void *p, uint64_t n, uint64_t want, uint64_t es, int w)\n{\n uintptr_t lo = (uintptr_t)p;\n if (!p || n != want || lo % es != 0u || n > (UINTPTR_MAX - lo) / es)\n return 1;\n sp[*ns].lo = lo;\n sp[*ns].hi = lo + n * es;\n sp[*ns].w = w;\n (*ns)++;\n return 0;\n}\nstatic int ombr_overlap(const ombr_span *sp, unsigned ns)\n{\n for (unsigned i = 0; i < ns; i++)\n for (unsigned j = i + 1; j < ns; j++)\n if ((sp[i].w || sp[j].w) && sp[i].lo < sp[j].hi && sp[j].lo < sp[i].hi)\n return 1;\n return 0;\n}\n/* One read-only runtime table for every call and thread: the code only reads it (a write would fault). */\nstatic const ombr_rt ombr_rt_table = {{ [0 ... 1] = ombr_no_entry, [2] = ombr_trap, [3 ... 31] = ombr_no_entry }};\nstatic uint32_t ombr_run(const void *code, const uint64_t *args, uint64_t *result, int has_value)\n{\n if (ombr_active)\n return OMEGA_REENTRY;\n ombr_active = 1;\n unsigned char *top = ombr_stack();\n if (!top) {\n ombr_active = 0;\n return OMEGA_NO_STACK;\n }\n uint64_t v = 0;\n uint32_t s = ombr_enter(code, args, &ombr_rt_table, &v, top);\n ombr_active = 0;\n if (s == OMEGA_OK)\n *result = has_value ? v : 0u;\n return s;\n}\n" +note ob: append one byte to the output pool (trap 6 when it is full). +fn ob b uchar to void +n = get st 1 +if ge n len outb +trap 6 +end +put outb n b +put st 1 add n 1 +end +note orng: copy input bytes s .. e-1 to the output. +fn orng s ulong e ulong to void +i = s +while lt i e +ob get inb i +i = add i 1 +end +end +note odec: v in decimal. +fn odec v ulong to void +x = v +n = ulong 0 +put dg n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +while ne x 0 +put dg n uchar add rem x 10 48 +n = add n 1 +x = div x 10 +end +while gt n 0 +n = sub n 1 +ob get dg n +end +end +note ohex: one byte as 0xNN. +fn ohex b uchar to void +ob uchar 48 +ob uchar 120 +ob get hx shr b 4 +ob get hx and b 15 +end +note opre: the fixed runtime part of the C file. +fn opre to void +for i ulong len pre +ob get pre i +end +end +note ofr: fragment k of fr (fragments are separated by ~, byte 126). +fn ofr k ulong to void +c = ulong 0 +for i ulong len fr +b = get fr i +if eq b 126 +c = add c 1 +else +if eq c k +ob b +end +end +end +end +note tkis: 1 when token k is the keyword kw[o .. o+n-1], else 0. +fn tkis k ulong o ulong n ulong to ulong +s = get tks k +e = get tke k +if ne sub e s n +ret 0 +end +for j ulong n +if ne get inb add s j get kw add o j +ret 0 +end +end +ret 1 +end +note tknum: token k as a decimal number of 1 .. 8 digits. +fn tknum k ulong to ulong +s = get tks k +e = get tke k +if or eq s e gt sub e s 8 +trap 10 +end +v = ulong 0 +for j ulong sub e s +c = get inb add s j +if or lt c 48 gt c 57 +trap 10 +end +v = add mul v 10 ulong sub c 48 +end +ret v +end +note tokln: split the line that starts at p (ending at a newline or at q) into tokens at spaces. +fn tokln p ulong q ulong to ulong +e = p +while and lt e q ne get inb e 10 +e = add e 1 +end +n = ulong 0 +s = p +i = p +while lt i e +if eq get inb i 32 +if gt i s +put tks n s +put tke n i +n = add n 1 +end +s = add i 1 +end +i = add i 1 +end +if gt e s +put tks n s +put tke n e +n = add n 1 +end +ret n +end +note oname: the name of token k. +fn oname k ulong to void +orng get tks k get tke k +end +note opn: the name of parameter j. +fn opn j ulong to void +orng get ps j get pe j +end +note sepat: where the 0 byte after the source starting at p is. +fn sepat p ulong to ulong +t = get st 0 +q = p +while and lt q t ne get inb q 0 +q = add q 1 +end +if ge q t +trap 10 +end +ret q +end +note isfn: 1 when the bytes at i are "fn ". +fn isfn i ulong to ulong +if ne get inb i 102 +ret 0 +end +if ne get inb add i 1 110 +ret 0 +end +if ne get inb add i 2 32 +ret 0 +end +ret 1 +end +note sigln: the start of the last line in p .. q-1 that begins with "fn " (the compiler's entry). +fn sigln p ulong q ulong to ulong +fl = ulong 0 +nf = ulong 0 +ls = p +i = p +while lt i q +if eq i ls +if eq isfn i 1 +fl = i +nf = add nf 1 +end +end +if eq get inb i 10 +ls = add i 1 +end +i = add i 1 +end +if eq nf 0 +trap 10 +end +ret fl +end +note pkind: the kind of the parameter whose type starts at token ty: 1 ulong, 2 long, 3 edit ulong, +note 4 view ulong, 5 edit uchar, 6 view uchar; 0 when refused. +fn pkind ty ulong nt ulong to ulong +if eq tkis ty 10 5 1 +ret 1 +end +if eq tkis ty 15 4 1 +ret 2 +end +w = ulong 0 +if eq tkis ty 6 4 1 +w = 1 +else +if ne tkis ty 2 4 1 +ret 0 +end +end +if ge add ty 2 nt +ret 0 +end +el = add ty 1 +if eq tkis el 10 5 1 +ret add 3 w +end +if eq tkis el 19 5 1 +ret add 5 w +end +ret 0 +end +note cidr: 1 when bytes s .. e-1 form a C identifier ([A-Za-z_][A-Za-z0-9_]*), else 0. +fn cidr s ulong e ulong to ulong +if ge s e +ret 0 +end +for j ulong sub e s +c = get inb add s j +ok = ulong 0 +if eq c 95 +ok = 1 +end +if and ge c 97 le c 122 +ok = 1 +end +if and ge c 65 le c 90 +ok = 1 +end +if and gt j 0 and ge c 48 le c 57 +ok = 1 +end +if eq ok 0 +ret 0 +end +end +ret 1 +end +note lensuf: 1 when bytes s .. e-1 end in "_len" (the binding names an array length o_<name>_len). +fn lensuf s ulong e ulong to ulong +if lt sub e s 4 +ret 0 +end +b = sub e 4 +if ne get inb b 95 +ret 0 +end +if ne get inb add b 1 108 +ret 0 +end +if ne get inb add b 2 101 +ret 0 +end +if ne get inb add b 3 110 +ret 0 +end +ret 1 +end +note pname: refuse a parameter name that is not a C identifier or ends in "_len". +fn pname s ulong e ulong to void +if eq cidr s e 0 +trap 10 +end +if eq lensuf s e 1 +trap 10 +end +end +note samenm: 1 when bytes a .. b-1 equal bytes c .. d-1. +fn samenm a ulong b ulong c ulong d ulong to ulong +if ne sub b a sub d c +ret 0 +end +for j ulong sub b a +if ne get inb add a j get inb add c j +ret 0 +end +end +ret 1 +end +note uname: refuse a unit name (token 1) that is not a C identifier or repeats an earlier unit name. +fn uname to void +s = get tks 1 +e = get tke 1 +if eq cidr s e 0 +trap 10 +end +n = get st 4 +if ge n 256 +trap 10 +end +for j ulong n +if eq samenm s e get us j get ue j 1 +trap 10 +end +end +put us n s +put ue n e +put st 4 add n 1 +end +note pparam: record the parameter at token k in slot st 2; return the token after it. +fn pparam k ulong nt ulong to ulong +np = get st 2 +if ge np 6 +trap 10 +end +put ps np get tks k +put pe np get tke k +ki = pkind add k 1 nt +if eq ki 0 +trap 10 +end +put pk np ki +pname get tks k get tke k +put st 2 add np 1 +if le ki 2 +ret add k 2 +end +ln = tknum add k 3 +if or eq ln 0 gt ln 16777216 +trap 10 +end +put pl np ln +ret add k 4 +end +note parse: read the signature line at fl; parameters into ps pe pk pl, their count into st 2, +note 1 or 0 into st 3 for a function with or without a value. +fn parse fl ulong q ulong to void +nt = tokln fl q +if lt nt 4 +trap 10 +end +if eq tkis 1 28 4 1 +trap 10 +end +uname +put st 2 0 +k = ulong 2 +while eq tkis k 0 2 0 +if ge add k 1 nt +trap 10 +end +k = pparam k nt +if ge k nt +trap 10 +end +end +if ne add k 2 nt +trap 10 +end +r = add k 1 +hv = ulong 2 +if or eq tkis r 10 5 1 eq tkis r 15 4 1 +hv = 1 +end +if eq tkis r 24 4 1 +hv = 0 +end +if eq hv 2 +trap 10 +end +put st 3 hv +end +note codelen: the 8-digit code length after the 0 byte at q, checked against the input. +fn codelen q ulong to ulong +t = get st 0 +c0 = add q 9 +if gt c0 t +trap 10 +end +cl = ulong 0 +for j ulong 8 +d = get inb add add q 1 j +if or lt d 48 gt d 57 +trap 10 +end +cl = add mul cl 10 ulong sub d 48 +end +if or eq cl 0 ne rem cl 4 0 +trap 10 +end +if gt cl sub t c0 +trap 10 +end +ret cl +end +note ecode: the embedded machine code, unchanged. +fn ecode c0 ulong cl ulong to void +ofr 0 +oname 1 +ofr 1 +oname 1 +ofr 2 +oname 1 +ofr 3 +for j ulong cl +if gt j 0 +ob uchar 44 +end +ohex get inb add c0 j +end +ofr 24 +oname 1 +ofr 25 +oname 1 +ofr 26 +oname 1 +ofr 27 +oname 1 +ofr 4 +oname 1 +ofr 5 +oname 1 +end +note esig: the exported C parameter list. +fn esig to void +ofr 6 +for j ulong get st 2 +x = get pk j +if le x 2 +ofr 7 +opn j +else +if or eq x 3 eq x 5 +ofr 8 +else +ofr 9 +end +opn j +ofr 7 +opn j +ofr 10 +end +end +end +note earr: the checks and argument word for array parameter j of kind x. +fn earr j ulong x ulong to void +ofr 12 +opn j +ofr 13 +opn j +ofr 14 +odec get pl j +ofr 15 +if le x 4 +odec 8 +else +odec 1 +end +ofr 15 +if or eq x 3 eq x 5 +odec 1 +else +odec 0 +end +ofr 16 +odec j +ofr 17 +opn j +ofr 18 +end +note ebody: argument words, overlap check and the call. +fn ebody to void +ofr 11 +for j ulong get st 2 +x = get pk j +if le x 2 +ofr 19 +odec j +ofr 20 +opn j +ofr 18 +else +earr j x +end +end +ofr 21 +oname 1 +ofr 22 +odec get st 3 +ofr 23 +end +note unit: accept the unit at p, emit its C, return where the next unit starts. +fn unit p ulong to ulong +q = sepat p +fl = sigln p q +parse fl q +cl = codelen q +c0 = add q 9 +ecode c0 cl +esig +ebody +ret add c0 cl +end +note slurp: all of stdin into inb; refuse input that fills the pool. +fn slurp to ulong +t = ulong 0 +k = read 0 inb 0 len inb +while gt k 0 +t = add t ulong k +k = long 0 +if lt t len inb +k = read 0 inb t sub len inb t +end +end +if lt k 0 +trap 11 +end +if ge t len inb +trap 6 +end +ret t +end +fn main to int +t = slurp +put st 0 t +put st 1 0 +put st 4 0 +opre +p = ulong 0 +nu = ulong 0 +while lt p t +p = unit p +nu = add nu 1 +end +if eq nu 0 +trap 10 +end +o = ulong 0 +m = get st 1 +while lt o m +w = write 1 outb o sub m o +if le w 0 +ret 1 +end +o = add o ulong w +end +ret 0 +end + +#### c2-00202 sha256=e691e10d627b5595ee1268efb35222546eea9ba7b12805bb5bd98d565900c2c2 len=39907 +note Omega Bridge. Apache-2.0 WITH LLVM-exception. Recovered lexer and names; typed nodes and ordered C/Python emitters. +global src uchar 65536 +global slen ulong 1 +global cur ulong 1 +global line ulong 1 +global tk ulong 1 +global tw ulong 1 +global tl ulong 1 +global ts ulong 1 +global held ulong 1 +global outb uchar 262144 +global oc ulong 1 +global msg uchar 64 +global digs uchar 24 +global side uchar 4096 +global sidec ulong 1 +global mc ulong 1 +global nf ulong 1 +global fn_name ulong 32 +global fn_off ulong 32 +global fn_nl ulong 32 +global fn_ret ulong 32 +global fn_np ulong 32 +global fn_pt ulong 128 +global fn_pl ulong 128 +global fn_pk ulong 128 +global fn_poff ulong 128 +global fn_pnl ulong 128 +global ng ulong 1 +global g_off ulong 8 +global g_nl ulong 8 +global g_ty ulong 8 +global g_len ulong 8 +global nloc ulong 1 +global loc_off ulong 32 +global loc_nl ulong 32 +global loc_ty ulong 32 +global loc_k ulong 32 +global loc_len ulong 32 +global loc_par ulong 32 +global bd ulong 1 +global bk ulong 32 +global cfi ulong 1 +global hasmain ulong 1 + +global localuse ulong 1 +global target ulong 1 +global nn ulong 1 +global nk ulong 1024 +global nt ulong 1024 +global na ulong 1024 +global nb ulong 1024 +global nv ulong 1024 +global nx ulong 1024 +global ny ulong 1024 +global args ulong 4096 +global saved ulong 32 +global loopvar ulong 32 +global loopty ulong 32 +text capmsg "unsupported bridge capability\n" +text z0 "/* Emitted by Omega Bridge. GNU C11, POSIX. Scalars use canonical 64-bit bits. */\n#include <stdint.h>\n#include <stddef.h>\n#include <unistd.h>\n#include <errno.h>\n#include <setjmp.h>\nstatic _Thread_local jmp_buf o_jmp;\nstatic _Thread_local int o_busy;\nstatic __attribute__((noreturn)) void o_trap(int c){if(o_busy)longjmp(o_jmp,c);_exit(100+c);}\nstatic _Thread_local unsigned o_depth;\nstatic void o_enter(void){if(++o_depth>128)o_trap(6);}\nstatic uint64_t o_leave(uint64_t v){--o_depth;return v;}\nstatic unsigned o_width(unsigned t){static const unsigned w[]={0,1,8,16,32,64,8,16,32,64};return w[t];}\nstatic __int128 o_value(unsigned t,uint64_t v){return t>=6 && v>>63 ? (__int128)v-(((__int128)1)<<64):(__int128)v;}\nstatic uint64_t o_norm(unsigned t,__int128 v,int code){unsigned w=o_width(t);if(t>=6){__int128 m=((__int128)1)<<(w-1);if(v< -m||v>=m)o_trap(code);}else {if(v<0||(__uint128_t)v>=(((__uint128_t)1)<<w))o_trap(code);}return (uint64_t)v;}\nstatic uint64_t o_cast(unsigned t,unsigned s,uint64_t a){return o_norm(t,o_value(s,a),5);}\nstatic uint64_t o_op(unsigned op,unsigned t,uint64_t a,uint64_t b){\n __int128 x=o_value(t,a),y=o_value(t,b),z=0;unsigned w=o_width(t);uint64_t mask=w==64?UINT64_MAX:(((uint64_t)1<<w)-1);\n if(op>=6&&op<=11){switch(op){case 6:return x==y;case 7:return x!=y;case 8:return x<y;case 9:return x<=y;case 10:return x>y;default:return x>=y;}}\n if(op==12)return a&b;if(op==13)return a|b;if(op==14)return a^b;\n if(op==15||op==16){if(b>=w)o_trap(7);if(op==15)return t>=6?o_norm(t,x*(((__int128)1)<<b),1):(a<<b)&mask;if(t<6)return a>>b;if(!b)return a;return (a>>b)|((a>>63)?(UINT64_MAX<<(64-b)):0);}\n if(op==17){if(t<6)return (0-a)&mask;return o_norm(t,-x,1);}if(op==18)return t==1?!a:(t>=6?~a:(~a)&mask);\n if(op==4||op==5){if(!b)o_trap(2);z=op==4?x/y:x%y;return t>=6?o_norm(t,z,1):(uint64_t)z;}\n if(t<6){if(op==1)return (a+b)&mask;if(op==2)return (a-b)&mask;return (a*b)&mask;}\n if(op==1)z=x+y;if(op==2)z=x-y;if(op==3)z=x*y;return o_norm(t,z,1);\n}\nstatic uint64_t o_get(void *p,uint64_t n,uint64_t i,unsigned t){if(i>=n)o_trap(3);switch(t){case 2:return ((uint8_t*)p)[i];case 3:return ((uint16_t*)p)[i];case 4:return ((uint32_t*)p)[i];case 5:return ((uint64_t*)p)[i];case 6:return (uint64_t)((int8_t*)p)[i];case 7:return (uint64_t)((int16_t*)p)[i];case 8:return (uint64_t)((int32_t*)p)[i];default:return (uint64_t)((int64_t*)p)[i];}}\nstatic void o_put(void *p,uint64_t n,uint64_t i,uint64_t v,unsigned t){if(i>=n)o_trap(3);o_norm(t,o_value(t,v),5);switch(t){case 2:((uint8_t*)p)[i]=(uint8_t)v;break;case 3:((uint16_t*)p)[i]=(uint16_t)v;break;case 4:((uint32_t*)p)[i]=(uint32_t)v;break;case 5:((uint64_t*)p)[i]=v;break;case 6:((int8_t*)p)[i]=(int8_t)o_value(t,v);break;case 7:((int16_t*)p)[i]=(int16_t)o_value(t,v);break;case 8:((int32_t*)p)[i]=(int32_t)o_value(t,v);break;default:((int64_t*)p)[i]=(int64_t)o_value(t,v);}}\nstatic void o_fill(void *p,uint64_t n,uint64_t v,unsigned t){for(uint64_t i=0;i<n;i++)o_put(p,n,i,v,t);}\nstatic uint64_t o_io(unsigned op,uint64_t fd,void *p,uint64_t n,uint64_t off,uint64_t len){if(off>n||len>n-off)o_trap(3);int f=(int)o_value(8,fd);ssize_t r=op==1?read(f,(uint8_t*)p+off,(size_t)len):write(f,(uint8_t*)p+off,(size_t)len);return r<0?(uint64_t)(-(int64_t)errno):(uint64_t)r;}\nstatic int o_valid(unsigned t,uint64_t v){unsigned w=o_width(t);__int128 x=o_value(t,v);__int128 m=((__int128)1)<<(t>=6?w-1:w);return t>=6?x>=-m&&x<m:x>=0&&x<m;}\nstatic int o_buf(void *p,uint64_t n,uint64_t want,unsigned t){uintptr_t a=(uintptr_t)p;uint64_t z=t==2?1:8;return p&&n==want&&a%z==0&&n<=UINTPTR_MAX/z&&a<=UINTPTR_MAX-n*z;}\nstatic int o_overlap(void *a,uint64_t an,void *b,uint64_t bn){uintptr_t x=(uintptr_t)a,y=(uintptr_t)b;return x<y+bn&&y<x+an;}\n" +text z1 "# Emitted by Omega Bridge. Scalar values use canonical 64-bit bits.\nimport os as _os\n_MASK = (1 << 64) - 1\n_depth = 0\n_busy = False\nclass _Trap(Exception):\n pass\ndef o_trap(c):\n if _busy: raise _Trap(c)\n _os._exit(100 + c)\ndef o_enter():\n global _depth\n _depth += 1\n if _depth > 128: o_trap(6)\ndef o_leave(v):\n global _depth\n _depth -= 1\n return v\ndef o_width(t):\n return (0,1,8,16,32,64,8,16,32,64)[t]\ndef o_value(t,v):\n return v - (1 << 64) if t >= 6 and v >> 63 else v\ndef o_norm(t,v,code):\n w = o_width(t)\n lo,hi = (-(1 << (w-1)),1 << (w-1)) if t >= 6 else (0,1 << w)\n if not lo <= v < hi: o_trap(code)\n return v & _MASK\ndef o_cast(t,s,a):\n return o_norm(t,o_value(s,a),5)\ndef o_op(op,t,a,b):\n x,y = o_value(t,a),o_value(t,b)\n w = o_width(t)\n mask = (1 << w)-1\n if 6 <= op <= 11: return int((x==y,x!=y,x<y,x<=y,x>y,x>=y)[op-6])\n if op == 12: return a & b\n if op == 13: return a | b\n if op == 14: return a ^ b\n if op in (15,16):\n if b >= w: o_trap(7)\n if op == 15: return o_norm(t,x*(1<<b),1) if t>=6 else (a<<b)&mask\n return (x >> b) & _MASK\n if op == 17: return ((-a)&mask) if t < 6 else o_norm(t,-x,1)\n if op == 18: return int(not a) if t==1 else (~a)&(_MASK if t>=6 else mask)\n if op in (4,5):\n if not b: o_trap(2)\n q = abs(x)//abs(y)\n if (x<0) != (y<0): q = -q\n z = q if op == 4 else x-q*y\n elif op == 1: z=x+y\n elif op == 2: z=x-y\n else: z=x*y\n return o_norm(t,z,1) if t>=6 else z & mask\ndef o_get(p,n,i,t):\n if i>=n: o_trap(3)\n return p[i]\ndef o_put(p,n,i,v,t):\n if i>=n: o_trap(3)\n p[i]=o_norm(t,o_value(t,v),5)\ndef o_fill(p,n,v,t):\n for i in range(n): o_put(p,n,i,v,t)\ndef o_io(op,fd,p,n,off,length):\n if off>n or length>n-off: o_trap(3)\n try:\n if op==1:\n data=_os.read(o_value(8,fd),length)\n p[off:off+len(data)]=data\n return len(data)\n return _os.write(o_value(8,fd),bytes(p[off:off+length]))\n except OSError as exc: return (-exc.errno)&_MASK\ndef o_valid(t,v):\n if type(v) is not int or not 0<=v<=_MASK: return False\n w=o_width(t)\n x=o_value(t,v)\n return -(1<<(w-1))<=x<(1<<(w-1)) if t>=6 else x<(1<<w)\ndef o_buf(p,n,want,t,edit):\n if type(n) is not int or n!=want: return False\n if t==2:\n return type(p) is bytearray and len(p)==n\n return type(p) is list and len(p)==n and all(o_valid(t,x) for x in p)\n" +text z2 "_n" +text z3 " " +text z4 "uint64_t " +text z5 "ULL" +text z6 "o_cast(" +text z7 "o_get(" +text z8 "({uint64_t _a=" +text z9 ";uint64_t _b=" +text z10 ";o_op(" +text z11 "o_op(" +text z12 "_a,_b);})" +text z13 "({uint64_t _fd=" +text z14 ";uint64_t _off=" +text z15 ";uint64_t _cnt=" +text z16 ";o_io(" +text z17 "o_io(" +text z18 "_fd" +text z19 "_off,_cnt);})" +text z20 "int" +text z21 "_t " +text z22 "]={0};\n" +text z23 "=bytearray(" +text z24 ")\n" +text z25 "=[0]*" +text z26 "o_fill(" +text z27 "static uint64_t " +text z28 "def " +text z29 "void *" +text z30 "_n" +text z31 "void" +text z32 "{uint64_t _i=" +text z33 ";uint64_t _v=" +text z34 ";o_put(" +text z35 "o_put(" +text z36 "_i,_v," +text z37 ";}\n" +text z38 "{\n" +text z39 ":\n" +text z40 "pass\n" +text z41 "{\n" +text z42 "=0" +text z43 "=0" +text z44 "for(;o_op(8," +text z45 "while o_op(8," +text z46 "=o_op(1," +text z47 ",1))" +text z48 "if(" +text z49 "++>=1000000)o_trap(4);\n" +text z50 "if " +text z51 ">=1000000: o_trap(4)\n" +text z52 "+=1\n" +text z53 "=o_op(1," +text z54 ",1)\n" +text z55 "return o_leave(0)" +text z56 "}\n" +text z57 "}\n" +text z58 "}else{\n" +text z59 "else:\n" +text z60 "pass\n" +text z61 "if(" +text z62 "{\n" +text z63 "=0" +text z64 "while(" +text z65 "if(" +text z66 "++>=" +text z67 ")o_trap(4);\n" +text z68 "if " +text z69 ">=" +text z70 ": o_trap(4)\n" +text z71 "+=1\n" +text z72 "return o_leave(" +text z73 "_exit((int)(" +text z74 "_os._exit((" +text z75 ")&255)" +text z76 "{\n" +text z77 ":\n" +text z78 "o_enter()" +text z79 ";\n" +text z80 "#ifndef OMEGA_LIBRARY\nint main(void){return (int)(" +text z81 "()&255);}\n#endif\n" +text z82 "if __name__ == '__main__':\n _os._exit(" +text z83 "()&255)\n" +text z84 "({" +text z85 "uint64_t " +text z86 ";})" +text z87 "omega_" +text z88 "_n" +text z89 ")return 8;\n" +text z90 ": return (8,None)\n" +text z91 "if(!" +text z92 "if not " +text z93 "o_valid(" +text z94 "o_buf(" +text z95 "_n," +text z96 "if(o_overlap(result,8," +text z97 "_n*" +text z98 "))return 8;\n" +text z99 "if(o_overlap(" +text z100 "_n*" +text z101 "_n*" +text z102 "))return 8;\n" +text z103 "if " +text z104 " is " +text z105 ": return (8,None)\n" +text z106 "uint32_t " +text z107 "def " +text z108 "uint64_t *result" +text z109 "void *" +text z110 "uint64_t " +text z111 "_n" +text z112 "){\nif(!o_buf(result,1,1,5))return 8;\n" +text z113 "):\n" +text z114 "if(o_busy)return 9;\no_busy=1;o_depth=0;int code=setjmp(o_jmp);\nif(!code)*result=" +text z115 ");\no_busy=0;o_depth=0;return (uint32_t)code;\n}\n" +text z116 "global _busy, _depth\n" +text z117 "if _busy: return (9,None)\n" +text z118 "_busy=True\n" +text z119 "_depth=0\n" +text z120 "try:\n" +text z121 "return (0," +text z122 "))\n" +text z123 "except _Trap as exc:\n" +text z124 "return (exc.args[0],None)\n" +text z125 "finally:\n" +text z126 "_busy=False\n" +text z127 "_depth=0\n" + +fn mputb b uchar to void +m = get mc 0 +put msg m b +put mc 0 add m 1 +end + +fn mputn v ulong to void +d = new uchar 20 0 +i = ulong 0 +x = v +put d 0 uchar add rem x 10 48 +x = div x 10 +i = add i 1 +while gt x 0 +put d i uchar add rem x 10 48 +x = div x 10 +i = add i 1 +end +j = i +while gt j 0 +j = sub j 1 +mputb get d j +end +end + +fn fail code ulong to void +put mc 0 0 +mputb 116 +mputb 111 +mputb 99 +mputb 58 +mputb 32 +mputb 108 +mputb 105 +mputb 110 +mputb 101 +mputb 32 +mputn get line 0 +mputb 58 +mputb 32 +mputb 101 +mputb 114 +mputb 114 +mputb 111 +mputb 114 +mputb 32 +mputn code +mputb 10 +w = write 2 msg 0 get mc 0 +if eq code 24 +w = write 2 capmsg 0 len capmsg +end +exit int code +end + +fn e_b c ulong to void +o = get oc 0 +if ge o 262144 +fail 14 +end +put outb o uchar c +put oc 0 add o 1 +end + +fn e_src a ulong n ulong to void +i = ulong 0 +while lt i n +e_b ulong get src add a i +i = add i 1 +end +end + +fn e_s0 to void +e_b 32 +end + +fn isw w ulong to ulong +if and eq get tk 0 1 eq get tw 0 w +ret 1 +end +ret 0 +end + +fn tok_num to void +v = ulong 0 +i = ulong 0 +minus = ulong 0 +p = get ts 0 +if eq get src p 45 +minus = 1 +i = 1 +end +while lt i get tl 0 +b = get src add p i +v = add mul v 10 sub ulong b ulong 48 +i = add i 1 +end +if eq minus 1 +v = sub 0 v +end +put tw 0 v +put tk 0 2 +end + +fn tok2 c uchar to void +put ts 0 get cur 0 +w = ulong 0 +sh = ulong 0 +n = ulong 0 +go = ulong 1 +while eq go 1 +if ge get cur 0 get slen 0 +go = 0 +else +b = get src get cur 0 +if le b 32 +go = 0 +else +if lt n 8 +w = or w shl ulong b sh +sh = add sh 8 +end +n = add n 1 +put cur 0 add get cur 0 1 +end +end +end +put tw 0 w +put tl 0 n +f = get src get ts 0 +num = ulong 0 +if eq f 45 +num = 1 +end +if and ge f 48 le f 57 +num = 1 +end +if eq num 1 +tok_num +else +put tk 0 1 +end +end + +fn tok to void +if eq get held 0 1 +put held 0 0 +ret +end +go = ulong 1 +while eq go 1 +if ge get cur 0 get slen 0 +put tk 0 3 +ret +end +c = get src get cur 0 +if or or eq c 32 eq c 9 eq c 13 +put cur 0 add get cur 0 1 +else +if eq c 10 +put cur 0 add get cur 0 1 +put line 0 add get line 0 1 +put tk 0 0 +ret +end +if lt c 32 +fail 16 +end +tok2 c +ret +end +end +end + +fn ty_of w ulong to ulong +if eq w 1819242338 +ret 1 +end +if eq w 491260502901 +ret 2 +end +if eq w 128034844210037 +ret 3 +end +if eq w 1953393013 +ret 4 +end +if eq w 444234427509 +ret 5 +end +if eq w 1702132066 +ret 6 +end +if eq w 500136110195 +ret 7 +end +if eq w 7630441 +ret 8 +end +if eq w 1735290732 +ret 9 +end +ret 0 +end + +fn signed t ulong to ulong +if ge t 6 +ret 1 +end +ret 0 +end + +fn same_name o ulong n ulong to ulong +if ne n get tl 0 +ret 0 +end +i = ulong 0 +while lt i n +if ne get src add o i get src add get ts 0 i +ret 0 +end +i = add i 1 +end +ret 1 +end + +fn loc_of to ulong +i = ulong 0 +while lt i get nloc 0 +if eq same_name get loc_off i get loc_nl i 1 +ret i +end +i = add i 1 +end +ret 99 +end + +fn glob_of to ulong +i = ulong 0 +while lt i get ng 0 +if eq same_name get g_off i get g_nl i 1 +ret i +end +i = add i 1 +end +ret 99 +end + +fn fn_of to ulong +i = ulong 0 +while lt i get nf 0 +if eq same_name get fn_off i get fn_nl i 1 +ret i +end +i = add i 1 +end +ret 99 +end + +fn add_loc o ulong n ulong ty ulong k ulong ln ulong par ulong to void +i = get nloc 0 +if ge i 32 +fail 14 +end +put loc_off i o +put loc_nl i n +put loc_ty i ty +put loc_k i k +put loc_len i ln +put loc_par i par +put nloc 0 add i 1 +end + +fn walk_sig rec ulong to void +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +ix = get nf 0 +if eq rec 1 +if ne fn_of 99 +fail 10 +end +if ge ix 32 +fail 14 +end +put fn_name ix get tw 0 +put fn_off ix get ts 0 +put fn_nl ix get tl 0 +put fn_np ix 0 +if eq get tw 0 1852399981 +put hasmain 0 1 +end +put cfi 0 ix +else +put cfi 0 fn_of +if eq get cfi 0 99 +fail 3 +end +end +tok +while eq isw 28532 0 +if ne get tk 0 1 +fail 16 +end +po = get ts 0 +pn = get tl 0 +tok +pk = ulong 0 +pty = ulong 0 +pln = ulong 0 +if eq isw 2003134838 1 +pk = 2 +end +if eq isw 1953064037 1 +pk = 3 +end +if gt pk 0 +tok +pty = ty_of get tw 0 +if eq pty 0 +fail 7 +end +tok +if ne get tk 0 2 +fail 16 +end +pln = get tw 0 +else +pty = ty_of get tw 0 +if eq pty 0 +fail 7 +end +end +if eq rec 1 +if ge get fn_np ix 4 +fail 24 +end +slot = add mul ix 4 get fn_np ix +put fn_pt slot pty +put fn_pl slot pln +put fn_pk slot pk +put fn_poff slot po +put fn_pnl slot pn +put fn_np ix add get fn_np ix 1 +end +tok +end +tok +rt = ulong 10 +if eq isw 1684631414 0 +rt = ty_of get tw 0 +if eq rt 0 +fail 7 +end +end +if eq rec 1 +put fn_ret ix rt +put nf 0 add ix 1 +end +end + +fn parse_global to void +tok +if ne get tk 0 1 +fail 16 +end +i = get ng 0 +if ge i 8 +fail 14 +end +put g_off i get ts 0 +put g_nl i get tl 0 +tok +ty = ty_of get tw 0 +if eq ty 0 +fail 7 +end +put g_ty i ty +tok +if ne get tk 0 2 +fail 16 +end +if or eq get tw 0 0 gt get tw 0 524288 +fail 23 +end +put g_len i get tw 0 +put ng 0 add i 1 +end + +fn namescan to void +put cur 0 1 +put line 0 1 +put held 0 0 +tok +go = ulong 1 +while eq go 1 +if eq get tk 0 3 +go = 0 +else +if eq get tk 0 0 +tok +else +if eq isw 28262 1 +walk_sig 1 +tok +else +if eq isw 119165519096935 1 +parse_global +tok +else +while and ne get tk 0 0 ne get tk 0 3 +tok +end +tok +end +end +end +end +end +end + +fn e_comma to void +e_b 44 +e_b 32 +end + +fn e_dec v ulong to void +x = v +p = ulong 0 +put digs 0 uchar add rem x 10 48 +x = div x 10 +p = add p 1 +while gt x 0 +put digs p uchar add rem x 10 48 +x = div x 10 +p = add p 1 +end +while gt p 0 +p = sub p 1 +e_b ulong get digs p +end +end + +fn op_of w ulong to ulong +if eq w 6579297 +ret 1 +end +if eq w 6452595 +ret 2 +end +if eq w 7107949 +ret 3 +end +if eq w 7760228 +ret 4 +end +if eq w 7169394 +ret 5 +end +if eq w 29029 +ret 6 +end +if eq w 25966 +ret 7 +end +if eq w 29804 +ret 8 +end +if eq w 25964 +ret 9 +end +if eq w 29799 +ret 10 +end +if eq w 25959 +ret 11 +end +if eq w 6581857 +ret 12 +end +if eq w 29295 +ret 13 +end +ret 0 +end + +fn span_eq a ulong an ulong b ulong bn ulong to ulong +if ne an bn +ret 0 +end +i = ulong 0 +while lt i an +if ne get src add a i get src add b i +ret 0 +end +i = add i 1 +end +ret 1 +end + + +fn emitstr k ulong to void +i = ulong 0 +if eq k 0 +while lt i len z0 +e_b ulong get z0 i +i = add i 1 +end +ret +end +if eq k 1 +while lt i len z1 +e_b ulong get z1 i +i = add i 1 +end +ret +end +if eq k 2 +while lt i len z2 +e_b ulong get z2 i +i = add i 1 +end +ret +end +if eq k 3 +while lt i len z3 +e_b ulong get z3 i +i = add i 1 +end +ret +end +if eq k 4 +while lt i len z4 +e_b ulong get z4 i +i = add i 1 +end +ret +end +if eq k 5 +while lt i len z5 +e_b ulong get z5 i +i = add i 1 +end +ret +end +if eq k 6 +while lt i len z6 +e_b ulong get z6 i +i = add i 1 +end +ret +end +if eq k 7 +while lt i len z7 +e_b ulong get z7 i +i = add i 1 +end +ret +end +if eq k 8 +while lt i len z8 +e_b ulong get z8 i +i = add i 1 +end +ret +end +if eq k 9 +while lt i len z9 +e_b ulong get z9 i +i = add i 1 +end +ret +end +if eq k 10 +while lt i len z10 +e_b ulong get z10 i +i = add i 1 +end +ret +end +if eq k 11 +while lt i len z11 +e_b ulong get z11 i +i = add i 1 +end +ret +end +if eq k 12 +while lt i len z12 +e_b ulong get z12 i +i = add i 1 +end +ret +end +if eq k 13 +while lt i len z13 +e_b ulong get z13 i +i = add i 1 +end +ret +end +if eq k 14 +while lt i len z14 +e_b ulong get z14 i +i = add i 1 +end +ret +end +if eq k 15 +while lt i len z15 +e_b ulong get z15 i +i = add i 1 +end +ret +end +if eq k 16 +while lt i len z16 +e_b ulong get z16 i +i = add i 1 +end +ret +end +if eq k 17 +while lt i len z17 +e_b ulong get z17 i +i = add i 1 +end +ret +end +if eq k 18 +while lt i len z18 +e_b ulong get z18 i +i = add i 1 +end +ret +end +if eq k 19 +while lt i len z19 +e_b ulong get z19 i +i = add i 1 +end +ret +end +if eq k 20 +while lt i len z20 +e_b ulong get z20 i +i = add i 1 +end +ret +end +if eq k 21 +while lt i len z21 +e_b ulong get z21 i +i = add i 1 +end +ret +end +if eq k 22 +while lt i len z22 +e_b ulong get z22 i +i = add i 1 +end +ret +end +if eq k 23 +while lt i len z23 +e_b ulong get z23 i +i = add i 1 +end +ret +end +if eq k 24 +while lt i len z24 +e_b ulong get z24 i +i = add i 1 +end +ret +end +if eq k 25 +while lt i len z25 +e_b ulong get z25 i +i = add i 1 +end +ret +end +if eq k 26 +while lt i len z26 +e_b ulong get z26 i +i = add i 1 +end +ret +end +if eq k 27 +while lt i len z27 +e_b ulong get z27 i +i = add i 1 +end +ret +end +if eq k 28 +while lt i len z28 +e_b ulong get z28 i +i = add i 1 +end +ret +end +if eq k 29 +while lt i len z29 +e_b ulong get z29 i +i = add i 1 +end +ret +end +if eq k 30 +while lt i len z30 +e_b ulong get z30 i +i = add i 1 +end +ret +end +if eq k 31 +while lt i len z31 +e_b ulong get z31 i +i = add i 1 +end +ret +end +if eq k 32 +while lt i len z32 +e_b ulong get z32 i +i = add i 1 +end +ret +end +if eq k 33 +while lt i len z33 +e_b ulong get z33 i +i = add i 1 +end +ret +end +if eq k 34 +while lt i len z34 +e_b ulong get z34 i +i = add i 1 +end +ret +end +if eq k 35 +while lt i len z35 +e_b ulong get z35 i +i = add i 1 +end +ret +end +if eq k 36 +while lt i len z36 +e_b ulong get z36 i +i = add i 1 +end +ret +end +if eq k 37 +while lt i len z37 +e_b ulong get z37 i +i = add i 1 +end +ret +end +if eq k 38 +while lt i len z38 +e_b ulong get z38 i +i = add i 1 +end +ret +end +if eq k 39 +while lt i len z39 +e_b ulong get z39 i +i = add i 1 +end +ret +end +if eq k 40 +while lt i len z40 +e_b ulong get z40 i +i = add i 1 +end +ret +end +if eq k 41 +while lt i len z41 +e_b ulong get z41 i +i = add i 1 +end +ret +end +if eq k 42 +while lt i len z42 +e_b ulong get z42 i +i = add i 1 +end +ret +end +if eq k 43 +while lt i len z43 +e_b ulong get z43 i +i = add i 1 +end +ret +end +if eq k 44 +while lt i len z44 +e_b ulong get z44 i +i = add i 1 +end +ret +end +if eq k 45 +while lt i len z45 +e_b ulong get z45 i +i = add i 1 +end +ret +end +if eq k 46 +while lt i len z46 +e_b ulong get z46 i +i = add i 1 +end +ret +end +if eq k 47 +while lt i len z47 +e_b ulong get z47 i +i = add i 1 +end +ret +end +if eq k 48 +while lt i len z48 +e_b ulong get z48 i +i = add i 1 +end +ret +end +if eq k 49 +while lt i len z49 +e_b ulong get z49 i +i = add i 1 +end +ret +end +if eq k 50 +while lt i len z50 +e_b ulong get z50 i +i = add i 1 +end +ret +end +if eq k 51 +while lt i len z51 +e_b ulong get z51 i +i = add i 1 +end +ret +end +if eq k 52 +while lt i len z52 +e_b ulong get z52 i +i = add i 1 +end +ret +end +if eq k 53 +while lt i len z53 +e_b ulong get z53 i +i = add i 1 +end +ret +end +if eq k 54 +while lt i len z54 +e_b ulong get z54 i +i = add i 1 +end +ret +end +if eq k 55 +while lt i len z55 +e_b ulong get z55 i +i = add i 1 +end +ret +end +if eq k 56 +while lt i len z56 +e_b ulong get z56 i +i = add i 1 +end +ret +end +if eq k 57 +while lt i len z57 +e_b ulong get z57 i +i = add i 1 +end +ret +end +if eq k 58 +while lt i len z58 +e_b ulong get z58 i +i = add i 1 +end +ret +end +if eq k 59 +while lt i len z59 +e_b ulong get z59 i +i = add i 1 +end +ret +end +if eq k 60 +while lt i len z60 +e_b ulong get z60 i +i = add i 1 +end +ret +end +if eq k 61 +while lt i len z61 +e_b ulong get z61 i +i = add i 1 +end +ret +end +if eq k 62 +while lt i len z62 +e_b ulong get z62 i +i = add i 1 +end +ret +end +if eq k 63 +while lt i len z63 +e_b ulong get z63 i +i = add i 1 +end +ret +end +if eq k 64 +while lt i len z64 +e_b ulong get z64 i +i = add i 1 +end +ret +end +if eq k 65 +while lt i len z65 +e_b ulong get z65 i +i = add i 1 +end +ret +end +if eq k 66 +while lt i len z66 +e_b ulong get z66 i +i = add i 1 +end +ret +end +if eq k 67 +while lt i len z67 +e_b ulong get z67 i +i = add i 1 +end +ret +end +if eq k 68 +while lt i len z68 +e_b ulong get z68 i +i = add i 1 +end +ret +end +if eq k 69 +while lt i len z69 +e_b ulong get z69 i +i = add i 1 +end +ret +end +if eq k 70 +while lt i len z70 +e_b ulong get z70 i +i = add i 1 +end +ret +end +if eq k 71 +while lt i len z71 +e_b ulong get z71 i +i = add i 1 +end +ret +end +if eq k 72 +while lt i len z72 +e_b ulong get z72 i +i = add i 1 +end +ret +end +if eq k 73 +while lt i len z73 +e_b ulong get z73 i +i = add i 1 +end +ret +end +if eq k 74 +while lt i len z74 +e_b ulong get z74 i +i = add i 1 +end +ret +end +if eq k 75 +while lt i len z75 +e_b ulong get z75 i +i = add i 1 +end +ret +end +if eq k 76 +while lt i len z76 +e_b ulong get z76 i +i = add i 1 +end +ret +end +if eq k 77 +while lt i len z77 +e_b ulong get z77 i +i = add i 1 +end +ret +end +if eq k 78 +while lt i len z78 +e_b ulong get z78 i +i = add i 1 +end +ret +end +if eq k 79 +while lt i len z79 +e_b ulong get z79 i +i = add i 1 +end +ret +end +if eq k 80 +while lt i len z80 +e_b ulong get z80 i +i = add i 1 +end +ret +end +if eq k 81 +while lt i len z81 +e_b ulong get z81 i +i = add i 1 +end +ret +end +if eq k 82 +while lt i len z82 +e_b ulong get z82 i +i = add i 1 +end +ret +end +if eq k 83 +while lt i len z83 +e_b ulong get z83 i +i = add i 1 +end +ret +end +if eq k 84 +while lt i len z84 +e_b ulong get z84 i +i = add i 1 +end +ret +end +if eq k 85 +while lt i len z85 +e_b ulong get z85 i +i = add i 1 +end +ret +end +if eq k 86 +while lt i len z86 +e_b ulong get z86 i +i = add i 1 +end +ret +end +if eq k 87 +while lt i len z87 +e_b ulong get z87 i +i = add i 1 +end +ret +end +if eq k 88 +while lt i len z88 +e_b ulong get z88 i +i = add i 1 +end +ret +end +if eq k 89 +while lt i len z89 +e_b ulong get z89 i +i = add i 1 +end +ret +end +if eq k 90 +while lt i len z90 +e_b ulong get z90 i +i = add i 1 +end +ret +end +if eq k 91 +while lt i len z91 +e_b ulong get z91 i +i = add i 1 +end +ret +end +if eq k 92 +while lt i len z92 +e_b ulong get z92 i +i = add i 1 +end +ret +end +if eq k 93 +while lt i len z93 +e_b ulong get z93 i +i = add i 1 +end +ret +end +if eq k 94 +while lt i len z94 +e_b ulong get z94 i +i = add i 1 +end +ret +end +if eq k 95 +while lt i len z95 +e_b ulong get z95 i +i = add i 1 +end +ret +end +if eq k 96 +while lt i len z96 +e_b ulong get z96 i +i = add i 1 +end +ret +end +if eq k 97 +while lt i len z97 +e_b ulong get z97 i +i = add i 1 +end +ret +end +if eq k 98 +while lt i len z98 +e_b ulong get z98 i +i = add i 1 +end +ret +end +if eq k 99 +while lt i len z99 +e_b ulong get z99 i +i = add i 1 +end +ret +end +if eq k 100 +while lt i len z100 +e_b ulong get z100 i +i = add i 1 +end +ret +end +if eq k 101 +while lt i len z101 +e_b ulong get z101 i +i = add i 1 +end +ret +end +if eq k 102 +while lt i len z102 +e_b ulong get z102 i +i = add i 1 +end +ret +end +if eq k 103 +while lt i len z103 +e_b ulong get z103 i +i = add i 1 +end +ret +end +if eq k 104 +while lt i len z104 +e_b ulong get z104 i +i = add i 1 +end +ret +end +if eq k 105 +while lt i len z105 +e_b ulong get z105 i +i = add i 1 +end +ret +end +if eq k 106 +while lt i len z106 +e_b ulong get z106 i +i = add i 1 +end +ret +end +if eq k 107 +while lt i len z107 +e_b ulong get z107 i +i = add i 1 +end +ret +end +if eq k 108 +while lt i len z108 +e_b ulong get z108 i +i = add i 1 +end +ret +end +if eq k 109 +while lt i len z109 +e_b ulong get z109 i +i = add i 1 +end +ret +end +if eq k 110 +while lt i len z110 +e_b ulong get z110 i +i = add i 1 +end +ret +end +if eq k 111 +while lt i len z111 +e_b ulong get z111 i +i = add i 1 +end +ret +end +if eq k 112 +while lt i len z112 +e_b ulong get z112 i +i = add i 1 +end +ret +end +if eq k 113 +while lt i len z113 +e_b ulong get z113 i +i = add i 1 +end +ret +end +if eq k 114 +while lt i len z114 +e_b ulong get z114 i +i = add i 1 +end +ret +end +if eq k 115 +while lt i len z115 +e_b ulong get z115 i +i = add i 1 +end +ret +end +if eq k 116 +while lt i len z116 +e_b ulong get z116 i +i = add i 1 +end +ret +end +if eq k 117 +while lt i len z117 +e_b ulong get z117 i +i = add i 1 +end +ret +end +if eq k 118 +while lt i len z118 +e_b ulong get z118 i +i = add i 1 +end +ret +end +if eq k 119 +while lt i len z119 +e_b ulong get z119 i +i = add i 1 +end +ret +end +if eq k 120 +while lt i len z120 +e_b ulong get z120 i +i = add i 1 +end +ret +end +if eq k 121 +while lt i len z121 +e_b ulong get z121 i +i = add i 1 +end +ret +end +if eq k 122 +while lt i len z122 +e_b ulong get z122 i +i = add i 1 +end +ret +end +if eq k 123 +while lt i len z123 +e_b ulong get z123 i +i = add i 1 +end +ret +end +if eq k 124 +while lt i len z124 +e_b ulong get z124 i +i = add i 1 +end +ret +end +if eq k 125 +while lt i len z125 +e_b ulong get z125 i +i = add i 1 +end +ret +end +if eq k 126 +while lt i len z126 +e_b ulong get z126 i +i = add i 1 +end +ret +end +if eq k 127 +while lt i len z127 +e_b ulong get z127 i +i = add i 1 +end +ret +end +fail 24 +end + +note Typed nodes: literal 1, local 2, op 3, cast 4, get 5, len 6, call 7, io 8. +fn node k ulong t ulong a ulong b ulong v ulong to ulong +n = get nn 0 +if ge n 1024 +fail 14 +end +put nk n k +put nt n t +put na n a +put nb n b +put nv n v +put nn 0 add n 1 +ret n +end + +fn width t ulong to ulong +if eq t 1 +ret 1 +end +if or eq t 2 eq t 6 +ret 8 +end +if or eq t 3 eq t 7 +ret 16 +end +if or eq t 4 eq t 8 +ret 32 +end +ret 64 +end + +fn checknum n ulong t ulong to void +v = get nv n +isneg = get nb n +w = width t +if eq signed t 1 +lim = shl ulong 1 sub w 1 +if eq isneg 1 +if gt sub 0 v lim +fail 8 +end +else +if ge v lim +fail 8 +end +end +else +if eq isneg 1 +fail 8 +end +if lt w 64 +if ge v shl ulong 1 w +fail 8 +end +end +end +put nt n t +end + +fn expect n ulong t ulong to void +if eq get nt n 0 +checknum n t +else +if ne get nt n t +fail 7 +end +end +end + +fn arr to ulong +tok +l = loc_of +if ne l 99 +if eq get loc_k l 0 +fail 7 +end +ret l +end +g = glob_of +if eq g 99 +fail 3 +end +ret add 32 g +end + +fn aty a ulong to ulong +if ge a 32 +ret get g_ty sub a 32 +end +ret get loc_ty a +end + +fn alen a ulong to ulong +if ge a 32 +ret get g_len sub a 32 +end +ret get loc_len a +end + +fn writable a ulong to void +if lt a 32 +if eq get loc_k a 2 +fail 20 +end +end +end + +fn expr exp ulong to ulong +tok +if eq get tk 0 2 +negative = ulong 0 +if eq get src get ts 0 45 +negative = 1 +end +n = node 1 0 0 negative get tw 0 +if gt exp 0 +checknum n exp +end +ret n +end +if ne get tk 0 1 +fail 4 +end +w = get tw 0 +if or eq w 1702195828 eq w 435728179558 +bv = ulong 0 +if eq w 1702195828 +bv = 1 +end +ret node 1 1 0 0 bv +end +t = ty_of w +if gt t 0 +a = expr 0 +if eq get nt a 0 +checknum a t +ret a +end +ret node 4 t a 0 0 +end +if eq w 7628135 +a = arr +i = expr 5 +expect i 5 +if eq get nk i 1 +if ge get nv i alen a +fail 21 +end +end +ret node 5 aty a a i 0 +end +if eq w 7234924 +a = arr +ret node 6 5 a 0 0 +end +if or eq w 1684104562 eq w 435744764535 +if eq get hasmain 0 0 +fail 24 +end +fd = expr 8 +expect fd 8 +a = arr +if ne aty a 2 +fail 7 +end +if eq w 1684104562 +writable a +end +off = expr 5 +expect off 5 +cnt = expr 5 +expect cnt 5 +io = ulong 1 +if eq w 435744764535 +io = 2 +end +p = node 8 9 fd off io +put nx p cnt +put ny p a +ret p +end +op = op_of w +if eq w 7499640 +op = 14 +end +if eq w 7104627 +op = 15 +end +if eq w 7497843 +op = 16 +end +if eq w 6776174 +op = 17 +end +if eq w 7630702 +op = 18 +end +if gt op 0 +a = expr 0 +b = ulong 0 +if lt op 17 +b = expr 0 +if and eq get nt a 0 eq get nt b 0 +fail 11 +end +if eq get nt a 0 +checknum a get nt b +end +if eq get nt b 0 +checknum b get nt a +end +if and ne op 15 ne op 16 +if ne get nt a get nt b +fail 7 +end +end +else +if eq get nt a 0 +fail 11 +end +end +t = get nt a +rt = t +if and ge op 6 le op 11 +rt = 1 +end +n = node 3 rt a b op +put nx n t +ret n +end +f = fn_of +if ne f 99 +ret callnode f +end +l = loc_of +if eq l 99 +fail 3 +end +if ne get loc_k l 0 +fail 7 +end +ret node 2 get loc_ty l l 0 0 +end + +fn callnode f ulong to ulong +n = node 7 get fn_ret f 0 0 f +i = ulong 0 +while lt i get fn_np f +slot = add mul f 4 i +arg = ulong 0 +if gt get fn_pk slot 0 +arg = arr +if or ne aty arg get fn_pt slot ne alen arg get fn_pl slot +fail 7 +end +if ge arg 32 +fail 19 +end +if eq get fn_pk slot 3 +writable arg +end +j = ulong 0 +while lt j i +s = add mul f 4 j +if gt get fn_pk s 0 +if eq get args add mul n 4 j arg +fail 19 +end +end +j = add j 1 +end +else +arg = expr get fn_pt slot +expect arg get fn_pt slot +end +put args add mul n 4 i arg +i = add i 1 +end +ret n +end + +fn named ch ulong n ulong to void +e_b ch +e_dec n +end + +fn arrp a ulong to void +if ge a 32 +named 103 sub a 32 +else +named 118 a +end +end + +fn arrn a ulong to void +arrp a +emitstr 2 +end + +fn indent to void +if eq get target 0 1 +i = ulong 0 +while lt i get bd 0 +emitstr 3 +i = add i 1 +end +end +end + +fn semi to void +if eq get target 0 0 +e_b 59 +end +e_b 10 +end + +fn euint to void +if eq get target 0 0 +emitstr 4 +end +end + +fn eexpr n ulong to void +k = get nk n +t = get nt n +a = get na n +b = get nb n +v = get nv n +py = get target 0 +if eq k 1 +e_dec v +if eq py 0 +emitstr 5 +end +ret +end +if eq k 2 +named 118 a +ret +end +if eq k 6 +arrn a +ret +end +if eq k 4 +emitstr 6 +e_dec t +e_comma +e_dec get nt a +e_comma +eexpr a +e_b 41 +ret +end +if eq k 5 +emitstr 7 +arrp a +e_comma +arrn a +e_comma +eexpr b +e_comma +e_dec t +e_b 41 +ret +end +if eq k 3 +if eq py 0 +emitstr 8 +eexpr a +emitstr 9 +if lt v 17 +eexpr b +else +e_b 48 +end +emitstr 10 +else +emitstr 11 +end +e_dec v +e_comma +e_dec get nx n +e_comma +if eq py 0 +emitstr 12 +else +eexpr a +e_comma +if lt v 17 +eexpr b +else +e_b 48 +end +e_b 41 +end +ret +end +if eq k 7 +ecall n +ret +end +if eq k 8 +if eq py 0 +emitstr 13 +eexpr a +emitstr 14 +eexpr b +emitstr 15 +eexpr get nx n +emitstr 16 +else +emitstr 17 +end +e_dec v +e_comma +if eq py 0 +emitstr 18 +else +eexpr a +end +e_comma +arrp get ny n +e_comma +arrn get ny n +e_comma +if eq py 0 +emitstr 19 +else +eexpr b +e_comma +eexpr get nx n +e_b 41 +end +ret +end +fail 16 +end + +fn earray a ulong n ulong t ulong init ulong to void +indent +if eq get target 0 0 +if eq signed t 0 +e_b 117 +end +emitstr 20 +e_dec width t +emitstr 21 +arrp a +e_b 91 +e_dec n +emitstr 22 +else +arrp a +if eq t 2 +emitstr 23 +e_dec n +emitstr 24 +else +emitstr 25 +e_dec n +e_b 10 +end +end +indent +euint +arrn a +e_b 61 +e_dec n +semi +if ne init 9999 +indent +emitstr 26 +arrp a +e_comma +arrn a +e_comma +eexpr init +e_comma +e_dec t +e_b 41 +semi +end +end + +fn signature f ulong to void +if eq get target 0 0 +emitstr 27 +else +emitstr 28 +end +named 102 f +e_b 40 +i = ulong 0 +while lt i get fn_np f +if gt i 0 +e_comma +end +s = add mul f 4 i +if gt get fn_pk s 0 +if eq get target 0 0 +emitstr 29 +end +named 118 i +e_comma +euint +named 118 i +emitstr 30 +else +euint +named 118 i +end +i = add i 1 +end +if and eq get target 0 0 eq i 0 +emitstr 31 +end +e_b 41 +end + +fn eassign to void +o = get ts 0 +n = get tl 0 +known = loc_of +if ne glob_of 99 +fail 7 +end +if gt n 8 +fail 13 +end +tok +if eq isw 61 1 +tok +end +if eq isw 7824750 1 +if ne known 99 +fail 7 +end +tok +t = ty_of get tw 0 +if lt t 2 +fail 7 +end +tok +if ne get tk 0 2 +fail 16 +end +ln = get tw 0 +if or eq ln 0 gt ln 524288 +fail 23 +end +sz = mul ln div width t 8 +put localuse 0 add get localuse 0 sz +if gt get localuse 0 32768 +fail 23 +end +v = expr t +expect v t +l = get nloc 0 +add_loc o n t 1 ln 0 +earray l ln t v +else +put held 0 1 +t = ulong 0 +if ne known 99 +t = get loc_ty known +end +v = expr t +if eq get nt v 0 +fail 11 +end +if eq get nt v 10 +fail 7 +end +indent +if eq known 99 +known = get nloc 0 +add_loc o n get nt v 0 0 0 +euint +else +expect v t +if ne get loc_k known 0 +fail 7 +end +end +named 118 known +e_b 61 +eexpr v +semi +end +end + +fn eput to void +a = arr +writable a +i = expr 5 +expect i 5 +v = expr aty a +expect v aty a +indent +if eq get target 0 0 +emitstr 32 +eexpr i +emitstr 33 +eexpr v +emitstr 34 +else +emitstr 35 +end +arrp a +e_comma +arrn a +e_comma +if eq get target 0 0 +emitstr 36 +else +eexpr i +e_comma +eexpr v +e_comma +end +e_dec aty a +e_b 41 +if eq get target 0 0 +emitstr 37 +else +e_b 10 +end +end + +fn block k ulong to void +d = get bd 0 +if ge d 32 +fail 14 +end +put bk d k +put saved d get nloc 0 +put bd 0 add d 1 +if eq get target 0 0 +emitstr 38 +else +emitstr 39 +indent +emitstr 40 +end +end + +fn efor to void +tok +o = get ts 0 +n = get tl 0 +tok +t = ty_of get tw 0 +if lt t 2 +fail 7 +end +v = expr t +expect v t +d = get bd 0 +l = get nloc 0 +if eq get target 0 0 +emitstr 41 +end +put saved d l +add_loc o n t 0 0 0 +indent +euint +named 118 l +emitstr 42 +semi +lim = get nk v +if ne lim 2 +indent +euint +named 107 d +e_b 61 +eexpr v +semi +end +indent +euint +named 99 d +emitstr 43 +semi +indent +if eq get target 0 0 +emitstr 44 +else +emitstr 45 +end +e_dec t +e_comma +named 118 l +e_comma +if eq lim 2 +eexpr v +else +named 107 d +end +e_b 41 +if eq get target 0 0 +e_b 59 +named 118 l +emitstr 46 +e_dec t +e_comma +named 118 l +emitstr 47 +end +block 5 +put saved d l +put loopvar d l +put loopty d t +if ne lim 1 +indent +if eq get target 0 0 +emitstr 48 +named 99 d +emitstr 49 +else +emitstr 50 +named 99 d +emitstr 51 +indent +named 99 d +emitstr 52 +end +end +end + +fn eone to ulong +w = get tw 0 +if eq w 1702129518 +while and ne get tk 0 0 ne get tk 0 3 +tok +end +put held 0 1 +ret 1 +end +if eq w 6581861 +d = sub get bd 0 1 +if and eq get target 0 1 eq get bk d 5 +indent +named 118 get loopvar d +emitstr 53 +e_dec get loopty d +e_comma +named 118 get loopvar d +emitstr 54 +end +if eq d 0 +if eq get fn_ret get cfi 0 10 +indent +emitstr 55 +semi +end +end +put bd 0 d +put nloc 0 get saved d +if eq get target 0 0 +emitstr 56 +if or eq get bk d 4 eq get bk d 5 +emitstr 57 +end +end +if eq d 0 +ret 0 +end +ret 1 +end +if eq w 1702063205 +d = sub get bd 0 1 +if ne get bk d 2 +fail 15 +end +put nloc 0 get saved d +put bd 0 d +indent +if eq get target 0 0 +emitstr 58 +else +emitstr 59 +end +put bd 0 add d 1 +put bk d 3 +indent +if eq get target 0 1 +emitstr 60 +end +ret 1 +end +if eq w 26217 +v = expr 1 +expect v 1 +indent +emitstr 61 +eexpr v +e_b 41 +block 2 +ret 1 +end +if eq w 435610544247 +v = expr 1 +expect v 1 +limit = ulong 1000000 +tok +if eq isw 431349919586 1 +tok +if ne get tk 0 2 +fail 16 +end +limit = get tw 0 +else +put held 0 1 +end +d = get bd 0 +if eq get target 0 0 +emitstr 62 +end +indent +euint +named 99 d +emitstr 63 +semi +indent +emitstr 64 +eexpr v +e_b 41 +block 4 +indent +if eq get target 0 0 +emitstr 65 +named 99 d +emitstr 66 +e_dec limit +emitstr 67 +else +emitstr 68 +named 99 d +emitstr 69 +e_dec limit +emitstr 70 +indent +named 99 d +emitstr 71 +end +ret 1 +end +if eq w 7499622 +efor +ret 1 +end +if eq w 7628146 +t = get fn_ret get cfi 0 +v = ulong 0 +if ne t 10 +v = expr t +expect v t +end +indent +emitstr 72 +if eq t 10 +e_b 48 +else +eexpr v +end +e_b 41 +semi +ret 1 +end +if eq w 1953069157 +if eq get hasmain 0 0 +fail 24 +end +v = expr 8 +expect v 8 +indent +if eq get target 0 0 +emitstr 73 +else +emitstr 74 +end +eexpr v +emitstr 75 +semi +ret 1 +end +if eq w 7632240 +eput +ret 1 +end +f = fn_of +if ne f 99 +if ne get fn_ret f 10 +fail 7 +end +put held 0 1 +v = expr 0 +indent +eexpr v +semi +ret 1 +end +eassign +ret 1 +end + +fn efn to void +walk_sig 0 +f = get cfi 0 +signature f +if eq get target 0 0 +emitstr 76 +else +emitstr 77 +end +put nloc 0 0 +put localuse 0 0 +i = ulong 0 +while lt i get fn_np f +s = add mul f 4 i +add_loc get fn_poff s get fn_pnl s get fn_pt s get fn_pk s get fn_pl s 1 +i = add i 1 +end +put bd 0 1 +indent +emitstr 78 +semi +go = ulong 1 +while eq go 1 +tok +if eq get tk 0 3 +fail 15 +end +if ne get tk 0 0 +put nn 0 0 +go = eone +tok +if and ne get tk 0 0 ne get tk 0 3 +fail 16 +end +put held 0 1 +end +end +end + +fn generate to void +put oc 0 0 +put bd 0 0 +if eq get target 0 0 +emitstr 0 +else +emitstr 1 +end +i = ulong 0 +while lt i get nf 0 +if eq get target 0 0 +signature i +emitstr 79 +end +i = add i 1 +end +i = ulong 0 +while lt i get ng 0 +earray add 32 i get g_len i get g_ty i 9999 +i = add i 1 +end +put cur 0 1 +put line 0 1 +put held 0 0 +tok +while ne get tk 0 3 +if eq isw 28262 1 +efn +else +if eq isw 119165519096935 1 +while and ne get tk 0 0 ne get tk 0 3 +tok +end +else +if eq isw 1702129518 1 +while and ne get tk 0 0 ne get tk 0 3 +tok +end +else +if ne get tk 0 0 +fail 24 +end +end +end +end +tok +end +if eq get hasmain 0 0 +i = ulong 0 +while lt i get nf 0 +exportfn i +i = add i 1 +end +end +if eq get hasmain 0 1 +i = ulong 0 +while lt i get nf 0 +if eq get fn_name i 1852399981 +if eq get target 0 0 +emitstr 80 +named 102 i +emitstr 81 +else +emitstr 82 +named 102 i +emitstr 83 +end +end +i = add i 1 +end +end +end + +fn main to int +off = ulong 0 +go = ulong 1 +while eq go 1 +n = read 0 src off sub 65536 off +if lt n 0 +fail 1 +end +if eq n 0 +go = 0 +else +off = add off ulong n +if ge off 65536 +fail 14 +end +end +end +put slen 0 off +put line 0 1 +if eq get src 0 80 +put target 0 1 +else +if ne get src 0 67 +fail 24 +end +end +namescan +if eq get nf 0 0 +fail 16 +end +generate +w = write 1 outb 0 get oc 0 +if ne w long get oc 0 +ret 1 +end +ret 0 +end + +fn ecall n ulong to void +py = get target 0 +v = get nv n +f = v +if eq py 0 +emitstr 84 +i = ulong 0 +while lt i get fn_np f +slot = add mul f 4 i +if eq get fn_pk slot 0 +emitstr 85 +named 112 i +e_b 61 +eexpr get args add mul n 4 i +e_b 59 +end +i = add i 1 +end +end +named 102 f +e_b 40 +i = ulong 0 +while lt i get fn_np f +if gt i 0 +e_comma +end +slot = add mul f 4 i +arg = get args add mul n 4 i +if gt get fn_pk slot 0 +arrp arg +e_comma +arrn arg +else +if eq py 0 +named 112 i +else +eexpr arg +end +end +i = add i 1 +end +e_b 41 +if eq py 0 +emitstr 86 +end +ret +end + +fn exname f ulong to void +emitstr 87 +e_src get fn_off f get fn_nl f +end + +fn exargs f ulong to void +i = ulong 0 +while lt i get fn_np f +if gt i 0 +e_comma +end +named 112 i +s = add mul f 4 i +if gt get fn_pk s 0 +e_comma +named 112 i +emitstr 88 +end +i = add i 1 +end +end + +fn invalid to void +if eq get target 0 0 +emitstr 89 +else +emitstr 90 +end +end + +fn excheck f ulong i ulong to void +s = add mul f 4 i +indent +if eq get target 0 0 +emitstr 91 +else +emitstr 92 +end +if eq get fn_pk s 0 +emitstr 93 +e_dec get fn_pt s +e_comma +named 112 i +e_b 41 +else +t = get fn_pt s +if and ne t 2 ne t 5 +fail 24 +end +emitstr 94 +named 112 i +e_comma +named 112 i +emitstr 95 +e_dec get fn_pl s +e_comma +e_dec t +if eq get target 0 1 +e_comma +e_dec get fn_pk s +end +e_b 41 +end +invalid +if and eq get target 0 0 gt get fn_pk s 0 +emitstr 96 +named 112 i +e_comma +named 112 i +emitstr 97 +if eq get fn_pt s 2 +e_b 49 +else +e_b 56 +end +emitstr 98 +end +end + +fn exalias f ulong i ulong j ulong to void +s = add mul f 4 i +r = add mul f 4 j +if and gt get fn_pk s 0 gt get fn_pk r 0 +if or eq get fn_pk s 3 eq get fn_pk r 3 +indent +if eq get target 0 0 +emitstr 99 +named 112 i +e_comma +named 112 i +emitstr 100 +if eq get fn_pt s 2 +e_b 49 +else +e_b 56 +end +e_comma +named 112 j +e_comma +named 112 j +emitstr 101 +if eq get fn_pt r 2 +e_b 49 +else +e_b 56 +end +emitstr 102 +else +emitstr 103 +named 112 i +emitstr 104 +named 112 j +emitstr 105 +end +end +end +end + +fn exportfn f ulong to void +py = get target 0 +put bd 0 0 +if eq py 0 +emitstr 106 +else +emitstr 107 +end +exname f +e_b 40 +if eq py 0 +emitstr 108 +end +i = ulong 0 +while lt i get fn_np f +s = add mul f 4 i +if or eq py 0 gt i 0 +e_comma +end +if eq py 0 +if gt get fn_pk s 0 +emitstr 109 +else +emitstr 110 +end +end +named 112 i +if gt get fn_pk s 0 +e_comma +euint +named 112 i +emitstr 111 +end +i = add i 1 +end +if eq py 0 +emitstr 112 +else +emitstr 113 +end +put bd 0 1 +i = ulong 0 +while lt i get fn_np f +excheck f i +j = ulong 0 +while lt j i +exalias f i j +j = add j 1 +end +i = add i 1 +end +if eq py 0 +emitstr 114 +named 102 f +e_b 40 +exargs f +emitstr 115 +else +indent +emitstr 116 +indent +emitstr 117 +indent +emitstr 118 +indent +emitstr 119 +indent +emitstr 120 +put bd 0 2 +indent +emitstr 121 +named 102 f +e_b 40 +exargs f +emitstr 122 +put bd 0 1 +indent +emitstr 123 +put bd 0 2 +indent +emitstr 124 +put bd 0 1 +indent +emitstr 125 +put bd 0 2 +indent +emitstr 126 +indent +emitstr 127 +end +put bd 0 0 +end + +#### c2-00203 sha256=6a574e1e1c41151f7a95af111fd58225459923f84b899d5c44a180553c69836e len=101 +fn main to int +n = ulong 4 +s = ulong 0 +for i ulong add n 0 +s = add s 1 +n = sub n 1 +end +ret int s +end + +#### c2-00204 sha256=58cea9bfa39bd60a1d2aa8e965473ef25137e6c74825b5fa55391b8c58067aa9 len=95 +fn main to int +n = ulong 4 +s = ulong 0 +for i ulong n +s = add s 1 +n = sub n 1 +end +ret int s +end + +#### c2-00205 sha256=630791e91f5e9152178fa380927110a2c91578198cae38e87a56ac7f963c67e5 len=69 +fn main to int +a = new uchar 1 0 +n = read -1 a 0 1 +ret int neg n +end + +#### c2-00206 sha256=87be5086fca9d07f36f80ea7d6e505527592e79cd940f813434f36b7583a2905 len=85 +fn main to int +a = new short 3 -9 +put a 1 short -17 +ret int add get a 1 short 20 +end + +#### c2-00207 sha256=ee0092915fd6b8fa5abc29c6867250e50221241db14068e2198ad2aa371a10e1 len=79 +fn main to int +x = true +y = xor x false +if and y not false +ret 7 +end +ret 1 +end + +#### c2-00208 sha256=68038f72a9711a18120695c0d74aa838e56432f4340eecb080c7468229e7c8da len=72 +fn main to int +x = byte 127 +y = add x byte 1 +ret int and y byte 127 +end + +#### c2-00209 sha256=afc61923cdf3f6ea87df1d62f14bcc7d3ef2f1cdd6bda1850f7d030b695fa476 len=67 +fn main to int +x = ulong 128 +y = byte x +ret int and y byte 127 +end + +#### c2-00210 sha256=91316fe7110c46094bdfd1c32a9f07fba1dfa3c9d8905d6cf3b1f3fa12043258 len=74 +fn main to int +x = byte -128 +y = div x byte -1 +ret int and y byte 127 +end + +#### c2-00211 sha256=a1fc62ea68b24e8600bb749a9865bcedd1c7d7a2c53312f55e6ba138b93d23db len=72 +fn main to int +x = byte 127 +y = mul x byte 2 +ret int and y byte 127 +end + +#### c2-00212 sha256=f7da7201638dde3f7149c998be2ac30966939a8eaaea0ac38e0ad1400ed6e276 len=66 +fn main to int +x = byte -128 +y = neg x +ret int and y byte 127 +end + +#### c2-00213 sha256=b6c23398fe877b30ccc60e9a0c0ccc53166ad552266d8b424a9d4546f00f609a len=74 +fn main to int +x = byte -128 +y = rem x byte -1 +ret int and y byte 127 +end + +#### c2-00214 sha256=7938baa8ea8dcefbc1792cdaa8203a9488790f1a53b984d801f7372533bfb739 len=64 +fn main to int +x = byte 1 +s = ulong 8 +y = shl x s +ret int y +end + +#### c2-00215 sha256=457221e12ce4c9ab0e73f7cb9c7fe13294a9a29d71f97f233571b6e5c134949a len=72 +fn main to int +x = byte 127 +y = shl x byte 1 +ret int and y byte 127 +end + +#### c2-00216 sha256=8ac25c77a4c705b3ac0516289447230f76496e89b56f3c02e6b0c984d4d34e41 len=71 +fn main to int +x = byte -3 +y = shr x byte 7 +ret int and y byte 127 +end + +#### c2-00217 sha256=c38dab6bcc5b4f0d4e617fcfdd17b3e13a0d49c50dd6d9914e549a3893c68eb8 len=73 +fn main to int +x = byte -128 +y = sub x byte 1 +ret int and y byte 127 +end + +#### c2-00218 sha256=1245d31fed0baec6bfffcf16b5fecfbb19f24007694424d8e77b92d9fc954d95 len=61 +fn main to int +x = long -17 +y = div x 5 +ret int add y 10 +end + +#### c2-00219 sha256=8db4d524482c8f0ec2aac307524b0cf9817e78ac6019ee119f4a45cfdabd1dd2 len=76 +fn main to int +x = int 2147483647 +y = add x int 1 +ret int and y int 127 +end + +#### c2-00220 sha256=c492d48be965917bc7ea149c9dea5f1fcc92c864ac32144f407cc5a63e1a3878 len=72 +fn main to int +x = ulong 2147483648 +y = int x +ret int and y int 127 +end + +#### c2-00221 sha256=3612af99c66044fac7673e75e2a95bed88ea08cd8dcd0198026becfddef300cf len=78 +fn main to int +x = int -2147483648 +y = div x int -1 +ret int and y int 127 +end + +#### c2-00222 sha256=1b2a61eb5a46563932c48f437b7e3a91a446f788434fda1f20cca27f2ed97680 len=76 +fn main to int +x = int 2147483647 +y = mul x int 2 +ret int and y int 127 +end + +#### c2-00223 sha256=6eab5e91c4fbc26871bd9b5265d9cb40536896a2699f1325b4f83fe6982feed5 len=71 +fn main to int +x = int -2147483648 +y = neg x +ret int and y int 127 +end + +#### c2-00224 sha256=c96afd22ccb99af3fa6d14aac1724fedb6dd328a2265cdfd63a9af283485687f len=78 +fn main to int +x = int -2147483648 +y = rem x int -1 +ret int and y int 127 +end + +#### c2-00225 sha256=fac0539ed29e04813d1eaf6dfe5658155b2777ebf546c45f851ed9e1b8055527 len=64 +fn main to int +x = int 1 +s = ulong 32 +y = shl x s +ret int y +end + +#### c2-00226 sha256=184e4fe886887ce88f3a30e7f75ce08c6d4321f7dcd595561ad28c9e9bfda568 len=76 +fn main to int +x = int 2147483647 +y = shl x int 1 +ret int and y int 127 +end + +#### c2-00227 sha256=74e7f6da3dee3017b34e3f84d8d6fbbacf8dd0c9677aa53171e6931cb3944a30 len=69 +fn main to int +x = int -3 +y = shr x int 31 +ret int and y int 127 +end + +#### c2-00228 sha256=4d8025819cce742e774a7d1a170f4d633da6db4c67ebb6e9185775e563aa81fc len=77 +fn main to int +x = int -2147483648 +y = sub x int 1 +ret int and y int 127 +end + +#### c2-00229 sha256=968d4d27bee2bfd74329cddc80b5ab5a04384f16faad01be3ab372bd8851ae62 len=66 +fn main to int +x = long -9223372036854775808 +ret int shr x 63 +end + +#### c2-00230 sha256=a3cc993410cd41666b07c530a7bb11829965b161373c17adf6ef031b1da0f5c3 len=88 +fn main to int +x = long 9223372036854775807 +y = add x long 1 +ret int and y long 127 +end + +#### c2-00231 sha256=fcdc094723e293d14b1d1b42ef40797058167e08a009816fe482870b1bb27279 len=83 +fn main to int +x = ulong 9223372036854775808 +y = long x +ret int and y long 127 +end + +#### c2-00232 sha256=c8030520d74509c9f04e8573787a206a8352b4ab515ffce315da9908f326b32e len=90 +fn main to int +x = long -9223372036854775808 +y = div x long -1 +ret int and y long 127 +end + +#### c2-00233 sha256=ac80927260d08107d949950a99194b4c1b8901756c72c8947b2fa743faced795 len=88 +fn main to int +x = long 9223372036854775807 +y = mul x long 2 +ret int and y long 127 +end + +#### c2-00234 sha256=041057c8cd0631f73a9df6e93c1a2cbbfa69fb1b9ae57fc9d67373e022f0df7b len=82 +fn main to int +x = long -9223372036854775808 +y = neg x +ret int and y long 127 +end + +#### c2-00235 sha256=018513c05b4e00ef5521a3c7516724825ab75df5d8fdcaf611badff382e045a5 len=90 +fn main to int +x = long -9223372036854775808 +y = rem x long -1 +ret int and y long 127 +end + +#### c2-00236 sha256=33cd9b57941e4228197582477f1c5ac693b80b4eae1f7cbd0a1434dcda680c06 len=65 +fn main to int +x = long 1 +s = ulong 64 +y = shl x s +ret int y +end + +#### c2-00237 sha256=6cf7f7bae1879bef5d8cf9dd575ceb99c1e39cc62ff177cc792bc27ea902eb5a len=88 +fn main to int +x = long 9223372036854775807 +y = shl x long 1 +ret int and y long 127 +end + +#### c2-00238 sha256=04a58e1909f77bc224f3bc244986e533ef38865ebf5c733eb092ca2aa80bbff9 len=72 +fn main to int +x = long -3 +y = shr x long 63 +ret int and y long 127 +end + +#### c2-00239 sha256=811301c14a68878ba6076b8acd85cd208ed310269103d341dc6b0198a28ad0b4 len=89 +fn main to int +x = long -9223372036854775808 +y = sub x long 1 +ret int and y long 127 +end + +#### c2-00240 sha256=6db4e2b43f62f127422366a0004e3e8acfbdd6c03af39146f24ecdbd532cac34 len=57 +fn main to int +x = byte 1 +y = not x +ret int add y 10 +end + +#### c2-00241 sha256=66a03464420855c2d9925d03c79cf99014f92fc6417fae3fbb470261020f11bb len=61 +fn main to int +x = long -17 +y = rem x 5 +ret int add y 10 +end + +#### c2-00242 sha256=82f9a564f6c89bbfc0f3239bd31beb260d598d79d7ebaeeb3e8b260c8126f3f4 len=77 +fn main to int +x = short 32767 +y = add x short 1 +ret int and y short 127 +end + +#### c2-00243 sha256=b611f7529ce00bfbcdb3f4d610035e4526eabfac107bc19b244f7c5c683c14bb len=71 +fn main to int +x = ulong 32768 +y = short x +ret int and y short 127 +end + +#### c2-00244 sha256=4293718e104e2d52f473f3e1693dc3277c35f0bc67b74a9798a1d24dad9557d9 len=79 +fn main to int +x = short -32768 +y = div x short -1 +ret int and y short 127 +end + +#### c2-00245 sha256=97cd9e598a891873e4a02806ece23967a1c780b9250ce580739bea3281d01bd9 len=77 +fn main to int +x = short 32767 +y = mul x short 2 +ret int and y short 127 +end + +#### c2-00246 sha256=761419a12e968922bb5f8dfd0b3053b65577743977d1c6ca034122fcee70471b len=70 +fn main to int +x = short -32768 +y = neg x +ret int and y short 127 +end + +#### c2-00247 sha256=d4161493a8ea4aa2b353f3599891af9e26f90b295aa6ca7f213095f3d64cc18a len=79 +fn main to int +x = short -32768 +y = rem x short -1 +ret int and y short 127 +end + +#### c2-00248 sha256=11faaa4654a06afd1e0ad039aec66df1d06c4ae3c03f1b0053b1bcd0932d9909 len=66 +fn main to int +x = short 1 +s = ulong 16 +y = shl x s +ret int y +end + +#### c2-00249 sha256=9355ff3350de72b6b3522d76f385faa98310933a32f5ef9c3eb41735b249e26a len=77 +fn main to int +x = short 32767 +y = shl x short 1 +ret int and y short 127 +end + +#### c2-00250 sha256=46ab1dfd5aa20d81a77547f943c954a6a750c0c3c9e67fe8b76c53057e743cfb len=75 +fn main to int +x = short -3 +y = shr x short 15 +ret int and y short 127 +end + +#### c2-00251 sha256=23a66b306585d2bb085ed086f275e595fba9c65517aa396e9f1131646d4e7a15 len=78 +fn main to int +x = short -32768 +y = sub x short 1 +ret int and y short 127 +end + +#### c2-00252 sha256=dd6abb6b2fa7e7f49fd15d330f94ca6660b82020254c7b7951209643585c305b len=75 +fn main to int +x = uchar 255 +y = add x uchar 1 +ret int and y uchar 127 +end + +#### c2-00253 sha256=373dea8e7549fd8f73a06ccd8ffb0e67464325db3b45eef0195060152cc23e4b len=69 +fn main to int +x = ulong 256 +y = uchar x +ret int and y uchar 127 +end + +#### c2-00254 sha256=b7b953d0d08b370bb3ad5b1c396434ff8bc76025cc7874a94982e068b7e5cc00 len=73 +fn main to int +x = uchar 0 +y = div x uchar 0 +ret int and y uchar 127 +end + +#### c2-00255 sha256=737aeff1712f0a7406f2bf42e8ff1bbf6983ee4c9caeada8f27cae8d1abe2d2d len=75 +fn main to int +x = uchar 255 +y = mul x uchar 2 +ret int and y uchar 127 +end + +#### c2-00256 sha256=f29012614ba1ced0949c98d2b4927e7dc07a1e653db16ee0f449034c80adb564 len=65 +fn main to int +x = uchar 1 +y = neg x +ret int and y uchar 127 +end + +#### c2-00257 sha256=764c7710c7ef62dab93a3f97dbc083ce85a8fc14905496b7152070b1c20bd8de len=73 +fn main to int +x = uchar 0 +y = rem x uchar 0 +ret int and y uchar 127 +end + +#### c2-00258 sha256=2b57c004823d96d60afb5486e3021e61e04a860f3a94d02c820065dc57e98177 len=65 +fn main to int +x = uchar 1 +s = ulong 8 +y = shl x s +ret int y +end + +#### c2-00259 sha256=84dd13b71457c4be753c84e43e47af98daecd7396636dd8660e48efe112bfe43 len=75 +fn main to int +x = uchar 255 +y = shl x uchar 1 +ret int and y uchar 127 +end + +#### c2-00260 sha256=fc849a576251d72472259255f55710a7226e2968f6dc2c93b767ba372566296d len=75 +fn main to int +x = uchar 255 +y = shr x uchar 7 +ret int and y uchar 127 +end + +#### c2-00261 sha256=0dd2b627e04cda4e4e6069708a752646d50742600bdf6e3fcdad4e32d504d043 len=73 +fn main to int +x = uchar 0 +y = sub x uchar 1 +ret int and y uchar 127 +end + +#### c2-00262 sha256=32490c81f31c4f9bffde9b2add6bbe4ebb5a9f4ee99cfa78883f485a48ca8279 len=79 +fn main to int +x = uint 4294967295 +y = add x uint 1 +ret int and y uint 127 +end + +#### c2-00263 sha256=bac3ca9b98942f4b1c14f7a1b4107eecf4938239a5257d8994ea4cd76743c5a7 len=74 +fn main to int +x = ulong 4294967296 +y = uint x +ret int and y uint 127 +end + +#### c2-00264 sha256=a573c33ddd9fc66647b85929fdf6fa02f313b7add76da54cfd2bc7c686adfe49 len=70 +fn main to int +x = uint 0 +y = div x uint 0 +ret int and y uint 127 +end + +#### c2-00265 sha256=a9ad5114faf6d70491d91e9aeaaac4492d694c111bc11f3a5ce64297ae6a94ba len=79 +fn main to int +x = uint 4294967295 +y = mul x uint 2 +ret int and y uint 127 +end + +#### c2-00266 sha256=582db7f80ac89737ca73b03d3471cc522d01bceaee52e3bddbd1321de8b555c3 len=63 +fn main to int +x = uint 1 +y = neg x +ret int and y uint 127 +end + +#### c2-00267 sha256=06065781cd1b15e759dc0182ad9e05210f48129de8170b541c4625760e67c3b0 len=70 +fn main to int +x = uint 0 +y = rem x uint 0 +ret int and y uint 127 +end + +#### c2-00268 sha256=7a6b02ea200e349ffd8a675f20365ec09d7196d35d35f21013ded6fd50019d8c len=65 +fn main to int +x = uint 1 +s = ulong 32 +y = shl x s +ret int y +end + +#### c2-00269 sha256=66f61e82d493831d1d3c79067f989a7d2ff7dd6daedf6a660f3b6965a614f23b len=79 +fn main to int +x = uint 4294967295 +y = shl x uint 1 +ret int and y uint 127 +end + +#### c2-00270 sha256=f3adcaa594580d2bb485ae0ecd77348dc5808b06b927446931acc8f5de80bb7b len=80 +fn main to int +x = uint 4294967295 +y = shr x uint 31 +ret int and y uint 127 +end + +#### c2-00271 sha256=39db27c9331d19de2c21e9bfaf1f488b0abbc024b439812d6299b3418d6b3449 len=70 +fn main to int +x = uint 0 +y = sub x uint 1 +ret int and y uint 127 +end + +#### c2-00272 sha256=b9775815369ca2e3e30b5a4acf85ff2b9c9993646812cb59f5049f14bb139043 len=92 +fn main to int +x = ulong 18446744073709551615 +y = add x ulong 1 +ret int and y ulong 127 +end + +#### c2-00273 sha256=80c66f2be3773296e54078c19e199db0cd8f432a7ecd4ba030aecde81df0c074 len=67 +fn main to int +x = ulong 0 +y = ulong x +ret int and y ulong 127 +end + +#### c2-00274 sha256=2cd0cc9b05dbb24ac0a1f1c7af260bb649d1154a5ee5d141f980bcd7cd7bf3be len=73 +fn main to int +x = ulong 0 +y = div x ulong 0 +ret int and y ulong 127 +end + +#### c2-00275 sha256=02c84816f59222da1785bc05d3eb4e5d50c223ce07bbfe8d4bdb2e38c748e176 len=92 +fn main to int +x = ulong 18446744073709551615 +y = mul x ulong 2 +ret int and y ulong 127 +end + +#### c2-00276 sha256=56637ed677ae06c9e8ecdb2196182980456a1b3a8deee3bcc7d1d5b51ba41a26 len=65 +fn main to int +x = ulong 1 +y = neg x +ret int and y ulong 127 +end + +#### c2-00277 sha256=b4b5a48553cf0ecf8f0f738616ab462e3d8f043676ec488ab92c34cbd01320b1 len=73 +fn main to int +x = ulong 0 +y = rem x ulong 0 +ret int and y ulong 127 +end + +#### c2-00278 sha256=d2f77a6e6863b0589aafc34f613c8ab072b74165013a5e9a281df7d2520e3ce8 len=66 +fn main to int +x = ulong 1 +s = ulong 64 +y = shl x s +ret int y +end + +#### c2-00279 sha256=9183af76469fd74872cd86f5ee9328a059f17acbe4a93896cf8c78ac33c3fce4 len=92 +fn main to int +x = ulong 18446744073709551615 +y = shl x ulong 1 +ret int and y ulong 127 +end + +#### c2-00280 sha256=2e55ca6321e11eb83842a5e0326f52ad8b863d893cac8423ef016234b00f363c len=93 +fn main to int +x = ulong 18446744073709551615 +y = shr x ulong 63 +ret int and y ulong 127 +end + +#### c2-00281 sha256=8b65035928322c8f0fffe95caca3084ce338673c6f9db896e765deaede787bdb len=73 +fn main to int +x = ulong 0 +y = sub x ulong 1 +ret int and y ulong 127 +end + +#### c2-00282 sha256=592016fcbe2b7d3009fcadcb37227b1489bcaa0af87b6ebdae1828ab3cc0a0a9 len=80 +fn main to int +x = ushort 65535 +y = add x ushort 1 +ret int and y ushort 127 +end + +#### c2-00283 sha256=e769285ca02fcb649b2a646393ff2315a97d27359d25e0aeb2bad4ddb00da636 len=73 +fn main to int +x = ulong 65536 +y = ushort x +ret int and y ushort 127 +end + +#### c2-00284 sha256=21daa07bfd8805a567ebc5e4798954228762b4392f3c33821c0fb2e2121c8a8d len=76 +fn main to int +x = ushort 0 +y = div x ushort 0 +ret int and y ushort 127 +end + +#### c2-00285 sha256=0bb8a367765a647247a8de4b5f99770f7818b099f83ac8d41f0588a08f25d147 len=80 +fn main to int +x = ushort 65535 +y = mul x ushort 2 +ret int and y ushort 127 +end + +#### c2-00286 sha256=7accb1fe719ad79f0a6e8be844170c1e372e035e0f9d6c554469f65b8837e00f len=67 +fn main to int +x = ushort 1 +y = neg x +ret int and y ushort 127 +end + +#### c2-00287 sha256=5e93148ba0a4e746095efdb9860dc6419d7ff4e595b445251131f8b4997db732 len=76 +fn main to int +x = ushort 0 +y = rem x ushort 0 +ret int and y ushort 127 +end + +#### c2-00288 sha256=8360f71e36450533ab5a61f8dfc8ed13e676f041a77f94770383b6a330389b30 len=67 +fn main to int +x = ushort 1 +s = ulong 16 +y = shl x s +ret int y +end + +#### c2-00289 sha256=b1d01cf39192a4bef308a30044bff16f9bcca2cc0d2db40e7de5ba0691fdf013 len=80 +fn main to int +x = ushort 65535 +y = shl x ushort 1 +ret int and y ushort 127 +end + +#### c2-00290 sha256=d8ea4fb39afcd0e353f971e88c7c0ab41dd873c516e94bbcbe59a32ffe4f50c9 len=81 +fn main to int +x = ushort 65535 +y = shr x ushort 15 +ret int and y ushort 127 +end + +#### c2-00291 sha256=f95ac282c3d9c1925f9be5302f2832a6fe02a656f9b9ec8a2e58f9a16601def9 len=76 +fn main to int +x = ushort 0 +y = sub x ushort 1 +ret int and y ushort 127 +end + +#### c2-00292 sha256=8efba010d072771b02a4ee7661457f0a4915761826d1cc4224922f0762843d87 len=219 +global out uchar 1 +fn mark x ulong to ulong +put out 0 uchar x +w = write 1 out 0 1 +ret x +end +fn pick a ulong b ulong to ulong +ret sub b a +end +fn main to int +x = pick mark 65 mark 66 +y = add mark 67 mark 68 +ret int x +end + +#### c2-00293 sha256=db19e581cb440739cf3070ca9bbe4a9cd6ac66d6c99edebc97232d4e8e9d33c9 len=219 +global out uchar 1 +fn mark x ulong to ulong +put out 0 uchar x +w = write 1 out 0 1 +ret x +end +fn pick a ulong b ulong to ulong +ret sub b a +end +fn main to int +a = new ulong 100 0 +put a mark 65 mark 66 +ret int get a 65 +end + +#### c2-00294 sha256=67f4c582862c7151fd1f0c507b5e9f50d71c835dec866b16dd05d86304160104 len=236 +global out uchar 1 +fn mark x ulong to ulong +put out 0 uchar x +w = write 1 out 0 1 +ret x +end +fn pick a ulong b ulong to ulong +ret sub b a +end +fn boom to ulong +x = ulong 0 +ret div x x +end +fn main to int +x = add boom mark 65