cielseven's picture
add benchmark corpora, groundtruth, symexec scripts and coverage docs
bff4ec7
Raw History Blame Contribute Delete
1.03 kB
#include "../../string.h"
int strcmp(char *s1, char *s2)
/*@ With str1 str2
Require valid_string(str1) && valid_string(str2) &&
string_length(str1) < INT_MAX && string_length(str2) < INT_MAX &&
store_string(s1, str1) * store_string(s2, str2)
Ensure strcmp_result(str1, str2, __return) &&
store_string(s1, str1) * store_string(s2, str2)
*/
{
int i = 0;
while (s1[i] != 0 && s1[i] == s2[i]) {
i++;
}
return s1[i] - s2[i];
}
int strncmp(char *s1, char *s2, int n)
/*@ With str1 str2
Require valid_string(str1) && valid_string(str2) &&
0 <= n && n < INT_MAX &&
string_length(str1) < INT_MAX && string_length(str2) < INT_MAX &&
store_string(s1, str1) * store_string(s2, str2)
Ensure strncmp_result(str1, str2, n, __return) &&
store_string(s1, str1) * store_string(s2, str2)
*/
{
int i = 0;
while (i < n && s1[i] != 0 && s1[i] == s2[i]) {
i++;
}
if (i == n) {
return 0;
}
return s1[i] - s2[i];
}