def c32decode(c32input, min_length=0):
    """
    >>> c32decode('MHQZH246RBQSERPSE2TD5HHPF21NQMWX')
    'a46ff88886c2ef9762d970b4d2c63678835bd39d'
    >>> c32decode('')
    ''
    >>> c32decode('00000000000000000000', 20)
    '0000000000000000000000000000000000000000'
    >>> c32decode('00000000000000000001', 20)
    '0000000000000000000000000000000000000001'
    >>> c32decode('20000000000000000000000000000001', 20)
    '1000000000000000000000000000000000000001'
    >>> c32decode('20000000000000000000000000000000', 20)
    '1000000000000000000000000000000000000000'
    >>> c32decode('1')
    '01'
    >>> c32decode('12')
    '22'
    >>> c32decode('01')
    '0001'
    >>> c32decode('001')
    '000001'
    >>> c32decode('G')
    '10'
    >>> c32decode('80')
    '0100'
    >>> c32decode('400')
    '1000'
    >>> c32decode('2000')
    '010000'
    >>> c32decode('10000')
    '100000'
    >>> c32decode('G0000')
    '01000000'
    """

    if len(c32input) == 0:
        return ''

    c32input = c32normalize(c32input)
    if not re.match(r'^[' + C32 + ']*$', c32input):
        raise ValueError('Not a c32-encoded string')

    num_leading_zero_bytes = 0
    for i in range(0, len(c32input)):
        if c32input[i] != C32[0]:
            break

        num_leading_zero_bytes += 1

    res = []
    carry = 0
    carry_bits = 0
    for i in range(len(c32input) - 1, -1, -1):
        if carry_bits == 4:
            res = [HEX[carry]] + res
            carry_bits = 0
            carry = 0

        current_code = C32.index(c32input[i]) << carry_bits
        current_value = current_code + carry
        current_hex_digit = HEX[current_value % len(HEX)]

        carry_bits += 1
        carry = current_value >> 4

        if carry > (1 << carry_bits):
            raise Exception('Panic error in decoding')

        res = [current_hex_digit] + res

    # one last carry
    res = [HEX[carry]] + res

    if len(res) % 2 == 1:
        res = [HEX[0]] + res

    # remove all leading zeros while keeping the string even-length
    hex_leading_zeros = 0
    for i in range(0, len(res)):
        if res[i] != '0':
            break

        hex_leading_zeros += 1

    res = res[hex_leading_zeros - (hex_leading_zeros % 2):]
    hexstr = ''.join(res)

    # add back leading zero bytes from the c32 string
    for i in range(0, num_leading_zero_bytes):
        hexstr = '00{}'.format(hexstr)

    if min_length > 0:
        count = min_length * 2 - len(hexstr)
        hexstr = '00' * (count / 2) + hexstr

    return hexstr
>>> c32decode('MHQZH246RBQSERPSE2TD5HHPF21NQMWX')
    'a46ff88886c2ef9762d970b4d2c63678835bd39d'
    >>> c32decode('')
    ''
    >>> c32decode('00000000000000000000', 20)
    '0000000000000000000000000000000000000000'
    >>> c32decode('00000000000000000001', 20)
    '0000000000000000000000000000000000000001'
    >>> c32decode('20000000000000000000000000000001', 20)
    '1000000000000000000000000000000000000001'
    >>> c32decode('20000000000000000000000000000000', 20)
    '1000000000000000000000000000000000000000'
    >>> c32decode('1')
    '01'
    >>> c32decode('12')
    '22'
    >>> c32decode('01')
    '0001'
    >>> c32decode('001')
    '000001'
    >>> c32decode('G')
    '10'
    >>> c32decode('80')
    '0100'
    >>> c32decode('400')
    '1000'
    >>> c32decode('2000')
    '010000'
    >>> c32decode('10000')
    '100000'
    >>> c32decode('G0000')
    '01000000'