Download benchmarks/Engineering/string/strlen/rocq/solution_annotated.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 529 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Engineering/string/strlen/rocq/solution_annotated.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Engineering/string/strlen/rocq/solution_annotated.c
-
curl -L -o solution_annotated.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Engineering/string/strlen/rocq/solution_annotated.c
529 Bytes
| int strlen(char *s) | |
| /*@ With str | |
| Require valid_string(str) && string_length(str) < INT_MAX && store_string(s, str) | |
| Ensure __return == string_length(str) && store_string(s, str) | |
| */ | |
| { | |
| int i = 0; | |
| /*@ Inv Assert | |
| valid_string(str) && | |
| string_length(str) < INT_MAX && | |
| 0 <= i && i <= string_length(str) && | |
| s == s@pre && | |
| (forall (k: Z), (0 <= k && k < i) => Znth(k, str, 0) != 0) && | |
| store_string(s@pre, str) | |
| */ | |
| while (s[i] != 0) { | |
| i++; | |
| } | |
| return i; | |
| } | |