def to_c_type(bit_width):
    """ Convert a bitwidth to the nearest <stdint.h> type that can hold it.
    """
    if bit_width > 32:
        return "std::uint64_t"
    if bit_width > 16:
        return "std::uint32_t"
    if bit_width > 8:
        return "std::uint16_t"
    if bit_width > 1:
        return "std::uint8_t"
    return "bool"