// The most evil program EVER. #include #include using namespace std; typedef struct ul_conv { unsigned long msb; unsigned long lsb; } ul_t; typedef union decomposer_u { ul_t ul; unsigned __int64 ull; } decomposer; typedef unsigned int func_t(unsigned __int64 &, unsigned __int64 &); unsigned int f0001(unsigned __int64 &state, unsigned __int64 &state2); unsigned int f0002(unsigned __int64 &state, unsigned __int64 &state2); unsigned int f0003(unsigned __int64 &state, unsigned __int64 &state2); func_t *g_fptr_array[40] = { 0, f0001, f0002, f0003, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int main(int argc, char **argv) { unsigned int index = 1; unsigned __int64 state = 0; unsigned __int64 state2 = 0; func_t *cfp = NULL; for(;;) { cfp = g_fptr_array[index]; if(cfp == NULL) { break; } index = (*cfp) (state, state2); } cout << "Press any key to continue.\n"; _getch(); return 0; } unsigned int f0001(unsigned __int64 &state, unsigned __int64 &state2) { static unsigned int sm1, sm2; decomposer dc, dc2; dc.ull = state; dc2.ull = state2; if(dc2.ul.msb == 0) { cout << "Please enter the first number to be multiplied: "; cin >> sm1; cout << "Please enter the second number to be multiplied: "; cin >> sm2; } else if(dc2.ul.msb == 1) { dc.ul.lsb = sm1; dc2.ul.msb = 1; } else if(dc2.ul.msb == 2) { dc.ul.lsb = sm2; dc2.ul.msb = 2; } else if(dc2.ul.msb == 3) { sm1 = 0; sm2 = 0; } state = dc.ull; state2 = dc2.ull; return 2; } unsigned int f0002(unsigned __int64 &state, unsigned __int64 &state2) { static bool b1 = false, b2 = false; static unsigned int sm1, sm2; decomposer dc, dc2; dc.ull = state; dc2.ull = state2; if(dc2.ul.msb == 0) { if(b1 == false) { dc2.ul.msb = 1; } else if(b2 == false) { dc2.ul.msb = 2; } else { dc2.ul.msb = 3; } } else if(dc2.ul.msb == 1) { sm1 = dc.ul.lsb; dc2.ul.msb = 0; b1 = true; } else if(dc2.ul.msb == 2) { sm2 = dc.ul.lsb; dc2.ul.msb = 0; b2 = true; } else if(dc2.ul.msb == 3) { dc2.ul.lsb = sm1 * sm2; } state = dc.ull; state2 = dc2.ull; if(dc2.ul.msb == 0) { return 2; } else if(dc2.ul.msb < 3) { return 1; } else { return 3; } } unsigned int f0003(unsigned __int64 &state, unsigned __int64 &state2) { static bool b1 = false; static unsigned int sm1; decomposer dc, dc2; dc.ull = state; dc2.ull = state2; if(dc2.ul.msb == 3) { if(b1 == false) { dc2.ul.msb = 3; b1 = true; } else { sm1 = dc2.ul.lsb; dc2.ul.msb = 1; } } else if(dc2.ul.msb == 1) { cout << "The two numbers multiplied equal: " << sm1 << endl; dc2.ul.msb = 0; } state = dc.ull; state2 = dc2.ull; if(dc2.ul.msb == 1) return 3; else if(dc2.ul.msb == 3) return 2; else return 0; }