Case 1

fun(x) == 128

uint64_t fun(uint64_t x) {
  uint64_t y = x & (0 - x);
  uint64_t z = y ^ 0xFFFFFFFFFFFFFF;
  uint64_t w = z & x;
  return w & (0 - w);
}

Case 2

fun(x) == 0

uint32_t fun(uint32_t x) {
  for(int i=0; i<10; i++)
    x = x & (x - 1);
  return x
}

Comment: This is essentially counting number of “1”s in the binary string