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
omega-mv / seed / qualification / security673 / game / io.om
| 1 | note SC1-G transport only. No transition or invariant code is shared. |
| 2 | global wire uchar 4096 |
| 3 | global pos ulong 1 |
| 4 | global avail ulong 1 |
| 5 | global digits uchar 32 |
| 6 | global samples ulong 101 |
| 7 | text nl "\n" |
| 8 | text sp " " |
| 9 | text tags "construct_ns=\nsolve_ns=\ncheck_ns=\nstates=\nedges=\nwinning=\nrounds=\narray_bytes=\nPASS SC1-G-v3 finite model only\nFAIL QUANTIFIER_CLOSURE\nFAIL OMITTED_DISTURBANCE_CLOSURE\nFAIL FRESHNESS_AT_RENAME\nFAIL UNCERTAIN_REFUND\nFAIL SELECTED_NOT_SAFE\nFAIL EARLY_STOP_CLOSURE\nFAIL CERTIFICATE\nPASS certified serial witnesses empty-set costs\nFAIL PAIRED_PRODUCT\ndistinct_hidden_states=\ndistinct_hidden_edges=\nsample_ns=\np50_ns=\np95_ns=\np99_ns=\nidentical_zero_states=\nidentical_zero_edges=\nWITNESS source action disturbance raw effective\nFAIL TRANSITION_CONFORMANCE\nFAIL CLOSURE\nFAIL SOURCE_INVARIANT\nFAIL DISABLED_ACTION\nFAIL EXACTNESS\nFAIL SELECTION_COST\n" |
| 10 | fn label id uint to void |
| 11 | p = ulong 0 |
| 12 | n = uint 0 |
| 13 | for j ulong len tags |
| 14 | if eq get tags j 10 |
| 15 | if eq n id |
| 16 | r = write 2 tags p add sub j p 1 |
| 17 | if ne r long add sub j p 1 |
| 18 | exit 90 |
| 19 | end |
| 20 | ret |
| 21 | end |
| 22 | n = add n 1 |
| 23 | p = add j 1 |
| 24 | end |
| 25 | end |
| 26 | exit 90 |
| 27 | end |
| 28 | fn number n ulong to void |
| 29 | p = ulong 0 |
| 30 | while ge n 10 bound 32 |
| 31 | put digits p uchar add rem n 10 48 |
| 32 | n = div n 10 |
| 33 | p = add p 1 |
| 34 | end |
| 35 | put digits p uchar add n 48 |
| 36 | p = add p 1 |
| 37 | for j ulong p |
| 38 | r = write 2 digits sub sub p j 1 1 |
| 39 | if ne r 1 |
| 40 | exit 90 |
| 41 | end |
| 42 | end |
| 43 | r = write 2 nl 0 1 |
| 44 | if ne r 1 |
| 45 | exit 90 |
| 46 | end |
| 47 | end |
| 48 | fn mode to uint |
| 49 | if eq argcnt 1 |
| 50 | ret 0 |
| 51 | end |
| 52 | if ne argcnt 2 |
| 53 | exit 90 |
| 54 | end |
| 55 | if ne argread 1 wire 0 1 1 |
| 56 | exit 90 |
| 57 | end |
| 58 | m = get wire 0 |
| 59 | if or lt m 48 gt m 56 |
| 60 | exit 90 |
| 61 | end |
| 62 | ret sub uint m 48 |
| 63 | end |
| 64 | fn flush to void |
| 65 | n = get pos 0 |
| 66 | if ne write 1 wire 0 n long n |
| 67 | exit 90 |
| 68 | end |
| 69 | put pos 0 0 |
| 70 | end |
| 71 | fn sendword x uint to void |
| 72 | for i ulong 4 |
| 73 | p = get pos 0 |
| 74 | put wire p uchar and shr x mul uint i 8 255 |
| 75 | put pos 0 add p 1 |
| 76 | if eq get pos 0 4096 |
| 77 | flush |
| 78 | end |
| 79 | end |
| 80 | end |
| 81 | fn recvword to uint |
| 82 | x = uint 0 |
| 83 | for i ulong 4 |
| 84 | if eq get pos 0 get avail 0 |
| 85 | n = read 0 wire 0 len wire |
| 86 | if le n 0 |
| 87 | exit 90 |
| 88 | end |
| 89 | put avail 0 ulong n |
| 90 | put pos 0 0 |
| 91 | end |
| 92 | p = get pos 0 |
| 93 | x = or x shl uint get wire p mul uint i 8 |
| 94 | put pos 0 add p 1 |
| 95 | end |
| 96 | ret x |
| 97 | end |
| 98 | fn endinput to void |
| 99 | if ne get pos 0 get avail 0 |
| 100 | exit 90 |
| 101 | end |
| 102 | if ne read 0 wire 0 len wire 0 |
| 103 | exit 90 |
| 104 | end |
| 105 | end |
| 106 | fn percentiles to void |
| 107 | for i ulong 101 |
| 108 | label 20 |
| 109 | number get samples i |
| 110 | end |
| 111 | for i ulong 101 |
| 112 | for j ulong 100 |
| 113 | if gt get samples j get samples add j 1 |
| 114 | t = get samples j |
| 115 | put samples j get samples add j 1 |
| 116 | put samples add j 1 t |
| 117 | end |
| 118 | end |
| 119 | end |
| 120 | label 21 |
| 121 | number get samples 50 |
| 122 | label 22 |
| 123 | number get samples 95 |
| 124 | label 23 |
| 125 | number get samples 99 |
| 126 | end |