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 / ng / bench / kernels / sort.c
| 1 | /* sort.c -- REFERENCE TWIN ONLY (gcc oracle) of seed/rung4/tests/sort.om: same generator, same sort. */ |
| 2 | #include <stdio.h> |
| 3 | #include <stdint.h> |
| 4 | static uint64_t a[40000]; |
| 5 | int main(void) { |
| 6 | uint64_t x = 12345, s = 0, bad = 0; |
| 7 | for (int i = 0; i < 40000; i++) { x = (x * 1103515245u + 12345u) % 2147483648u; a[i] = x % 4000000; } |
| 8 | for (int j = 0; j < 40000; j++) { uint64_t v = a[j]; int k = j; |
| 9 | while (k > 0 && a[k-1] > v) { a[k] = a[k-1]; k--; } a[k] = v; } |
| 10 | for (int i = 0; i < 40000; i++) s += a[i] * (uint64_t)(i + 1); |
| 11 | for (int i = 0; i < 39999; i++) if (a[i] > a[i+1]) bad++; |
| 12 | printf("%llu\n%llu\n%llu\n%llu\n", (unsigned long long)s, (unsigned long long)bad, |
| 13 | (unsigned long long)a[0], (unsigned long long)a[39999]); |
| 14 | return 0; |
| 15 | } |