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 / train / aien-train / native / neuralese / nl1r-task / evidence / mutant-wrong-width.om

1209 lines · 17619 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Extension of affine.om staged explicit SGD; historical bytes remain immutable.
3note Globals are bounded scratch state. Receiver never reads NX or NT.
4global NP f64 83
5global NG f64 83
6global NC f64 83
7global NX f64 4
8global NT f64 4
9global NA f64 4
10global NH f64 4
11global NZ f64 4
12global NO f64 4
13global ND f64 4
14global NU f64 8
15global NV f64 8
16global NE f64 8
17global NSH ulong 4
18global RNG ulong 1
19
20fn nsoft x f64 to f64
21ret div x add 1.0f64 fabs x
22end
23fn nslope x f64 to f64
24d = add 1.0f64 fabs x
25ret div 1.0f64 mul d d
26end
27fn nrelu x f64 to f64
28if gt x 0.0f64
29ret x
30end
31ret 0.0f64
32end
33fn nshape arm ulong to int
34if gt arm 3
35ret 1
36end
37put NSH 0 arm
38put NSH 1 3
39put NSH 2 31
40if eq arm 1
41put NSH 1 4
42put NSH 2 40
43end
44if eq arm 2
45put NSH 2 83
46end
47if eq arm 3
48put NSH 1 1
49put NSH 2 0
50end
51put NSH 3 0
52ret 0
53end
54fn nrand to ulong
55x = get RNG 0
56x = and xor x shl x 13 4294967295
57x = xor x shr x 17
58x = and xor x shl x 5 4294967295
59put RNG 0 x
60ret x
61end
62fn ninit seed ulong to void
63put RNG 0 seed
64for i ulong get NSH 2
65v = sub long rem nrand 33 16
66put NP i div f64 v 64.0f64
67end
68put NSH 3 0
69end
70fn ninput id ulong target ulong to void
71for j ulong 4
72put NX j f64 and shr id j 1
73put NT j f64 and shr target j 1
74end
75end
76fn nsend to void
77d = get NSH 1
78for k ulong d
79v = get NP add mul 4 d k
80for j ulong 4
81v = add v mul get NX j get NP add mul j d k
82end
83put NA k v
84put NH k nsoft v
85end
86end
87fn nhidden to void
88for k ulong 8
89v = get NP add 39 k
90for j ulong 3
91v = add v mul get NH j get NP add 15 add mul j 8 k
92end
93put NU k v
94put NV k nrelu v
95end
96end
97fn nrecv to void
98d = get NSH 1
99if eq get NSH 0 2
100nhidden
101end
102for j ulong 4
103v = 0.0f64
104if eq get NSH 0 2
105v = get NP add 79 j
106for k ulong 8
107v = add v mul get NV k get NP add 47 add mul k 4 j
108end
109else
110v = get NP add mul 9 d j
111for k ulong d
112v = add v mul get NH k get NP add mul 5 d add mul k 4 j
113end
114end
115put NZ j v
116put NO j mul 0.5f64 add 1.0f64 nsoft v
117end
118end
119fn nloss to f64
120v = 0.0f64
121for j ulong 4
122r = sub get NO j get NT j
123v = add v mul r r
124end
125ret v
126end
127fn ngout j ulong to f64
128ret mul sub get NO j get NT j nslope get NZ j
129end
130fn ngaff to void
131d = get NSH 1
132for j ulong 4
133v = ngout j
134put NG add mul 9 d j v
135for k ulong d
136p = add mul 5 d add mul k 4 j
137put NG p mul v get NH k
138put ND k add get ND k mul v get NP p
139end
140end
141end
142fn ngnon to void
143for j ulong 4
144v = ngout j
145put NG add 79 j v
146for k ulong 8
147p = add 47 add mul k 4 j
148put NG p mul v get NV k
149put NE k add get NE k mul v get NP p
150end
151end
152for k ulong 8
153v = 0.0f64
154note ReLU subgradient is exactly zero at zero.
155if gt get NU k 0.0f64
156v = get NE k
157end
158put NG add 39 k v
159for j ulong 3
160p = add 15 add mul j 8 k
161put NG p mul v get NH j
162put ND j add get ND j mul v get NP p
163end
164end
165end
166fn ngrad to void
167for i ulong get NSH 2
168put NG i 0.0f64
169end
170for k ulong 4
171put ND k 0.0f64
172end
173for k ulong 8
174put NE k 0.0f64
175end
176if eq get NSH 0 2
177ngnon
178else
179ngaff
180end
181d = get NSH 1
182for k ulong d
183v = mul get ND k nslope get NA k
184put NG add mul 4 d k v
185for j ulong 4
186put NG add mul j d k mul v get NX j
187end
188end
189end
190fn nstep lr f64 to int
191if not and ge lr 0.0f64 le lr 1.0f64
192ret 1
193end
194for i ulong get NSH 2
195v = sub get NP i mul lr get NG i
196if not le fabs v 1000000.0f64
197ret 2
198end
199put NC i v
200end
201note No parameter mutation until every candidate has passed admission.
202for i ulong get NSH 2
203put NP i get NC i
204end
205put NSH 3 add get NSH 3 1
206ret 0
207end
208fn ntrain mask ulong to int
209if eq get NSH 0 3
210ret 0
211end
212for epoch ulong 2000
213for id ulong 16
214if ne and shr mask id 1 0
215ninput id id
216nsend
217nrecv
218ngrad
219rc = nstep 0.1f64
220if ne rc 0
221ret rc
222end
223end
224end
225end
226ret 0
227end
228
229note SPDX-License-Identifier: AGPL-3.0-only
230note FINAL-C32 payload is actual little-endian bytes, not merely declared precision.
231global WB uchar 32
232global WI uchar 729
233global WH f64 4
234global AR uchar 32
235global CFG ulong 4
236text COM ","
237text NL "\n"
238text CT "C,1,"
239text PT "P,"
240text RT "R,"
241text TT "T,"
242text DONE "END\n"
243
244fn outnum n ulong to void
245v = n
246i = ulong 32
247while gt i 0 bound 33
248i = sub i 1
249put AR i uchar add rem v 10 48
250v = div v 10
251if eq v 0
252break
253end
254end
255z = write 1 AR i sub 32 i
256if ne z long sub 32 i
257exit 80
258end
259end
260fn sep to void
261z = write 1 COM 0 1
262if ne z 1
263exit 80
264end
265end
266fn newline to void
267z = write 1 NL 0 1
268if ne z 1
269exit 80
270end
271end
272fn field n ulong to void
273outnum n
274sep
275end
276fn argnum ix ulong to ulong
277n = argread ix AR 0 32
278if or le n 0 gt n 10
279exit 90
280end
281v = ulong 0
282for i ulong ulong n
283c = get AR i
284if or lt c 48 gt c 57
285exit 90
286end
287v = add mul v 10 ulong sub c 48
288end
289ret v
290end
291fn wput k ulong v ulong to void
292for b ulong 8
293put WB add mul k 8 b uchar and shr v mul b 8 255
294end
295end
296fn wget k ulong to ulong
297v = ulong 0
298for b ulong 8
299v = or v shl ulong get WB add mul k 8 b mul b 8
300end
301ret v
302end
303fn iload off ulong to ulong
304v = ulong 0
305for b ulong 8
306v = or v shl ulong get WI add off b mul b 8
307end
308ret v
309end
310fn npack to void
311for b ulong 32
312put WB b uchar 0
313end
314if eq get NSH 0 3
315put WB 0 uchar get CFG 3
316else
317for k ulong get NSH 1
318wput k bitcast ulong get NH k
319end
320end
321end
322fn ndecode schema ulong dim ulong bytes ulong codec ulong to int
323if ne schema 1
324ret 2
325end
326if or ne dim get NSH 1 ne bytes wirelen
327ret 2
328end
329if eq get NSH 0 3
330if gt get WB 0 15
331ret 2
332end
333for j ulong 4
334put NO j f64 and shr ulong get WB 0 j 1
335end
336ret 0
337end
338for k ulong dim
339v = bitcast f64 wget k
340if not le fabs v 1.0f64
341ret 2
342end
343put WH k v
344end
345note All coordinates validated before changing receiver state or output.
346for k ulong dim
347put NH k get WH k
348end
349if eq codec 2
350ncodec
351else
352nrecv
353end
354ret 0
355end
356fn wirelen to ulong
357if eq get NSH 0 3
358ret 1
359end
360ret mul get NSH 1 8
361end
362fn npert q ulong to void
363if eq get NSH 0 3
364if eq q 3
365put WB 0 xor get WB 0 uchar 1
366end
367if eq q 4
368v = ulong get WB 0
369v = or and v 12 or shl and v 1 1 shr and v 2 1
370put WB 0 uchar v
371end
372if eq q 5
373put WB 0 uchar 0
374end
375ret
376end
377for k ulong get NSH 1
378v = bitcast f64 wget k
379if or eq q 1 eq q 2
380factor = 16.0f64
381if eq q 2
382factor = 32.0f64
383end
384r = div f64 long add mul fabs v factor 0.5f64 factor
385if lt v 0.0f64
386r = neg r
387end
388v = r
389end
390if and eq q 3 eq k 0
391v = neg v
392end
393if eq q 5
394v = 0.0f64
395end
396wput k bitcast ulong v
397end
398if eq q 4
399v = wget 0
400wput 0 wget 1
401wput 1 v
402end
403end
404fn nload to int
405n = ulong 0
406while lt n 729 bound 730
407z = read 0 WI n sub 729 n
408if lt z 0
409ret 2
410end
411if eq z 0
412break
413end
414n = add n ulong z
415end
416if ne n add 64 mul get NSH 2 8
417ret 2
418end
419if or ne iload 0 1 ne iload 8 get NSH 0
420ret 2
421end
422if or ne iload 16 get NSH 1 ne iload 24 get NSH 2
423ret 2
424end
425if or ne iload 32 get CFG 0 ne iload 40 get CFG 1
426ret 2
427end
428if or ne iload 56 0 gt iload 48 32000
429ret 2
430end
431for i ulong get NSH 2
432v = bitcast f64 iload add 64 mul i 8
433if not le fabs v 1000000.0f64
434ret 2
435end
436put NC i v
437end
438for i ulong get NSH 2
439put NP i get NC i
440end
441put NSH 3 iload 48
442ret 0
443end
444fn nconstruct mode ulong to int
445for i ulong get NSH 2
446put NP i 0.0f64
447end
448if eq mode 1
449if ne get NSH 0 1
450ret 2
451end
452for j ulong 4
453put NP add mul j 4 j 2.0f64
454put NP add 16 j -1.0f64
455put NP add 20 add mul j 4 j 1.0f64
456end
457ret 0
458end
459if or ne get NSH 0 2 not or eq mode 2 eq mode 3
460ret 2
461end
462if eq mode 2
463ret 0
464end
465put NP 0 2.0f64
466put NP 3 1.0f64
467put NP 7 1.0f64
468put NP 11 1.0f64
469put NP 15 1.0f64
470put NP 16 1.0f64
471put NP 17 1.0f64
472put NP 26 1.0f64
473put NP 35 1.0f64
474put NP 40 -0.5f64
475put NP 41 neg div 2.0f64 3.0f64
476put NP 51 12.0f64
477put NP 55 -12.0f64
478put NP 48 4.0f64
479put NP 52 -16.0f64
480put NP 56 36.0f64
481put NP 61 4.0f64
482put NP 66 4.0f64
483for j ulong 4
484put NP add 79 j -1.0f64
485end
486ret 0
487end
488fn ncodec to void
489t = mul get NH 0 3.0f64
490a = nrelu sub t 1.0f64
491b = nrelu sub t 2.0f64
492put NO 0 sub a b
493put NO 1 add sub t mul 2.0f64 a mul 2.0f64 b
494put NO 2 get NH 1
495put NO 3 get NH 2
496end
497fn codeenc to void
498put NH 0 div add mul 2.0f64 get NX 0 get NX 1 3.0f64
499put NH 1 get NX 2
500put NH 2 get NX 3
501end
502
503note SPDX-License-Identifier: AGPL-3.0-only
504note Frozen NL6-NL1R-20261028-1; imports unchanged capacity.om and wire.om.
505note TC is shared task, seed, split; receiver reads only task plus explicit context.
506global TC ulong 3
507global TL ulong 1
508
509fn tpar id ulong to ulong
510ret and xor xor id shr id 1 xor shr id 2 shr id 3 1
511end
512fn tactive j ulong to bool
513if eq get TC 0 1
514ret eq j 0
515end
516if eq get TC 0 2
517ret ge j 2
518end
519ret true
520end
521fn tprep id ulong to void
522ninput id id
523if eq get TC 0 1
524put NT 0 f64 tpar id
525end
526nsend
527nrecv
528note Inactive residuals are zero; their targets are not learned or communicated.
529for j ulong 4
530if not tactive j
531put NT j get NO j
532end
533end
534end
535fn tloss id ulong to f64
536tprep id
537ret nloss
538end
539fn ttrain mask ulong to int
540for epoch ulong 2000
541for id ulong 16
542if ne and shr mask id 1 0
543tprep id
544ngrad
545rc = nstep 0.1f64
546if ne rc 0
547ret rc
548end
549end
550end
551end
552ret 0
553end
554fn tclear to void
555for i ulong 32
556put WB i uchar 0
557end
558put TL 0 0
559end
560fn tencode id ulong arm ulong variant ulong to int
561tclear
562if or gt id 15 or gt arm 4 gt variant 2
563ret 2
564end
565if or eq variant 2 eq arm 3
566ret 0
567end
568src = id
569if eq variant 1
570src = and add id 1 15
571end
572if eq arm 0
573v = src
574if eq get TC 0 1
575v = tpar src
576end
577if eq get TC 0 2
578v = shr src 2
579end
580put WB 0 uchar v
581put TL 0 1
582ret 0
583end
584if eq arm 4
585for j ulong 4
586put WB j uchar add and shr src j 1 48
587end
588put TL 0 4
589ret 0
590end
591ninput src src
592nsend
593v = ulong 0
594for j ulong 4
595h = get NH j
596if not le fabs h 1.0f64
597ret 2
598end
599q = ulong 0
600if eq arm 1
601note Exact frozen inference quantizer; not a straight-through training rule.
602r = add div mul 3.0f64 add h 1.0f64 2.0f64 0.5f64
603q = ulong r
604if gt q 3
605q = 3
606end
607v = or v shl q mul j 2
608else
609if ge h 0.0f64
610q = 1
611end
612v = or v shl q j
613end
614end
615put WB 0 uchar v
616put TL 0 1
617ret 0
618end
619fn tcanon context ulong to void
620if eq get TC 0 1
621for j ulong 3
622put NO add j 1 0.0f64
623end
624end
625if eq get TC 0 2
626put NO 0 f64 and context 1
627put NO 1 f64 and shr context 1 1
628end
629end
630fn tbits value ulong context ulong to void
631for j ulong 4
632put NO j f64 and shr value j 1
633end
634tcanon context
635end
636fn tvalid arm ulong variant ulong context ulong bytes ulong to bool
637if or gt get TC 0 2 or gt arm 4 gt variant 2
638ret false
639end
640if eq variant 2
641ret false
642end
643if eq get TC 0 2
644if gt context 3
645ret false
646end
647else
648if ne context 0
649ret false
650end
651end
652want = ulong 1
653if eq arm 3
654want = 0
655end
656if eq arm 4
657want = 4
658end
659ret eq bytes want
660end
661fn tdecode schema ulong arm ulong variant ulong context ulong bytes ulong effect ulong to int
662note No sample ID, sender NX/NT, or training mask is consulted by this receiver.
663if or ne schema 2 ne effect 0
664ret 2
665end
666if ne get NSH 0 1
667ret 2
668end
669note MUTANT removed width check
670if ne get NSH 2 40
671ret 2
672end
673if not tvalid arm variant context bytes
674ret 2
675end
676ret treceive arm context
677end
678fn treceive arm ulong context ulong to int
679v = ulong get WB 0
680if eq arm 0
681limit = ulong 15
682if eq get TC 0 1
683limit = 1
684end
685if eq get TC 0 2
686limit = 3
687end
688if gt v limit
689ret 2
690end
691if eq get TC 0 2
692v = shl v 2
693end
694tbits v context
695ret 0
696end
697if eq arm 4
698v = 0
699for j ulong 4
700c = get WB j
701if not or eq c 48 eq c 49
702ret 2
703end
704v = or v shl ulong sub c 48 j
705end
706if eq get TC 0 1
707v = tpar v
708end
709tbits v context
710ret 0
711end
712if and eq arm 2 gt v 15
713ret 2
714end
715for j ulong 4
716h = 0.0f64
717if eq arm 1
718q = and shr v mul j 2 3
719h = div sub mul 2.0f64 f64 q 3.0f64 3.0f64
720end
721if eq arm 2
722h = sub mul 2.0f64 f64 and shr v j 1 1.0f64
723end
724put WH j h
725end
726note All schema, context, shape and bytes validated before output/state commit.
727for j ulong 4
728put NH j get WH j
729end
730nrecv
731tcanon context
732ret 0
733end
734fn tabst rc int to ulong
735if ne rc 0
736ret 1
737end
738for j ulong 4
739if and tactive j lt fabs sub get NO j 0.5f64 0.1f64
740ret 1
741end
742end
743ret 0
744end
745
746note SPDX-License-Identifier: AGPL-3.0-only
747note Central differences at strictly positive hidden preactivations; separate kink policy.
748global GB f64 83
749global GV f64 83
750text GT "G,"
751text PASS "CONTROLS PASS\n"
752fn ginit to void
753for i ulong get NSH 2
754v = div f64 add i 1 128.0f64
755put NP i v
756put GB i v
757end
758ninput 5 5
759end
760fn geval to f64
761nsend
762nrecv
763ret nloss
764end
765fn gcheck to int
766ginit
767v = geval
768ngrad
769for i ulong get NSH 2
770put GV i get NG i
771end
772for i ulong get NSH 2
773put NP i add get GB i 0.000001f64
774plus = geval
775put NP i sub get GB i 0.000001f64
776minus = geval
777put NP i get GB i
778diff = div sub plus minus 0.000002f64
779if gt fabs sub diff get GV i 0.00000001f64
780ret 61
781end
782end
783for i ulong get NSH 2
784put NG i get GV i
785end
786rc = nstep 0.1f64
787if ne rc 0
788ret 62
789end
790for i ulong get NSH 2
791wanted = sub get GB i mul 0.1f64 get GV i
792if gt fabs sub get NP i wanted 0.000000000001f64
793ret 63
794end
795z = write 1 GT 0 len GT
796if ne z long len GT
797ret 80
798end
799field get NSH 0
800field i
801field bitcast ulong get GB i
802field bitcast ulong get GV i
803outnum bitcast ulong get NP i
804newline
805end
806ret 0
807end
808fn atomic to int
809ginit
810for i ulong get NSH 2
811put NG i 1.0f64
812end
813put NG sub get NSH 2 1 div 0.0f64 0.0f64
814rc = nstep 0.1f64
815if ne rc 2
816ret 64
817end
818for i ulong get NSH 2
819if ne get NP i get GB i
820ret 65
821end
822end
823rc = nstep -0.1f64
824if ne rc 1
825ret 66
826end
827rc = nstep div 1.0f64 0.0f64
828if ne rc 1
829ret 67
830end
831if ne get NSH 3 0
832ret 68
833end
834ret 0
835end
836fn refuses to int
837for j ulong 4
838put NO j -77.0f64
839put NH j 0.0f64
840end
841npack
842rc = ndecode 0 get NSH 1 wirelen 0
843if ne rc 2
844ret 41
845end
846rc = ndecode 1 add get NSH 1 1 wirelen 0
847if ne rc 2
848ret 42
849end
850rc = ndecode 1 get NSH 1 add wirelen 1 0
851if ne rc 2
852ret 43
853end
854for mode ulong 3
855v = 2.0f64
856if eq mode 0
857v = div 0.0f64 0.0f64
858end
859if eq mode 1
860v = div 1.0f64 0.0f64
861end
862wput sub get NSH 1 1 bitcast ulong v
863rc = ndecode 1 get NSH 1 wirelen 0
864if ne rc 2
865ret 44
866end
867for j ulong 4
868if ne get NO j -77.0f64
869ret 45
870end
871end
872end
873ret 0
874end
875fn kink to int
876ginit
877v = geval
878for k ulong 8
879put NU k 0.0f64
880put NV k 0.0f64
881end
882ngrad
883for i ulong 47
884if ne get NG i 0.0f64
885ret 69
886end
887end
888for k ulong 8
889put NU k -1.0f64
890end
891ngrad
892for i ulong 47
893if ne get NG i 0.0f64
894ret 70
895end
896end
897ret 0
898end
899fn dcontrol to int
900put CFG 3 15
901npack
902rc = ndecode 1 1 1 0
903if ne rc 0
904ret 71
905end
906for j ulong 4
907if ne get NO j 1.0f64
908ret 72
909end
910end
911put WB 0 uchar 0
912rc = ndecode 1 1 1 0
913for j ulong 4
914if ne get NO j 0.0f64
915ret 73
916end
917end
918put WB 0 uchar 16
919rc = ndecode 1 1 1 0
920if ne rc 2
921ret 74
922end
923ret 0
924end
925fn controls to int
926if eq get NSH 0 3
927ret dcontrol
928end
929rc = gcheck
930if ne rc 0
931ret rc
932end
933put NSH 3 0
934rc = atomic
935if ne rc 0
936ret rc
937end
938rc = refuses
939if ne rc 0
940ret rc
941end
942if eq get NSH 0 2
943rc = kink
944if ne rc 0
945ret rc
946end
947end
948z = write 1 PASS 0 len PASS
949if ne z long len PASS
950ret 80
951end
952ret 0
953end
954
955note SPDX-License-Identifier: AGPL-3.0-only
956note Imports unchanged capacity controls for bounded GB/GV and ginit.
957fn tgcheck to int
958ginit
959v = tloss 5
960ngrad
961for j ulong 4
962if not tactive j
963if ne get NG add 36 j 0.0f64
964ret 60
965end
966end
967end
968for i ulong 40
969put GV i get NG i
970end
971for i ulong 40
972put NP i add get GB i 0.000001f64
973plus = tloss 5
974put NP i sub get GB i 0.000001f64
975minus = tloss 5
976put NP i get GB i
977diff = div sub plus minus 0.000002f64
978if gt fabs sub diff get GV i 0.00000001f64
979ret 61
980end
981end
982for i ulong 40
983put NG i get GV i
984end
985rc = nstep 0.1f64
986if ne rc 0
987ret 62
988end
989for i ulong 40
990wanted = sub get GB i mul 0.1f64 get GV i
991if gt fabs sub get NP i wanted 0.000000000001f64
992ret 63
993end
994z = write 1 GT 0 len GT
995if ne z long len GT
996ret 80
997end
998field get TC 0
999field i
1000field bitcast ulong get GB i
1001field bitcast ulong get GV i
1002outnum bitcast ulong get NP i
1003newline
1004end
1005ret 0
1006end
1007fn tsentin to void
1008for j ulong 4
1009put NO j -77.0f64
1010put NH j -66.0f64
1011end
1012end
1013fn tstay rc int to void
1014if ne rc 2
1015exit 41
1016end
1017for j ulong 4
1018if or ne get NO j -77.0f64 ne get NH j -66.0f64
1019exit 42
1020end
1021end
1022end
1023fn trefuse to void
1024put TC 0 0
1025tclear
1026put TL 0 1
1027tsentin
1028rc = tdecode 1 0 0 0 1 0
1029tstay rc
1030rc = tdecode 2 0 0 0 1 1
1031tstay rc
1032rc = tdecode 2 0 0 0 0 0
1033tstay rc
1034rc = tdecode 2 0 0 0 2 0
1035tstay rc
1036rc = tdecode 2 0 2 0 0 0
1037tstay rc
1038rc = tdecode 2 0 0 1 1 0
1039tstay rc
1040rc = tdecode 2 5 0 0 1 0
1041tstay rc
1042put NSH 1 3
1043rc = tdecode 2 0 0 0 1 0
1044tstay rc
1045put NSH 1 4
1046put NSH 2 31
1047rc = tdecode 2 0 0 0 1 0
1048tstay rc
1049put NSH 2 40
1050put TC 0 2
1051rc = tdecode 2 0 0 4 1 0
1052tstay rc
1053put TC 0 3
1054rc = tdecode 2 0 0 0 1 0
1055tstay rc
1056put TC 0 0
1057end
1058fn ttarget id ulong context ulong to ulong
1059if eq get TC 0 1
1060ret tpar id
1061end
1062if eq get TC 0 2
1063ret or and id 12 context
1064end
1065ret id
1066end
1067fn texact want ulong to void
1068for j ulong 4
1069if ne get NO j f64 and shr want j 1
1070exit 51
1071end
1072end
1073end
1074fn twitness to void
1075rc = nconstruct 1
1076if ne rc 0
1077exit 52
1078end
1079for task ulong 3
1080put TC 0 task
1081for id ulong 16
1082context = ulong 0
1083if eq task 2
1084context = and id 3
1085end
1086for arm ulong 5
1087for variant ulong 3
1088rc = tencode id arm variant
1089if ne rc 0
1090exit 53
1091end
1092note Destroy all sender-private inputs before receiving the actual byte carrier.
1093for j ulong 4
1094put NX j div 0.0f64 0.0f64
1095put NT j div 0.0f64 0.0f64
1096end
1097rc = tdecode 2 arm variant context get TL 0 0
1098if eq variant 2
1099if ne rc 2
1100exit 54
1101end
1102else
1103if ne rc 0
1104exit 55
1105end
1106src = id
1107if eq variant 1
1108src = and add id 1 15
1109end
1110if or eq arm 0 eq arm 4
1111texact ttarget src context
1112end
1113if and eq task 0 or eq arm 1 eq arm 2
1114for j ulong 4
1115p = ulong 0
1116if ge get NO j 0.5f64
1117p = 1
1118end
1119if ne p and shr src j 1
1120exit 56
1121end
1122end
1123if ne tabst rc 0
1124exit 57
1125end
1126end
1127end
1128end
1129end
1130end
1131end
1132end
1133fn tbytes to void
1134for task ulong 3
1135put TC 0 task
1136limit = ulong 15
1137if eq task 1
1138limit = 1
1139end
1140if eq task 2
1141limit = 3
1142end
1143for value ulong 256
1144tclear
1145put WB 0 uchar value
1146tsentin
1147rc = tdecode 2 0 0 0 1 0
1148if gt value limit
1149tstay rc
1150else
1151if ne rc 0
1152exit 58
1153end
1154end
1155tsentin
1156rc = tdecode 2 2 0 0 1 0
1157if gt value 15
1158tstay rc
1159else
1160if ne rc 0
1161exit 59
1162end
1163end
1164rc = tdecode 2 1 0 0 1 0
1165if ne rc 0
1166exit 64
1167end
1168end
1169for pos ulong 4
1170for value ulong 256
1171tclear
1172for j ulong 4
1173put WB j uchar 48
1174end
1175put WB pos uchar value
1176tsentin
1177rc = tdecode 2 4 0 0 4 0
1178if or eq value 48 eq value 49
1179if ne rc 0
1180exit 65
1181end
1182else
1183tstay rc
1184end
1185end
1186end
1187end
1188end
1189fn main to int
1190rc = nshape 1
1191if ne rc 0
1192ret rc
1193end
1194for task ulong 3
1195put TC 0 task
1196rc = tgcheck
1197if ne rc 0
1198ret rc
1199end
1200end
1201trefuse
1202twitness
1203tbytes
1204z = write 1 PASS 0 len PASS
1205if ne z long len PASS
1206ret 80
1207end
1208ret 0
1209end