__attribute__ ((noinline)) int f3 (S * s) { int result = 0; result += __builtin_strcmp (s->s, "a"); result += __builtin_strcmp (s->s, "ab"); return result; }
__attribute__ ((noinline)) int f4 (char *p) { int result = 0; result += __builtin_strcmp (p, "a"); result += __builtin_strcmp (p, "ab"); return result; }
int main (void) { if (__builtin_strcmp (str1, latin2_1) != 0 || __builtin_strcmp (str2, latin2_2) != 0 || __builtin_strcmp (str3, utf8_1) != 0 || __builtin_strcmp (str4, utf8_2) != 0 || __builtin_strncmp (str5, latin2_1, sizeof (latin2_1) - 1) != 0 || __builtin_strcmp (str5 + sizeof (latin2_1) - 1, latin2_2) != 0 || __builtin_strncmp (str6, utf8_1, sizeof (utf8_1) - 1) != 0 || __builtin_strcmp (str6 + sizeof (utf8_1) - 1, utf8_2) != 0 || __builtin_strncmp (str7, utf8_1, sizeof (utf8_1) - 1) != 0 || __builtin_strcmp (str7 + sizeof (utf8_1) - 1, utf8_2) != 0 || __builtin_strncmp (str8, utf8_1, sizeof (utf8_1) - 1) != 0 || __builtin_strcmp (str8 + sizeof (utf8_1) - 1, utf8_2) != 0) __builtin_abort (); if (sizeof ("a" u8"b"[0]) != 1 || sizeof (u8"a" "b"[0]) != 1 || sizeof (u8"a" u8"b"[0]) != 1 || sizeof ("a" "\u010d") != 3 || sizeof ("a" u8"\u010d") != 4 || sizeof (u8"a" "\u010d") != 4 || sizeof (u8"a" "\u010d") != 4) __builtin_abort (); return 0; }
const int * getAlgorithmicTypeFromName(const char *realName) { unsigned mid, start, limit; unsigned lastMid; int result; start = 0; limit = sizeof(cnvNameType)/sizeof(cnvNameType[0]); mid = limit; lastMid = 0xffffffff; for (;;) { mid = (start + limit) / 2; if (lastMid == mid) { /* Have we moved? */ break; /* We haven't moved, and it wasn't found. */ } lastMid = mid; result = __builtin_strcmp(realName, cnvNameType[mid].name); if (result < 0) { limit = mid; } else if (result > 0) { start = mid; } else { return converterData[cnvNameType[mid].type]; } } return 0; }
static __always_inline void free_param(const char *type, void *x) { if (!__builtin_strcmp(type, "char *")) { kfree(*(void **)x); *(void **)x = NULL; } }
void main_test (void) { const char *const foo = "hello world"; if (strcmp (foo, "hello") <= 0) abort (); if (strcmp (foo + 2, "llo") <= 0) abort (); if (strcmp (foo, foo) != 0) abort (); if (strcmp (foo, "hello world ") >= 0) abort (); if (strcmp (foo + 10, "dx") >= 0) abort (); if (strcmp (10 + foo, "dx") >= 0) abort (); if (strcmp (bar, "") <= 0) abort (); if (strcmp ("", bar) >= 0) abort (); if (strcmp (bar+8, "") != 0) abort (); if (strcmp ("", bar+8) != 0) abort (); if (strcmp (bar+(--x), "") <= 0 || x != 6) abort (); if (strcmp ("", bar+(++x)) >= 0 || x != 7) abort (); /* Test at least one instance of the __builtin_ style. We do this to ensure that it works and that the prototype is correct. */ if (__builtin_strcmp (foo, "hello") <= 0) abort (); }
void main_test (void) { const char *const foo = "hello world"; if (strcmp (foo, "hello") <= 0) abort (); if (strcmp (foo + 2, "llo") <= 0) abort (); if (strcmp (foo, foo) != 0) abort (); if (strcmp (foo, "hello world ") >= 0) abort (); if (strcmp (foo + 10, "dx") >= 0) abort (); if (strcmp (10 + foo, "dx") >= 0) abort (); if (strcmp (bar, "") <= 0) abort (); if (strcmp ("", bar) >= 0) abort (); if (strcmp (bar+8, "") != 0) abort (); if (strcmp ("", bar+8) != 0) abort (); if (strcmp (bar+(--x), "") <= 0 || x != 6) abort (); if (strcmp ("", bar+(++x)) >= 0 || x != 7) abort (); if (__builtin_strcmp (foo, "hello") <= 0) abort (); }
static __always_inline void _print_param(struct drm_printer *p, const char *name, const char *type, const void *x) { if (!__builtin_strcmp(type, "bool")) drm_printf(p, "i915.%s=%s\n", name, yesno(*(const bool *)x)); else if (!__builtin_strcmp(type, "int")) drm_printf(p, "i915.%s=%d\n", name, *(const int *)x); else if (!__builtin_strcmp(type, "unsigned int")) drm_printf(p, "i915.%s=%u\n", name, *(const unsigned int *)x); else if (!__builtin_strcmp(type, "char *")) drm_printf(p, "i915.%s=%s\n", name, *(const char **)x); else WARN_ONCE(1, "no printer defined for param type %s (i915.%s)\n", type, name); }
__attribute__ ((noinline)) int f1 (void) { char *s0= "abcd"; char s[8]; __builtin_strcpy (s, s0); return __builtin_strcmp(s, "abc") != 0; }
int matherr (struct exception* e) { const char *n; if (e->type != DOMAIN) return 0; n = e->name; if (__builtin_strcmp (n, "acos") == 0 || __builtin_strcmp (n, "asin") == 0) e->retval = __builtin_nan (""); else if (__builtin_strcmp (n, "atan2") == 0) { if (e->arg1 == 0 && e->arg2 == 0) { double nz; nz = -0.0; if (__builtin_memcmp (&e->arg2, &nz, sizeof (double)) != 0) e->retval = e->arg1; else e->retval = copysign (PI, e->arg1); } else return 0; } else if (__builtin_strcmp (n, "log") == 0 || __builtin_strcmp (n, "log10") == 0) e->retval = __builtin_nan (""); else if (__builtin_strcmp (n, "pow") == 0) { if (e->arg1 < 0) e->retval = __builtin_nan (""); else if (e->arg1 == 0 && e->arg2 == 0) e->retval = 1.0; else if (e->arg1 == 0 && e->arg2 < 0) { double i; if (modf (e->arg2, &i) == 0 && ((int64_t) i & 1) == 1) e->retval = copysign (__builtin_inf (), e->arg1); else e->retval = __builtin_inf (); } else return 0; } else if (__builtin_strcmp (n, "sqrt") == 0) { if (e->arg1 < 0) e->retval = __builtin_nan (""); else return 0; } else return 0; return 1; }
int main() { if (__builtin_strcmp (TEXT1 TEXT2, "ABCDEF") != 0) link_error (); #pragma push_macro("TEXT1") #undef TEXT1 #define TEXT1 "XYZ" if (__builtin_strcmp (TEXT1 TEXT2, "XYZDEF") != 0) link_error (); #pragma pop_macro("TEXT1") if (__builtin_strcmp (TEXT1 TEXT2, "ABCDEF") != 0) link_error (); return 0; }
int main(int argc, char *argv[]) { char *source = "asdf"; char target[__builtin_strlen(source) + 1]; move(target, source, __builtin_strlen(source) + 1); if (__builtin_strcmp(target, source) != 0) { abort(); } else { exit(0); } }
int main () { ValueStruct v; v.arrayType = 0; v.dataType = 0; v.value.LocalizedText = new LocalizedTextStruct ("Localized Text"); LocalizedText t = ValueHelper::getLocalizedText (&v); if (__builtin_strcmp (t.getInternHandle ()->getT (), "Localized Text")) __builtin_abort (); return 0; }
static struct user_info* find_user(const char *user_name) { struct user_info *user_item; user_item = users; while (user_item != ((void *)0)) { /* SEGV due to NULL access here on user_name. See also comment below. */ if ((__builtin_strcmp(user_item->name, user_name) == 0)) break; user_item = user_item->next; } return user_item; }
int main(void) { char buf[128]; int ab = __builtin_abs(-7) - __builtin_abs(5); printf("Res1: %d\n", ab); __builtin_memcpy(vals1, vals0, sizeof(vals0)); printf("Res2: %d\n", __builtin_memcmp(vals0, vals1, sizeof(vals0))); __builtin_memset(vals0, 0, sizeof(vals0)); printf("Res3: %d %d %d %d %d\n", vals0[0], vals0[1], vals0[2], vals0[3], vals0[4]); printf("Res4: %d\n", (int) __builtin_strlen("Hello World")); printf("Res5: %d\n", __builtin_strcmp(hello, "Hello World") > 0); __builtin_strcpy(buf, hello); printf("Res6: %s\n", buf); return 0; }
int main(int argc, char **argv) { int a; a = __builtin_bswap32(a); a = __builtin_bswap64(a); a = __builtin_constant_p(1); a = __builtin_constant_p("string"); char *b = __builtin_strchr("string", 's'); a = __builtin_expect(1, a); a = __builtin_strlen("string"); a = __builtin_strcmp("string1", "string2"); a = __builtin_offsetof(struct point, y); char c[100]; b = __builtin_strcpy(c, "a"); b = __builtin_strncpy(c, "a", 1); a = __builtin_ctzl(a); varargsfn(0); __builtin_prefetch(b); __builtin_prefetch(b, 1); __builtin_prefetch(b, 1, 1); return a; }
authent_author(request *req) { struct realm *realm; char *user_name = ((void *)0); struct user_info *user_item = ((void *)0); int res = 0; asm (""); realm = realms; if (__builtin_strcmp("Wsd", realm->name) == 0) { req->internal_realm = ws_realm; is_digest(&user_name); } if (authenticate_user(req, &user_name, &user_item) < 0) { if (user_name != ((void *)0)) req->user = user_name; res = -2; goto authent_author_return; } if (is_member_of_groups(user_item, realm->groups) < 0) res = -1; authent_author_return: return res; }
static int callback (void *data, uintptr_t pc, const char *filename, int lineno, const char *function) { struct callers_data *arg = (struct callers_data *) data; Location *loc; /* Skip split stack functions. */ if (function != NULL) { const char *p; p = function; if (__builtin_strncmp (p, "___", 3) == 0) ++p; if (__builtin_strncmp (p, "__morestack_", 12) == 0) return 0; } else if (filename != NULL) { const char *p; p = strrchr (filename, '/'); if (p == NULL) p = filename; if (__builtin_strncmp (p, "/morestack.S", 12) == 0) return 0; } /* Skip thunks and recover functions. There is no equivalent to these functions in the gc toolchain, so returning them here means significantly different results for runtime.Caller(N). */ if (function != NULL) { const char *p; p = __builtin_strchr (function, '.'); if (p != NULL && __builtin_strncmp (p + 1, "$thunk", 6) == 0) return 0; p = __builtin_strrchr (function, '$'); if (p != NULL && __builtin_strcmp(p, "$recover") == 0) return 0; } if (arg->skip > 0) { --arg->skip; return 0; } loc = &arg->locbuf[arg->index]; loc->pc = pc; /* The libbacktrace library says that these strings might disappear, but with the current implementation they won't. We can't easily allocate memory here, so for now assume that we can save a pointer to the strings. */ loc->filename = runtime_gostringnocopy ((const byte *) filename); loc->function = runtime_gostringnocopy ((const byte *) function); loc->lineno = lineno; ++arg->index; return arg->index >= arg->max; }
void main_test (void) { const char *const foo = "hello world"; if (strlen (foo) != 11) abort (); if (strlen (foo + 4) != 7) abort (); if (strlen (foo + (x++ & 7)) != 5) abort (); if (x != 7) abort (); if (strcmp (foo, "hello") <= 0) abort (); if (strcmp (foo + 2, "llo") <= 0) abort (); if (strcmp (foo, foo) != 0) abort (); if (strcmp (foo, "hello world ") >= 0) abort (); if (strcmp (foo + 10, "dx") >= 0) abort (); if (strcmp (10 + foo, "dx") >= 0) abort (); if (strcmp (bar, "") <= 0) abort (); if (strcmp ("", bar) >= 0) abort (); if (strcmp (bar+8, "") != 0) abort (); if (strcmp ("", bar+8) != 0) abort (); if (strcmp (bar+(--x), "") <= 0 || x != 6) abort (); if (strcmp ("", bar+(++x)) >= 0 || x != 7) abort (); if (strrchr (foo, 'x')) abort (); if (strrchr (foo, 'o') != foo + 7) abort (); if (strrchr (foo, 'e') != foo + 1) abort (); if (strrchr (foo + 3, 'e')) abort (); if (strrchr (foo, '\0') != foo + 11) abort (); if (strrchr (bar, '\0') != bar + 8) abort (); if (strrchr (bar + 4, '\0') != bar + 8) abort (); if (strrchr (bar + (x++ & 3), '\0') != bar + 8) abort (); if (x != 8) abort (); /* Test only one instance of rindex since the code path is the same as that of strrchr. */ if (rindex ("hello", 'z') != 0) abort (); /* Test at least one instance of the __builtin_ style. We do this to ensure that it works and that the prototype is correct. */ if (__builtin_rindex (foo, 'o') != foo + 7) abort (); if (__builtin_strrchr (foo, 'o') != foo + 7) abort (); if (__builtin_strlen (foo) != 11) abort (); if (__builtin_strcmp (foo, "hello") <= 0) abort (); }
__attribute__ ((noinline)) int f1 (S *s) { return __builtin_strcmp (s->s, "abc") != 0; }
static __always_inline void dup_param(const char *type, void *x) { if (!__builtin_strcmp(type, "char *")) *(void **)x = kstrdup(*(void **)x, GFP_ATOMIC); }
// file libbb/single_argv.c line 11 static char * single_argv(char **argv) { signed int tmp_statement_expression$1; _Bool tmp_if_expr$2; signed int tmp_if_expr$5; signed int tmp_statement_expression$3; signed int return_value___builtin_strcmp$4; if(!(*(1l + argv) == ((char *)NULL))) { unsigned long int __s1_len; unsigned long int __s2_len; if((_Bool)1) { if(!((unsigned long int)("--" + 1l) + -((unsigned long int)"--") == 1ul)) goto __CPROVER_DUMP_L1; __s2_len=__builtin_strlen("--"); tmp_if_expr$2 = (__s2_len < (unsigned long int)4 ? (signed int)(1 != 0) : (signed int)(0 != 0)) != 0; } else { __CPROVER_DUMP_L1: ; tmp_if_expr$2 = 0 != 0; } if(!(tmp_if_expr$2 == (_Bool)0)) { const unsigned char *__s2 = (const char *)argv[(signed long int)1]; signed int __result = (signed int)((const char *)"--")[(signed long int)0] - (signed int)__s2[(signed long int)0]; if(__s2_len > 0ul) { if(__result == 0) { __result = (signed int)((const char *)"--")[(signed long int)1] - (signed int)__s2[(signed long int)1]; if(__s2_len > 1ul) { if(__result == 0) { __result = (signed int)((const char *)"--")[(signed long int)2] - (signed int)__s2[(signed long int)2]; if(__s2_len > 2ul) { if(__result == 0) __result = (signed int)((const char *)"--")[(signed long int)3] - (signed int)__s2[(signed long int)3]; } } } } } tmp_statement_expression$3 = __result; tmp_if_expr$5 = -tmp_statement_expression$3; } else { return_value___builtin_strcmp$4=__builtin_strcmp(argv[(signed long int)1], "--"); tmp_if_expr$5 = return_value___builtin_strcmp$4; } tmp_statement_expression$1 = tmp_if_expr$5; if(tmp_statement_expression$1 == 0) argv = argv + 1l; } _Bool tmp_if_expr$6; if(*(1l + argv) == ((char *)NULL)) tmp_if_expr$6 = 1 != 0; else tmp_if_expr$6 = (argv[(signed long int)2] != (char *)NULL ? (signed int)(1 != 0) : (signed int)(0 != 0)) != 0; if(!(tmp_if_expr$6 == (_Bool)0)) bb_show_usage(); return argv[(signed long int)1]; }
static int callback (void *data, uintptr_t pc, const char *filename, int lineno, const char *function) { struct callers_data *arg = (struct callers_data *) data; Location *loc; /* Skip split stack functions. */ if (function != NULL) { const char *p; p = function; if (__builtin_strncmp (p, "___", 3) == 0) ++p; if (__builtin_strncmp (p, "__morestack_", 12) == 0) return 0; } else if (filename != NULL) { const char *p; p = strrchr (filename, '/'); if (p == NULL) p = filename; if (__builtin_strncmp (p, "/morestack.S", 12) == 0) return 0; } /* Skip thunks and recover functions. There is no equivalent to these functions in the gc toolchain, so returning them here means significantly different results for runtime.Caller(N). */ if (function != NULL) { const char *p; p = __builtin_strchr (function, '.'); if (p != NULL && __builtin_strncmp (p + 1, "$thunk", 6) == 0) return 0; p = __builtin_strrchr (function, '$'); if (p != NULL && __builtin_strcmp(p, "$recover") == 0) return 0; } if (arg->skip > 0) { --arg->skip; return 0; } loc = &arg->locbuf[arg->index]; loc->pc = pc; /* The libbacktrace library says that these strings might disappear, but with the current implementation they won't. We can't easily allocate memory here, so for now assume that we can save a pointer to the strings. */ loc->filename = runtime_gostringnocopy ((const byte *) filename); loc->function = runtime_gostringnocopy ((const byte *) function); loc->lineno = lineno; ++arg->index; /* There is no point to tracing past certain runtime functions. Stopping the backtrace here can avoid problems on systems that don't provide proper unwind information for makecontext, such as Solaris (http://gcc.gnu.org/PR52583 comment #21). */ if (function != NULL) { if (__builtin_strcmp (function, "makecontext") == 0) return 1; if (filename != NULL) { const char *p; p = strrchr (filename, '/'); if (p == NULL) p = filename; if (__builtin_strcmp (p, "/proc.c") == 0) { if (__builtin_strcmp (function, "kickoff") == 0 || __builtin_strcmp (function, "runtime_mstart") == 0 || __builtin_strcmp (function, "runtime_main") == 0) return 1; } } } return arg->index >= arg->max; }
__attribute__ ((noinline)) int f2 (void) { return __builtin_strcmp (s, "abc") != 0; }
__attribute__ ((noinline)) int f4 (void) { return __builtin_strcmp ("abc", s) != 0; }
// file coreutils/basename.c line 49 signed int __main(signed int argc, char **argv) { unsigned long int m; unsigned long int n; char *s; if(!(argv == ((char **)NULL))) (void)0; else /* assertion !(argv == ((char **)((void*)0))) */ __VERIFIER_error(); signed int tmp_statement_expression$1; _Bool tmp_if_expr$2; signed int tmp_if_expr$5; signed int tmp_statement_expression$3; signed int return_value___builtin_strcmp$4; if(!(*(1l + argv) == ((char *)NULL))) { unsigned long int basename_main$$1$$1$$__s1_len; unsigned long int __s2_len; if((_Bool)1) { if(!((unsigned long int)("--" + 1l) + -((unsigned long int)"--") == 1ul)) goto __CPROVER_DUMP_L3; __s2_len=__builtin_strlen("--"); tmp_if_expr$2 = (__s2_len < (unsigned long int)4 ? (signed int)(1 != 0) : (signed int)(0 != 0)) != 0; } else { __CPROVER_DUMP_L3: ; tmp_if_expr$2 = 0 != 0; } if(!(tmp_if_expr$2 == (_Bool)0)) { const unsigned char *__s2; if(!(argv == ((char **)NULL))) (void)0; else /* assertion !(argv == ((char **)((void*)0))) */ __VERIFIER_error(); __s2 = (const char *)argv[(signed long int)1]; signed int __result; if(!(__s2 == ((const unsigned char *)NULL))) (void)0; else /* assertion !(__s2 == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); __result = (signed int)((const char *)"--")[(signed long int)0] - (signed int)__s2[(signed long int)0]; if(__s2_len > 0ul) { if(__result == 0) { if(!("--" == ((const char *)NULL))) (void)0; else /* assertion !("--" == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); if(!(__s2 == ((const unsigned char *)NULL))) (void)0; else /* assertion !(__s2 == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); __result = (signed int)((const char *)"--")[(signed long int)1] - (signed int)__s2[(signed long int)1]; if(__s2_len > 1ul) { if(__result == 0) { if(!("--" == ((const char *)NULL))) (void)0; else /* assertion !("--" == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); if(!(__s2 == ((const unsigned char *)NULL))) (void)0; else /* assertion !(__s2 == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); __result = (signed int)((const char *)"--")[(signed long int)2] - (signed int)__s2[(signed long int)2]; if(__s2_len > 2ul) { if(__result == 0) { if(!("--" == ((const char *)NULL))) (void)0; else /* assertion !("--" == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); /* assertion (_Bool)0 */ __VERIFIER_error(); if(!(__s2 == ((const unsigned char *)NULL))) (void)0; else /* assertion !(__s2 == ((const unsigned char *)((void*)0))) */ __VERIFIER_error(); __result = (signed int)((const char *)"--")[(signed long int)3] - (signed int)__s2[(signed long int)3]; } } } } } } tmp_statement_expression$3 = __result; tmp_if_expr$5 = -tmp_statement_expression$3; } else { if(!(argv == ((char **)NULL))) (void)0; else /* assertion !(argv == ((char **)((void*)0))) */ __VERIFIER_error(); return_value___builtin_strcmp$4=__builtin_strcmp(argv[(signed long int)1], "--"); tmp_if_expr$5 = return_value___builtin_strcmp$4; } tmp_statement_expression$1 = tmp_if_expr$5; if(tmp_statement_expression$1 == 0) { argv = argv + 1l; argc = argc - 1; } }
__attribute__ ((noinline)) int f3 (S *s) { return __builtin_strcmp ("abc", s->s) != 0; }