cleanups/fixes for ASM handling
[libfirm] / ir / be / test / fehler035.c
1 #include <stdio.h>
2 #include <assert.h>
3
4 unsigned int p0 = 0;
5 unsigned int p1 = 42;
6
7 int simpler(void)
8 {
9         if (p0 != p1)
10                 if (p0  == 0)
11                         return -1;
12                 else
13                         return 1;
14         return 0;
15 }
16
17 int compare_string(char *CompValue, char         *ValuePtr)
18 {
19     int              i           = 0;
20     unsigned char   *p0          = (unsigned char *)CompValue;
21     unsigned char   *p1          = (unsigned char *)ValuePtr;
22
23     for (i = 0; i == 0 && *p0 != '\0' && *p1 != '\0'; p0++, p1++)
24     {
25         if (*p0 != *p1)
26             if (*p0  < *p1)
27                 i      = -1;
28             else
29                 i      = 1;
30     }
31
32     if (i == 0)
33         if (*p0  != *p1)
34             if (*p0 == '\0')
35                 i      = -1;
36             else
37                 i      = 1;
38
39     return(i);
40 }
41
42 int main()
43 {
44 #define test(a,b,shouldbe)   { int res = compare_string(a, b); printf("Compare %s, %s -> %d (should be %d)\n", a, b, res, shouldbe); assert(res == shouldbe); }
45         test("a", "b", -1);
46         test("", "", 0);
47         test("Rothe", "Rother", -1);
48         test("hallo", "hallo", 0);
49         test("hallo", "welt", -1);
50         test("welt", "hallo", 1);
51
52         printf("Simpler: %d\n", simpler());
53         return 0;
54 }