import re


def parse_modified_output(outfile):
    """Parse solving statistics from the given file, which contains
    the stdout from the solver run.
    """
    info = {}
    with open(outfile) as f:
        for line in f:
            line = line.rstrip()
            m = re.search(r'\| (\S+):\s+(\d+\.\d+|\d+)', line)
            if m:
                left = m.group(1)
                right = m.group(2)
                if left == 'Search':
                    info['search_time'] = float(right)
                elif left == 'Cubification':
                    info['cubify_time'] = float(right)
                elif left == 'Search(cube)':
                    info['cube_search_time'] = float(right)
                elif left == 'End simplify':
                    info['simplify_time'] = float(right)
                elif left == 'Exit':
                    info['exit_point'] = int(right)
            m = re.search(r'(.+\S)\s+:\s*(\d+.\d+|\d+)', line)
            if m:
                left = m.group(1)
                right = m.group(2)
                if left == 'cubifications':
                    info['num_cubifications'] = int(right)
                elif left == 'cube refutations':
                    info['num_refutations'] = int(right)
                elif left == 'final mean score':
                    info['final_mean_score'] = float(right)
                elif left == 'CPU time':
                    info['cpu_time'] = float(right)
            if line in ('SATISFIABLE', 'UNSATISFIABLE', 'INDETERMINATE'):
                info['result'] = line
    return info