const char humanize_lua[] =
"-- Simple human-readable renderer of LuaJIT's memprof profile.\n"
"--\n"
"-- Major portions taken verbatim or adapted from the LuaVela.\n"
"-- Copyright (C) 2015-2019 IPONWEB Ltd.\n"
"\n"
"local symtab = require \"utils.symtab\"\n"
"\n"
"local M = {}\n"
"\n"
"function M.render(events, symbols)\n"
"  local ids = {}\n"
"\n"
"  for id, _ in pairs(events) do\n"
"    table.insert(ids, id)\n"
"  end\n"
"\n"
"  table.sort(ids, function(id1, id2)\n"
"    return events[id1].num > events[id2].num\n"
"  end)\n"
"\n"
"  for i = 1, #ids do\n"
"    local event = events[ids[i]]\n"
"    print(string.format(\"%s: %d events\\t+%d bytes\\t-%d bytes\",\n"
"      symtab.demangle(symbols, event.loc),\n"
"      event.num,\n"
"      event.alloc,\n"
"      event.free\n"
"    ))\n"
"\n"
"    local prim_loc = {}\n"
"    for _, loc in pairs(event.primary) do\n"
"      table.insert(prim_loc, symtab.demangle(symbols, loc))\n"
"    end\n"
"    if #prim_loc ~= 0 then\n"
"      table.sort(prim_loc)\n"
"      print(\"\\tOverrides:\")\n"
"      for j = 1, #prim_loc do\n"
"        print(string.format(\"\\t\\t%s\", prim_loc[j]))\n"
"      end\n"
"      print(\"\")\n"
"    end\n"
"  end\n"
"end\n"
"\n"
"return M\n"
""
;
