import re


def parse_general_int(s):
    """Parse integer with power-of-2 suffix eg. 32k."""
    mo = re.match(r'(\d+)([KkMGT]?)$', s)
    if mo:
        i, suffix = mo.group(1, 2)
        v = int(i)
        if suffix:
            if suffix == 'K' or suffix == 'k':
                v *= 1024
            elif suffix == 'M':
                v *= (1024 * 1024)
            elif suffix == 'G':
                v *= (1024 * 1024 * 1024)
            elif suffix == 'T':
                v *= (1024 * 1024 * 1024 * 1024)
            else:
                raise ValueError('invalid integer string %s' % s)
        return v
    else:
        v = int(s)
    return v