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 / tools / crumbline_learner.om

914 lines · 18085 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3note
4note tools/crumbline_learner.om -- pure seeded OM-2 Crumbline learner binary.
5note Replaces tools/crumbline_learner.c. Composed after src/crumbline/crumbline.om.
6note Modes:
7note crumbline-learner serve the protocol on stdin/stdout
8note crumbline-learner --decode FILE decode a visible crumb file and print its shape
9
10text t_dec_flag "--decode"
11text t_dec_err "decode-error "
12text t_ok_enc "ok enc="
13text t_sp_in " in="
14text t_sp_out " out="
15text t_sp_n " n="
16text t_sp_bud " budget="
17text t_bar " |"
18text t_arr " ->"
19
20global g_arg1 uchar 256
21global g_path uchar 1024
22global g_out uchar 8192
23global g_outn ulong 1
24global g_io uchar 4096
25global g_hdr uchar 8
26global g_evbuf uchar 82000
27global g_evcnt ulong 1
28global g_evfail ulong 1
29global g_wbuf uchar 4096
30global g_wlen ulong 1
31
32fn lo_c c uchar to void
33 n = get g_outn 0
34 if lt n 8191
35 put g_out n c
36 put g_outn 0 add n 1
37 end
38end
39
40fn lo_s s view uchar * to void
41 i = ulong 0
42 n = len s
43 while lt i n
44 lo_c get s i
45 i = add i 1
46 end
47end
48
49fn lo_u64 v ulong to void
50 tmp = new uchar 24 0
51 if eq v 0
52 lo_c 48
53 ret
54 end
55 k = ulong 0
56 while gt v 0
57 put tmp k uchar add 48 rem v 10
58 v = div v 10
59 k = add k 1
60 end
61 while gt k 0
62 k = sub k 1
63 lo_c get tmp k
64 end
65end
66
67fn lo_i64 v long to void
68 if lt v 0
69 lo_c 45
70 lo_u64 ulong neg v
71 ret
72 end
73 lo_u64 ulong v
74end
75
76fn lo_flush fd int to void
77 n = get g_outn 0
78 off = ulong 0
79 while lt off n
80 w = write fd g_out off sub n off
81 if le w 0
82 break
83 end
84 off = add off ulong w
85 end
86 put g_outn 0 0
87end
88
89fn fd_write_all fd int n ulong use_ev bool use_hdr bool to bool
90 off = ulong 0
91 while lt off n
92 w = long 0
93 if use_hdr
94 w = write fd g_hdr off sub n off
95 else
96 if use_ev
97 w = write fd g_evbuf off sub n off
98 else
99 w = write fd g_wbuf off sub n off
100 end
101 end
102 if le w 0
103 ret false
104 end
105 off = add off ulong w
106 end
107 ret true
108end
109
110fn fd_read_exact fd int n ulong to_hdr bool to bool
111 if not to_hdr
112 if lt len g_rbuf add n 1
113 _e = enlarge g_rbuf add n 1
114 end
115 end
116 got = ulong 0
117 while lt got n
118 want = sub n got
119 if gt want 4096
120 want = 4096
121 end
122 r = read fd g_io 0 want
123 if le r 0
124 ret false
125 end
126 ur = ulong r
127 i = ulong 0
128 while lt i ur
129 if to_hdr
130 put g_hdr add got i get g_io i
131 else
132 put g_rbuf add got i get g_io i
133 end
134 i = add i 1
135 end
136 got = add got ur
137 end
138 ret true
139end
140
141fn send_frame ftype ulong length ulong use_ev bool to bool
142 put g_hdr 0 uchar ftype
143 put g_hdr 1 uchar and length 255
144 put g_hdr 2 uchar and shr length 8 255
145 put g_hdr 3 uchar and shr length 16 255
146 put g_hdr 4 uchar and shr length 24 255
147 if not fd_write_all 1 5 false true
148 ret false
149 end
150 if gt length 0
151 ret fd_write_all 1 length use_ev false
152 end
153 ret true
154end
155
156fn recv_frame to long
157 if not fd_read_exact 0 5 true
158 ret neg long 1
159 end
160 ft = ulong get g_hdr 0
161 b0 = ulong get g_hdr 1
162 b1 = ulong get g_hdr 2
163 b2 = ulong get g_hdr 3
164 b3 = ulong get g_hdr 4
165 n = or or b0 shl b1 8 or shl b2 16 shl b3 24
166 if gt n 16777216
167 ret neg long 1
168 end
169 if gt n 0
170 if not fd_read_exact 0 n false
171 ret neg long 1
172 end
173 end
174 put g_rlen 0 n
175 ret long ft
176end
177
178fn wb_u8 b uchar to void
179 p = get g_wlen 0
180 if lt p 4095
181 put g_wbuf p b
182 put g_wlen 0 add p 1
183 end
184end
185
186fn wb_u16 v ulong to void
187 wb_u8 uchar and v 255
188 wb_u8 uchar and shr v 8 255
189end
190
191fn wb_u32 v ulong to void
192 wb_u8 uchar and v 255
193 wb_u8 uchar and shr v 8 255
194 wb_u8 uchar and shr v 16 255
195 wb_u8 uchar and shr v 24 255
196end
197
198fn wb_u64 v ulong to void
199 i = ulong 0
200 while lt i 8
201 wb_u8 uchar and shr v mul i 8 255
202 i = add i 1
203 end
204end
205
206fn wb_cpg1_ts slot ulong to void
207 wb_u8 67
208 wb_u8 80
209 wb_u8 71
210 wb_u8 49
211 wb_u16 1
212 n = get g_ts_n slot
213 wb_u8 uchar n
214 base = mul slot 24
215 i = ulong 0
216 while lt i n
217 wb_u8 uchar get g_ts_op add base i
218 wb_u64 get g_ts_imm add base i
219 i = add i 1
220 end
221end
222
223fn wb_cpg1_bank oi ulong to void
224 wb_u8 67
225 wb_u8 80
226 wb_u8 71
227 wb_u8 49
228 wb_u16 1
229 n = get g_bnk_sn oi
230 wb_u8 uchar n
231 base = mul oi 24
232 i = ulong 0
233 while lt i n
234 wb_u8 uchar get g_bnk_sop add base i
235 wb_u64 get g_bnk_simm add base i
236 i = add i 1
237 end
238end
239
240fn flush_events to void
241 cnt = get g_evcnt 0
242 if eq cnt 0
243 ret
244 end
245 put g_evbuf 0 uchar and cnt 255
246 put g_evbuf 1 uchar and shr cnt 8 255
247 put g_evbuf 2 uchar and shr cnt 16 255
248 put g_evbuf 3 uchar and shr cnt 24 255
249 if not send_frame 132 add 4 mul cnt 20 true
250 put g_evfail 0 1
251 end
252 put g_evcnt 0 0
253end
254
255fn emit_event to void
256 cnt = get g_evcnt 0
257 o = add 4 mul cnt 20
258 put g_evbuf o uchar get g_ev 0
259 put g_evbuf add o 1 uchar get g_ev 1
260 put g_evbuf add o 2 uchar get g_ev 2
261 put g_evbuf add o 3 uchar get g_ev 3
262 op = get g_ev 4
263 put g_evbuf add o 4 uchar and op 255
264 put g_evbuf add o 5 uchar and shr op 8 255
265 v = get g_ev 5
266 put g_evbuf add o 6 uchar and v 255
267 put g_evbuf add o 7 uchar and shr v 8 255
268 put g_evbuf add o 8 uchar and shr v 16 255
269 put g_evbuf add o 9 uchar and shr v 24 255
270 v = get g_ev 6
271 put g_evbuf add o 10 uchar and v 255
272 put g_evbuf add o 11 uchar and shr v 8 255
273 put g_evbuf add o 12 uchar and shr v 16 255
274 put g_evbuf add o 13 uchar and shr v 24 255
275 v = get g_ev 7
276 put g_evbuf add o 14 uchar and v 255
277 put g_evbuf add o 15 uchar and shr v 8 255
278 put g_evbuf add o 16 uchar and shr v 16 255
279 put g_evbuf add o 17 uchar and shr v 24 255
280 op = get g_ev 8
281 put g_evbuf add o 18 uchar and op 255
282 put g_evbuf add o 19 uchar and shr op 8 255
283 cnt = add cnt 1
284 put g_evcnt 0 cnt
285 if eq cnt 4096
286 flush_events
287 end
288end
289
290fn send_bank to bool
291 put g_wlen 0 0
292 cnt = get g_bnk_cnt 0
293 wb_u32 cnt
294 i = ulong 0
295 while lt i cnt
296 wb_u8 uchar get g_bnk_orig i
297 wb_u32 get g_bnk_ref i
298 wb_cpg1_bank i
299 i = add i 1
300 end
301 ret send_frame 130 get g_wlen 0 false
302end
303
304fn send_done to bool
305 put g_wlen 0 0
306 wb_u8 uchar get g_res 0
307 wb_u32 get g_res 1
308 i = ulong 2
309 while lt i 14
310 wb_u32 get g_res i
311 i = add i 1
312 end
313 wb_u64 get g_res 14
314 wb_u64 get g_res 15
315 ret send_frame 133 get g_wlen 0 false
316end
317
318fn submit_one nid ulong slot ulong flags ulong to void
319 oq = get g_res 10
320 if ge oq get g_cfg 3
321 put g_sr 9 1
322 ret
323 end
324 oq = add oq 1
325 put g_res 10 oq
326 if eq get g_sr 11 0
327 put g_sr 11 1
328 put g_res 13 get g_sr 8
329 end
330 put g_ev 0 CL_EV_SUBMIT
331 put g_ev 1 0
332 put g_ev 2 CL_VERIFY_PASS
333 if ne and flags 1 0
334 put g_ev 3 CL_FIT_ROBUST
335 else
336 put g_ev 3 CL_FIT_EXACT
337 end
338 put g_ev 4 0
339 put g_ev 5 nid
340 put g_ev 6 nid
341 put g_ev 7 0
342 put g_ev 8 oq
343 emit_event
344 flush_events
345 put g_wlen 0 0
346 wb_u32 nid
347 wb_u8 uchar flags
348 hyp = get g_sr 8
349 if gt hyp 255
350 hyp = 255
351 end
352 wb_u8 uchar hyp
353 wb_cpg1_ts slot
354 if not send_frame 131 get g_wlen 0 false
355 put g_sr 9 1
356 ret
357 end
358 ft = recv_frame
359 if or ne ft 3 ne get g_rlen 0 1
360 put g_sr 9 1
361 ret
362 end
363 vd = ulong get g_rbuf 0
364 if eq vd CL_VERDICT_ACCEPT
365 put g_sr 10 1
366 put g_sr 9 1
367 put g_res 0 CL_OUTCOME_SOLVED
368 put g_res 1 nid
369 put g_res 12 get g_res 2
370 else
371 if eq vd CL_VERDICT_EXHAUSTED
372 put g_sr 9 1
373 else
374 put g_res 11 add get g_res 11 1
375 end
376 end
377end
378
379fn flush_pending to void
380 np = get g_sr 6
381 i = ulong 0
382 while and lt i np eq get g_sr 9 0
383 nid = get g_pend_nid i
384 sn = get g_pend_sn i
385 put g_ts_n 0 sn
386 src = mul i 24
387 j = ulong 0
388 while lt j sn
389 put g_ts_op j get g_pend_sop add src j
390 put g_ts_imm j get g_pend_simm add src j
391 j = add j 1
392 end
393 submit_one nid 0 0
394 i = add i 1
395 end
396 put g_sr 6 0
397end
398
399fn sr_alloc_tables cap ulong tsize ulong w ulong to void
400 if lt len g_nd_id cap
401 _e = enlarge g_nd_id cap
402 _e = enlarge g_nd_par cap
403 _e = enlarge g_nd_op cap
404 _e = enlarge g_nd_nst cap
405 _e = enlarge g_nd_ins cap
406 end
407 vn = mul cap w
408 if lt len g_nd_vals vn
409 _e = enlarge g_nd_vals vn
410 end
411 if lt len g_ht_used tsize
412 _e = enlarge g_ht_h1 tsize
413 _e = enlarge g_ht_h2 tsize
414 _e = enlarge g_ht_ins tsize
415 _e = enlarge g_ht_used tsize
416 end
417 i = ulong 0
418 while lt i tsize
419 put g_ht_used i 0
420 i = add i 1
421 end
422end
423
424fn sr_record_fit pi ulong oi ulong child ulong to void
425 put g_ev 3 CL_FIT_EXACT
426 put g_res 8 add get g_res 8 1
427 if ne cl_build_steps pi oi 0 0
428 put g_ev 2 4
429 put g_res 9 add get g_res 9 1
430 ret
431 end
432 put g_ev 2 CL_VERIFY_PASS
433 put g_res 14 add get g_res 14 add get g_sr 0 32
434 cl_ts_behavior 0 0
435 nh = get g_sr 8
436 is_new = true
437 h = ulong 0
438 while lt h nh
439 ho = mul h 32
440 same = true
441 j = ulong 0
442 while lt j 32
443 if ne get g_hyps add ho j get g_dig_tmp j
444 same = false
445 break
446 end
447 j = add j 1
448 end
449 if same
450 is_new = false
451 break
452 end
453 h = add h 1
454 end
455 if and is_new lt nh 64
456 ho = mul nh 32
457 j = ulong 0
458 while lt j 32
459 put g_hyps add ho j get g_dig_tmp j
460 j = add j 1
461 end
462 put g_sr 8 add nh 1
463 end
464 np = get g_sr 6
465 if and is_new lt np 64
466 if eq np 0
467 put g_sr 7 get g_res 2
468 end
469 put g_pend_nid np child
470 sn = get g_ts_n 0
471 put g_pend_sn np sn
472 dst = mul np 24
473 j = ulong 0
474 while lt j sn
475 put g_pend_sop add dst j get g_ts_op j
476 put g_pend_simm add dst j get g_ts_imm j
477 j = add j 1
478 end
479 put g_sr 6 add np 1
480 end
481end
482
483fn sr_keep_node pi ulong oi ulong child ulong nst ulong ins ulong to void
484 cnt = get g_sr 3
485 w = get g_sr 1
486 put g_nd_id cnt child
487 put g_nd_par cnt pi
488 put g_nd_op cnt oi
489 put g_nd_nst cnt nst
490 put g_nd_ins cnt ins
491 co = mul cnt w
492 k = ulong 0
493 while lt k w
494 put g_nd_vals add co k get g_sr_scr k
495 k = add k 1
496 end
497 put g_sr 3 add cnt 1
498end
499
500fn sr_count_mm to ulong
501 n = get g_sr 0
502 mask = get g_sr 2
503 mm = ulong 0
504 k = ulong 0
505 while lt k n
506 if ne and get g_sr_scr k mask get g_crb_out mul k 8
507 mm = add mm 1
508 end
509 k = add k 1
510 end
511 ret mm
512end
513
514fn sr_check_and_keep pi ulong oi ulong child ulong lk ulong to ulong
515 mm = sr_count_mm
516 if and lt lk get g_cfg 2 lt get g_sr 3 get g_sr 4
517 sr_keep_node pi oi child add get g_nd_nst pi get g_bnk_sn oi add get g_nd_ins pi cl_bnk_op_insns oi
518 lk = add lk 1
519 else
520 put g_ev 1 CL_PRUNE_FRONTIER_CAP
521 put g_res 7 add get g_res 7 1
522 end
523 if eq mm 0
524 sr_record_fit pi oi child
525 else
526 mt = sub get g_sr 0 mm
527 if and ge mt get g_sr 17 gt mt get g_sr 13
528 put g_sr 13 mt
529 put g_sr 14 child
530 put g_sr 15 pi
531 put g_sr 16 oi
532 end
533 end
534 ret lk
535end
536
537fn sr_expand_op pi ulong oi ulong lk ulong to ulong
538 child = get g_sr 12
539 put g_sr 12 add child 1
540 put g_ev 0 CL_EV_EXPAND
541 put g_ev 1 CL_PRUNE_NONE
542 put g_ev 2 CL_VERIFY_NOT_REACHED
543 put g_ev 3 CL_FIT_NONE
544 put g_ev 4 oi
545 put g_ev 5 get g_nd_id pi
546 put g_ev 6 child
547 put g_ev 7 0
548 put g_ev 8 0
549 nst = add get g_nd_nst pi get g_bnk_sn oi
550 ins = add get g_nd_ins pi cl_bnk_op_insns oi
551 if gt nst CL_MAX_STEPS
552 put g_ev 1 CL_PRUNE_STEP_CAP
553 emit_event
554 ret lk
555 end
556 if gt add ins 1 get g_cfg 6
557 put g_ev 1 CL_PRUNE_COST
558 put g_res 6 add get g_res 6 1
559 emit_event
560 ret lk
561 end
562 w = get g_sr 1
563 pvo = mul pi w
564 k = ulong 0
565 while lt k w
566 put g_sr_scr k cl_eval_bank_op oi get g_nd_vals add pvo k
567 k = add k 1
568 end
569 put g_ev 7 w
570 cl_hash_vals w
571 if cl_equiv_seen ins
572 put g_ev 1 CL_PRUNE_EQUIV
573 put g_res 5 add get g_res 5 1
574 emit_event
575 ret lk
576 end
577 put g_res 3 add get g_res 3 1
578 lk = sr_check_and_keep pi oi child lk
579 emit_event
580 if ne get g_sr 6 0
581 if ge get g_res 2 add get g_sr 7 get g_cfg 4
582 flush_pending
583 end
584 end
585 ret lk
586end
587
588fn sr_run_levels to void
589 ls = ulong 0
590 le_ = ulong 1
591 depth = ulong 1
592 while and le depth get g_cfg 1 eq get g_sr 9 0
593 lk = ulong 0
594 pi = ls
595 while and lt pi le_ eq get g_sr 9 0
596 put g_res 4 add get g_res 4 1
597 oi = ulong 0
598 bc = get g_bnk_cnt 0
599 while and lt oi bc eq get g_sr 9 0
600 if ge get g_res 2 get g_cfg 0
601 put g_sr 9 1
602 break
603 end
604 put g_res 2 add get g_res 2 1
605 lk = sr_expand_op pi oi lk
606 oi = add oi 1
607 end
608 pi = add pi 1
609 end
610 ls = le_
611 le_ = get g_sr 3
612 if eq ls le_
613 break
614 end
615 depth = add depth 1
616 end
617end
618
619fn cl_search_run to void
620 i = ulong 0
621 while lt i 16
622 put g_res i 0
623 i = add i 1
624 end
625 put g_res 0 CL_OUTCOME_UNSOLVED
626 put g_res 1 4294967295
627 if ne get g_crb_meta 6 0
628 b0 = get g_crb_meta 7
629 if and gt b0 0 lt b0 get g_cfg 0
630 put g_cfg 0 b0
631 end
632 b0 = get g_crb_meta 8
633 if and gt b0 0 lt b0 get g_cfg 1
634 put g_cfg 1 b0
635 end
636 b0 = get g_crb_meta 9
637 if and gt b0 0 lt b0 get g_cfg 3
638 put g_cfg 3 b0
639 end
640 end
641 if or ne get g_crb_meta 1 1 ne get g_crb_meta 2 1
642 put g_res 0 CL_OUTCOME_UNSUPPORTED
643 ret
644 end
645 cl_init_probes
646 n = get g_crb_meta 5
647 w = add n 32
648 put g_sr 0 n
649 put g_sr 1 w
650 put g_sr 2 cl_crumb_out_mask
651 cap = add mul get g_cfg 2 get g_cfg 1 1
652 if gt cap add get g_cfg 0 1
653 cap = add get g_cfg 0 1
654 end
655 tsize = ulong 1024
656 need = mul 2 add get g_cfg 0 2
657 while lt tsize need
658 tsize = shl tsize 1
659 end
660 put g_sr 4 cap
661 put g_sr 5 sub tsize 1
662 i = ulong 6
663 while lt i 14
664 put g_sr i 0
665 i = add i 1
666 end
667 put g_sr 12 1
668 rp = get g_cfg 5
669 if gt rp 0
670 put g_sr 17 div add mul n rp 99 100
671 else
672 put g_sr 17 4294967295
673 end
674 sr_alloc_tables cap tsize w
675 put g_nd_id 0 0
676 put g_nd_par 0 4294967295
677 put g_nd_op 0 65535
678 put g_nd_nst 0 0
679 put g_nd_ins 0 0
680 i = ulong 0
681 while lt i n
682 v = get g_crb_in mul i 8
683 put g_sr_inp i v
684 put g_nd_vals i v
685 put g_sr_scr i v
686 i = add i 1
687 end
688 i = ulong 0
689 while lt i 32
690 v = get g_probes i
691 put g_nd_vals add n i v
692 put g_sr_scr add n i v
693 i = add i 1
694 end
695 cl_hash_vals w
696 _seen = cl_equiv_seen 0
697 put g_sr 3 1
698 sr_run_levels
699 if eq get g_sr 10 0
700 if ne get g_sr 6 0
701 put g_sr 9 0
702 flush_pending
703 end
704 end
705 if eq get g_sr 10 0
706 if gt get g_sr 13 0
707 if lt get g_res 10 get g_cfg 3
708 if eq cl_build_steps get g_sr 15 get g_sr 16 0 0
709 put g_sr 9 0
710 submit_one get g_sr 14 0 1
711 end
712 end
713 end
714 end
715end
716
717fn print_decoded_crumb to void
718 lo_s t_ok_enc
719 lo_u64 get g_crb_meta 0
720 lo_s t_sp_in
721 lo_u64 get g_crb_meta 1
722 lo_c 120
723 lo_u64 get g_crb_meta 3
724 lo_s t_sp_out
725 lo_u64 get g_crb_meta 2
726 lo_c 120
727 lo_u64 get g_crb_meta 4
728 lo_s t_sp_n
729 n = get g_crb_meta 5
730 lo_u64 n
731 if ne get g_crb_meta 6 0
732 lo_s t_sp_bud
733 lo_u64 get g_crb_meta 7
734 lo_c 44
735 lo_u64 get g_crb_meta 8
736 lo_c 44
737 lo_u64 get g_crb_meta 9
738 lo_c 44
739 lo_u64 get g_crb_meta 10
740 end
741 ia = get g_crb_meta 1
742 oa = get g_crb_meta 2
743 i = ulong 0
744 while lt i n
745 lo_s t_bar
746 l = ulong 0
747 while lt l ia
748 lo_c 32
749 lo_u64 get g_crb_in add mul i 8 l
750 l = add l 1
751 end
752 lo_s t_arr
753 l = ulong 0
754 while lt l oa
755 lo_c 32
756 lo_u64 get g_crb_out add mul i 8 l
757 l = add l 1
758 end
759 i = add i 1
760 end
761 lo_c 10
762 lo_flush 1
763end
764
765fn decode_file plen ulong to int
766 fd = fopen g_path 0 plen 0 0
767 if lt fd 0
768 ret 1
769 end
770 if lt len g_rbuf 65536
771 _e = enlarge g_rbuf 65536
772 end
773 tot = ulong 0
774 while true
775 r = read int fd g_io 0 4096
776 if le r 0
777 break
778 end
779 ur = ulong r
780 if lt len g_rbuf add add tot ur 1
781 _e = enlarge g_rbuf mul add add tot ur 1 2
782 end
783 i = ulong 0
784 while lt i ur
785 put g_rbuf add tot i get g_io i
786 i = add i 1
787 end
788 tot = add tot ur
789 end
790 _fc = fclose int fd
791 rc = cl_crumb_decode tot
792 if ne rc 0
793 lo_s t_dec_err
794 lo_i64 rc
795 lo_c 10
796 lo_flush 1
797 ret 1
798 end
799 print_decoded_crumb
800 ret 0
801end
802
803fn serve_loop to int
804 put g_cfg 0 20000
805 put g_cfg 1 6
806 put g_cfg 2 4000
807 put g_cfg 3 4
808 put g_cfg 4 400
809 put g_cfg 5 75
810 put g_cfg 6 80
811 lib_on = false
812 put g_lib_cnt 0 0
813 while true
814 ft = recv_frame
815 if lt ft 0
816 ret 2
817 end
818 cl_r_init get g_rlen 0
819 if eq ft 1
820 if ne cl_r_u16 1
821 ret 2
822 end
823 lib_on = ne cl_r_u8 0
824 put g_cfg 0 cl_r_u32
825 put g_cfg 1 cl_r_u32
826 put g_cfg 2 cl_r_u32
827 put g_cfg 3 cl_r_u32
828 put g_cfg 4 cl_r_u32
829 put g_cfg 5 cl_r_u32
830 if not cl_r_done
831 ret 2
832 end
833 put g_wbuf 0 1
834 put g_wbuf 1 0
835 if not send_frame 129 2 false
836 ret 2
837 end
838 continue
839 end
840 if eq ft 4
841 oref = cl_r_u32
842 sc = cl_r_u8
843 if or ne cl_decode_cpg1_to_ts 0 0 not cl_r_done
844 ret 2
845 end
846 if lib_on
847 cl_lib_admit_ts 0 sc oref
848 end
849 continue
850 end
851 if eq ft 2
852 rc = cl_crumb_decode get g_rlen 0
853 if ne rc 0
854 i = ulong 0
855 while lt i 16
856 put g_res i 0
857 i = add i 1
858 end
859 put g_res 0 CL_OUTCOME_UNSUPPORTED
860 put g_res 1 4294967295
861 if or not send_bank not send_done
862 ret 2
863 end
864 continue
865 end
866 cl_bank_init_base
867 if lib_on
868 cl_lib_export cl_crumb_input_bits
869 end
870 if not send_bank
871 ret 2
872 end
873 put g_evcnt 0 0
874 put g_evfail 0 0
875 cl_search_run
876 flush_events
877 if or ne get g_evfail 0 0 not send_done
878 ret 2
879 end
880 continue
881 end
882 if eq ft 5
883 ret 0
884 end
885 ret 2
886 end
887 ret 0
888end
889
890fn main to int
891 ac = argcnt
892 if eq ac 3
893 l1 = argread 1 g_arg1 0 255
894 l2 = argread 2 g_path 0 1023
895 if and eq l1 8 ge l2 0
896 ok = true
897 i = ulong 0
898 while lt i 8
899 if ne get g_arg1 i get t_dec_flag i
900 ok = false
901 break
902 end
903 i = add i 1
904 end
905 if ok
906 ret decode_file ulong l2
907 end
908 end
909 end
910 if ne ac 1
911 ret 64
912 end
913 ret serve_loop
914end