https://bugs.libre-soc.org/show_bug.cgi?id=672

func count8safe(counts *[8]int, buf []uint8) {
    for i := range buf {
        for j := 0; j < 8; j++ {
            counts[j] += int(buf[i] >> j & 1)
        }
    }
}

func count16safe(counts *[16]int, buf []uint16) {
    for i := range buf {
        for j := 0; j < 16; j++ {
            counts[j] += int(buf[i] >> j & 1)
        }
    }
}