mono_runtime_set_shutting_down ()
{
  shutting_down = 1;
}


mono_runtime_is_shutting_down ()
{
  mono_bool D.16999;

  D.16999 = shutting_down;
  return D.16999;
}


mono_runtime_try_shutdown ()
{
  int D.17001;
  gboolean D.17004;

  D.17001 = InterlockedCompareExchange (&shutting_down_inited, 1, 0);
  if (D.17001 != 0) goto <D.17002>; else goto <D.17003>;
  <D.17002>:
  D.17004 = 0;
  return D.17004;
  <D.17003>:
  mono_runtime_fire_process_exit_event ();
  shutting_down = 1;
  mono_threads_set_shutting_down ();
  mono_runtime_set_shutting_down ();
  mono_thread_pool_cleanup ();
  D.17004 = 1;
  return D.17004;
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.17006;
  unsigned int comp.0;
  unsigned int exch.1;
  unsigned int D.17009;

  comp.0 = (unsigned int) comp;
  exch.1 = (unsigned int) exch;
  D.17009 = __sync_val_compare_and_swap_4 (dest, comp.0, exch.1);
  D.17006 = (gint32) D.17009;
  return D.17006;
}


mono_runtime_fire_process_exit_event ()
{
  mono_domain_foreach (fire_process_exit_event, 0B);
}


fire_process_exit_event (struct MonoDomain * domain, void * user_data)
{
  struct MonoClass * D.17011;
  _Bool D.17012;
  long int D.17013;
  long int D.17014;
  struct MonoAppDomain * D.17017;
  int D.17018;
  sizetype D.17019;
  struct MonoObject * * D.17020;
  struct MonoClassField * field;
  void * pa[2];
  struct MonoObject * delegate;
  struct MonoObject * exc;

  try
    {
      D.17011 = mono_defaults.appdomain_class;
      field = mono_class_get_field_from_name (D.17011, "ProcessExit");
      D.17012 = field == 0B;
      D.17013 = (long int) D.17012;
      D.17014 = __builtin_expect (D.17013, 0);
      if (D.17014 != 0) goto <D.17015>; else goto <D.17016>;
      <D.17015>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "runtime.c", 64, "field");
      <D.17016>:
      D.17017 = domain->domain;
      D.17018 = field->offset;
      D.17019 = (sizetype) D.17018;
      D.17020 = D.17017 + D.17019;
      delegate = *D.17020;
      if (delegate == 0B) goto <D.17021>; else goto <D.17022>;
      <D.17021>:
      return;
      <D.17022>:
      pa[0] = domain;
      pa[1] = 0B;
      mono_runtime_delegate_invoke (delegate, &pa, &exc);
    }
  finally
    {
      pa = {CLOBBER};
      exc = {CLOBBER};
    }
}


mono_runtime_is_critical_method (struct MonoMethod * method)
{
  int D.17026;
  gboolean D.17029;

  D.17026 = mono_monitor_is_il_fastpath_wrapper (method);
  if (D.17026 != 0) goto <D.17027>; else goto <D.17028>;
  <D.17027>:
  D.17029 = 1;
  return D.17029;
  <D.17028>:
  D.17029 = 0;
  return D.17029;
}


mono_runtime_init_tls ()
{
  mono_marshal_init_tls ();
  mono_thread_pool_init_tls ();
  mono_thread_init_tls ();
}


