| 43 | }; |
| 44 | |
| 45 | int main(int argc, char **argv) |
| 46 | { |
| 47 | int64_t x1 = 0x1234def123450789ULL; |
| 48 | int64_t x2 = 0x1234def123450788ULL; |
| 49 | int64_t x3 = 0x1234def123450789ULL; |
| 50 | printf("*%lld\n%d,%d,%d,%d,%d\n%d,%d,%d,%d,%d*\n", x1, x1==x2, x1<x2, x1<=x2, x1>x2, x1>=x2, // note: some rounding in the printing! |
| 51 | x1==x3, x1<x3, x1<=x3, x1>x3, x1>=x3); |
| 52 | printf("*%lld*\n", returner1()); |
| 53 | printf("*%lld*\n", returner2(30)); |
| 54 | |
| 55 | uint64_t maxx = -1ULL; |
| 56 | printf("*%llu*\n*%llu*\n", maxx, maxx >> 5); |
| 57 | |
| 58 | // Make sure params are not modified if they shouldn't be |
| 59 | int64_t t = 123; |
| 60 | modifier1(t); |
| 61 | printf("*%lld*\n", t); |
| 62 | modifier2(t); |
| 63 | printf("*%lld*\n", t); |
| 64 | |
| 65 | // global structs with i64s |
| 66 | printf("*%d,%lld*\n*%d,%lld*\n", iub[0].c, iub[0].d, iub[1].c, iub[1].d); |
| 67 | |
| 68 | // Bitshifts |
| 69 | { |
| 70 | int64_t a = -1; |
| 71 | int64_t b = a >> 29; |
| 72 | int64_t c = a >> 32; |
| 73 | int64_t d = a >> 34; |
| 74 | printf("*%lld,%lld,%lld,%lld*\n", a, b, c, d); |
| 75 | uint64_t ua = -1; |
| 76 | int64_t ub = ua >> 29; |
| 77 | int64_t uc = ua >> 32; |
| 78 | int64_t ud = ua >> 34; |
| 79 | printf("*%lld,%lld,%lld,%lld*\n", ua, ub, uc, ud); |
| 80 | } |
| 81 | |
| 82 | // Nonconstant bitshifts |
| 83 | { |
| 84 | int64_t a = -1; |
| 85 | int64_t b = a >> (29 - argc + 1); |
| 86 | int64_t c = a >> (32 - argc + 1); |
| 87 | int64_t d = a >> (34 - argc + 1); |
| 88 | printf("*%lld,%lld,%lld,%lld*\n", a, b, c, d); |
| 89 | uint64_t ua = -1; |
| 90 | int64_t ub = ua >> (29 - argc + 1); |
| 91 | int64_t uc = ua >> (32 - argc + 1); |
| 92 | int64_t ud = ua >> (34 - argc + 1); |
| 93 | printf("*%lld,%lld,%lld,%lld*\n", ua, ub, uc, ud); |
| 94 | } |
| 95 | |
| 96 | // Math mixtures with doubles |
| 97 | { |
| 98 | uint64_t a = 5; |
| 99 | double b = 6.8; |
| 100 | uint64_t c = a * b; |
| 101 | if (truthy()) printf("*%ld,%ld,%ld*\n", (long)&a, (long)&b, (long)&c); // printing addresses prevents optimizations |
| 102 | printf("*prod:%llu*\n", c); |