modernc.org/cc@v1.0.1/testdata/gcc-6.3.0/gcc/testsuite/gcc.c-torture/execute/builtins/lib/strncmp.c (about)

     1  extern void abort (void);
     2  extern int inside_main;
     3  
     4  typedef __SIZE_TYPE__ size_t;
     5  
     6  __attribute__ ((__noinline__))
     7  int
     8  strncmp(const char *s1, const char *s2, size_t n)
     9  {
    10    const unsigned char *u1 = (const unsigned char *)s1;
    11    const unsigned char *u2 = (const unsigned char *)s2;
    12    unsigned char c1, c2;
    13  
    14  #ifdef __OPTIMIZE__
    15    if (inside_main)
    16      abort();
    17  #endif
    18  
    19    while (n > 0)
    20      {
    21        c1 = *u1++, c2 = *u2++;
    22        if (c1 == '\0' || c1 != c2)
    23  	return c1 - c2;
    24        n--;
    25      }
    26    return c1 - c2;
    27  }