interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / qualification / security673 / relational / patchword.om

75 lines · 1203 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Exact-once aligned u32 replacement in raw compiler output or full ELF, no instruction hiding.
3text err "REFUSED patch: usage, size, word range or occurrence count\n"
4global buf uchar 1048576
5global arg uchar 32
6fn number k ulong to ulong
7n = argread k arg 0 32
8if or le n 0 gt n 10
9exit 90
10end
11v = ulong 0
12for i ulong ulong n
13c = get arg i
14if or lt c 48 gt c 57
15exit 90
16end
17v = add mul v 10 ulong sub c 48
18end
19if gt v 4294967295
20exit 90
21end
22ret v
23end
24fn word p ulong to ulong
25v = ulong 0
26for k ulong 4
27v = or v shl ulong get buf add p k mul k 8
28end
29ret v
30end
31fn main to int
32if ne argcnt 3
33ret 90
34end
35old = number 1
36fresh = number 2
37n = ulong 0
38while lt n len buf bound 100000
39r = read 0 buf n sub len buf n
40if lt r 0
41ret 91
42end
43if eq r 0
44break
45end
46n = add n ulong r
47end
48if or eq n len buf ne rem n 4 0
49ret 92
50end
51hits = ulong 0
52at = ulong 0
53for i ulong div n 4
54if eq word mul i 4 old
55hits = add hits 1
56at = mul i 4
57end
58end
59if ne hits 1
60r = write 2 err 0 len err
61ret 93
62end
63for k ulong 4
64put buf add at k uchar and shr fresh mul k 8 255
65end
66at = 0
67while lt at n bound 100000
68r = write 1 buf at sub n at
69if le r 0
70ret 94
71end
72at = add at ulong r
73end
74ret 0
75end