Jnsc - Janus Compiler Tools

Select a program in the list below or write your own

procedure main() int x int y int z int a int b int c[5] x += 100 y += 150 call f(x,y,z,a,b,c) procedure f(int x, int y,int z,int a, int b, int c[]) if x + y >= y + x + 10 then y -= 4 a += 100 b += 100 else y += 4 a -= 100 b -= 200 c[2] += a a <=> z fi x + y = 250 c@4 = 0 c@3 = 0 c@2 = -100 c@1 = 0 c@0 = 0 b = -200 a = 0 z = -100 y = 154 x = 100 procedure main() int x int y x += 100 y += 150 call f(x,y) procedure f(int x, int y) if x + y >= y + x + 10 then y += 4 else y += 4 fi x + y = 250 x = 100 y = 154 procedure main() int x int y x += 100 y += 150 uncall f(x,y) procedure f(int x, int y) if x + y >= y + x + 10 then y += 4 else y += 4 fi x + y = 252 x = 100 y = 146 procedure main() int x int y x += 100 y += 150 call f(x,y) procedure f(int x, int y) if x > y && y > 10 + 20 then y -= 4 else y += 4 fi x + y = 246 && y > x x = 100 y = 154 procedure main() int x int y x += 100 y += 150 uncall f(x,y) procedure f(int x, int y) if x > y && y > 10 + 20 then y -= 4 else y += 4 fi x + y = 246 && y > x x = 100 y = 146 // factor num into table in fact[] procedure main() int num // Number to factor. Ends up zero int fact[20] // Factor table. Starts zero. Ends with factors in ascending order num += 840 call factor(num, fact) procedure factor(int num, int fact[]) local int try = 0 // Attempted factor. local int i = 0 // Pointer to last factor in factor table. from ((try = 0) && (num > 1)) do skip loop call nexttry(try) from fact[i] != try do skip loop // Divide out all occurrences of this i += 1 // factor fact[i] += try local int z = num / try z <=> num delocal int z = num * try until (num % try) != 0 until (try * try) > num // Exit early if possible if num != 1 then i += 1 // Put last prime away, if not done fact[i] ^= num // and zero num num ^= fact[i] fact[i] ^= num else num -= 1 fi fact[i] != fact[i-1] if (fact[i-1] * fact[i-1]) < fact[i] then // Zero try from (try * try) > fact[i] do skip loop uncall nexttry(try) until try = 0 else try -= fact[i-1] fi (fact[i-1] * fact[i-1]) < fact[i] call zeroi(i, fact) // Zero i delocal int i = 0 delocal int try = 0 procedure zeroi(int i, int fact[]) from fact[i+1] = 0 do skip loop i -= 1 until i = 0 procedure nexttry(int try) try += 2 if try = 4 then try -= 1 else skip fi try = 3 fact@19 = 0 fact@18 = 0 fact@17 = 0 fact@16 = 0 fact@15 = 0 fact@14 = 0 fact@13 = 0 fact@12 = 0 fact@11 = 0 fact@10 = 0 fact@9 = 0 fact@8 = 0 fact@7 = 0 fact@6 = 7 fact@5 = 5 fact@4 = 3 fact@3 = 2 fact@2 = 2 fact@1 = 2 fact@0 = 0 num = 0 procedure main() int num // Number to factor. Ends up zero int fact[20] // Factor table. Starts zero. Ends with factors in ascending order fact[1] += 2 fact[2] += 2 fact[3] += 2 fact[4] += 3 fact[5] += 5 fact[6] += 7 uncall factor(num, fact) procedure factor(int num, int fact[]) local int try = 0 // Attempted factor. local int i = 0 // Pointer to last factor in factor table. from (try = 0) && (num > 1) do skip loop call nexttry(try) from fact[i] != try do skip loop // Divide out all occurrences of this i += 1 // factor fact[i] += try local int z = num / try z <=> num delocal int z = num * try until (num % try) != 0 until (try * try) > num // Exit early if possible if num != 1 then i += 1 // Put last prime away, if not done fact[i] ^= num // and zero num num ^= fact[i] fact[i] ^= num else num -= 1 fi fact[i] != fact[i-1] if (fact[i-1] * fact[i-1]) < fact[i] then // Zero try from (try * try) > fact[i] do skip loop uncall nexttry(try) until try = 0 else try -= fact[i-1] fi (fact[i-1] * fact[i-1]) < fact[i] call zeroi(i, fact) // Zero i delocal int i = 0 delocal int try = 0 procedure zeroi(int i, int fact[]) from fact[i+1] = 0 do skip loop i -= 1 until i = 0 procedure nexttry(int try) try += 2 if try = 4 then try -= 1 else skip fi try = 3 fact@19 = 0 fact@18 = 0 fact@17 = 0 fact@16 = 0 fact@15 = 0 fact@14 = 0 fact@13 = 0 fact@12 = 0 fact@11 = 0 fact@10 = 0 fact@9 = 0 fact@8 = 0 fact@7 = 0 fact@6 = 0 fact@5 = 0 fact@4 = 0 fact@3 = 0 fact@2 = 0 fact@1 = 0 fact@0 = 0 num = 840 procedure main() int x1 int x2 int n n += 8 call fib(x1, x2, n) procedure fib(int x1, int x2, int n) if n = 0 then x1 += 1 x2 += 1 else n -= 1 call fib(x1, x2, n) x1 += x2 x1 <=> x2 fi x1 = x2 n = 0 x1 = 34 x2 = 55 procedure main() int x1 int x2 int n x1 += 34 x2 += 55 uncall fib(x1, x2, n) procedure fib(int x1, int x2, int n) if n = 0 then x1 += 1 x2 += 1 else n -= 1 call fib(x1, x2, n) x1 += x2 x1 <=> x2 fi x1 = x2 n = 8 x1 = 0 x2 = 0 procedure main() int x int y x += 100 y += 150 call f(x,y) procedure f(int x, int y) if x + y >= y + x + 10 then y -= 4 else y += 4 fi x + y = 250 x = 100 y = 154 procedure main() int x int y x += 100 y += 150 uncall f(x,y) procedure f(int x, int y) if x + y >= y + 10 then y += 4 else y += 4 fi x + y = 250 x = 100 y = 146 procedure main() int x int y x += 100 y += 150 call f(x,y) procedure f(int x, int y) if x < y && y > 2 * (x - 50) then y -= 2 * (x - 98) else y += 4 fi x + y = 246 && y > x x = 100 y = 146 procedure main() int x int y x += 100 y += 150 uncall f(x,y) procedure f(int x, int y) if x < y && y > 10 + 20 then y -= 4 else y += 4 fi x + y = 250 && y > x x = 100 y = 154 procedure main() int a[10] int i call f(a,i) procedure f(int a[],int i) a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i a[i + 1] += i a[i] += a[i + 2] * 2 i += 1 a@0 = 0 a@1 = 1 a@2 = 2 a@3 = 3 a@4 = 4 a@5 = 5 a@6 = 6 a@7 = 7 a@8 = 7 a@9 = 0 i = 8 procedure main() int a[10] int i i += 10 uncall f(a,i) procedure f(int a[],int i) a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a[i] += i i += 1 a@0 = 0 a@1 = -1 a@2 = -2 a@3 = -3 a@4 = -4 a@5 = -5 a@6 = -6 a@7 = -7 a@8 = -8 a@9 = -9 i = 0 procedure main() int x call f(x) procedure f(int x) local int a = 200 x += a a -= 30 delocal int a = 170 x = 200 procedure main() int x uncall f(x) procedure f(int x) local int a = 200 x += a a -= 30 delocal int a = 170 x = -200 procedure main() int a[10] call f(a) procedure f(int a[]) local int i = 0 from i = 0 do skip loop i += 1 a[(i + i) / 2] += i until i = 9 delocal int i = 9 a@9 = 9 a@8 = 8 a@7 = 7 a@6 = 6 a@5 = 5 a@4 = 4 a@3 = 3 a@2 = 2 a@1 = 1 a@0 = 0 procedure main() int a[10] uncall f(a) procedure f(int a[]) local int i = 0 from i = 0 do skip loop i += 1 a[(i + i) / 2] += i until i = 9 delocal int i = 9 a@9 = -9 a@8 = -8 a@7 = -7 a@6 = -6 a@5 = -5 a@4 = -4 a@3 = -3 a@2 = -2 a@1 = -1 a@0 = 0 procedure main() int a[10] call f(a) procedure f(int a[]) local int i = 0 from i = 0 do skip loop local int j = i + 1 i += 1 a[(j + j) / 2] += i delocal int j = i until i = 9 delocal int i = 9 a@0 = 0 a@1 = 1 a@2 = 2 a@3 = 3 a@4 = 4 a@5 = 5 a@6 = 6 a@7 = 7 a@8 = 8 a@9 = 9 procedure main() int a[10] uncall f(a) procedure f(int a[]) local int i = 0 from i = 0 do skip loop local int j = i + 1 i += 1 a[(j + j) / 2] += i delocal int j = i until i = 9 delocal int i = 9 a@0 = 0 a@1 = -1 a@2 = -2 a@3 = -3 a@4 = -4 a@5 = -5 a@6 = -6 a@7 = -7 a@8 = -8 a@9 = -9 procedure main() int a[10] int i call f(a,i) procedure f(int a[],int i) from i = 2 * 4 - 8 && 1 = 0 + 1 do skip loop i += 1 a[i] += i until i = 2 * 4 + 1 && 1 = 0 + 1 a@0 = 0 a@1 = 1 a@2 = 2 a@3 = 3 a@4 = 4 a@5 = 5 a@6 = 6 a@7 = 7 a@8 = 8 a@9 = 9 i = 9 procedure main() int a[10] int i i += 9 uncall f(a,i) procedure f(int a[],int i) from i = 2 * 4 - 8 && 1 = 0 + 1 do skip loop i += 1 a[i] += i until i = 2 * 4 + 1 && 1 = 0 + 1 a@0 = 0 a@1 = -1 a@2 = -2 a@3 = -3 a@4 = -4 a@5 = -5 a@6 = -6 a@7 = -7 a@8 = -8 a@9 = -9 i = 0 procedure main() int a[10] int i call f(a,i) procedure f(int a[],int i) from i = 0 do skip loop i += 1 a[(i + i) / 2] += i until i = 9 a@0 = 0 a@1 = 1 a@2 = 2 a@3 = 3 a@4 = 4 a@5 = 5 a@6 = 6 a@7 = 7 a@8 = 8 a@9 = 9 i = 9 procedure main() int a[10] int i i += 9 uncall f(a,i) procedure f(int a[],int i) from i = 0 do skip loop i += 1 a[(i + i) / 2] += i until i = 9 a@0 = 0 a@1 = -1 a@2 = -2 a@3 = -3 a@4 = -4 a@5 = -5 a@6 = -6 a@7 = -7 a@8 = -8 a@9 = -9 i = 0 procedure main() int x[4] int i x[0] += 1 x[1] += 2 x[2] += 3 x[3] += 4 call f(x,i) procedure f(int x[], int i) from i = 0 do skip loop local int j = 1 from j = 1 do skip loop x[i] += j j += 1 until j = 3 delocal int j = 3 i += 1 until i = size(x) i = 4 x@0 = 4 x@1 = 5 x@2 = 6 x@3 = 7 procedure main() int x[2] int i i += 2 x[0] += 1 x[1] += 2 uncall f(x,i) procedure f(int x[], int i) from i = 0 do skip loop local int j = 1 from j = 1 do skip loop x[i] += j j += 1 until j = 3 delocal int j = 3 i += 1 until i = size(x) i = 0 x@1 = -1 x@0 = -2 procedure main() int x[4] int i x[0] += 1 x[1] += 2 x[2] += 3 x[3] += 4 call f(x,i) procedure f(int x[], int i) from i = 0 do skip loop if x[i] < x[1] then x[i] -= 10 else skip fi x[i] < x[1] i += 1 until i = size(x) i = 4 x@0 = -9 x@1 = 2 x@2 = 3 x@3 = 4 procedure main() int x[4] int i i += 4 x[0] -= 9 x[1] += 2 x[2] += 3 x[3] += 4 uncall f(x,i) procedure f(int x[], int i) from i = 0 do skip loop if x[i] < x[1] then x[i] -= 10 else skip fi x[i] < x[1] i += 1 until i = size(x) i = 0 x@0 = 1 x@1 = 2 x@2 = 3 x@3 = 4 procedure main() int x[6] x[0] += 2 x[1] += 0 x[2] += 3 x[3] += 1 x[4] += 5 x[5] += 4 //show(x) call perm_to_code(x) procedure perm_to_code(int x[]) local int k = size(x) from k = size(x) do skip loop k -= 1 local int j = 0 from j = 0 do skip loop if x[j] > x[k] then x[j] -= 1 else skip fi x[j] >= x[k] j += 1 until j = k delocal int j = k until k = 0 delocal int k = 0 x@0 = 0 x@1 = 0 x@2 = 2 x@3 = 1 x@4 = 4 x@5 = 4 procedure main() int x[6] x[0] += 2 x[1] += 0 x[2] += 3 x[3] += 1 x[4] += 5 x[5] += 4 //show(x) uncall perm_to_code(x) procedure perm_to_code(int x[]) local int k = size(x) from k = size(x) do skip loop k -= 1 local int j = 0 from j = 0 do skip loop if x[j] > x[k] then x[j] -= 1 else skip fi x[j] >= x[k] j += 1 until j = k delocal int j = k until k = 0 delocal int k = 0 x@5 = 4 x@4 = 6 x@3 = 1 x@2 = 5 x@1 = 0 x@0 = 7 procedure main() int text[7] int arc[14] text[0] += 1 text[1] += 1 text[2] += 2 text[3] += 2 text[4] += 2 text[5] += 1 call encode(text, arc) procedure encode(int text[], int arc[]) local int i = 0 local int j = 0 from i = 0 && j = 0 do skip loop arc[j] += text[i] // arc[j] <=> text[i] text[i] -=arc[j] from arc[j+1] = 0 do arc[j+1] += 1 i += 1 loop text[i] -= arc[j] until arc[j] != text[i] j += 2 until text[i] = 0 // i & j should be cleared from arc[j] = 0 do j -= 2 i -= arc[j+1] loop skip until i = 0 delocal int j = 0 delocal int i = 0 arc@13 = 0 arc@12 = 0 arc@11 = 0 arc@10 = 0 arc@9 = 0 arc@8 = 0 arc@7 = 0 arc@6 = 0 arc@5 = 1 arc@4 = 1 arc@3 = 3 arc@2 = 2 arc@1 = 2 arc@0 = 1 text@6 = 0 text@5 = 0 text@4 = 0 text@3 = 0 text@2 = 0 text@1 = 0 text@0 = 0 procedure main() int text[7] int arc[14] arc[0] += 1 arc[1] += 2 arc[2] += 2 arc[3] += 3 arc[4] += 1 arc[5] += 1 arc[6] += 0 arc[7] += 0 arc[8] += 0 arc[9] += 0 arc[10] += 0 arc[11] += 0 arc[12] += 0 arc[13] += 0 uncall encode(text, arc) procedure encode(int text[], int arc[]) local int i = 0 local int j = 0 from i = 0 && j = 0 do skip loop arc[j] += text[i] // arc[j] <=> text[i] text[i] -=arc[j] from arc[j+1] = 0 do arc[j+1] += 1 i += 1 loop text[i] -= arc[j] until arc[j] != text[i] j += 2 until text[i] = 0 // i & j should be cleared from arc[j] = 0 do j -= 2 i -= arc[j+1] loop skip until i = 0 delocal int j = 0 delocal int i = 0 arc@13 = 0 arc@12 = 0 arc@11 = 0 arc@10 = 0 arc@9 = 0 arc@8 = 0 arc@7 = 0 arc@6 = 0 arc@5 = 0 arc@4 = 0 arc@3 = 0 arc@2 = 0 arc@1 = 0 arc@0 = 0 text@6 = 0 text@5 = 1 text@4 = 2 text@3 = 2 text@2 = 2 text@1 = 1 text@0 = 1 procedure main() int num int root num += 66 call root(num, root) procedure root(int num, int root) local int bit = 1 from bit = 1 do skip loop // find exponential ball park call doublebit(bit) until (bit * bit) > num from (bit * bit) > num do uncall doublebit(bit) if ((root + bit) * (root + bit)) <= num then root += bit else skip fi (root / bit) % 2 != 0 loop skip until bit = 1 delocal int bit = 1 num -= root * root procedure doublebit(int bit) local int z = bit bit += z delocal int z = bit / 2 num = 2 root = 8 procedure main() int num int root root += 25 uncall root(num, root) procedure root(int num, int root) local int bit = 1 from bit = 1 do skip loop // find exponential ball park call doublebit(bit) until (bit * bit) > num from (bit * bit) > num do uncall doublebit(bit) if ((root + bit) * (root + bit)) <= num then root += bit else skip fi (root / bit) % 2 != 0 loop skip until bit = 1 delocal int bit = 1 num -= root * root procedure doublebit(int bit) local int z = bit bit += z delocal int z = bit / 2 num = 625 root = 0