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

  prof = monoeg_malloc0 (4);
  D.7404 = monoeg_g_hash_table_new (0B, 0B);
  prof->images = D.7404;
  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.7407;
  struct GHashTable * D.7408;
  struct GList * D.7411;
  struct GList * D.7412;
  struct MonoImage * image;
  struct PerImageData * data;

  D.7407 = mono_method_get_class (method);
  image = mono_class_get_image (D.7407);
  D.7408 = prof->images;
  data = monoeg_g_hash_table_lookup (D.7408, image);
  if (data == 0B) goto <D.7409>; else goto <D.7410>;
  <D.7409>:
  data = monoeg_malloc0 (4);
  D.7408 = prof->images;
  monoeg_g_hash_table_insert_replace (D.7408, image, data, 0);
  <D.7410>:
  D.7411 = data->methods;
  D.7412 = monoeg_g_list_append (D.7411, method);
  data->methods = D.7412;
}


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

}


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

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


output_image (void * key, void * value, void * user_data)
{
  const gchar * D.7419;
  int D.7420;
  int * D.7425;
  int D.7426;
  const gchar * D.7427;
  struct _IO_FILE * stderr.0;
  const char * D.7429;
  int D.7430;
  _Bool D.7432;
  long int D.7433;
  long int D.7434;
  struct GList * D.7437;
  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.7419 = monoeg_g_get_home_dir ();
      tmp = monoeg_g_strdup_printf ("%s/.mono/aot-profile-data", D.7419);
      D.7420 = monoeg_g_file_test (tmp, 4);
      if (D.7420 == 0) goto <D.7421>; else goto <D.7422>;
      <D.7421>:
      err = mkdir (tmp, 511);
      if (err != 0) goto <D.7423>; else goto <D.7424>;
      <D.7423>:
      D.7425 = __errno_location ();
      D.7426 = *D.7425;
      D.7427 = monoeg_g_strerror (D.7426);
      stderr.0 = stderr;
      fprintf (stderr.0, "mono-profiler-aot: Unable to create output directory \'%s\': %s\n", tmp, D.7427);
      exit (1);
      <D.7424>:
      <D.7422>:
      i = 0;
      <D.7382>:
      D.7429 = mono_image_get_name (image);
      outfile_name = monoeg_g_strdup_printf ("%s/%s-%d", tmp, D.7429, i);
      D.7430 = monoeg_g_file_test (outfile_name, 1);
      if (D.7430 == 0) goto <D.7381>; else goto <D.7431>;
      <D.7431>:
      i = i + 1;
      goto <D.7382>;
      <D.7381>:
      printf ("Creating output file: %s\n", outfile_name);
      outfile = fopen (outfile_name, "w+");
      D.7432 = outfile == 0B;
      D.7433 = (long int) D.7432;
      D.7434 = __builtin_expect (D.7433, 0);
      if (D.7434 != 0) goto <D.7435>; else goto <D.7436>;
      <D.7435>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "mono-profiler-aot.c", 98, "outfile");
      <D.7436>:
      fprintf (outfile, "#VER:%d\n", 2);
      data.prof = prof;
      data.outfile = outfile;
      data.image = image;
      D.7437 = image_data->methods;
      monoeg_g_list_foreach (D.7437, foreach_method, &data);
    }
  finally
    {
      data = {CLOBBER};
    }
}


foreach_method (void * data, void * user_data)
{
  unsigned int D.7450;
  struct MonoClass * D.7452;
  struct MonoImage * D.7453;
  struct MonoImage * D.7454;
  struct FILE * D.7455;
  struct ForeachData * udata;
  struct MonoMethod * method;
  char * name;

  udata = user_data;
  method = data;
  D.7450 = mono_method_get_token (method);
  if (D.7450 == 0) goto <D.7448>; else goto <D.7451>;
  <D.7451>:
  D.7452 = mono_method_get_class (method);
  D.7453 = mono_class_get_image (D.7452);
  D.7454 = udata->image;
  if (D.7453 != D.7454) goto <D.7448>; else goto <D.7449>;
  <D.7448>:
  return;
  <D.7449>:
  name = mono_method_full_name (method, 1);
  D.7455 = udata->outfile;
  fprintf (D.7455, "%s\n", name);
  monoeg_g_free (name);
}


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

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


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

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


