def _pretty_hex(value, width=None):
    """
    Return a value of width bits as a pretty hexadecimal formatted string.
    """
    if value is None:
        return 'Undefined'
    if width is None:
        return '{0:#x}'.format(value)
    width = (width + 3) // 4
    hex_str = "{{0:#0{0:d}x}}".format(width + 2)
    return hex_str.format(value)