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 / evidence / gate2 / 25.src

2432 lines · 39475 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/qualification/om2/leak/leakscan.om: static leakage scan of one omc FUNCTION-MODE artifact
3note (raw little-endian AArch64 words, entry word 0), contract spec/omegese-om2.md section 8, evidence (a)
4note (#748, ledger L836). Handwritten seeded Omega, OM-1, program mode, built by the pinned omc 734f0a39.
5note README.txt in this directory states the decode subset, the taint rules, the call rule and what is
6note MANUAL. The scan is a may-analysis: "data" means "may depend on data", never "proved to leak".
7note
8note Usage: leakscan [xN | pub:SLOT:OFF:LEN ...] < artifact. xN marks DATA (N 0..5).
9note pub declares public memory relative to entry xSLOT, fully contained in the half-open byte range.
10note Output, in this order: one LEAKSCAN line; per word, in word order, UNKNOWN, UNHANDLED, BRANCH and MEM
11note lines; one SUMMARY line; MANUAL-ITEMS when needed; one VERDICT line.
12note Exit status: 0 PASS, 1 FAIL (data address), 2 NOT_RUN (MANUAL), 90 usage, 91 invalid artifact.
13note
14note Taint state per word (the state on entry to the word): rm bit b is 1 when the value may be DATA;
15note bits 0..30 x0..x30, bit 31 the NZCV flags, bits 32..63 v0..v31. sm bit j is 1 when the 8 bytes
16note at [SP + 8j] (current SP) may hold DATA. dep is the bytes the SP is below the function's entry SP,
17note plus 1 (0: never reached). fid is the function's entry word.
18global inb uchar 8388612
19global wd uint 2097152
20global rm ulong 2097152
21global sm ulong 2097152
22global dep ulong 2097152
23global fid ulong 2097152
24global ex ulong 2097152
25global exs uchar 2097152
26global blt ulong 2097152
27global trp uchar 2097152
28global uh uchar 2097152
29global inq uchar 2097152
30global wl ulong 2097152
31global dc ulong 24
32global cu ulong 4
33global gv ulong 32
34global ob uchar 1048576
35global obn ulong 1
36global dig uchar 32
37global tbo ulong 128
38global tbl ulong 128
39global ab uchar 16
40global pab uchar 128
41note Exact provenance and E12 known-zero bits, allocated for reached words.
42note Tokens: tag:8 | signed-offset:56; tag 1 constant, tags 2..7 entry x0..x5 + offset, 0 unknown.
43note ps/pe point into pp (128 cells: 31 regs, AND-proof mask, 64 spill slots, 32 known-zero masks).
44note At most 131072 records; exhaustion is UNHANDLED provenance-cap and forces NOT_RUN.
45global pp ulong 16777216
46global ps ulong 2097152
47global pe ulong 2097152
48global pc ulong 128
49global pdecl ulong 96
50note E13 whole-artifact revocation: rv[word] lists the public-range bits revoked by that store.
51global rv ulong 2097152
52text revmsg "PUBLIC-MEM-REVOKED @"
53text pmsg "PUBLIC-DECL \nPUBLIC-MEM @\n public-mem \n+\n:\nprovenance-cap\nusage: leakscan [x0..x5 | pub:SLOT:OFF:LEN ...] < function-mode artifact\n"
54text e12 "data MANUAL\nVERDICT TRACE-EQUIV-STATIC NOT_RUN\n"
55note decoded fields, indices into dc
56const dkind ulong 0
57const dtgt ulong 1
58const ddst ulong 2
59const ds1 ulong 3
60const ds2 ulong 4
61const ds3 ulong 5
62const dfl ulong 6
63const dmk ulong 7
64const dmb ulong 8
65const dmi ulong 9
66const dmo ulong 10
67const dms ulong 11
68const dmt ulong 12
69const dmt2 ulong 13
70const dwb ulong 14
71const dmn ulong 15
72const dcc ulong 16
73const dspo ulong 17
74const dspa ulong 18
75const dmf ulong 19
76note gv: 0 words, 1 worklist size, 2 entry word, 3 DATA parameter bits, 4 len branches, 5 trap checks,
77note 6 data branches, 7 unreached branches, 8 const, 9 public-index, 10 data-index, 11 unreached memory,
78note 12 unknown, 13 unhandled, 14 branches, 15 memory accesses, 16 word 0 is the entry branch
79text tb "b\nbl\ncbz\ncbnz\ntbz\ntbnz\nret\nbr\nblr\nsvc\nldrb\nldrsb\nldrh\nldrsh\nldr\nldrsw\nstrb\nstrh\nstr\nldp\nstp\nldpsw\n?\nnop\ndsb\nb.eq\nb.ne\nb.cs\nb.cc\nb.mi\nb.pl\nb.vs\nb.vc\nb.hi\nb.ls\nb.ge\nb.lt\nb.gt\nb.le\nb.al\nb.nv\nLEAKSCAN 1 words=\n entry=@\n data=\nnone\nUNKNOWN @\nUNHANDLED @\nBRANCH @\nMEM @\n ->@\nlen\ndata never-taken-trap-check\ndata DATA-BRANCH\nunreached\nconst\npublic-index\ndata-index\n trap=\n base=\n index=\nsp\n-\n trap-tail\nSUMMARY branches=\n len=\n trap-check=\n data-branch=\n branch-unreached=\n mem=\n const=\n public-index=\n data-index=\n mem-unreached=\n unknown=\n unhandled=\nVERDICT TRACE-EQUIV-STATIC PASS\nVERDICT TRACE-EQUIV-STATIC FAIL\nVERDICT TRACE-EQUIV-STATIC MANUAL\n 0x\nusage: leakscan [x0..x5 ...] < function-mode artifact\nleakscan: input is not a function-mode artifact: empty, not whole words, ELF, or over 8 MiB\nimm\nreg\nunscaled\npost\npre\npair\nliteral\nunpriv\n?\nsp-write\nsp-writeback\nstack-escape\ndepth-mismatch\nshared-code\nret-depth\nret-x30-data\nbr-indirect\nblr-indirect\nsvc-syscall\nflow-out\nsp-underflow\nx7-write\nbelow-sp\n \nMANUAL-ITEMS \n listed above as UNKNOWN and UNHANDLED lines\n always\nx\n,\n"
80
81note ---- output ----------------------------------------------------------------------------------
82fn inittb to void
83k = ulong 0
84s = ulong 0
85for i ulong len tb
86if eq get tb i 10
87put tbo k s
88put tbl k sub i s
89k = add k 1
90s = add i 1
91end
92end
93end
94fn obf to void
95n = get obn 0
96o = ulong 0
97while lt o n
98r = write 1 ob o sub n o
99if le r 0
100exit 93
101end
102o = add o ulong r
103end
104put obn 0 0
105end
106fn ob1 b uchar to void
107n = get obn 0
108if ge n 1048000
109obf
110n = ulong 0
111end
112put ob n b
113put obn 0 add n 1
114end
115fn say id ulong to void
116o = get tbo id
117for i ulong get tbl id
118ob1 get tb add o i
119end
120end
121fn onl to void
122ob1 10
123end
124fn od v ulong to void
125x = v
126n = ulong 0
127while ge x 10
128put dig n uchar add 48 rem x 10
129x = div x 10
130n = add n 1
131end
132put dig n uchar add 48 x
133n = add n 1
134for i ulong n
135ob1 get dig sub sub n i 1
136end
137end
138fn hexd v ulong to uchar
139if lt v 10
140ret uchar add v 48
141end
142ret uchar add v 87
143end
144fn oh v ulong to void
145for i ulong 8
146ob1 hexd and shr v mul sub 7 i 4 15
147end
148end
149note a register field: 255 "-", 31 "sp" (a base), else xN
150fn oreg r ulong to void
151if eq r 255
152say 61
153ret
154end
155if eq r 31
156say 60
157ret
158end
159say 108
160od r
161end
162fn inc k ulong to void
163put gv k add get gv k 1
164end
165
166note ---- bit helpers -----------------------------------------------------------------------------
167fn fld x ulong lo ulong n ulong to ulong
168ret and shr x lo sub shl ulong 1 n 1
169end
170note a general register field where 31 is the zero register (public, no state bit)
171fn gz r ulong to ulong
172if eq r 31
173ret 255
174end
175ret r
176end
177note sign extension of an n-bit field to 64 bits (two's complement in a ulong)
178fn sx v ulong n ulong to ulong
179if eq and shr v sub n 1 1 0
180ret v
181end
182ret or v not sub shl ulong 1 n 1
183end
184fn tnt r ulong b ulong to ulong
185if ge b 64
186ret 0
187end
188ret and shr r b 1
189end
190fn sbit r ulong b ulong v ulong to ulong
191if ge b 64
192ret r
193end
194m = shl ulong 1 b
195if eq v 0
196ret and r not m
197end
198ret or r m
199end
200
201note ---- decoder: the classes omc emits (README.txt lists them with their omc.om sources) ---------
202fn dclr to void
203for i ulong 24
204put dc i 255
205end
206put dc dkind 0
207put dc dfl 0
208put dc dmk 0
209put dc dwb 0
210put dc dmn 22
211put dc dspo 0
212put dc dspa 0
213put dc dmf 0
214put dc dtgt 0
215put dc dmo 0
216put dc dms 0
217end
218note kinds: 0 straight-line, 1 B, 2 BL, 3 B.cond, 4 CBZ/CBNZ, 5 TBZ/TBNZ, 6 RET, 7 BR, 8 BLR, 9 SVC,
219note 10 unknown, 11 no effect (NOP, DSB)
220fn dbr x ulong w ulong to bool
221m = and x 4227858432
222if eq m 335544320
223put dc dkind 1
224put dc dtgt add w sx and x 67108863 26
225put dc dmn 0
226ret true
227end
228if eq m 2483027968
229put dc dkind 2
230put dc dtgt add w sx and x 67108863 26
231put dc dmn 1
232ret true
233end
234if eq and x 4278190096 1409286144
235put dc dkind 3
236put dc dtgt add w sx fld x 5 19 19
237put dc dcc and x 15
238put dc dmn add 25 and x 15
239ret true
240end
241m = and x 2113929216
242if eq m 872415232
243put dc dkind 4
244put dc dtgt add w sx fld x 5 19 19
245put dc ds1 gz and x 31
246put dc dmn add 2 fld x 24 1
247ret true
248end
249if eq m 905969664
250put dc dkind 5
251put dc dtgt add w sx fld x 5 14 14
252put dc ds1 gz and x 31
253put dc dcc or shl fld x 31 1 5 fld x 19 5
254put dc dmn add 4 fld x 24 1
255ret true
256end
257m = and x 4294966303
258if eq m 3592355840
259put dc dkind 7
260put dc ds1 fld x 5 5
261put dc dmn 7
262ret true
263end
264if eq m 3594452992
265put dc dkind 8
266put dc ds1 fld x 5 5
267put dc dmn 8
268ret true
269end
270if eq m 3596550144
271put dc dkind 6
272put dc ds1 fld x 5 5
273put dc dmn 6
274ret true
275end
276if eq and x 4292870175 3556769793
277put dc dkind 9
278put dc dmn 9
279ret true
280end
281if eq x 3573751839
282put dc dkind 11
283put dc dmn 23
284ret true
285end
286if eq and x 4294963455 3573756063
287put dc dkind 11
288put dc dmn 24
289ret true
290end
291ret false
292end
293
294note ADD/SUB (immediate): Rn 31 is SP; Rd 31 is SP unless flags are set (then the zero register)
295fn daddi x ulong to void
296rd = and x 31
297rn = fld x 5 5
298if eq fld x 29 1 1
299put dc ddst gz rd
300put dc ds1 gz rn
301put dc dfl 2
302ret
303end
304if eq rd 31
305if eq rn 31
306put dc dspo add 1 fld x 30 1
307put dc dspa shl fld x 10 12 mul fld x 22 1 12
308ret
309end
310put dc dspo 3
311ret
312end
313put dc ddst rd
314put dc ds1 gz rn
315end
316fn dlogi x ulong to void
317rd = and x 31
318if eq fld x 29 2 3
319put dc dfl 2
320put dc ddst gz rd
321else
322if eq rd 31
323put dc dspo 3
324ret
325end
326put dc ddst rd
327end
328put dc ds1 gz fld x 5 5
329end
330fn dmovw x ulong to bool
331opc = fld x 29 2
332if eq opc 1
333ret false
334end
335put dc ddst gz and x 31
336if eq opc 3
337put dc dfl 4
338end
339ret true
340end
341fn dbfm x ulong to bool
342opc = fld x 29 2
343if eq opc 3
344ret false
345end
346put dc ddst gz and x 31
347put dc ds1 gz fld x 5 5
348if eq opc 1
349put dc dfl 4
350end
351ret true
352end
353note three-register forms: Rd, Rn, Rm (31 the zero register); fl as given
354fn d3r x ulong fl ulong to void
355put dc ddst gz and x 31
356put dc ds1 gz fld x 5 5
357put dc ds2 gz fld x 16 5
358put dc dfl fl
359end
360note ADD/SUB (extended register): Rn 31 is SP (public); Rd 31 is SP unless flags are set
361fn daddx x ulong to void
362rd = and x 31
363s = fld x 29 1
364if eq s 1
365put dc ddst gz rd
366put dc dfl 2
367else
368if eq rd 31
369put dc dspo 3
370ret
371end
372put dc ddst rd
373end
374put dc ds1 gz fld x 5 5
375put dc ds2 gz fld x 16 5
376end
377fn dalu x ulong to bool
378m = and x 528482304
379if eq m 285212672
380daddi x
381ret true
382end
383if eq m 301989888
384dlogi x
385ret true
386end
387if eq m 310378496
388ret dmovw x
389end
390if eq m 318767104
391ret dbfm x
392end
393if eq m 327155712
394if or ne fld x 29 2 0 ne fld x 21 1 0
395ret false
396end
397d3r x 0
398ret true
399end
400if eq and x 520093696 268435456
401put dc ddst gz and x 31
402ret true
403end
404if eq and x 520093696 167772160
405if eq fld x 29 2 3
406d3r x 2
407else
408d3r x 0
409end
410ret true
411end
412m = and x 522190848
413if eq m 184549376
414d3r x shl fld x 29 1 1
415ret true
416end
417if eq m 186646528
418daddx x
419ret true
420end
421m = and x 534773760
422if eq m 436207616
423if ne fld x 10 6 0
424ret false
425end
426d3r x or 1 shl fld x 29 1 1
427ret true
428end
429if eq m 440401920
430if eq fld x 29 1 0
431ret false
432end
433put dc ds1 gz fld x 5 5
434if eq fld x 11 1 0
435put dc ds2 gz fld x 16 5
436end
437put dc dfl 3
438ret true
439end
440if eq m 444596224
441if or ne fld x 29 1 0 ne fld x 11 1 0
442ret false
443end
444d3r x 1
445ret true
446end
447m = and x 1608515584
448if eq m 448790528
449d3r x 0
450ret true
451end
452if eq m 1522532352
453put dc ddst gz and x 31
454put dc ds1 gz fld x 5 5
455ret true
456end
457if eq and x 520093696 452984832
458d3r x 0
459put dc ds3 gz fld x 10 5
460ret true
461end
462ret false
463end
464note allocation checks (Arm ARM C4.1): an encoding of a decoded class that is unallocated, reserved
465note or outside the subset is UNKNOWN. bmok: the logical-immediate bitmask (DecodeBitMasks) is valid.
466fn bmok x ulong to bool
467n = fld x 22 1
468s = fld x 10 6
469if and eq fld x 31 1 0 eq n 1
470ret false
471end
472v = or shl n 6 and not s 63
473if eq v 0
474ret false
475end
476l = ulong 6
477while eq and shr v l 1 0 bound 8
478l = sub l 1
479end
480if eq l 0
481ret false
482end
483lv = sub shl ulong 1 l 1
484ret ne and s lv lv
485end
486fn dp3ok x ulong sf ulong to bool
487if ne fld x 29 2 0
488ret false
489end
490o = fld x 21 3
491if eq o 0
492ret true
493end
494if eq sf 0
495ret false
496end
497if or eq o 1 eq o 5
498ret true
499end
500if or eq o 2 eq o 6
501ret eq fld x 15 1 0
502end
503ret false
504end
505fn aluok x ulong to bool
506sf = fld x 31 1
507m = and x 528482304
508if eq m 301989888
509ret bmok x
510end
511if eq m 310378496
512ret or eq sf 1 eq fld x 22 1 0
513end
514if or eq m 318767104 eq m 327155712
515if ne fld x 22 1 sf
516ret false
517end
518if and eq sf 0 eq m 318767104
519ret and eq fld x 21 1 0 eq fld x 15 1 0
520end
521ret or eq sf 1 eq fld x 15 1 0
522end
523if eq and x 520093696 167772160
524ret or eq sf 1 eq fld x 15 1 0
525end
526m = and x 522190848
527if eq m 184549376
528if eq fld x 22 2 3
529ret false
530end
531ret or eq sf 1 eq fld x 15 1 0
532end
533if eq m 186646528
534if ne fld x 22 2 0
535ret false
536end
537ret le fld x 10 3 4
538end
539if eq and x 534773760 440401920
540ret and eq fld x 10 1 0 eq fld x 4 1 0
541end
542m = and x 1608515584
543if eq m 448790528
544if ne fld x 29 1 0
545ret false
546end
547o = fld x 10 6
548ret or or eq o 2 eq o 3 and ge o 8 le o 11
549end
550if eq m 1522532352
551o = fld x 10 6
552if or gt o 5 ne fld x 16 5 0
553ret false
554end
555ret or eq sf 1 ne o 3
556end
557if eq and x 520093696 452984832
558ret dp3ok x sf
559end
560ret true
561end
562fn fpok x ulong to bool
563ty = fld x 22 2
564if gt ty 1
565ret false
566end
567if eq and x 1595997184 505413632
568op = fld x 16 3
569if le op 1
570ret true
571end
572if ne fld x 19 2 0
573ret false
574end
575if le op 5
576ret true
577end
578ret eq fld x 31 1 ty
579end
580if eq and x 1595964416 505430016
581op = fld x 15 6
582if le op 3
583ret true
584end
585if or eq op 4 eq op 5
586ret ne sub op 4 ty
587end
588ret false
589end
590if eq and x 1595948032 505421824
591ret and eq fld x 14 2 0 eq and x 7 0
592end
593ret le fld x 12 4 8
594end
595note constrained-unpredictable load/store forms omc never emits: writeback with Rt or Rt2 = Rn, and a
596note load pair with Rt = Rt2
597fn lsok to bool
598b = get dc dmb
599if and ne get dc dwb 0 ne b 31
600if or eq get dc dmt b eq get dc dmt2 b
601ret false
602end
603end
604if and eq get dc dmk 1 ne get dc dmt2 255
605ret ne get dc dmt get dc dmt2
606end
607ret true
608end
609note scalar floating point: FMOV/convert (general <-> FP), 1-source, compare, 2-source
610fn dfp x ulong to bool
611if ne fld x 29 2 0
612ret false
613end
614rd = and x 31
615rn = fld x 5 5
616if eq and x 1595997184 505413632
617op = fld x 16 3
618if or or eq op 2 eq op 3 eq op 7
619put dc ddst add 32 rd
620put dc ds1 gz rn
621else
622put dc ddst gz rd
623put dc ds1 add 32 rn
624end
625ret true
626end
627if ne fld x 31 1 0
628ret false
629end
630if eq and x 1595964416 505430016
631put dc ddst add 32 rd
632put dc ds1 add 32 rn
633ret true
634end
635if eq and x 1595948032 505421824
636put dc ds1 add 32 rn
637if eq fld x 3 1 0
638put dc ds2 add 32 fld x 16 5
639end
640put dc dfl 2
641ret true
642end
643if eq and x 1595935744 505415680
644put dc ddst add 32 rd
645put dc ds1 add 32 rn
646put dc ds2 add 32 fld x 16 5
647ret true
648end
649ret false
650end
651
652note load/store kind, size and mnemonic from size, V and opc; false for PRFM and unallocated forms
653fn lsk sz ulong v ulong opc ulong rt ulong to bool
654if eq v 1
655b = shl ulong 1 sz
656if ne and opc 2 0
657if ne sz 0
658ret false
659end
660b = ulong 16
661end
662put dc dms b
663put dc dmt add 32 rt
664if eq and opc 1 1
665put dc dmk 1
666put dc dmn 14
667else
668put dc dmk 2
669put dc dmn 18
670end
671ret true
672end
673put dc dms shl ulong 1 sz
674put dc dmt gz rt
675k = sz
676if gt k 2
677k = ulong 2
678end
679if eq opc 0
680put dc dmk 2
681put dc dmn add 16 k
682ret true
683end
684put dc dmk 1
685if eq opc 1
686put dc dmn add 10 mul k 2
687ret true
688end
689if eq opc 2
690if eq sz 3
691ret false
692end
693put dc dmn add 11 mul k 2
694ret true
695end
696if ge sz 2
697ret false
698end
699put dc dmn add 11 mul k 2
700ret true
701end
702fn dpair x ulong to bool
703v = fld x 26 1
704opc = fld x 30 2
705l = fld x 22 1
706es = ulong 0
707if eq v 0
708if eq opc 0
709es = ulong 4
710end
711if eq opc 2
712es = ulong 8
713end
714if and and eq opc 1 eq l 1 ne fld x 23 2 0
715es = ulong 4
716end
717put dc dmt gz and x 31
718put dc dmt2 gz fld x 10 5
719else
720if lt opc 3
721es = shl ulong 4 opc
722end
723put dc dmt add 32 and x 31
724put dc dmt2 add 32 fld x 10 5
725end
726if eq es 0
727ret false
728end
729put dc dms es
730put dc dmf 6
731if eq l 1
732put dc dmk 1
733put dc dmn 19
734if and eq v 0 eq opc 1
735put dc dmn 21
736end
737else
738put dc dmk 2
739put dc dmn 20
740end
741put dc dmb fld x 5 5
742ty = fld x 23 2
743off = mul sx fld x 15 7 7 es
744if ne ty 1
745put dc dmo off
746end
747if or eq ty 1 eq ty 3
748put dc dwb 1
749put dc dspa off
750end
751ret true
752end
753note the immediate (unscaled / pre / post / unprivileged) forms by bits 11..10: 3 unscaled, 4 post,
754note 8 unprivileged, 5 pre
755fn uform ty ulong to ulong
756if eq ty 0
757ret 3
758end
759if eq ty 1
760ret 4
761end
762if eq ty 2
763ret 8
764end
765ret 5
766end
767fn dls x ulong to bool
768sz = fld x 30 2
769v = fld x 26 1
770opc = fld x 22 2
771rt = and x 31
772if eq and x 989855744 956301312
773if not lsk sz v opc rt
774ret false
775end
776sc = sz
777if and eq v 1 ne and opc 2 0
778sc = ulong 4
779end
780put dc dmf 1
781put dc dmb fld x 5 5
782put dc dmo shl fld x 10 12 sc
783ret true
784end
785if eq and x 991955968 941623296
786if eq fld x 14 1 0
787ret false
788end
789if not lsk sz v opc rt
790ret false
791end
792put dc dmf 2
793put dc dmb fld x 5 5
794put dc dmi gz fld x 16 5
795ret true
796end
797if eq and x 991952896 939524096
798if not lsk sz v opc rt
799ret false
800end
801ty = fld x 10 2
802im = sx fld x 12 9 9
803put dc dmb fld x 5 5
804if and eq v 1 eq ty 2
805ret false
806end
807put dc dmf uform ty
808if ne ty 1
809put dc dmo im
810end
811if or eq ty 1 eq ty 3
812put dc dwb 1
813put dc dspa im
814end
815ret true
816end
817if eq and x 973078528 671088640
818ret dpair x
819end
820if eq and x 989855744 402653184
821o2 = fld x 30 2
822if eq o2 3
823ret false
824end
825put dc dmk 3
826put dc dmf 7
827put dc dmn 14
828if eq v 1
829put dc dmt add 32 rt
830else
831put dc dmt gz rt
832if eq o2 2
833put dc dmn 15
834end
835end
836ret true
837end
838ret false
839end
840fn dec x ulong w ulong to void
841dclr
842if dbr x w
843ret
844end
845if dls x
846if lsok
847ret
848end
849end
850dclr
851if dalu x
852if aluok x
853ret
854end
855end
856dclr
857if dfp x
858if fpok x
859ret
860end
861end
862dclr
863put dc dkind 10
864put dc dmn 22
865end
866
867note ---- dataflow ----------------------------------------------------------------------------------
868fn unh w ulong k ulong to void
869if eq get uh w 0
870put uh w uchar k
871end
872end
873fn push u ulong to void
874if eq get inq u 0
875put inq u 1
876n = get gv 1
877put wl n u
878put gv 1 add n 1
879end
880end
881note join the current state cu into word u
882fn join u ulong to void
883dd = add get cu 2 1
884if eq get dep u 0
885put rm u get cu 0
886put sm u get cu 1
887put dep u dd
888put fid u get cu 3
889push u
890pjoin u true
891ret
892end
893if ne get dep u dd
894unh u 4
895ret
896end
897if ne get fid u get cu 3
898unh u 5
899ret
900end
901a = or get rm u get cu 0
902b = or get sm u get cu 1
903if or ne a get rm u ne b get sm u
904put rm u a
905put sm u b
906push u
907end
908pjoin u false
909end
910note an edge from w to u: outside the artifact is unhandled; into the trap stubs it ends the path
911fn flow w ulong u ulong to void
912if ge u get gv 0
913unh w 11
914ret
915end
916if ne get trp u 0
917ret
918end
919join u
920end
921fn talu to void
922r = get cu 0
923t = or or tnt r get dc ds1 tnt r get dc ds2 tnt r get dc ds3
924fl = get dc dfl
925if ne and fl 1 0
926t = or t tnt r 31
927end
928if ne and fl 4 0
929t = or t tnt r get dc ddst
930end
931if ne and fl 2 0
932r = sbit r 31 t
933end
934put cu 0 sbit r get dc ddst t
935end
936note SP arithmetic: k = bytes / 8 slots shift; the slots that come into view are unknown (DATA)
937fn tsp w ulong to void
938k = get dc dspo
939if eq k 3
940unh w 1
941ret
942end
943a = get dc dspa
944d = get cu 2
945s = get cu 1
946q = div a 8
947all = not ulong 0
948if ne rem a 8 0
949q = ulong 64
950end
951if eq k 1
952if gt a d
953unh w 12
954put cu 2 0
955put cu 1 all
956ret
957end
958put cu 2 sub d a
959if ge q 64
960put cu 1 all
961ret
962end
963if ne q 0
964put cu 1 or shr s q not shr all q
965end
966ret
967end
968put cu 2 add d a
969if ge q 64
970put cu 1 all
971ret
972end
973if ne q 0
974put cu 1 or shl s q sub shl ulong 1 q 1
975end
976end
977note SP-relative slot range check: below SP or above the function's entry SP is unhandled
978fn slotok w ulong off ulong es ulong to bool
979if ne shr off 63 0
980unh w 14
981ret false
982end
983if gt add off es get cu 2
984unh w 3
985ret false
986end
987ret true
988end
989fn slotld w ulong off ulong es ulong to ulong
990if not slotok w off es
991ret 1
992end
993s = get cu 1
994t = ulong 0
995j = div off 8
996e = div add off sub es 1 8
997while le j e bound 8
998if ge j 64
999t = ulong 1
1000else
1001t = or t and shr s j 1
1002end
1003j = add j 1
1004end
1005ret t
1006end
1007fn slotst w ulong off ulong es ulong v ulong to void
1008if not slotok w off es
1009ret
1010end
1011s = get cu 1
1012j = div off 8
1013if and and eq rem off 8 0 eq es 8 lt j 64
1014put cu 1 sbit s j v
1015ret
1016end
1017e = div add off sub es 1 8
1018while le j e bound 8
1019if lt j 64
1020s = sbit s j or v and shr s j 1
1021end
1022j = add j 1
1023end
1024put cu 1 s
1025end
1026fn tslot w ulong to void
1027off = get dc dmo
1028es = get dc dms
1029r = get cu 0
1030if eq get dc dmk 1
1031t = slotld w off es
1032r = sbit r get dc dmt t
1033if ne get dc dmt2 255
1034r = sbit r get dc dmt2 slotld w add off es es
1035end
1036put cu 0 r
1037ret
1038end
1039slotst w off es tnt r get dc dmt
1040if ne get dc dmt2 255
1041slotst w add off es es tnt r get dc dmt2
1042end
1043end
1044fn tmem w ulong to void
1045mk = get dc dmk
1046r = get cu 0
1047if eq mk 3
1048put cu 0 sbit r get dc dmt 0
1049ret
1050end
1051b = get dc dmb
1052if eq b 31
1053if ne get dc dwb 0
1054unh w 2
1055else
1056if eq get dc dmi 255
1057tslot w
1058ret
1059end
1060end
1061end
1062if eq mk 1
1063t = ppublic ulong get wd w
1064v = ulong 1
1065if ne t 0
1066v = ulong 0
1067end
1068r = sbit r get dc dmt v
1069r = sbit r get dc dmt2 v
1070put cu 0 r
1071end
1072end
1073fn pseq w ulong to void
1074if ne get dc dspo 0
1075tsp w
1076pshift
1077flow w add w 1
1078ret
1079end
1080if eq get dc ddst 7
1081unh w 13
1082end
1083mk = get dc dmk
1084if ne mk 0
1085if eq mk 1
1086if or eq get dc dmt 7 eq get dc dmt2 7
1087unh w 13
1088end
1089end
1090tmem w
1091else
1092talu
1093end
1094zstep w
1095pstep w
1096flow w add w 1
1097end
1098note BL: the callee's entry state joins the caller's registers (x30 public), a fresh stack; after the
1099note call the registers are the callee's exit summary, the caller's own slots and depth are kept
1100fn pbl w ulong to void
1101t = get dc dtgt
1102if ge t get gv 0
1103unh w 11
1104ret
1105end
1106r = get cu 0
1107s = get cu 1
1108d = get cu 2
1109f = get cu 3
1110put cu 0 and r not shl ulong 1 30
1111put cu 1 not ulong 0
1112put cu 2 0
1113put cu 3 t
1114pcall
1115if eq get trp t 0
1116join t
1117end
1118put cu 1 s
1119put cu 2 d
1120put cu 3 f
1121if ne get exs t 0
1122put cu 0 get ex t
1123preturn w t
1124flow w add w 1
1125end
1126end
1127fn requeue f ulong to void
1128n = get gv 0
1129for a ulong 5
1130for b ulong 500000
1131j = add mul a 500000 b
1132if ge j n
1133ret
1134end
1135if and eq get blt j add f 1 ne get dep j 0
1136push j
1137end
1138end
1139end
1140end
1141fn pret w ulong to void
1142if ne get dc ds1 30
1143unh w 8
1144end
1145if ne get cu 2 0
1146unh w 6
1147end
1148if ne tnt get cu 0 30 0
1149unh w 7
1150end
1151f = get cu 3
1152e = get ex f
1153n = or e get cu 0
1154if pexit f
1155requeue f
1156end
1157if or eq get exs f 0 ne n e
1158put ex f n
1159put exs f 1
1160requeue f
1161end
1162end
1163fn proc w ulong to void
1164dec ulong get wd w w
1165put cu 0 get rm w
1166put cu 1 get sm w
1167put cu 2 sub get dep w 1
1168put cu 3 get fid w
1169pload w
1170k = get dc dkind
1171if eq k 0
1172pseq w
1173ret
1174end
1175if eq k 11
1176flow w add w 1
1177ret
1178end
1179if eq k 1
1180flow w get dc dtgt
1181ret
1182end
1183if eq k 3
1184flow w get dc dtgt
1185if lt get dc dcc 14
1186flow w add w 1
1187end
1188ret
1189end
1190if or eq k 4 eq k 5
1191flow w get dc dtgt
1192flow w add w 1
1193ret
1194end
1195if eq k 2
1196pbl w
1197ret
1198end
1199if eq k 6
1200pret w
1201ret
1202end
1203if eq k 7
1204unh w 8
1205ret
1206end
1207if eq k 8
1208unh w 9
1209ret
1210end
1211if eq k 9
1212unh w 10
1213put cu 0 sbit get cu 0 0 1
1214put pc 0 0
1215flow w add w 1
1216end
1217end
1218fn fix to void
1219for a ulong 999999
1220if eq get gv 1 0
1221ret
1222end
1223for b ulong 999999
1224n = get gv 1
1225if eq n 0
1226break
1227end
1228u = get wl sub n 1
1229put gv 1 sub n 1
1230put inq u 0
1231proc u
1232end
1233end
1234exit 92
1235end
1236
1237note ---- preparation -------------------------------------------------------------------------------
1238note trap stubs (omc.om finish): MOVZ X1, #code (1..14); B tail; tail = MOV X0, X7; LDR X16, [X7, #16];
1239note BR X16. trp: code at the MOVZ, 16 at its B, 15 on the three tail words
1240fn stubat w ulong to void
1241n = get gv 0
1242x = ulong get wd w
1243if ne and x 4292870175 3531603969
1244ret
1245end
1246code = fld x 5 16
1247if or lt code 1 gt code 14
1248ret
1249end
1250if ge add w 1 n
1251ret
1252end
1253y = ulong get wd add w 1
1254if ne and y 4227858432 335544320
1255ret
1256end
1257u = add add w 1 sx and y 67108863 26
1258if or ge u n ge add u 2 n
1259ret
1260end
1261if ne ulong get wd u 2852586464
1262ret
1263end
1264if ne ulong get wd add u 1 4181723376
1265ret
1266end
1267if ne ulong get wd add u 2 3592356352
1268ret
1269end
1270put trp w uchar code
1271put trp add w 1 16
1272put trp u 15
1273put trp add u 1 15
1274put trp add u 2 15
1275end
1276fn blat w ulong to void
1277x = ulong get wd w
1278if eq and x 4227858432 2483027968
1279t = add w sx and x 67108863 26
1280if lt t get gv 0
1281put blt w add t 1
1282end
1283end
1284end
1285fn prep to void
1286n = get gv 0
1287for a ulong 5
1288for b ulong 500000
1289j = add mul a 500000 b
1290if ge j n
1291ret
1292end
1293stubat j
1294blat j
1295end
1296end
1297end
1298fn seed to void
1299e = ulong 0
1300x = ulong get wd 0
1301if eq and x 4227858432 335544320
1302t = sx and x 67108863 26
1303if and lt t get gv 0 ne t 0
1304e = t
1305put gv 16 1
1306end
1307end
1308put gv 2 e
1309m = not ulong 63
1310m = and m not shl ulong 1 7
1311m = and m not shl ulong 1 30
1312put cu 0 or m get gv 3
1313put cu 1 not ulong 0
1314put cu 2 0
1315put cu 3 e
1316for i ulong 6
1317put pc i ptok add i 2 0
1318end
1319if eq get trp e 0
1320join e
1321end
1322end
1323
1324note ---- report ------------------------------------------------------------------------------------
1325fn reached w ulong to bool
1326if ne get dep w 0
1327ret true
1328end
1329ret and eq w 0 eq get gv 16 1
1330end
1331fn rbr w ulong to void
1332inc 14
1333say 47
1334od w
1335say 104
1336say get dc dmn
1337say 49
1338t = get dc dtgt
1339od t
1340say 104
1341tc = ulong 0
1342if lt t get gv 0
1343tc = ulong get trp t
1344end
1345if not reached w
1346say 53
1347inc 7
1348onl
1349ret
1350end
1351k = get dc dkind
1352d = ulong 0
1353r = get rm w
1354if eq k 3
1355if lt get dc dcc 14
1356d = tnt r 31
1357end
1358else
1359d = tnt r get dc ds1
1360end
1361if eq d 0
1362say 50
1363inc 4
1364else
1365pload w
1366if and ne tc 0 ztrap w
1367say 51
1368inc 5
1369else
1370ezsay 0
1371inc 6
1372end
1373end
1374if and eq k 3 ge get dc dcc 14
1375say 107
1376end
1377if ne tc 0
1378say 57
1379if le tc 14
1380od tc
1381else
1382say 61
1383end
1384end
1385onl
1386end
1387fn listed to bool
1388mk = get dc dmk
1389if or eq mk 0 eq mk 3
1390ret false
1391end
1392b = get dc dmb
1393if and ne b 31 ne b 29
1394ret true
1395end
1396ret ne get dc dmi 255
1397end
1398fn rmem w ulong to void
1399inc 15
1400say 48
1401od w
1402say 104
1403say get dc dmn
1404say 104
1405say add 80 get dc dmf
1406say 58
1407b = get dc dmb
1408oreg b
1409say 59
1410i = get dc dmi
1411oreg i
1412say 104
1413if ne get trp w 0
1414say 54
1415say 62
1416inc 8
1417onl
1418ret
1419end
1420if not reached w
1421say 53
1422inc 11
1423onl
1424ret
1425end
1426r = get rm w
1427t = tnt r i
1428if ne b 31
1429t = or t tnt r b
1430end
1431if ne t 0
1432say 56
1433inc 10
1434else
1435if ne i 255
1436say 55
1437inc 9
1438else
1439say 54
1440inc 8
1441end
1442end
1443onl
1444end
1445fn rep w ulong to void
1446x = ulong get wd w
1447dec x w
1448k = get dc dkind
1449if eq k 10
1450say 45
1451od w
1452say 78
1453oh x
1454onl
1455inc 12
1456end
1457u = ulong get uh w
1458if ne u 0
1459say 46
1460od w
1461say 104
1462if eq u 15
1463psay 5
1464else
1465say add 89 u
1466end
1467onl
1468inc 13
1469end
1470if or or eq k 3 eq k 4 eq k 5
1471rbr w
1472end
1473if listed
1474rmem w
1475end
1476if ne get dep w 0
1477pload w
1478t = ppublic x
1479if ne t 0
1480psay 1
1481od w
1482psay 2
1483od sub shr t 56 2
1484psay 3
1485od and t 72057594037927935
1486onl
1487end
1488end
1489end
1490fn header to void
1491say 41
1492od get gv 0
1493say 42
1494od get gv 2
1495say 43
1496m = get gv 3
1497if eq m 0
1498say 44
1499else
1500first = true
1501for i ulong 6
1502if ne and shr m i 1 0
1503if not first
1504say 109
1505end
1506say 108
1507od i
1508first = false
1509end
1510end
1511end
1512onl
1513for i ulong get gv 19
1514psay 0
1515od get pdecl mul i 3
1516psay 3
1517od get pdecl add mul i 3 1
1518psay 4
1519od get pdecl add mul i 3 2
1520onl
1521end
1522end
1523fn sumkv id ulong k ulong to void
1524say id
1525od get gv k
1526end
1527fn summary to int
1528sumkv 63 14
1529sumkv 64 4
1530sumkv 65 5
1531sumkv 66 6
1532sumkv 67 7
1533sumkv 68 15
1534sumkv 69 8
1535sumkv 70 9
1536sumkv 71 10
1537sumkv 72 11
1538sumkv 73 12
1539sumkv 74 13
1540onl
1541man = add get gv 12 get gv 13
1542if ne man 0
1543say 105
1544od man
1545say 106
1546onl
1547ezsay 1
1548onl
1549ret 2
1550end
1551if ne get gv 6 0
1552ezsay 1
1553onl
1554ret 2
1555end
1556if ne get gv 10 0
1557say 76
1558onl
1559ret 1
1560end
1561say 75
1562onl
1563ret 0
1564end
1565fn report to int
1566header
1567n = get gv 0
1568for a ulong 5
1569for b ulong 500000
1570j = add mul a 500000 b
1571if ge j n
1572break
1573end
1574rep j
1575rvshow j
1576end
1577end
1578v = summary
1579obf
1580ret v
1581end
1582
1583note ---- input -------------------------------------------------------------------------------------
1584note xN marks a DATA entry register; pub:SLOT:OFF:LEN declares a public immutable memory range.
1585fn args to bool
1586c = argcnt
1587i = ulong 1
1588while lt long i c bound 64
1589r = argread i pab 0 len pab
1590if lt r 0
1591ret false
1592end
1593if and eq r 2 eq get pab 0 120
1594d = get pab 1
1595if or lt d 48 gt d 53
1596ret false
1597end
1598put gv 3 or get gv 3 shl ulong 1 ulong sub d 48
1599else
1600if not parg ulong r
1601ret false
1602end
1603end
1604i = add i 1
1605end
1606ret true
1607end
1608fn rdin to ulong
1609n = ulong 0
1610go = true
1611while go bound 999999
1612r = read 0 inb n sub len inb n
1613if lt r 0
1614ret 0
1615end
1616if eq r 0
1617go = false
1618else
1619n = add n ulong r
1620if eq n len inb
1621go = false
1622end
1623end
1624end
1625ret n
1626end
1627fn bad to void
1628say 80
1629onl
1630obf
1631exit 91
1632end
1633fn main to int
1634inittb
1635if not args
1636psay 6
1637onl
1638obf
1639ret 90
1640end
1641n = rdin
1642if or or eq n 0 ne rem n 4 0 gt n 8388608
1643bad
1644end
1645nw = div n 4
1646put gv 0 nw
1647for a ulong 5
1648for b ulong 500000
1649j = add mul a 500000 b
1650if ge j nw
1651break
1652end
1653o = mul j 4
1654v = or ulong get inb o shl ulong get inb add o 1 8
1655v = or v shl ulong get inb add o 2 16
1656v = or v shl ulong get inb add o 3 24
1657put wd j uint v
1658end
1659end
1660if eq ulong get wd 0 1179403647
1661bad
1662end
1663prep
1664seed
1665rvfix
1666ret report
1667end
1668
1669note ---- exact entry-parameter provenance (constant domain, no interval or call specialization) -----
1670fn psay id ulong to void
1671k = ulong 0
1672s = ulong 0
1673for i ulong len pmsg
1674if eq get pmsg i 10
1675if eq k id
1676for j ulong sub i s
1677ob1 get pmsg add s j
1678end
1679ret
1680end
1681k = add k 1
1682s = add i 1
1683end
1684end
1685end
1686fn parg n ulong to bool
1687if or lt n 9 ge get gv 19 32
1688ret false
1689end
1690if ne get pab 0 112
1691ret false
1692end
1693if ne get pab 1 117
1694ret false
1695end
1696if ne get pab 2 98
1697ret false
1698end
1699if ne get pab 3 58
1700ret false
1701end
1702f = ulong 0
1703v = ulong 0
1704digits = ulong 0
1705b = mul get gv 19 3
1706for i ulong sub n 3
1707j = add i 4
1708c = uchar 58
1709if lt j n
1710c = get pab j
1711end
1712if eq c 58
1713if or eq digits 0 ge f 3
1714ret false
1715end
1716put pdecl add b f v
1717f = add f 1
1718v = ulong 0
1719digits = ulong 0
1720else
1721if or lt c 48 gt c 57
1722ret false
1723end
1724if gt v 3602879701896396
1725ret false
1726end
1727v = add mul v 10 ulong sub c 48
1728if gt v 36028797018963967
1729ret false
1730end
1731digits = add digits 1
1732end
1733end
1734if ne f 3
1735ret false
1736end
1737if gt get pdecl b 5
1738ret false
1739end
1740if gt add get pdecl add b 1 get pdecl add b 2 36028797018963967
1741ret false
1742end
1743inc 19
1744ret true
1745end
1746fn ptok k ulong v ulong to ulong
1747if ne sx and v 72057594037927935 56 v
1748ret 0
1749end
1750ret or shl k 56 and v 72057594037927935
1751end
1752fn pget i ulong to ulong
1753if ge i 31
1754ret 0
1755end
1756ret get pc i
1757end
1758fn pval v ulong to ulong
1759ret sx and v 72057594037927935 56
1760end
1761fn pconst i ulong to ulong
1762if eq i 255
1763ret ptok 1 0
1764end
1765ret pget i
1766end
1767fn padd a ulong b ulong subtr bool to ulong
1768ak = shr a 56
1769bk = shr b 56
1770if or eq ak 0 eq bk 0
1771ret 0
1772end
1773if subtr
1774if ne bk 1
1775ret 0
1776end
1777ret ptok ak sub pval a pval b
1778end
1779if eq bk 1
1780ret ptok ak add pval a pval b
1781end
1782if eq ak 1
1783ret ptok bk add pval a pval b
1784end
1785ret 0
1786end
1787fn palloc w ulong to ulong
1788n = get gv 18
1789if gt add n 128 len pp
1790unh w 15
1791ret 0
1792end
1793put gv 18 add n 128
1794for i ulong 128
1795put pp add n i get pc i
1796end
1797ret add n 1
1798end
1799fn pmerge ptr ulong count ulong to bool
1800if eq ptr 0
1801ret false
1802end
1803b = sub ptr 1
1804changed = false
1805for i ulong count
1806v = get pp add b i
1807n = ulong 0
1808if or ge i 96 eq i 31
1809n = and v get pc i
1810else
1811if eq v get pc i
1812n = v
1813end
1814end
1815if ne v n
1816put pp add b i n
1817changed = true
1818end
1819end
1820ret changed
1821end
1822fn pjoin w ulong fresh bool to void
1823if fresh
1824put ps w palloc w
1825ret
1826end
1827if pmerge get ps w 128
1828push w
1829end
1830end
1831fn pload w ulong to void
1832b = get ps w
1833for i ulong 128
1834v = ulong 0
1835if ne b 0
1836v = get pp add sub b 1 i
1837end
1838put pc i v
1839end
1840end
1841fn pexit f ulong to bool
1842if eq get pe f 0
1843put pe f palloc f
1844ret ne get pe f 0
1845end
1846ret pmerge get pe f 128
1847end
1848fn pcall to void
1849put pc 30 0
1850for i ulong 64
1851put pc add i 32 0
1852end
1853end
1854fn preturn w ulong t ulong to void
1855s = get ps w
1856e = get pe t
1857if ne e 0
1858put pc 31 get pp add sub e 1 31
1859else
1860put pc 31 0
1861end
1862for i ulong 31
1863v = ulong 0
1864if ne e 0
1865v = get pp add sub e 1 i
1866end
1867put pc i v
1868end
1869for i ulong 64
1870v = ulong 0
1871if ne s 0
1872v = get pp add add sub s 1 i 32
1873end
1874put pc add i 32 v
1875end
1876for i ulong 32
1877v = ulong 0
1878if ne e 0
1879v = get pp add add sub e 1 i 96
1880end
1881put pc add i 96 v
1882end
1883end
1884fn pshift to void
1885a = get dc dspa
1886k = get dc dspo
1887if or eq k 3 ne rem a 8 0
1888a = ulong 512
1889end
1890q = div a 8
1891if eq k 1
1892for i ulong 64
1893v = ulong 0
1894if lt add i q 64
1895v = get pc add add i q 32
1896end
1897put pc add i 32 v
1898end
1899else
1900for i ulong 64
1901j = sub 63 i
1902v = ulong 0
1903if ge j q
1904v = get pc add sub j q 32
1905end
1906put pc add j 32 v
1907end
1908end
1909end
1910note Register-offset addressing: UXTW/UXTX/SXTW/SXTX; S means scale by element size.
1911fn pindex x ulong to ulong
1912i = get dc dmi
1913if eq i 255
1914ret ptok 1 0
1915end
1916v = pget i
1917if ne shr v 56 1
1918ret 0
1919end
1920v = pval v
1921opt = fld x 13 3
1922if eq opt 2
1923v = and v 4294967295
1924end
1925if eq opt 6
1926v = sx and v 4294967295 32
1927end
1928if ne fld x 12 1 0
1929v = mul v get dc dms
1930end
1931ret ptok 1 v
1932end
1933fn paddr x ulong to ulong
1934b = pget get dc dmb
1935v = padd b pindex x false
1936ret padd v ptok 1 get dc dmo false
1937end
1938fn pinrange b ulong k ulong off ulong size ulong to bool
1939if ne get pdecl b sub k 2
1940ret false
1941end
1942lo = get pdecl add b 1
1943hi = add lo get pdecl add b 2
1944ret and ge off lo le add off size hi
1945end
1946fn ppublic x ulong to ulong
1947if or eq get gv 19 0 ne get dc dmk 1
1948ret 0
1949end
1950v = paddr x
1951k = shr v 56
1952if or lt k 2 gt k 7
1953ret 0
1954end
1955off = pval v
1956if ne shr off 63 0
1957ret 0
1958end
1959size = get dc dms
1960if ne get dc dmt2 255
1961size = mul size 2
1962end
1963for i ulong get gv 19
1964if and eq tnt get gv 20 i 0 pinrange mul i 3 k off size
1965ret v
1966end
1967end
1968ret 0
1969end
1970note Exact immediate constants plus param-base +/- constant. Other results lose provenance.
1971fn pim x ulong to ulong
1972k = fld x 29 2
1973shift = mul fld x 21 2 16
1974v = shl fld x 5 16 shift
1975if eq k 0
1976v = not v
1977end
1978if eq k 3
1979a = pget and x 31
1980if ne shr a 56 1
1981ret 0
1982end
1983v = or and pval a not shl ulong 65535 shift v
1984end
1985if eq fld x 31 1 0
1986v = and v 4294967295
1987end
1988ret ptok 1 v
1989end
1990fn pregcalc x ulong to ulong
1991a = pconst get dc ds1
1992b = pconst get dc ds2
1993if ne shr b 56 1
1994ret 0
1995end
1996v = pval b
1997if eq and x 522190848 186646528
1998opt = fld x 13 3
1999if lt opt 3
2000v = and v sub shl ulong 1 shl ulong 8 opt 1
2001end
2002if ge opt 4
2003bits = shl ulong 8 sub opt 4
2004if lt bits 64
2005v = sx and v sub shl ulong 1 bits 1 bits
2006end
2007end
2008v = shl v fld x 10 3
2009else
2010sh = fld x 10 6
2011ty = fld x 22 2
2012if eq ty 0
2013v = shl v sh
2014end
2015if eq ty 1
2016v = shr v sh
2017end
2018if eq ty 2
2019if ne sh 0
2020v = or shr v sh shl sub 0 shr v 63 sub 64 sh
2021end
2022end
2023end
2024ret padd a ptok 1 v eq fld x 30 1 1
2025end
2026fn palu x ulong to ulong
2027m = and x 528482304
2028if eq m 310378496
2029ret pim x
2030end
2031if eq m 285212672
2032a = pconst get dc ds1
2033b = shl fld x 10 12 mul fld x 22 1 12
2034ret padd a ptok 1 b eq fld x 30 1 1
2035end
2036if eq and x 520093696 184549376
2037ret pregcalc x
2038end
2039note MOV is ORR Xd,XZR,Xm with no shift; full-width copies preserve base identity.
2040if eq and x 4292935648 2852127712
2041ret pconst fld x 16 5
2042end
2043ret 0
2044end
2045fn pslotone off ulong size ulong rt ulong to void
2046idx = div off 8
2047if eq get dc dmk 1
2048v = ulong 0
2049if and and eq rem off 8 0 eq size 8 lt idx 64
2050v = get pc add idx 32
2051end
2052if lt rt 31
2053put pc rt v
2054end
2055ret
2056end
2057if and and eq rem off 8 0 eq size 8 lt idx 64
2058put pc add idx 32 pconst rt
2059ret
2060end
2061last = div add off sub size 1 8
2062while le idx last bound 8
2063if lt idx 64
2064put pc add idx 32 0
2065end
2066idx = add idx 1
2067end
2068end
2069fn pslot to void
2070pslotone get dc dmo get dc dms get dc dmt
2071if ne get dc dmt2 255
2072pslotone add get dc dmo get dc dms get dc dms get dc dmt2
2073end
2074end
2075fn pspmem to bool
2076if ne get dc dmb 31
2077ret false
2078end
2079if ne get dc dwb 0
2080ret false
2081end
2082ret eq get dc dmi 255
2083end
2084fn pstep w ulong to void
2085x = ulong get wd w
2086mk = get dc dmk
2087if ne mk 0
2088if pspmem
2089pslot
2090ret
2091end
2092if or eq mk 1 eq mk 3
2093if lt get dc dmt 31
2094put pc get dc dmt 0
2095end
2096if lt get dc dmt2 31
2097put pc get dc dmt2 0
2098end
2099end
2100if and ne get dc dwb 0 lt get dc dmb 31
2101put pc get dc dmb 0
2102end
2103ret
2104end
2105d = get dc ddst
2106if lt d 31
2107v = palu x
2108if and eq fld x 31 1 0 ne shr v 56 1
2109v = ulong 0
2110end
2111if and eq fld x 31 1 0 ne v 0
2112v = ptok 1 and pval v 4294967295
2113end
2114put pc d v
2115end
2116end
2117
2118note E12: only a proven-zero CBNZ conversion check discharges a DATA trap edge.
2119note pc[96+r] is known-zero bits of Xr. Meet at joins is intersection, unlike provenance tokens.
2120fn ezsay id ulong to void
2121s = ulong 0
2122k = ulong 0
2123for i ulong len e12
2124if eq get e12 i 10
2125if eq k id
2126for j ulong sub i s
2127ob1 get e12 add s j
2128end
2129ret
2130end
2131k = add k 1
2132s = add i 1
2133end
2134end
2135end
2136fn zget r ulong to ulong
2137if ge r 31
2138ret not ulong 0
2139end
2140ret get pc add r 96
2141end
2142fn zimm x ulong to ulong
2143k = fld x 29 2
2144sh = mul fld x 21 2 16
2145v = shl fld x 5 16 sh
2146if eq k 0
2147ret v
2148end
2149if eq k 3
2150old = zget and x 31
2151ret or and old not shl ulong 65535 sh and not v shl ulong 65535 sh
2152end
2153ret not v
2154end
2155fn zalu x ulong to ulong
2156if and eq and x 528482304 301989888 or eq fld x 29 2 0 eq fld x 29 2 3
2157ret or zget get dc ds1 not zmask x
2158end
2159if eq and x 528482304 310378496
2160ret zimm x
2161end
2162if eq and x 520093696 167772160
2163a = zget get dc ds1
2164b = zget get dc ds2
2165if ne fld x 21 1 0
2166ret 0
2167end
2168if ne fld x 10 6 0
2169ret 0
2170end
2171op = fld x 29 2
2172if or eq op 0 eq op 3
2173ret or a b
2174end
2175if eq op 1
2176ret and a b
2177end
2178ret 0
2179end
2180if and eq and x 528482304 318767104 eq fld x 29 2 2
2181r = fld x 16 6
2182s = fld x 10 6
2183z = zget get dc ds1
2184bits = ulong 64
2185if eq fld x 31 1 0
2186bits = ulong 32
2187end
2188if eq r 0
2189if lt s 63
2190ret or z not sub shl ulong 1 add s 1 1
2191end
2192ret z
2193end
2194if eq s sub bits 1
2195ret or shr z r not shr not ulong 0 r
2196end
2197end
2198ret 0
2199end
2200fn zstep w ulong to void
2201x = ulong get wd w
2202if ne get dc dmk 0
2203if or eq get dc dmk 1 eq get dc dmk 3
2204for i ulong 2
2205r = get dc dmt
2206if eq i 1
2207r = get dc dmt2
2208end
2209if lt r 31
2210z = ulong 0
2211put pc add r 96 z
2212put pc 31 sbit get pc 31 r 0
2213end
2214end
2215end
2216ret
2217end
2218d = get dc ddst
2219if lt d 31
2220proof = zproof x
2221put pc 31 sbit get pc 31 d proof
2222z = zalu x
2223if eq fld x 31 1 0
2224z = or z 18446744069414584320
2225end
2226put pc add d 96 z
2227end
2228end
2229fn ztrap w ulong to bool
2230x = ulong get wd w
2231if ne and x 4278190080 3036676096
2232ret false
2233end
2234if eq tnt get pc 31 and x 31 0
2235ret false
2236end
2237ret eq zget and x 31 not ulong 0
2238end
2239note Arm DecodeBitMasks (logical immediate), unallocated masks already rejected by bmok.
2240fn zmask x ulong to ulong
2241v = or shl fld x 22 1 6 and not fld x 10 6 63
2242l = ulong 6
2243while eq and shr v l 1 0 bound 8
2244l = sub l 1
2245end
2246width = shl ulong 1 l
2247levels = sub width 1
2248s = and fld x 10 6 levels
2249r = and fld x 16 6 levels
2250base = sub shl ulong 1 add s 1 1
2251if ne r 0
2252base = or shr base r shl base sub width r
2253end
2254if lt width 64
2255base = and base sub shl ulong 1 width 1
2256end
2257result = ulong 0
2258for i ulong div 64 width
2259result = or result shl base mul i width
2260end
2261ret result
2262end
2263fn zproof x ulong to ulong
2264m = and x 528482304
2265if and eq m 301989888 or eq fld x 29 2 0 eq fld x 29 2 3
2266ret 1
2267end
2268if eq and x 520093696 167772160
2269op = fld x 29 2
2270if and eq fld x 21 1 0 or eq op 0 eq op 3
2271a = pconst get dc ds1
2272b = pconst get dc ds2
2273if or eq shr a 56 1 eq shr b 56 1
2274ret 1
2275end
2276end
2277if eq and x 4292935648 2852127712
2278ret tnt get pc 31 fld x 16 5
2279end
2280end
2281if eq m 318767104
2282ret tnt get pc 31 get dc ds1
2283end
2284ret 0
2285end
2286note Rotation decode citations, independent of all OM-2 compiler sources:
2287note ARM DDI0487M.d C6.2.160 (p2201): EXTR sf|00|100111|N|0|Rm|imms|Rn|Rd, N=sf; ROR immediate Rn=Rm.
2288note C6.2.349 (p2580): RORV sf|00|11010110|Rm|001011|Rn|Rd (DP2 opcode 11).
2289note C6.2.295 (p2475): NEG is SUB shifted-register with Rn=31 (XZR), not SP.
2290note dalu already covers these instruction classes; E12 zero/provenance transfer drops rotate knowledge.
2291
2292note E13 fallback: revoke ranges globally if any DATA/unclassified store may overlap.
2293note Re-run the analysis after revocation so declassified-load dependencies cannot retain false PUBLIC.
2294fn rvoutside decl ulong addr ulong size ulong to bool
2295b = mul decl 3
2296if eq get pdecl add b 2 0
2297ret true
2298end
2299if ne shr addr 56 add get pdecl b 2
2300ret false
2301end
2302off = pval addr
2303endoff = add off size
2304lo = get pdecl add b 1
2305hi = add lo get pdecl add b 2
2306if ne shr off 63 0
2307if ne shr endoff 63 0
2308ret true
2309end
2310ret le endoff lo
2311end
2312ret or ge off hi le endoff lo
2313end
2314fn rvbad w ulong to bool
2315if ne get uh w 0
2316ret true
2317end
2318if eq get dc dkind 10
2319ret true
2320end
2321if ne get dc dmk 2
2322ret false
2323end
2324if eq get dep w 0
2325ret true
2326end
2327r = get rm w
2328v = or tnt r get dc dmt tnt r get dc dmt2
2329if ne get dc dmb 31
2330v = or v tnt r get dc dmb
2331end
2332v = or v tnt r get dc dmi
2333ret ne v 0
2334end
2335fn rvstore w ulong to void
2336dec ulong get wd w w
2337if not rvbad w
2338ret
2339end
2340addr = ulong 0
2341size = ulong 0
2342if and eq get dc dmk 2 ne get dep w 0
2343note Proven current-frame SP spills cannot alias entry-parameter ranges (existing A1 invariant).
2344if and eq get uh w 0 pspmem
2345ret
2346end
2347pload w
2348addr = paddr ulong get wd w
2349size = get dc dms
2350if ne get dc dmt2 255
2351size = mul size 2
2352end
2353end
2354for i ulong get gv 19
2355if not rvoutside i addr size
2356bit = shl ulong 1 i
2357put rv w or get rv w bit
2358put gv 20 or get gv 20 bit
2359end
2360end
2361end
2362fn rvcollect to void
2363n = get gv 0
2364for a ulong 5
2365for b ulong 500000
2366j = add mul a 500000 b
2367if ge j n
2368ret
2369end
2370rvstore j
2371end
2372end
2373end
2374fn rvclearword w ulong to void
2375put dep w 0
2376put ex w 0
2377put exs w 0
2378put inq w 0
2379put ps w 0
2380put pe w 0
2381end
2382fn rvreset to void
2383put gv 1 0
2384put gv 18 0
2385put gv 16 0
2386for i ulong 128
2387put pc i 0
2388end
2389n = get gv 0
2390for a ulong 5
2391for b ulong 500000
2392j = add mul a 500000 b
2393if ge j n
2394ret
2395end
2396rvclearword j
2397end
2398end
2399end
2400fn rvfix to void
2401for pass ulong 33
2402fix
2403if eq get gv 19 0
2404ret
2405end
2406before = get gv 20
2407rvcollect
2408if eq before get gv 20
2409ret
2410end
2411rvreset
2412seed
2413end
2414exit 92
2415end
2416fn rvshow w ulong to void
2417for i ulong get gv 19
2418if ne tnt get rv w i 0
2419for j ulong len revmsg
2420ob1 get revmsg j
2421end
2422od w
2423psay 2
2424od get pdecl mul i 3
2425psay 3
2426od get pdecl add mul i 3 1
2427psay 4
2428od get pdecl add mul i 3 2
2429onl
2430end
2431end
2432end