def main(filenames, show_graphs):
    names = map(os.path.basename, filenames)
    cffs = map(get_cff, filenames)
    tds = map(lambda f: f.topDictIndex[0], cffs)
    fds = map(lambda td: td.FDArray if hasattr(td, 'FDArray') else [], tds)

    n_bytes = map(get_cs_bytes, tds, fds)
    for name, b in zip(names, n_bytes):
        print("%s:\n\t%d bytes" % (name, b))

    map(decompile_charstrings, tds, fds)
    
    map(print_n_subroutines, names, tds, fds)

    sav_usag = map(get_savings, tds, fds)
    for name, (savings, usages) in zip(names, sav_usag):
        tot_savings = savings[0] + list(itertools.chain.from_iterable(savings[1]))
        tot_usages = usages[0] + list(itertools.chain.from_iterable(usages[1]))
        avg = float(sum(tot_savings)) / len(tot_savings)
        print("%s:\n\tAverage savings per subr: %f\n\tMax saving subr: %d\n\tMax usage subr: %d" % (name, avg, max(tot_savings), max(tot_usages)))

    if show_graphs:
        # plot subrs
        SHOW_START = 0
        SHOW_LEN = 200
        mins = []
        maxes = []
        plt.figure(0)
        for savings, usages in sav_usag:
            tot_savings = savings[0] + list(itertools.chain.from_iterable(savings[1]))
            plot_savings = sorted(tot_savings, reverse=True)[SHOW_START:SHOW_START+SHOW_LEN]
            plt.plot(range(len(plot_savings)), plot_savings)
            mins.append(min(plot_savings))
            maxes.append(max(plot_savings))
        plt.ylim([min(mins) - 1, max(maxes) + 1])
        plt.title("Subroutine Savings")
        plt.xlabel("Subroutine")
        plt.ylabel("Savings (bytes)")

        raw_usages = map(get_raw_usages, tds, fds)
        fig = 1
        for gusages, lusages in raw_usages:
            for idx, usages in zip(['Global'] + range(len(lusages)), [gusages] + lusages):
                if usages:
                    bias = psCharStrings.calcSubrBias(usages)
                    if bias == 1131:
                        orig_order_usages = usages[1024:1240] + usages[0:1024] + usages[1240:]
                    elif bias == 32768:
                        orig_order_usages = (usages[32661:32877] + usages[31637:32661] +
                                             usages[32877:33901] + usages[0:31637] + 
                                             usages[33901:])
                    else:
                        orig_order_usages = usages
                    plt.figure(fig)
                    plt.plot(range(len(orig_order_usages)), orig_order_usages, color='b')
                    plt.title(idx % "Subroutine usages for FD %s")
                    plt.axvline(215, 0, max(orig_order_usages), color='r')
                    plt.axvline(2263, 0, max(orig_order_usages), color='r')
                    plt.ylim([0, max(orig_order_usages)])
                    plt.xlim([0, len(orig_order_usages)])
                    fig += 1
        plt.show()
dataset/ETHPy150Open googlei18n/compreffor/tools/subr_grapher.py/main/swapped operands of `%`