Guest User

Untitled

a guest
Jun 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. a = first_word;
  2. b = second_word;
  3. while [a] == [b] && [a] != 0 {
  4. a += 1;
  5. b += 1;
  6. }
  7.  
  8. if [a] < [b] {
  9. output(first_word);
  10. } else {
  11. output(second_word);
  12. }
  13.  
  14. // or slightly translated:
  15. a = first_word;
  16. b = second_word;
  17. loop: {
  18. left = [a];
  19. right = [b];
  20. a += 1;
  21. b += 1;
  22. if left - right != 0 {
  23. goto endloop;
  24. }
  25. if left == 0 {
  26. goto endloop;
  27. }
  28. }
  29. goto loop:
  30. endloop:
  31.  
  32. if left - right < 0 {
  33. output(first_word);
  34. } else {
  35. output(second_word);
  36. }
  37.  
  38. // musl strcmp for reference:
  39. int strcmp(const char *l, const char *r)
  40. {
  41. for (/*nothing*/; *l==*r && *l; l++, r++);
  42. return *(unsigned char *)l - *(unsigned char *)r;
  43. }
  44.  
  45. // but don't be scared about the above for syntax, it means:
  46. /*nothing*/;
  47. while *l == *r && *l != 0 {
  48. l++;
  49. r++;
  50. }
Add Comment
Please, Sign In to add comment