11 int mul1(int x, int y)
16 int mul2(int x, int y, int z)
21 int mul3(int x, int y, int z)
26 int sub0(int x, int y, int z)
31 int sub1(int x, int y)
33 return x - (y * CONST);
36 int sub2(int x, int y)
41 int sub3(int x, int y)
50 int cmp1(int x, int y) {
54 int cmp2(int x, int y) {
58 int cmp3(int x, int y) {
62 int cmp4(int x, int y) {
66 int cmp5(int x, int y, int z) {
67 return x + z == z + y;
70 int cmp6(int x, int y, int z) {
71 return x + z != y + z;
74 int cmp7(int x, int y, int z) {
75 return x - z == y - z;
78 int cmp8(int x, int y, int z) {
90 int and1(int a, int b) {
94 int and2(int a, int b) {
95 return (a|b) & ~(a&b);
104 #define TU(func,x,expect) \
105 printf("%s(%d) = %d (should be %d)\n", #func, x, func(x), expect);
106 #define TB(func,x,y,expect) \
107 printf("%s(%d,%d) = %d (should be %d)\n", #func, x, y, func(x,y), expect);
108 #define TT(func,x,y,z,expect) \
109 printf("%s(%d,%d,%d) = %d (should be %d)\n", #func, x, y, z, func(x,y,z), expect);
113 TT(mul2, 9, 2, 5, 27);
114 TT(mul3, 5, 2, 9, 27);
115 TT(sub0, 42, 17, 59, 84);
116 TB(sub1, 23, 17, -691);
117 TB(sub2, 42, 17, 59);
118 TB(sub3, 42, 17, -59);
124 TT(cmp5, 42, 17, -4, 0);
125 TT(cmp6, 42, 17, -4, 1);
126 TT(cmp7, 42, 17, -4, 0);
127 TT(cmp8, 42, 17, -4, 1);
130 TB(and1, 42, 17, 42);
131 TB(and2, 42, 17, 42^17);