Download benchmarks/Engineering/string/strcmp/rocq/solution_spec.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Engineering/string/strcmp/rocq/solution_spec.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Engineering/string/strcmp/rocq/solution_spec.c
-
curl -L -o solution_spec.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Engineering/string/strcmp/rocq/solution_spec.c
1.03 kB
| 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]; | |
| } | |