c ports of the array algorithms

Signed-off-by: Mattias Andrée <maandree@operamail.com>
c ports of some things from algorithms.bits

Signed-off-by: Mattias Andrée <maandree@operamail.com>