def METHOD_NAME(fmt):
    state = 0
    bits = []
    literal = ""
    macro = ""
    escape = 0;
    for i in range(len(fmt)):
        if fmt[i] == '\\':
            if escape:
                escape = 0
            else:
                escape = 1
            if state != STATE_LITERAL:
                raise Exception("Unexpected escape outside string literal")
            literal = literal + fmt[i]
        elif fmt[i] == '"' and not escape:
            if state == STATE_LITERAL:
                state = STATE_SKIP
                bits.append(literal)
                literal = ""
            else:
                if state == STATE_MACRO:
                    bits.append(c_macro_to_format(macro))
                    macro = ""
                state = STATE_LITERAL
        elif fmt[i] == ' ' or fmt[i] == '\t':
            if state == STATE_MACRO:
                bits.append(c_macro_to_format(macro))
                macro = ""
                state = STATE_SKIP
            elif state == STATE_LITERAL:
                literal = literal + fmt[i]
        else:
            escape = 0
            if state == STATE_SKIP:
                state = STATE_MACRO
            if state == STATE_LITERAL:
                literal = literal + fmt[i]
            else:
                macro = macro + fmt[i]
    if state == STATE_MACRO:
        bits.append(c_macro_to_format(macro))
    elif state == STATE_LITERAL:
        bits.append(literal)
    # All variables in systemtap are 64-bit in size
    # The "%l" integer size qualifier is thus redundant
    # and "%ll" is not valid at all. Similarly the size_t
    # based "%z" size qualifier is not valid. We just
    # strip all size qualifiers for sanity.
    fmt = re.sub("%(\d*)(l+|z)(x|u|d)", "%\\1\\3", "".join(bits))
    return fmt