aboutsummaryrefslogtreecommitdiffhomepage
path: root/test.c
blob: 83a9d8b3e36ca3f62f19b84eec0cf51648eb1e4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* coment */

#if 1+1 < (-2*'a')
wawa
#elif 9<<1
#define wow 3
#else
boop
#endif

#define NULL ((void *)0)
int glob [ wow+wow];

struct foo {
    int x, y, z;
};


int test0(struct foo *foo) { return foo->x ? foo->y : foo->z; }
int test1(int x, int y, int z) { return x && y || z; }
int test2(int x, int y, int z) { return x || y && z; }

extern void f();
int test3(int x, int y) {
    if (x < 0 && y < 0 && 1) return x - y;
    if ((x == 0 || x > 0) && y > 0) return y;
    if (f(), x == y ? x && 1 : 0 || y) return x;
    return x + y;
}

int test4(int c) {
    return c == 'a' || c == 'x' ? 1
         : (f(), c == 'b' || c == 'y') ? 2
         : c == 'c' || c == 'z' ? 3
         : 0;
}

int test5(int *p)
{
    return p ? *p : 0;
}

int test6(int x)
{
    return !!!!x;
}

float sqr(float x) { return x * x; }

int mula(int x, int y, int z) {
    if (x < 0)
        return -x * y + z;
    return x * y + z;
}

void *copy(char *d, char *s, int n) {
    while (n--)
        *d++ = *s++;
    return d;
}

int hmm(float x, int a, char *p, char *q) {
    return x > 1 ? a || p : p < q && a > 0;
}

struct v2f { float x, y; };

struct v2f add(struct v2f a, struct v2f b) {
    struct v2f r;
    r.x = a.x + b.x;
    r.y = a.y + b.y;
    return r;
}

//