import re


def replaceSlamch(source):
    """Replace slamch_ calls with appropiate macros"""
    def repl(m):
        s = m.group(1)
        return dict(E='EPSILON', P='PRECISION', S='SAFEMINIMUM',
                    B='BASE')[s[0]]
    source = re.sub(r'slamch_\("(.*?)"\)', repl, source)
    source = re.sub(r'^\s+extern.*? slamch_.*?;$(?m)', '', source)
    return source