'Write a C file with python wrappers
This file contains all the definitions of the routines in c code.
Arguments
routines
List of Routine instances
f
File-like object to write the file to
prefix
The filename prefix, used to name the imported module.
funcname
Name of the main function to be returned.'

def dump_c(self, routines, f, prefix, funcname=None):

    if ((funcname is None) and (len(routines) == 1)):
        funcname = routines[0].name
    elif (funcname is None):
        msg = 'funcname    must    be    specified    for    multiple    output    routines'
        raise ValueError(msg)
    functions = []
    function_creation = []
    ufunc_init = []
    module = self.module_name
    include_file = '"{0}.h"'.format(prefix)
    top = _ufunc_top.substitute(include_file=include_file, module=module)
    name = funcname
    r_index = 0
    (py_in, _) = self._partition_args(routines[0].arguments)
    n_in = len(py_in)
    n_out = len(routines)
    form = 'char    *{0}{1}    =    args[{2}];'
    arg_decs = [form.format('in', i, i) for i in range(n_in)]
    arg_decs.extend([form.format('out', i, (i + n_in)) for i in range(n_out)])
    declare_args = '\n                '.join(arg_decs)
    form = 'npy_intp    {0}{1}_step    =    steps[{2}];'
    step_decs = [form.format('in', i, i) for i in range(n_in)]
    step_decs.extend([form.format('out', i, (i + n_in)) for i in range(n_out)])
    declare_steps = '\n                '.join(step_decs)
    form = '*(double    *)in{0}'
    call_args = ',    '.join([form.format(a) for a in range(n_in)])
    form = '{0}{1}    +=    {0}{1}_step;'
    step_incs = [form.format('in', i) for i in range(n_in)]
    step_incs.extend([form.format('out', i, i) for i in range(n_out)])
    step_increments = '\n                                '.join(step_incs)
    n_types = (n_in + n_out)
    types = (('{' + ',    '.join((['NPY_DOUBLE'] * n_types))) + '};')
    docstring = '"Created    in    SymPy    with    Ufuncify"'
    function_creation.append('PyObject    *ufunc{0};'.format(r_index))
    init_form = _ufunc_init_form.substitute(module=module, funcname=name, docstring=docstring, n_in=n_in, n_out=n_out, ind=r_index)
    ufunc_init.append(init_form)
    outcalls = [_ufunc_outcalls.substitute(outnum=i, call_args=call_args, funcname=routines[i].name) for i in range(n_out)]
    body = _ufunc_body.substitute(module=module, funcname=name, declare_args=declare_args, declare_steps=declare_steps, call_args=call_args, step_increments=step_increments, n_types=n_types, types=types, outcalls='\n                                '.join(outcalls))
    functions.append(body)
    body = '\n\n'.join(functions)
    ufunc_init = '\n                '.join(ufunc_init)
    function_creation = '\n                '.join(function_creation)
    bottom = _ufunc_bottom.substitute(module=module, ufunc_init=ufunc_init, function_creation=function_creation)
    text = [top, body, bottom]
    f.write('\n\n'.join(text))
