eucl.ssa 375 B

12345678910111213141516171819202122232425
  1. # euclide's algorithm in ssa
  2. # it is a fairly interesting
  3. # ssa program because of the
  4. # swap of b and a
  5. export
  6. function $test() {
  7. @start
  8. @loop
  9. %a =w phi @start 380, @loop %r
  10. %b =w phi @start 747, @loop %a
  11. %r =w rem %b, %a
  12. jnz %r, @loop, @end
  13. @end
  14. storew %a, $a
  15. ret
  16. }
  17. # >>> driver
  18. # extern void test(void);
  19. # int a;
  20. # int main() { test(); return !(a == 1); }
  21. # <<<