int pcount_do(unsigned x) {
  int result = 0;
  do {
    result += x & 0x1;
    x >>= 1;
  } while (x);
  return result;
}

int pcount_while(unsigned x) {
  int result = 0;
  while (x) {
    result += x & 0x1;
    x >>= 1;
  }
  return result;
}

#define WSIZE 8*sizeof(int)
int pcount_for(unsigned x) {
  int i;
  int result = 0;
  for (i = 0; i < WSIZE; i++) {
    unsigned mask = 1 << i;
    result += (x & mask) != 0;
  }
  return result;
}

int pcount_for_goto(unsigned x) {
  int i;
  int result = 0;
  i = 0;
  if (!(i < WSIZE))
    goto done;
 loop:
  {
    unsigned mask = 1 << i;
    result += (x & mask) != 0;
  }
  i++;
  if (i < WSIZE)
    goto loop;
 done:
  return result;
}


int pcount_for2(unsigned x) {
  unsigned mask;
  int result = 0;
  for (mask = 1; mask; mask <<= 1)
    result += (x & mask) != 0;
  return result;
}

int one() {
  return 1;
}

int pcount_for2b(unsigned x) {
  unsigned mask;
  int result = 0;
  for (mask = one(); mask; mask <<= 1)
    result += (x & mask) != 0;
  return result;
}
