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