<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def front_middle_end(module_name, code, optimizations=None, module_dir=None):
 """Front-end and middle-end compilation steps"""

    pm = PassManager(module_name, module_dir)

    # front end
    ir, renamings, docstrings = frontend.parse(pm, code)

    # middle-end
    if optimizations is None:
        optimizations = cfg.get('pythran', 'optimizations').split()
    optimizations = [_parse_optimization(opt) for opt in optimizations]
    refine(pm, ir, optimizations)

    return pm, ir, renamings, docstrings