#include #include volatile unsigned int scratchpad = 0; void __attribute__((noinline)) leaf1(unsigned long long count) { while (count--) { scratchpad ^= 0x1; } } void __attribute__((noinline)) leaf2(unsigned long long count) { while (count--) { scratchpad ^= 0x2; } } void __attribute__((noinline)) leaf3(unsigned long long count) { while (count--) { scratchpad ^= 0x4; } } void __attribute__((noinline)) leaf4(unsigned long long count) { while (count--) { scratchpad ^= 0x8; } } void __attribute__((noinline)) call1(unsigned long long count) { leaf1(count); printf("Done with %s\n", __func__); } void __attribute__((noinline)) call1_2(unsigned long long count) { leaf1(count); leaf2(count); printf("Done with %s\n", __func__); } void __attribute__((noinline)) call1_2_3(unsigned long long count) { leaf1(count); leaf2(count); leaf3(count); printf("Done with %s\n", __func__); } void __attribute__((noinline)) call1_2_3_4(unsigned long long count) { leaf1(count); leaf2(count); leaf3(count); leaf4(count); printf("Done with %s\n", __func__); } void __attribute__((noinline)) call_all_four_combos(unsigned long long count) { call1(count); call1_2(count); call1_2_3(count); call1_2_3_4(count); printf("Done with %s\n", __func__); } int main (int argc, char **argv) { unsigned long long count; if (argc != 2) { fprintf(stderr, "Wrong arg count %d\n", argc); return -1; } sscanf(argv[1], "%llu", &count); call1(count); call1_2(count); call1_2_3(count); call1_2_3_4(count); call_all_four_combos(count); printf("Done with %llu loops, scratch=%#010x\n", count, scratchpad); return 0; }