afca484e992d1229eb7664ab5b2326dce8ea76da
[riscv-tests.git] / debug / programs / debug.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdint.h>
4
5 unsigned int crc32a(uint8_t *message, unsigned int size);
6
7 void rot13(char *buf)
8 {
9 while (*buf) {
10 if ((*buf >= 'a' && *buf <= 'm') ||
11 (*buf >= 'A' && *buf <= 'M')) {
12 *buf += 13;
13 } else if ((*buf >= 'n' && *buf <= 'z') ||
14 (*buf >= 'N' && *buf <= 'Z')) {
15 *buf -= 13;
16 }
17 buf++;
18 }
19 }
20
21 size_t strlen(const char *buf)
22 {
23 int len = 0;
24 while (buf[len])
25 len++;
26 return len;
27 }
28
29 int main()
30 {
31 volatile int i = 0;
32 int j = 0;
33 char *fox = "The quick brown fox jumps of the lazy dog.";
34 unsigned int checksum = 0;
35
36 start:
37 while (i)
38 j++;
39
40 rot13(fox);
41 checksum ^= crc32a(fox, strlen(fox));
42 rot13(fox);
43 checksum ^= crc32a(fox, strlen(fox));
44
45 return checksum;
46 }