mono_runtime_set_shutting_down ()
{
  shutting_down = 1;
}


mono_runtime_is_shutting_down ()
{
  mono_bool D.17019;

  D.17019 = shutting_down;
  return D.17019;
}


mono_runtime_try_shutdown ()
{
  int D.17021;
  gboolean D.17024;

  D.17021 = InterlockedCompareExchange (&shutting_down_inited, 1, 0);
  if (D.17021 != 0) goto <D.17022>; else goto <D.17023>;
  <D.17022>:
  D.17024 = 0;
  return D.17024;
  <D.17023>:
  mono_runtime_fire_process_exit_event ();
  shutting_down = 1;
  mono_threads_set_shutting_down ();
  mono_runtime_set_shutting_down ();
  mono_thread_pool_cleanup ();
  D.17024 = 1;
  return D.17024;
}


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

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


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.17031;
  _Bool D.17032;
  long int D.17033;
  long int D.17034;
  struct MonoAppDomain * D.17037;
  int D.17038;
  sizetype D.17039;
  struct MonoObject * * D.17040;
  struct MonoClassField * field;
  void * pa[2];
  struct MonoObject * delegate;
  struct MonoObject * exc;

  try
    {
      D.17031 = mono_defaults.appdomain_class;
      field = mono_class_get_field_from_name (D.17031, "ProcessExit");
      D.17032 = field == 0B;
      D.17033 = (long int) D.17032;
      D.17034 = __builtin_expect (D.17033, 0);
      if (D.17034 != 0) goto <D.17035>; else goto <D.17036>;
      <D.17035>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "runtime.c", 64, "field");
      <D.17036>:
      D.17037 = domain->domain;
      D.17038 = field->offset;
      D.17039 = (sizetype) D.17038;
      D.17040 = D.17037 + D.17039;
      delegate = *D.17040;
      if (delegate == 0B) goto <D.17041>; else goto <D.17042>;
      <D.17041>:
      return;
      <D.17042>:
      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.17046;
  gboolean D.17049;

  D.17046 = mono_monitor_is_il_fastpath_wrapper (method);
  if (D.17046 != 0) goto <D.17047>; else goto <D.17048>;
  <D.17047>:
  D.17049 = 1;
  return D.17049;
  <D.17048>:
  D.17049 = 0;
  return D.17049;
}


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


