Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/bench/omc_efficiency/kernels/om2/branch.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / bench / omc_efficiency / kernels / om2 / branch.om` 45 lines ยท 880 bytes Raw Blame History 1 note branch: Collatz steps to reach 1 for every start 1 .. `1000000`; prints the total steps and the 2 note largest step count. Data-dependent branch in a bounded while. 3 note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without 4 note start-up and output) as one decimal line on stderr; stdout is unchanged. 5 om2 6 global obuf uchar 32 7 fn putnum fd int v ulong to void 8 put obuf 31 10 9 p = ulong 31 10 x = v 11 while gt x 9 12 p = sub p 1 13 put obuf p uchar add rem x 10 48 14 x = div x 10 15 end 16 p = sub p 1 17 put obuf p uchar add x 48 18 w = write fd obuf p sub 32 p 19 end 20 fn main to int 21 t0 = monons 22 tot = ulong 0 23 mx = ulong 0 24 for n ulong `1000000` 25 x = add n 1 26 k = ulong 0 27 while ne x 1 28 if eq and x 1 0 29 x = shr x 1 30 else 31 x = add mul x 3 1 32 end 33 k = add k 1 34 end 35 tot = add tot k 36 if gt k mx 37 mx = k 38 end 39 end 40 t1 = monons 41 putnum 2 ulong sub t1 t0 42 putnum 1 tot 43 putnum 1 mx 44 ret 0 45 end