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 / ddc650 / ddc.om

1102 lines · 19708 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/qualification/ddc650/ddc.om: diverse double compilation conductor for issue #650.
3note Handwritten seeded Omega, program mode, Linux AArch64, modelled on security673/gate669.om and
4note om2/gate.om. README.md in this directory states the trust argument, scope and limitations.
5note
6note Run from the repository root:
7note ddc OM4 OM4_SHA256 CC ORACLE_SRC ORACLE_SRC_SHA256 SRC BIN SCRATCH [CONTROL]
8note OM4 seed-born om4 compiler (route S trusted compiler); refused unless its SHA-256 is OM4_SHA256
9note CC host C compiler, absolute path; it builds the oracle (route I) with fixed flags
10note ORACLE_SRC interpreter source written from the spec; refused unless its SHA-256 is ORACLE_SRC_SHA256
11note SRC the claimed compiler source (seed/omc/omc.om)
12note BIN the compiler binary under test (seed/out/omc)
13note SCRATCH evidence directory; must not exist (exit 91), created 0700, never overwritten
14note CONTROL optional injected difference; a control run never passes:
15note stage1 route S stage 1 is built from SRC with one codegen mutation (expected FAIL)
16note oracle route I oracle is built from ORACLE_SRC with one semantic mutation (expected FAIL)
17note source SRC is replaced by the codegen-mutated source for every step (expected FAIL)
18note binary BIN is replaced by a copy with byte 1000 xor 1 (expected FAIL)
19note comparator the byte comparator answers "equal" for everything (expected INVALID)
20note
21note Route S: stage1 = OM4 < SRC, stage2 = stage1 < SRC (each built twice, copies must be equal).
22note Route I: oracle = CC -B/usr/bin/ -O2 -std=gnu11 -Wall -Wextra -Werror -o oracle ORACLE_SRC
23note -lpthread; ref = oracle run SRC < SRC (run twice, outputs must be equal).
24note Subject: self = BIN < SRC must equal BIN (self-regeneration precondition).
25note DDC: stage2 == BIN, ref == BIN and stage2 == ref, byte for byte. stage1 == BIN is printed and
26note not required. Sensitivity: stage 1 built from SRC with an extra NOP before each zero or
27note minus-one constant must give a stage 2 that differs from BIN; if it does not, the run is INVALID.
28note Exit: PASS 0, FAIL 1 (a comparison or the subject failed), INVALID 3 (no evidence: identity
29note mismatch, comparator self-test, trusted route refused, nondeterminism, signal, deadline, I/O),
30note CONTROL SURVIVED 4, usage 90, existing scratch 91. Children run with the caller's permissions
31note and an empty environment; this is not a sandbox and only trusted inputs belong here.
32text words "stage1\nstage1.b\nstage2\nstage2.b\noracle\nref\nref.b\nself\nmutant.om\nmstage1\nmstage2\ncmp.a\ncmp.b\ncmp.c\ncmp.d\nseed/qualification/om2/fixtures/sha256-k.dec\nseed/qualification/om2/fixtures/sha256-iv.dec\nrun\n-B/usr/bin/\n-O2\n-std=gnu11\n-Wall\n-Wextra\n-Werror\n-o\n-lpthread\n.err\nbin\nmutant.c\nstage1\noracle\nsource\nbinary\ncomparator\n/dev/null\ncc.out\n"
33text msg "DDC650 diverse double compilation: does BIN equal what two independent routes build from SRC\ninput OM4 \ninput CC \ninput ORACLE_SRC \ninput SRC \ninput BIN \n sha256 \n pin \n match\n MISMATCH\n $\n < \n > \n 2> \n exit=\n unreadable\nartifact \n bytes \ncheck \n PASS\n FAIL\n INVALID\ncomparator self-test (equal files, one differing byte, differing length):\nroute S stage1 = OM4(SRC), two builds, exit 0, ELF:\nroute S stage1 deterministic (two builds identical):\nroute S stage2 = stage1(SRC), two builds, exit 0, ELF:\nroute S stage2 deterministic (two builds identical):\nroute I oracle = CC(ORACLE_SRC), exit 0, ELF:\nroute I ref = oracle run SRC < SRC, two runs, exit 0:\nroute I deterministic (two runs identical):\nsubject self = BIN(SRC), exit 0:\nself-regeneration BIN(SRC) == BIN:\nDDC route S: stage2 == BIN:\nDDC route I: ref == BIN:\nroutes agree: stage2 == ref:\nsensitivity: mstage1 = OM4(SRC with an extra NOP per zero/minus-one constant), mstage2 = mstage1(SRC) != BIN:\ninfo stage1 == BIN (not required): \nyes\nno\ncontrol \ncontrol site found exactly once in \nVERDICT DDC650 PASS: BIN equals what route S (seed om4) and route I (CC-built spec interpreter) build from SRC; scope: these SRC, BIN, OM4, ORACLE_SRC, CC and this host only; not a proof that SRC is correct or safe and not a trusting-trust cure\nVERDICT DDC650 FAIL: correspondence between SRC and BIN is not shown\nVERDICT DDC650 INVALID: no evidence either way\nCONTROL SURVIVED: the injected difference was not detected\nCONTROL CAUGHT: the injected difference stopped a PASS\nusage: ddc OM4 OM4_SHA256 CC ORACLE_SRC ORACLE_SRC_SHA256 SRC BIN SCRATCH [stage1|oracle|source|binary|comparator]\nscratch exists or cannot be created\nSHA-256 constants unreadable\n child signal or deadline exceeded; wait low byte=\n child exec or redirect failed (exit 127)\nINVALID scratch I/O, argument or capacity failure\ncontrol site not found exactly once in \n (route not run)\n"
34text site1 "\nemit or mop r\n"
35text rep1 "\nemit 3573751839\nemit or mop r\n"
36text site2 "return canon(t, x << s);"
37text rep2 "return canon(t, (x << s) ^ (s == 3));"
38global pb uchar 4096
39global pn ulong 1
40global scr uchar 4096
41global scn ulong 1
42global av uchar 4096
43global ap ulong 2
44global big uchar *
45global bgn ulong 1
46global buf uchar 65536
47global oth uchar 65536
48global dig uchar 32
49global stb uchar 4
50global gst ulong 2
51global rok ulong 2
52global ctl ulong 1
53global srcp ulong 1
54global binp ulong 1
55global osp ulong 1
56global spos ulong 2
57global pin uchar 64
58global hexd uchar 64
59global nums ulong 64
60global kk uint 64
61global ivs uint 8
62global hv uint 8
63global ws uint 64
64global st uint 8
65global blk uchar 64
66global bk ulong 2
67global hsz ulong 1
68note ---- output -------------------------------------------------------------------------------
69fn say id ulong to void
70k = ulong 1
71s = ulong 0
72for i ulong len msg
73if eq get msg i 10
74if eq k id
75r = write 1 msg s sub i s
76ret
77end
78k = add k 1
79s = add i 1
80end
81end
82exit 99
83end
84fn newline to void
85put dig 0 10
86r = write 1 dig 0 1
87end
88fn space to void
89put dig 0 32
90r = write 1 dig 0 1
91end
92fn decimal v ulong to ulong
93x = v
94n = ulong 0
95while ge x 10
96put dig n uchar add 48 rem x 10
97x = div x 10
98n = add n 1
99end
100put dig n uchar add 48 x
101ret add n 1
102end
103fn num v ulong to void
104n = decimal v
105for i ulong n
106r = write 1 dig sub sub n i 1 1
107end
108end
109fn abort to void
110newline
111say 52
112newline
113exit 3
114end
115note ---- paths: code 1..99 is SCRATCH/<word>, 101..109 is argument code-100, 201.. is <word code-200>
116fn pclear to void
117put pn 0 0
118end
119fn pbyte b uchar to void
120n = get pn 0
121if ge n 4095
122abort
123end
124put pb n b
125put pn 0 add n 1
126end
127fn pword id ulong to void
128k = ulong 1
129s = ulong 0
130for i ulong len words
131if eq get words i 10
132if eq k id
133for j ulong sub i s
134pbyte get words add s j
135end
136ret
137end
138k = add k 1
139s = add i 1
140end
141end
142exit 99
143end
144fn setp c ulong to void
145pclear
146if ge c 200
147pword sub c 200
148ret
149end
150if ge c 100
151r = argread sub c 100 pb 0 4095
152if lt r 1
153abort
154end
155put pn 0 ulong r
156ret
157end
158for i ulong get scn 0
159pbyte get scr i
160end
161pword c
162end
163fn showpb to void
164r = write 1 pb 0 get pn 0
165end
166fn popen fl int to int
167r = fopen pb 0 get pn 0 fl 384
168if lt r 0
169abort
170end
171ret int r
172end
173fn fclo fd int to void
174if ge fd 0
175r = fclose fd
176end
177end
178note ---- children ----------------------------------------------------------------------------
179fn apb to void
180n = get pn 0
181p = get ap 0
182if or gt add add p n 2 len av ge get ap 1 64
183abort
184end
185put av p uchar and n 255
186put av add p 1 uchar shr n 8
187p = add p 2
188for i ulong n
189put av add p i get pb i
190end
191put ap 0 add p n
192put ap 1 add get ap 1 1
193space
194showpb
195end
196fn cmd c ulong to void
197put ap 0 2
198put ap 1 0
199say 11
200setp c
201apb
202end
203fn arg c ulong to void
204setp c
205apb
206end
207fn redir s int d int to void
208if ne s d
209if ne dupfd s d 0 long d
210exit 127
211end
212end
213end
214fn reap pid int to ulong
215t0 = monons
216while true
217r = waitpid pid stb 0 len stb 1
218if eq r long pid
219if ne get stb 0 0
220say 50
221num ulong get stb 0
222newline
223ret 256
224end
225x = ulong get stb 1
226if eq x 127
227say 51
228newline
229end
230ret x
231end
232if lt r 0
233abort
234end
235now = monons
236if or lt now t0 gt sub now t0 300000000000
237r = killpid pid 9
238r = waitpid pid stb 0 len stb 0
239say 50
240num ulong get stb 0
241newline
242ret 257
243end
244if ne sleepns 1000000 0
245abort
246end
247end
248exit 99
249end
250note run the command in av with stdin from path code ic, stdout to SCRATCH/<oc>, stderr to .err
251fn spawn ic ulong oc ulong to ulong
252say 12
253setp ic
254showpb
255fi = popen 524288
256say 13
257setp oc
258showpb
259fo = popen 524481
260say 14
261setp oc
262pword 27
263showpb
264fe = popen 524481
265newline
266put av 0 uchar and get ap 1 255
267put av 1 uchar shr get ap 1 8
268pid = fork
269if lt pid 0
270abort
271end
272if eq pid 0
273redir fi 0
274redir fo 1
275redir fe 2
276r = execprog av 0 get ap 0
277exit 127
278end
279fclo fi
280fclo fo
281fclo fe
282x = reap int pid
283say 15
284num x
285newline
286ret x
287end
288note make SCRATCH/<c> or BIN executable after checking its ELF magic; false when it is not ELF
289fn enable c ulong to bool
290setp c
291fd = popen 524288
292r = read fd buf 0 4
293ok = true
294if ne r 4
295ok = false
296else
297if or ne get buf 0 127 ne get buf 1 69
298ok = false
299end
300if or ne get buf 2 76 ne get buf 3 70
301ok = false
302end
303end
304if ok
305if ne fchmod fd 448 0
306abort
307end
308end
309fclo fd
310ret ok
311end
312note ---- byte comparator ---------------------------------------------------------------------
313fn rfa fd int to long
314n = ulong 0
315while lt n len buf
316r = read fd buf n sub len buf n
317if lt r 0
318ret r
319end
320if eq r 0
321ret long n
322end
323n = add n ulong r
324end
325ret long n
326end
327fn rfb fd int to long
328n = ulong 0
329while lt n len oth
330r = read fd oth n sub len oth n
331if lt r 0
332ret r
333end
334if eq r 0
335ret long n
336end
337n = add n ulong r
338end
339ret long n
340end
341fn cmpfd fa int fb int to bool
342while true
343ra = rfa fa
344rb = rfb fb
345if or lt ra 0 lt rb 0
346abort
347end
348if ne ra rb
349ret false
350end
351if eq ra 0
352ret true
353end
354for i ulong ulong ra
355if ne get buf i get oth i
356ret false
357end
358end
359end
360ret false
361end
362fn same a ulong b ulong to bool
363if eq get ctl 0 5
364ret true
365end
366setp a
367fa = popen 524288
368setp b
369fb = popen 524288
370eqv = cmpfd fa fb
371fclo fa
372fclo fb
373ret eqv
374end
375note ---- SHA-256 (FIPS 180-4), copied from seed/qualification/om2/gate.om; artifact identity only
376fn rotr x uint n uint to uint
377ret or shr x n shl x sub 32 n
378end
379fn shasched to void
380for i ulong 16
381b = mul i 4
382v = shl uint get blk b 24
383v = or v shl uint get blk add b 1 16
384v = or v shl uint get blk add b 2 8
385v = or v uint get blk add b 3
386put ws i v
387end
388for j ulong 48
389q = add j 16
390x = get ws sub q 15
391y = get ws sub q 2
392s0 = xor xor rotr x 7 rotr x 18 shr x 3
393s1 = xor xor rotr y 17 rotr y 19 shr y 10
394put ws q add add add get ws sub q 16 s0 get ws sub q 7 s1
395end
396end
397fn shat1 i ulong to uint
398e = get st 4
399s1 = xor xor rotr e 6 rotr e 11 rotr e 25
400ch = xor and e get st 5 and not e get st 6
401ret add add add add get st 7 s1 ch get kk i get ws i
402end
403fn shat2 to uint
404a = get st 0
405b = get st 1
406c = get st 2
407s0 = xor xor rotr a 2 rotr a 13 rotr a 22
408mj = xor xor and a b and a c and b c
409ret add s0 mj
410end
411fn shacomp to void
412shasched
413for i ulong 8
414put st i get hv i
415end
416for i ulong 64
417t1 = shat1 i
418t2 = shat2
419put st 7 get st 6
420put st 6 get st 5
421put st 5 get st 4
422put st 4 add get st 3 t1
423put st 3 get st 2
424put st 2 get st 1
425put st 1 get st 0
426put st 0 add t1 t2
427end
428for i ulong 8
429put hv i add get hv i get st i
430end
431end
432fn shabyte b uchar to void
433n = get bk 0
434put blk n b
435n = add n 1
436if eq n 64
437shacomp
438n = ulong 0
439end
440put bk 0 n
441put bk 1 add get bk 1 1
442end
443fn hexch v uint to uchar
444if lt v 10
445ret uchar add v 48
446end
447ret uchar add v 87
448end
449fn shafinal to void
450bits = mul get bk 1 8
451shabyte 128
452while ne get bk 0 56 bound 64
453shabyte 0
454end
455for i ulong 8
456shabyte uchar and shr bits mul sub 7 i 8 255
457end
458for i ulong 8
459v = get hv i
460for j ulong 8
461put hexd add mul i 8 j hexch and shr v mul sub 7 j 4 15
462end
463end
464end
465note hash the file named by path code c into hexd; false when it cannot be read; bk[1] = bytes
466fn hashp c ulong to bool
467setp c
468r = fopen pb 0 get pn 0 524288 384
469if lt r 0
470ret false
471end
472fd = int r
473for i ulong 8
474put hv i get ivs i
475end
476put bk 0 0
477put bk 1 0
478while true
479n = rfa fd
480if lt n 0
481fclo fd
482ret false
483end
484if eq n 0
485fclo fd
486put hsz 0 get bk 1
487shafinal
488ret true
489end
490for i ulong ulong n
491shabyte get buf i
492end
493end
494ret false
495end
496fn parsenum n ulong want ulong to bool
497m = ulong not uint 0
498k = ulong 0
499v = ulong 0
500nd = ulong 0
501for i ulong n
502c = get buf i
503if and ge c 48 le c 57
504if ge nd 10
505ret false
506end
507v = add mul v 10 ulong sub c 48
508nd = add nd 1
509else
510if or ne c 10 eq nd 0
511ret false
512end
513if ge k want
514ret false
515end
516if gt v m
517ret false
518end
519put nums k v
520k = add k 1
521v = ulong 0
522nd = ulong 0
523end
524end
525ret and eq nd 0 eq k want
526end
527fn loadnums c ulong want ulong to bool
528setp c
529r = fopen pb 0 get pn 0 524288 384
530if lt r 0
531ret false
532end
533fd = int r
534n = rfa fd
535fclo fd
536if or le n 0 ge n long len buf
537ret false
538end
539ret parsenum ulong n want
540end
541fn loadconst to bool
542if not loadnums 216 64
543ret false
544end
545for i ulong 64
546put kk i uint get nums i
547end
548if not loadnums 217 8
549ret false
550end
551for i ulong 8
552put ivs i uint get nums i
553end
554ret true
555end
556note ---- checks and identities ---------------------------------------------------------------
557note res 0 PASS, 1 FAIL, 2 INVALID
558fn check m ulong res ulong to void
559say 19
560say m
561if eq res 0
562say 20
563end
564if eq res 1
565say 21
566put gst 0 1
567end
568if eq res 2
569say 22
570put gst 1 1
571end
572newline
573end
574fn notrun m ulong to void
575say 19
576say m
577say 22
578say 54
579newline
580put gst 1 1
581end
582fn showhash to void
583say 7
584r = write 1 hexd 0 64
585say 18
586num get hsz 0
587end
588fn art c ulong to void
589say 17
590setp c
591showpb
592if hashp c
593showhash
594else
595say 16
596put gst 1 1
597end
598newline
599end
600note print an input, its digest and, when pinarg is not 0, its pin; 0 when readable and pinned
601fn ident m ulong c ulong pinarg ulong to ulong
602say m
603setp c
604showpb
605if not hashp c
606say 16
607newline
608ret 2
609end
610showhash
611if eq pinarg 0
612newline
613ret 0
614end
615say 8
616r = argread sub pinarg 100 pin 0 64
617if ne r 64
618say 10
619newline
620ret 2
621end
622q = write 1 pin 0 64
623for i ulong 64
624if ne get hexd i get pin i
625say 10
626newline
627ret 2
628end
629end
630say 9
631newline
632ret 0
633end
634fn inputs to void
635bad = ident 2 101 102
636bad = or bad ident 3 103 0
637bad = or bad ident 4 104 105
638bad = or bad ident 5 106 0
639bad = or bad ident 6 107 0
640if ne bad 0
641put gst 1 1
642end
643end
644note ---- comparator self-test ----------------------------------------------------------------
645fn wfile c ulong n ulong b0 uchar b1 uchar to void
646setp c
647fd = popen 524481
648put oth 0 b0
649put oth 1 b1
650r = write fd oth 0 n
651if ne r long n
652abort
653end
654fclo fd
655end
656fn selftest to void
657wfile 12 1 120 0
658wfile 13 1 120 0
659wfile 14 1 121 0
660wfile 15 2 120 121
661ok = same 12 13
662ok = and ok not same 12 14
663ok = and ok not same 12 15
664ok = and ok not same 15 12
665res = ulong 2
666if ok
667res = ulong 0
668end
669check 23 res
670end
671note ---- mutants: exact-once byte substitution of site w in the file at path code c ----------
672fn loadbig c ulong to void
673setp c
674fd = popen 524288
675n = ulong 0
676while true
677if eq n len big
678next = mul len big 2
679if eq next 0
680next = ulong 65536
681end
682if le next n
683abort
684end
685grown = enlarge big next
686if ne grown 0
687abort
688end
689end
690r = read fd big n sub len big n
691if lt r 0
692abort
693end
694if eq r 0
695fclo fd
696put bgn 0 n
697ret
698end
699n = add n ulong r
700end
701abort
702end
703fn sitelen w ulong to ulong
704if eq w 1
705ret len site1
706end
707ret len site2
708end
709fn siteb w ulong i ulong to uchar
710if eq w 1
711ret get site1 i
712end
713ret get site2 i
714end
715fn replen w ulong to ulong
716if eq w 1
717ret len rep1
718end
719ret len rep2
720end
721fn repb w ulong i ulong to uchar
722if eq w 1
723ret get rep1 i
724end
725ret get rep2 i
726end
727fn matchat w ulong p ulong to bool
728n = sitelen w
729if gt add p n get bgn 0
730ret false
731end
732for i ulong n
733if ne get big add p i siteb w i
734ret false
735end
736end
737ret true
738end
739note count occurrences of site w in big; spos[0] = count, spos[1] = last position
740fn findsite w ulong to void
741put spos 0 0
742for p ulong get bgn 0
743if matchat w p
744put spos 0 add get spos 0 1
745put spos 1 p
746end
747end
748end
749fn wbig fd int o ulong n ulong to void
750if gt n 0
751r = write fd big o n
752if ne r long n
753abort
754end
755end
756end
757fn mutate w ulong sc ulong dc ulong to bool
758loadbig sc
759findsite w
760if ne get spos 0 1
761say 53
762setp sc
763showpb
764newline
765ret false
766end
767say 41
768setp sc
769showpb
770newline
771setp dc
772fd = popen 524481
773p = get spos 1
774wbig fd 0 p
775for i ulong replen w
776put oth i repb w i
777end
778r = write fd oth 0 replen w
779if ne r long replen w
780abort
781end
782e = add p sitelen w
783wbig fd e sub get bgn 0 e
784fclo fd
785ret true
786end
787fn flipbin to bool
788loadbig 107
789if le get bgn 0 1000
790ret false
791end
792put big 1000 xor get big 1000 1
793setp 28
794fd = popen 524481
795wbig fd 0 get bgn 0
796fclo fd
797ret enable 28
798end
799fn prepare to void
800if not mutate 1 106 9
801put gst 1 1
802ret
803end
804c = get ctl 0
805if eq c 2
806if not mutate 2 104 29
807put gst 1 1
808ret
809end
810put osp 0 29
811end
812if eq c 3
813put srcp 0 9
814end
815if eq c 4
816if not flipbin
817put gst 1 1
818ret
819end
820put binp 0 28
821end
822end
823note ---- routes ------------------------------------------------------------------------------
824fn exe c ulong ic ulong oc ulong to ulong
825cmd c
826ret spawn ic oc
827end
828fn pair c ulong ic ulong o1 ulong o2 ulong to ulong
829x = exe c ic o1
830y = exe c ic o2
831if or ne x 0 ne y 0
832ret 2
833end
834ret 0
835end
836fn verdict2 ok bool to ulong
837if ok
838ret 0
839end
840ret 2
841end
842fn routes to void
843s = get srcp 0
844in1 = s
845if eq get ctl 0 1
846in1 = ulong 9
847end
848r = pair 101 in1 1 2
849if eq r 0
850r = verdict2 and enable 1 enable 2
851end
852check 24 r
853if ne r 0
854notrun 26
855ret
856end
857d = verdict2 same 1 2
858check 25 d
859art 1
860if ne d 0
861notrun 26
862ret
863end
864r = pair 1 s 3 4
865if eq r 0
866r = verdict2 and enable 3 enable 4
867end
868check 26 r
869if ne r 0
870ret
871end
872d = verdict2 same 3 4
873check 27 d
874art 3
875if eq d 0
876put rok 0 1
877end
878end
879fn oracle to void
880cmd 103
881for i ulong 6
882arg add 219 i
883end
884arg 225
885arg 5
886arg get osp 0
887arg 226
888x = spawn 235 36
889r = ulong 2
890if eq x 0
891r = verdict2 enable 5
892end
893check 28 r
894if ne r 0
895notrun 29
896ret
897end
898art 5
899s = get srcp 0
900cmd 5
901arg 218
902arg s
903x = spawn s 6
904cmd 5
905arg 218
906arg s
907y = spawn s 7
908r = ulong 0
909if or ne x 0 ne y 0
910r = ulong 2
911end
912check 29 r
913if ne r 0
914ret
915end
916d = verdict2 same 6 7
917check 30 d
918art 6
919if eq d 0
920put rok 1 1
921end
922end
923fn fail1 eqv bool to ulong
924if eqv
925ret 0
926end
927ret 1
928end
929fn subject to void
930b = get binp 0
931x = exe b get srcp 0 8
932r = ulong 0
933if ne x 0
934r = ulong 1
935end
936check 31 r
937if eq r 0
938check 32 fail1 same 8 b
939art 8
940else
941check 32 1
942end
943end
944fn ddc to void
945b = get binp 0
946if ne get rok 0 0
947check 33 fail1 same 3 b
948say 37
949if same 1 b
950say 38
951else
952say 39
953end
954newline
955else
956notrun 33
957end
958if ne get rok 1 0
959check 34 fail1 same 6 b
960else
961notrun 34
962end
963if and ne get rok 0 0 ne get rok 1 0
964check 35 fail1 same 3 6
965else
966notrun 35
967end
968end
969fn sense to void
970x = exe 101 9 10
971r = ulong 2
972if eq x 0
973if enable 10
974r = ulong 0
975end
976end
977if eq r 0
978y = exe 10 get srcp 0 11
979if ne y 0
980r = ulong 2
981else
982if same 11 get binp 0
983r = ulong 2
984end
985end
986end
987check 36 r
988art 10
989art 11
990end
991fn verdict to int
992code = int 0
993if ne get gst 1 0
994say 44
995code = 3
996else
997if ne get gst 0 0
998say 43
999code = 1
1000else
1001say 42
1002end
1003end
1004newline
1005if ne get ctl 0 0
1006if eq code 0
1007say 45
1008newline
1009ret 4
1010end
1011say 46
1012newline
1013end
1014ret code
1015end
1016note ---- main --------------------------------------------------------------------------------
1017fn control to bool
1018r = argread 9 oth 0 4095
1019if lt r 1
1020ret false
1021end
1022n = ulong r
1023for k ulong 5
1024pclear
1025pword add 30 k
1026hit = eq get pn 0 n
1027if hit
1028for i ulong n
1029if ne get pb i get oth i
1030hit = false
1031end
1032end
1033end
1034if hit
1035put ctl 0 add k 1
1036ret true
1037end
1038end
1039ret false
1040end
1041fn usage to int
1042say 47
1043newline
1044ret 90
1045end
1046fn main to int
1047if and ne argcnt 9 ne argcnt 10
1048ret usage
1049end
1050r = argread 8 scr 0 4094
1051if lt r 1
1052ret usage
1053end
1054n = ulong r
1055if eq argcnt 10
1056if not control
1057ret usage
1058end
1059end
1060if ne makedir scr 0 n 448 0
1061say 48
1062newline
1063ret 91
1064end
1065put scr n 47
1066put scn 0 add n 1
1067put srcp 0 106
1068put binp 0 107
1069put osp 0 104
1070if not loadconst
1071say 49
1072newline
1073ret 3
1074end
1075say 1
1076newline
1077if ne get ctl 0 0
1078say 40
1079pclear
1080pword add 29 get ctl 0
1081showpb
1082newline
1083end
1084inputs
1085if ne get gst 1 0
1086ret verdict
1087end
1088selftest
1089if ne get gst 1 0
1090ret verdict
1091end
1092prepare
1093if ne get gst 1 0
1094ret verdict
1095end
1096routes
1097oracle
1098subject
1099ddc
1100sense
1101ret verdict
1102end