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 / bench / omc_efficiency / kernels / branch.om

44 lines · 871 bytes Raw Blame History
1note branch: Collatz steps to reach 1 for every start 1 .. 1000000; prints the total steps and the
2note largest step count. Data-dependent branch in a bounded while.
3note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without
4note start-up and output) as one decimal line on stderr; stdout is unchanged.
5global out uchar 32
6fn putnum fd int v ulong to void
7put out 31 10
8p = ulong 31
9x = v
10while gt x 9
11p = sub p 1
12put out p uchar add rem x 10 48
13x = div x 10
14end
15p = sub p 1
16put out p uchar add x 48
17w = write fd out p sub 32 p
18end
19fn main to int
20t0 = monons
21tot = ulong 0
22mx = ulong 0
23for n ulong 1000000
24x = add n 1
25k = ulong 0
26while ne x 1
27if eq and x 1 0
28x = shr x 1
29else
30x = add mul x 3 1
31end
32k = add k 1
33end
34tot = add tot k
35if gt k mx
36mx = k
37end
38end
39t1 = monons
40putnum 2 ulong sub t1 t0
41putnum 1 tot
42putnum 1 mx
43ret 0
44end