void printi(int val);

int _memcmp(void *b1, void *b2, int len)
{
  char *s1 = b1, *s2 = b2;
  while (len-- > 0) {
    if ((*s1 < *s2) || (*s1 > *s2))
      return *s1 - *s2;
    s1++;
    s2++;
  }
  return 0;
}

int main()
{
  printi(_memcmp("abc", "abc", 3));
  printi(_memcmp("abc", "ABC", 3));
  printi(_memcmp("ABC", "abc", 3));
  printi(_memcmp("a", "aaa", 1));
  printi(_memcmp("aaa", "a", 1));
  printi(_memcmp("aaaa", "abcd", 3));
  printi(_memcmp("abcd", "aaaa", 3));
  printi(_memcmp("aaaa", "abcd", 1));
  printi(_memcmp("abcd", "aaaa", 1));
  printi(_memcmp("012", "0123", 4));
  printi(_memcmp("0123", "012", 4));
  printi(_memcmp("012", "0123", 3));
  printi(_memcmp("0123", "012", 3));

  return 0;
}
