Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = first_word;
- b = second_word;
- while [a] == [b] && [a] != 0 {
- a += 1;
- b += 1;
- }
- if [a] < [b] {
- output(first_word);
- } else {
- output(second_word);
- }
- // or slightly translated:
- a = first_word;
- b = second_word;
- loop: {
- left = [a];
- right = [b];
- a += 1;
- b += 1;
- if left - right != 0 {
- goto endloop;
- }
- if left == 0 {
- goto endloop;
- }
- }
- goto loop:
- endloop:
- if left - right < 0 {
- output(first_word);
- } else {
- output(second_word);
- }
- // musl strcmp for reference:
- int strcmp(const char *l, const char *r)
- {
- for (/*nothing*/; *l==*r && *l; l++, r++);
- return *(unsigned char *)l - *(unsigned char *)r;
- }
- // but don't be scared about the above for syntax, it means:
- /*nothing*/;
- while *l == *r && *l != 0 {
- l++;
- r++;
- }
Add Comment
Please, Sign In to add comment