forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <assert.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
|
||
#define ARRAYMAX 256 | ||
|
||
uint8_t *strndfy (uint8_t *dest, const uint8_t *src, size_t n) { | ||
int i = 0; | ||
int j = 0; | ||
|
||
switch (n & 0x3) { | ||
do { | ||
case 0 : dest[i++] = src[j++]; | ||
case 1 : dest[i++] = src[j++]; | ||
case 2 : dest[i++] = src[j++]; | ||
case 3 : dest[i++] = src[j++]; | ||
} while (j < n); | ||
} | ||
|
||
return dest; | ||
} | ||
|
||
|
||
int main (int argc, char **argv) { | ||
uint8_t src[ARRAYMAX]; | ||
uint8_t dest[ARRAYMAX]; | ||
|
||
int length = 0; | ||
scanf("%u", &length); | ||
|
||
if (length <= ARRAYMAX) { | ||
for (int i = 0; i < length; ++i) { | ||
src[i] = (uint8_t)i; | ||
} | ||
|
||
strndfy(dest, src, length); | ||
|
||
for (int i = 0; i < length; ++i) { | ||
assert(dest[i] == (uint8_t)i); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
main.c | ||
--unwind 257 | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^\[main.assertion.\d+\] line \d+ assertion 0: SUCCESS$ | ||
^\[main.assertion.\d+\] line \d+ assertion history == 0: SUCCESS$ | ||
^VERIFICATION SUCCESSFUL$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
This checks whether Duff's device is handled correctly. |