Make variables local again, now that gdb is "fixed."
[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 char __malloc_start[512];
8
9 void rot13(char *buf)
10 {
11 while (*buf) {
12 if ((*buf >= 'a' && *buf <= 'm') ||
13 (*buf >= 'A' && *buf <= 'M')) {
14 *buf += 13;
15 } else if ((*buf >= 'n' && *buf <= 'z') ||
16 (*buf >= 'N' && *buf <= 'Z')) {
17 *buf -= 13;
18 }
19 buf++;
20 }
21 }
22
23 size_t strlen(const char *buf)
24 {
25 int len = 0;
26 while (buf[len])
27 len++;
28 return len;
29 }
30
31 int main()
32 {
33 volatile int i = 0;
34 int j = 0;
35 char *fox = "The quick brown fox jumps of the lazy dog.";
36 unsigned int checksum = 0;
37
38 start:
39 while (i)
40 j++;
41
42 rot13(fox);
43 checksum ^= crc32a(fox, strlen(fox));
44 rot13(fox);
45 checksum ^= crc32a(fox, strlen(fox));
46
47 return checksum;
48 }