mono_profiler_startup (const char * desc)
{
  struct GHashTable * D.8270;
  struct MonoProfiler * prof;

  prof = monoeg_malloc0 (8);
  D.8270 = monoeg_g_hash_table_new (0B, 0B);
  prof->images = D.8270;
  mono_profiler_install (prof, prof_shutdown);
  mono_profiler_install_jit_compile (prof_jit_enter, prof_jit_leave);
  mono_profiler_set_events (16);
}


prof_jit_leave (struct MonoProfiler * prof, struct MonoMethod * method, int result)
{
  struct MonoClass * D.8273;
  struct GHashTable * D.8274;
  struct GList * D.8277;
  struct GList * D.8278;
  struct MonoImage * image;
  struct PerImageData * data;

  D.8273 = mono_method_get_class (method);
  image = mono_class_get_image (D.8273);
  D.8274 = prof->images;
  data = monoeg_g_hash_table_lookup (D.8274, image);
  if (data == 0B) goto <D.8275>; else goto <D.8276>;
  <D.8275>:
  data = monoeg_malloc0 (8);
  D.8274 = prof->images;
  monoeg_g_hash_table_insert_replace (D.8274, image, data, 0);
  <D.8276>:
  D.8277 = data->methods;
  D.8278 = monoeg_g_list_append (D.8277, method);
  data->methods = D.8278;
}


prof_jit_enter (struct MonoProfiler * prof, struct MonoMethod * method)
{

}


prof_shutdown (struct MonoProfiler * prof)
{
  struct GHashTable * D.8284;

  D.8284 = prof->images;
  monoeg_g_hash_table_foreach (D.8284, output_image, prof);
}


output_image (void * key, void * value, void * user_data)
{
  const gchar * D.8285;
  int D.8286;
  struct _IO_FILE * stderr.0;
  int * D.8292;
  int D.8293;
  const gchar * D.8294;
  const char * D.8295;
  int D.8296;
  _Bool D.8298;
  long int D.8299;
  long int D.8300;
  struct GList * D.8303;
  struct MonoImage * image;
  struct PerImageData * image_data;
  struct MonoProfiler * prof;
  char * tmp;
  char * outfile_name;
  struct FILE * outfile;
  int i;
  int err;
  struct ForeachData data;

  try
    {
      image = key;
      image_data = value;
      prof = user_data;
      D.8285 = monoeg_g_get_home_dir ();
      tmp = monoeg_g_strdup_printf ("%s/.mono/aot-profile-data", D.8285);
      D.8286 = monoeg_g_file_test (tmp, 4);
      if (D.8286 == 0) goto <D.8287>; else goto <D.8288>;
      <D.8287>:
      err = mkdir (tmp, 511);
      if (err != 0) goto <D.8289>; else goto <D.8290>;
      <D.8289>:
      stderr.0 = stderr;
      D.8292 = __errno_location ();
      D.8293 = *D.8292;
      D.8294 = monoeg_g_strerror (D.8293);
      fprintf (stderr.0, "mono-profiler-aot: Unable to create output directory \'%s\': %s\n", tmp, D.8294);
      exit (1);
      <D.8290>:
      <D.8288>:
      i = 0;
      <D.8248>:
      D.8295 = mono_image_get_name (image);
      outfile_name = monoeg_g_strdup_printf ("%s/%s-%d", tmp, D.8295, i);
      D.8296 = monoeg_g_file_test (outfile_name, 1);
      if (D.8296 == 0) goto <D.8247>; else goto <D.8297>;
      <D.8297>:
      i = i + 1;
      goto <D.8248>;
      <D.8247>:
      printf ("Creating output file: %s\n", outfile_name);
      outfile = fopen (outfile_name, "w+");
      D.8298 = outfile == 0B;
      D.8299 = (long int) D.8298;
      D.8300 = __builtin_expect (D.8299, 0);
      if (D.8300 != 0) goto <D.8301>; else goto <D.8302>;
      <D.8301>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mono-profiler-aot.c", 98, "outfile");
      <D.8302>:
      fprintf (outfile, "#VER:%d\n", 2);
      data.prof = prof;
      data.outfile = outfile;
      data.image = image;
      D.8303 = image_data->methods;
      monoeg_g_list_foreach (D.8303, foreach_method, &data);
    }
  finally
    {
      data = {CLOBBER};
    }
}


foreach_method (void * data, void * user_data)
{
  unsigned int D.8316;
  struct MonoClass * D.8318;
  struct MonoImage * D.8319;
  struct MonoImage * D.8320;
  struct FILE * D.8321;
  struct ForeachData * udata;
  struct MonoMethod * method;
  char * name;

  udata = user_data;
  method = data;
  D.8316 = mono_method_get_token (method);
  if (D.8316 == 0) goto <D.8314>; else goto <D.8317>;
  <D.8317>:
  D.8318 = mono_method_get_class (method);
  D.8319 = mono_class_get_image (D.8318);
  D.8320 = udata->image;
  if (D.8319 != D.8320) goto <D.8314>; else goto <D.8315>;
  <D.8314>:
  return;
  <D.8315>:
  name = mono_method_full_name (method, 1);
  D.8321 = udata->outfile;
  fprintf (D.8321, "%s\n", name);
  monoeg_g_free (name);
}


printf (const char * restrict __fmt)
{
  int D.8327;

  D.8327 = __printf_chk (1, __fmt, __builtin_va_arg_pack ());
  return D.8327;
}


fprintf (struct FILE * restrict __stream, const char * restrict __fmt)
{
  int D.8330;

  D.8330 = __fprintf_chk (__stream, 1, __fmt, __builtin_va_arg_pack ());
  return D.8330;
}


