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 / seed / qualification / security673 / branch-corpus.om

114 lines · 2599 bytes Raw Blame History
1note Synthetic source generator for issue669. Reads one mode byte and a 4-byte little-endian repetition
2note count on stdin, then writes one program. Mode0 if over the body, mode1 nested if, mode2 while over
3note the body, mode3 a trap followed by the body. Modes 0..3 end with a unique mov x1, 12345 marker whose
4note address is the expected forward branch target. Mode4 is a while whose body is the statements and then
5note `if eq z 1` / continue: that continue is a backward B.cond to the loop head, which loads 12345 into
6note x4 (mov x4, 12345); it runs once, so a correct program exits 0. Only synthetic source is produced.
7global arg uchar 5
8global extra uchar 1
9text pre0 "fn main to int\nx = ulong 0\ny = ulong 0\nif eq x 1\n"
10text pre1 "fn main to int\nx = ulong 0\ny = ulong 0\nif eq x 1\nif eq x 2\n"
11text pre2 "fn main to int\nx = ulong 0\ny = ulong 0\nwhile eq x 1\n"
12text pre3 "fn main to int\nx = ulong 1\ny = ulong 0\nz = div x 0\n"
13text pre4 "fn main to int\nx = ulong 0\ny = ulong 0\nz = ulong 0\nwhile lt y 12345\nz = add z 1\n"
14text stmt "x = add x 1\n"
15text post0 "end\ny = ulong 12345\nret int x\nend\n"
16text post1 "end\nend\ny = ulong 12345\nret int x\nend\n"
17text post2 "end\ny = ulong 12345\nret int x\nend\n"
18text post3 "y = ulong 12345\nret int x\nend\n"
19text post4 "if eq z 1\ncontinue\nend\nbreak\nend\nret int sub z 2\nend\n"
20fn main to int
21pos = ulong 0
22while lt pos 5
23r = read 0 arg pos sub 5 pos
24if le r 0
25ret 90
26end
27pos = add pos ulong r
28end
29mode = ulong get arg 0
30if gt mode 4
31ret 90
32end
33if ne read 0 extra 0 1 0
34ret 90
35end
36n = ulong 0
37i = ulong 0
38while lt i 4
39b = ulong get arg add i 1
40n = or n shl b mul i 8
41i = add i 1
42end
43if gt n 600000
44ret 90
45end
46if eq mode 0
47r = write 1 pre0 0 len pre0
48if ne r long len pre0
49ret 91
50end
51else
52if eq mode 1
53r = write 1 pre1 0 len pre1
54if ne r long len pre1
55ret 91
56end
57else
58if eq mode 2
59r = write 1 pre2 0 len pre2
60if ne r long len pre2
61ret 91
62end
63else
64if eq mode 3
65r = write 1 pre3 0 len pre3
66if ne r long len pre3
67ret 91
68end
69else
70r = write 1 pre4 0 len pre4
71if ne r long len pre4
72ret 91
73end
74end
75end
76end
77end
78i = ulong 0
79while lt i n
80r = write 1 stmt 0 len stmt
81if ne r long len stmt
82ret 91
83end
84i = add i 1
85end
86r = long 0
87expected = ulong 0
88if eq mode 0
89r = write 1 post0 0 len post0
90expected = len post0
91else
92if eq mode 1
93r = write 1 post1 0 len post1
94expected = len post1
95else
96if eq mode 2
97r = write 1 post2 0 len post2
98expected = len post2
99else
100if eq mode 3
101r = write 1 post3 0 len post3
102expected = len post3
103else
104r = write 1 post4 0 len post4
105expected = len post4
106end
107end
108end
109end
110if ne r long expected
111ret 91
112end
113ret 0
114end