CS计算机代考程序代写 // COMP1521 21T2 … final exam, question 4

// COMP1521 21T2 … final exam, question 4

#include

long
mul (long a, long b_)
{
unsigned long b = b_;

// NOTE: Maximum 5 operations allowed
// for each multiplication
// NOTE: Permitted operations:
// [x + y, x – y, -x, x << y] if (a == 7) { // Two operations: // 1 2 return (b << 3) - b; } if (a == 17) { return 42; // TODO } if (a == -3) { return 42; // TODO } if (a == 60) { return 42; // TODO } if (a == -112) { return 42; // TODO } // Invalid inputs will simply abort. abort(); }