__attribute__((visibility ("hidden")))
mono_monitor_init ()
{
  InitializeCriticalSection (&monitor_mutex);
}


__attribute__((visibility ("hidden")))
mono_monitor_cleanup ()
{
  struct MonoThreadsSync * mon;

  mon = monitor_freelist;
  goto <D.18417>;
  <D.18416>:
  mon->wait_list = -1B;
  mon = mon->data;
  <D.18417>:
  if (mon != 0B) goto <D.18416>; else goto <D.18418>;
  <D.18418>:
}


__attribute__((visibility ("hidden")))
mono_monitor_init_tls ()
{
  long unsigned int D.18660;

  D.18660 = pthread_self ();
  tls_pthread_self = D.18660;
}


mono_locks_dump (gboolean include_untaken)
{
  int D.18661;
  void * D.18662;
  int D.18665;
  int D.18669;
  void * * D.18672;
  long unsigned int D.18673;
  void * D.18676;
  unsigned int D.18677;
  void * D.18678;
  int D.18681;
  int i;
  int used;
  int on_freelist;
  int to_recycle;
  int total;
  int num_arrays;
  struct MonoThreadsSync * mon;
  struct MonitorArray * marray;

  used = 0;
  on_freelist = 0;
  to_recycle = 0;
  total = 0;
  num_arrays = 0;
  mon = monitor_freelist;
  goto <D.18441>;
  <D.18440>:
  on_freelist = on_freelist + 1;
  mon = mon->data;
  <D.18441>:
  if (mon != 0B) goto <D.18440>; else goto <D.18442>;
  <D.18442>:
  marray = monitor_allocated;
  goto <D.18448>;
  <D.18447>:
  D.18661 = marray->num_monitors;
  total = D.18661 + total;
  num_arrays = num_arrays + 1;
  i = 0;
  goto <D.18445>;
  <D.18444>:
  mon = &marray->monitors[i];
  D.18662 = mon->data;
  if (D.18662 == 0B) goto <D.18663>; else goto <D.18664>;
  <D.18663>:
  D.18661 = marray->num_monitors;
  D.18665 = D.18661 + -1;
  if (D.18665 > i) goto <D.18666>; else goto <D.18667>;
  <D.18666>:
  to_recycle = to_recycle + 1;
  <D.18667>:
  goto <D.18668>;
  <D.18664>:
  D.18662 = mon->data;
  D.18669 = monitor_is_on_freelist (D.18662);
  if (D.18669 == 0) goto <D.18670>; else goto <D.18671>;
  <D.18670>:
  {
    struct MonoObject * holder;

    D.18672 = &mon->data;
    holder = mono_gc_weak_link_get (D.18672);
    D.18673 = mon->owner;
    if (D.18673 != 0) goto <D.18674>; else goto <D.18675>;
    <D.18674>:
    D.18673 = mon->owner;
    D.18676 = (void *) D.18673;
    D.18677 = mon->nest;
    monoeg_g_print ("Lock %p in object %p held by thread %p, nest level: %d\n", mon, holder, D.18676, D.18677);
    D.18678 = mon->entry_sem;
    if (D.18678 != 0B) goto <D.18679>; else goto <D.18680>;
    <D.18679>:
    D.18678 = mon->entry_sem;
    D.18681 = mon->entry_count;
    monoeg_g_print ("\tWaiting on semaphore %p: %d\n", D.18678, D.18681);
    <D.18680>:
    goto <D.18682>;
    <D.18675>:
    if (include_untaken != 0) goto <D.18683>; else goto <D.18684>;
    <D.18683>:
    monoeg_g_print ("Lock %p in object %p untaken\n", mon, holder);
    <D.18684>:
    <D.18682>:
    used = used + 1;
  }
  <D.18671>:
  <D.18668>:
  i = i + 1;
  <D.18445>:
  D.18661 = marray->num_monitors;
  if (D.18661 > i) goto <D.18444>; else goto <D.18446>;
  <D.18446>:
  marray = marray->next;
  <D.18448>:
  if (marray != 0B) goto <D.18447>; else goto <D.18449>;
  <D.18449>:
  monoeg_g_print ("Total locks (in %d array(s)): %d, used: %d, on freelist: %d, to recycle: %d\n", num_arrays, total, used, on_freelist, to_recycle);
}


monitor_is_on_freelist (struct MonoThreadsSync * mon)
{
  struct MonoThreadsSync[0:] * D.18685;
  int D.18688;
  struct MonoThreadsSync * D.18689;
  int D.18692;
  struct MonitorArray * marray;

  marray = monitor_allocated;
  goto <D.18427>;
  <D.18426>:
  D.18685 = &marray->monitors;
  if (D.18685 <= mon) goto <D.18686>; else goto <D.18687>;
  <D.18686>:
  D.18688 = marray->num_monitors;
  D.18689 = &marray->monitors[D.18688];
  if (D.18689 > mon) goto <D.18690>; else goto <D.18691>;
  <D.18690>:
  D.18692 = 1;
  return D.18692;
  <D.18691>:
  <D.18687>:
  marray = marray->next;
  <D.18427>:
  if (marray != 0B) goto <D.18426>; else goto <D.18428>;
  <D.18428>:
  D.18692 = 0;
  return D.18692;
}


mono_object_hash (struct MonoObject * obj)
{
  int D.18696;
  struct MonoThreadsSync * D.18697;
  long unsigned int D.18698;
  long unsigned int D.18699;
  unsigned int D.18702;
  unsigned int D.18703;
  long unsigned int D.18704;
  long unsigned int D.18707;
  struct MonoThreadsSync * D.18708;
  long int obj.0;
  unsigned int D.18710;
  unsigned int D.18711;
  int hash.1;
  long unsigned int D.18715;
  unsigned int D.18717;
  unsigned int D.18718;
  long unsigned int D.18719;
  struct MonoThreadsSync * * D.18720;
  void * D.18721;
  union LockWord lw;
  unsigned int hash;

  try
    {
      if (obj == 0B) goto <D.18694>; else goto <D.18695>;
      <D.18694>:
      D.18696 = 0;
      return D.18696;
      <D.18695>:
      D.18697 = obj->synchronisation;
      lw.sync = D.18697;
      D.18698 = lw.lock_word;
      D.18699 = D.18698 & 1;
      if (D.18699 != 0) goto <D.18700>; else goto <D.18701>;
      <D.18700>:
      D.18698 = lw.lock_word;
      D.18702 = (unsigned int) D.18698;
      D.18703 = D.18702 >> 2;
      D.18696 = (int) D.18703;
      return D.18696;
      <D.18701>:
      D.18698 = lw.lock_word;
      D.18704 = D.18698 & 2;
      if (D.18704 != 0) goto <D.18705>; else goto <D.18706>;
      <D.18705>:
      D.18698 = lw.lock_word;
      D.18707 = D.18698 & 18446744073709551612;
      lw.lock_word = D.18707;
      D.18708 = lw.sync;
      D.18696 = D.18708->hash_code;
      return D.18696;
      <D.18706>:
      obj.0 = (long int) obj;
      D.18710 = (unsigned int) obj.0;
      D.18711 = D.18710 >> 3;
      hash = D.18711 * 2654435761;
      hash = hash & 1073741823;
      D.18708 = lw.sync;
      if (D.18708 != 0B) goto <D.18712>; else goto <D.18713>;
      <D.18712>:
      D.18708 = lw.sync;
      hash.1 = (int) hash;
      D.18708->hash_code = hash.1;
      D.18698 = lw.lock_word;
      D.18715 = D.18698 | 2;
      lw.lock_word = D.18715;
      D.18708 = lw.sync;
      obj->synchronisation = D.18708;
      goto <D.18716>;
      <D.18713>:
      D.18717 = hash << 2;
      D.18718 = D.18717 | 1;
      D.18719 = (long unsigned int) D.18718;
      lw.lock_word = D.18719;
      D.18720 = &obj->synchronisation;
      D.18708 = lw.sync;
      D.18721 = InterlockedCompareExchangePointer (D.18720, D.18708, 0B);
      if (D.18721 == 0B) goto <D.18722>; else goto <D.18723>;
      <D.18722>:
      D.18696 = (int) hash;
      return D.18696;
      <D.18723>:
      D.18697 = obj->synchronisation;
      lw.sync = D.18697;
      D.18698 = lw.lock_word;
      D.18699 = D.18698 & 1;
      if (D.18699 != 0) goto <D.18724>; else goto <D.18725>;
      <D.18724>:
      D.18696 = (int) hash;
      return D.18696;
      <D.18725>:
      D.18698 = lw.lock_word;
      D.18707 = D.18698 & 18446744073709551612;
      lw.lock_word = D.18707;
      D.18708 = lw.sync;
      hash.1 = (int) hash;
      D.18708->hash_code = hash.1;
      D.18698 = lw.lock_word;
      D.18715 = D.18698 | 2;
      lw.lock_word = D.18715;
      D.18708 = lw.sync;
      obj->synchronisation = D.18708;
      <D.18716>:
      D.18696 = (int) hash;
      return D.18696;
    }
  finally
    {
      lw = {CLOBBER};
    }
}


InterlockedCompareExchangePointer (void * volatile * dest, void * exch, void * comp)
{
  void * D.18728;
  long unsigned int comp.2;
  long unsigned int exch.3;
  long unsigned int D.18731;

  comp.2 = (long unsigned int) comp;
  exch.3 = (long unsigned int) exch;
  D.18731 = __sync_val_compare_and_swap_8 (dest, comp.2, exch.3);
  D.18728 = (void *) D.18731;
  return D.18728;
}


mono_monitor_enter (struct MonoObject * obj)
{
  mono_bool D.18733;
  int D.18734;
  _Bool D.18735;

  D.18734 = mono_monitor_try_enter_internal (obj, 4294967295, 0);
  D.18735 = D.18734 == 1;
  D.18733 = (mono_bool) D.18735;
  return D.18733;
}


mono_monitor_try_enter_internal (struct MonoObject * obj, guint32 ms, gboolean allow_interruption)
{
  _Bool D.18737;
  long int D.18738;
  long int D.18739;
  struct MonoException * D.18742;
  gint32 D.18743;
  _Bool D.18744;
  long int D.18745;
  long int D.18746;
  _Bool D.18751;
  long int D.18752;
  long int D.18753;
  struct MonoThreadsSync * * D.18756;
  void * D.18757;
  void * * D.18760;
  _Bool D.18763;
  long int D.18764;
  long int D.18765;
  struct MonoThreadsSync * D.18768;
  long unsigned int D.18769;
  long unsigned int D.18770;
  long unsigned int D.18773;
  int D.18774;
  long unsigned int D.18775;
  struct MonoThreadsSync * D.18776;
  void * D.18777;
  _Bool D.18782;
  long int D.18783;
  long int D.18784;
  _Bool D.18789;
  long int D.18790;
  long int D.18791;
  long unsigned int D.18794;
  _Bool D.18799;
  long int D.18800;
  long int D.18801;
  long unsigned int D.18804;
  _Bool D.18808;
  long int D.18809;
  long int D.18810;
  long unsigned int D.18814;
  long unsigned int D.18815;
  _Bool D.18820;
  long int D.18821;
  long int D.18822;
  long unsigned int D.18825;
  int D.18826;
  long unsigned int D.18827;
  struct MonoThreadsSync * D.18828;
  void * D.18829;
  _Bool D.18834;
  long int D.18835;
  long int D.18836;
  _Bool D.18841;
  long int D.18842;
  long int D.18843;
  long unsigned int D.18846;
  long unsigned int D.18847;
  long unsigned int D.18848;
  _Bool D.18849;
  long int D.18850;
  long int D.18851;
  gsize * D.18854;
  void * id.4;
  void * D.18856;
  _Bool D.18857;
  long int D.18858;
  long int D.18859;
  unsigned int D.18861;
  _Bool D.18862;
  long int D.18863;
  long int D.18864;
  unsigned int D.18869;
  struct MonoPerfCounters * mono_perfcounters.5;
  unsigned int D.18871;
  unsigned int D.18872;
  void * D.18877;
  _Bool D.18878;
  long int D.18879;
  long int D.18880;
  void * D.18887;
  _Bool D.18890;
  long int D.18891;
  long int D.18892;
  void * * D.18895;
  void * D.18896;
  volatile gint32 * D.18905;
  unsigned int D.18906;
  unsigned int D.18907;
  unsigned int D.18908;
  unsigned int D.18909;
  volatile gint32 * D.18910;
  unsigned int D.18911;
  unsigned int D.18916;
  struct MonoInternalThread * D.18932;
  int D.18933;
  struct MonoThreadsSync * mon;
  gsize id;
  void * sem;
  guint32 then;
  guint32 now;
  guint32 delta;
  guint32 waitms;
  guint32 ret;
  struct MonoInternalThread * thread;
  void retry = <<< error >>>;
  void retry_contended = <<< error >>>;

  id = tls_pthread_self;
  then = 0;
  D.18737 = obj == 0B;
  D.18738 = (long int) D.18737;
  D.18739 = __builtin_expect (D.18738, 0);
  if (D.18739 != 0) goto <D.18740>; else goto <D.18741>;
  <D.18740>:
  D.18742 = mono_get_exception_argument_null ("obj");
  mono_raise_exception (D.18742);
  D.18743 = 0;
  return D.18743;
  <D.18741>:
  retry:
  mon = obj->synchronisation;
  D.18744 = mon == 0B;
  D.18745 = (long int) D.18744;
  D.18746 = __builtin_expect (D.18745, 0);
  if (D.18746 != 0) goto <D.18747>; else goto <D.18748>;
  <D.18747>:
  {
    int ret;

    ret = pthread_mutex_lock (&monitor_mutex.mutex);
    if (ret != 0) goto <D.18749>; else goto <D.18750>;
    <D.18749>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.18750>:
    D.18751 = ret != 0;
    D.18752 = (long int) D.18751;
    D.18753 = __builtin_expect (D.18752, 0);
    if (D.18753 != 0) goto <D.18754>; else goto <D.18755>;
    <D.18754>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 439, "ret == 0");
    <D.18755>:
  }
  mon = mon_new (id);
  D.18756 = &obj->synchronisation;
  D.18757 = InterlockedCompareExchangePointer (D.18756, mon, 0B);
  if (D.18757 == 0B) goto <D.18758>; else goto <D.18759>;
  <D.18758>:
  D.18760 = &mon->data;
  mono_gc_weak_link_add (D.18760, obj, 0);
  {
    int ret;

    ret = pthread_mutex_unlock (&monitor_mutex.mutex);
    if (ret != 0) goto <D.18761>; else goto <D.18762>;
    <D.18761>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.18762>:
    D.18763 = ret != 0;
    D.18764 = (long int) D.18763;
    D.18765 = __builtin_expect (D.18764, 0);
    if (D.18765 != 0) goto <D.18766>; else goto <D.18767>;
    <D.18766>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 443, "ret == 0");
    <D.18767>:
  }
  D.18743 = 1;
  return D.18743;
  <D.18759>:
  {
    union LockWord lw;

    try
      {
        D.18768 = obj->synchronisation;
        lw.sync = D.18768;
        D.18769 = lw.lock_word;
        D.18770 = D.18769 & 1;
        if (D.18770 != 0) goto <D.18771>; else goto <D.18772>;
        <D.18771>:
        {
          struct MonoThreadsSync * oldlw;

          oldlw = lw.sync;
          D.18769 = lw.lock_word;
          D.18773 = D.18769 >> 2;
          D.18774 = (int) D.18773;
          mon->hash_code = D.18774;
          lw.sync = mon;
          D.18769 = lw.lock_word;
          D.18775 = D.18769 | 2;
          lw.lock_word = D.18775;
          D.18756 = &obj->synchronisation;
          D.18776 = lw.sync;
          D.18777 = InterlockedCompareExchangePointer (D.18756, D.18776, oldlw);
          if (D.18777 == oldlw) goto <D.18778>; else goto <D.18779>;
          <D.18778>:
          D.18760 = &mon->data;
          mono_gc_weak_link_add (D.18760, obj, 0);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18780>; else goto <D.18781>;
            <D.18780>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18781>:
            D.18782 = ret != 0;
            D.18783 = (long int) D.18782;
            D.18784 = __builtin_expect (D.18783, 0);
            if (D.18784 != 0) goto <D.18785>; else goto <D.18786>;
            <D.18785>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 458, "ret == 0");
            <D.18786>:
          }
          D.18743 = 1;
          return D.18743;
          <D.18779>:
          mon_finalize (mon);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18787>; else goto <D.18788>;
            <D.18787>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18788>:
            D.18789 = ret != 0;
            D.18790 = (long int) D.18789;
            D.18791 = __builtin_expect (D.18790, 0);
            if (D.18791 != 0) goto <D.18792>; else goto <D.18793>;
            <D.18792>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 463, "ret == 0");
            <D.18793>:
          }
          goto retry;
        }
        <D.18772>:
        D.18769 = lw.lock_word;
        D.18794 = D.18769 & 2;
        if (D.18794 != 0) goto <D.18795>; else goto <D.18796>;
        <D.18795>:
        mon_finalize (mon);
        {
          int ret;

          ret = pthread_mutex_unlock (&monitor_mutex.mutex);
          if (ret != 0) goto <D.18797>; else goto <D.18798>;
          <D.18797>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.18798>:
          D.18799 = ret != 0;
          D.18800 = (long int) D.18799;
          D.18801 = __builtin_expect (D.18800, 0);
          if (D.18801 != 0) goto <D.18802>; else goto <D.18803>;
          <D.18802>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 468, "ret == 0");
          <D.18803>:
        }
        D.18769 = lw.lock_word;
        D.18804 = D.18769 & 18446744073709551612;
        lw.lock_word = D.18804;
        mon = lw.sync;
        goto <D.18805>;
        <D.18796>:
        mon_finalize (mon);
        {
          int ret;

          ret = pthread_mutex_unlock (&monitor_mutex.mutex);
          if (ret != 0) goto <D.18806>; else goto <D.18807>;
          <D.18806>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.18807>:
          D.18808 = ret != 0;
          D.18809 = (long int) D.18808;
          D.18810 = __builtin_expect (D.18809, 0);
          if (D.18810 != 0) goto <D.18811>; else goto <D.18812>;
          <D.18811>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 474, "ret == 0");
          <D.18812>:
        }
        mon = obj->synchronisation;
        <D.18805>:
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  goto <D.18813>;
  <D.18748>:
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.18814 = lw.lock_word;
        D.18815 = D.18814 & 1;
        if (D.18815 != 0) goto <D.18816>; else goto <D.18817>;
        <D.18816>:
        {
          struct MonoThreadsSync * oldlw;

          oldlw = lw.sync;
          {
            int ret;

            ret = pthread_mutex_lock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18818>; else goto <D.18819>;
            <D.18818>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
            <D.18819>:
            D.18820 = ret != 0;
            D.18821 = (long int) D.18820;
            D.18822 = __builtin_expect (D.18821, 0);
            if (D.18822 != 0) goto <D.18823>; else goto <D.18824>;
            <D.18823>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 489, "ret == 0");
            <D.18824>:
          }
          mon = mon_new (id);
          D.18814 = lw.lock_word;
          D.18825 = D.18814 >> 2;
          D.18826 = (int) D.18825;
          mon->hash_code = D.18826;
          lw.sync = mon;
          D.18814 = lw.lock_word;
          D.18827 = D.18814 | 2;
          lw.lock_word = D.18827;
          D.18756 = &obj->synchronisation;
          D.18828 = lw.sync;
          D.18829 = InterlockedCompareExchangePointer (D.18756, D.18828, oldlw);
          if (D.18829 == oldlw) goto <D.18830>; else goto <D.18831>;
          <D.18830>:
          D.18760 = &mon->data;
          mono_gc_weak_link_add (D.18760, obj, 1);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18832>; else goto <D.18833>;
            <D.18832>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18833>:
            D.18834 = ret != 0;
            D.18835 = (long int) D.18834;
            D.18836 = __builtin_expect (D.18835, 0);
            if (D.18836 != 0) goto <D.18837>; else goto <D.18838>;
            <D.18837>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 497, "ret == 0");
            <D.18838>:
          }
          D.18743 = 1;
          return D.18743;
          <D.18831>:
          mon_finalize (mon);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18839>; else goto <D.18840>;
            <D.18839>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18840>:
            D.18841 = ret != 0;
            D.18842 = (long int) D.18841;
            D.18843 = __builtin_expect (D.18842, 0);
            if (D.18843 != 0) goto <D.18844>; else goto <D.18845>;
            <D.18844>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 502, "ret == 0");
            <D.18845>:
          }
          goto retry;
        }
        <D.18817>:
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  <D.18813>:
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.18846 = lw.lock_word;
        D.18847 = D.18846 & 18446744073709551612;
        lw.lock_word = D.18847;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  D.18848 = mon->owner;
  D.18849 = D.18848 == 0;
  D.18850 = (long int) D.18849;
  D.18851 = __builtin_expect (D.18850, 1);
  if (D.18851 != 0) goto <D.18852>; else goto <D.18853>;
  <D.18852>:
  D.18854 = &mon->owner;
  id.4 = (void *) id;
  D.18856 = InterlockedCompareExchangePointer (D.18854, id.4, 0B);
  D.18857 = D.18856 == 0B;
  D.18858 = (long int) D.18857;
  D.18859 = __builtin_expect (D.18858, 1);
  if (D.18859 != 0) goto <D.18860>; else goto retry;
  <D.18860>:
  D.18861 = mon->nest;
  D.18862 = D.18861 != 1;
  D.18863 = (long int) D.18862;
  D.18864 = __builtin_expect (D.18863, 0);
  if (D.18864 != 0) goto <D.18865>; else goto <D.18866>;
  <D.18865>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 530, "mon->nest == 1");
  <D.18866>:
  D.18743 = 1;
  return D.18743;
  <D.18853>:
  D.18848 = mon->owner;
  if (D.18848 == id) goto <D.18867>; else goto <D.18868>;
  <D.18867>:
  D.18861 = mon->nest;
  D.18869 = D.18861 + 1;
  mon->nest = D.18869;
  D.18743 = 1;
  return D.18743;
  <D.18868>:
  mono_perfcounters.5 = mono_perfcounters;
  D.18871 = mono_perfcounters.5->thread_contentions;
  D.18872 = D.18871 + 1;
  mono_perfcounters.5->thread_contentions = D.18872;
  if (ms == 0) goto <D.18873>; else goto <D.18874>;
  <D.18873>:
  D.18743 = 0;
  return D.18743;
  <D.18874>:
  mono_profiler_monitor_event (obj, 1);
  retry_contended:
  D.18848 = mon->owner;
  D.18849 = D.18848 == 0;
  D.18850 = (long int) D.18849;
  D.18851 = __builtin_expect (D.18850, 1);
  if (D.18851 != 0) goto <D.18875>; else goto <D.18876>;
  <D.18875>:
  D.18854 = &mon->owner;
  id.4 = (void *) id;
  D.18877 = InterlockedCompareExchangePointer (D.18854, id.4, 0B);
  D.18878 = D.18877 == 0B;
  D.18879 = (long int) D.18878;
  D.18880 = __builtin_expect (D.18879, 1);
  if (D.18880 != 0) goto <D.18881>; else goto <D.18882>;
  <D.18881>:
  D.18861 = mon->nest;
  D.18862 = D.18861 != 1;
  D.18863 = (long int) D.18862;
  D.18864 = __builtin_expect (D.18863, 0);
  if (D.18864 != 0) goto <D.18883>; else goto <D.18884>;
  <D.18883>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 574, "mon->nest == 1");
  <D.18884>:
  mono_profiler_monitor_event (obj, 2);
  D.18743 = 1;
  return D.18743;
  <D.18882>:
  <D.18876>:
  D.18848 = mon->owner;
  if (D.18848 == id) goto <D.18885>; else goto <D.18886>;
  <D.18885>:
  D.18861 = mon->nest;
  D.18869 = D.18861 + 1;
  mon->nest = D.18869;
  mono_profiler_monitor_event (obj, 2);
  D.18743 = 1;
  return D.18743;
  <D.18886>:
  D.18887 = mon->entry_sem;
  if (D.18887 == 0B) goto <D.18888>; else goto <D.18889>;
  <D.18888>:
  sem = CreateSemaphore (0B, 0, 2147483647, 0B);
  D.18890 = sem == 0B;
  D.18891 = (long int) D.18890;
  D.18892 = __builtin_expect (D.18891, 0);
  if (D.18892 != 0) goto <D.18893>; else goto <D.18894>;
  <D.18893>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 593, "sem != NULL");
  <D.18894>:
  D.18895 = &mon->entry_sem;
  D.18896 = InterlockedCompareExchangePointer (D.18895, sem, 0B);
  if (D.18896 != 0B) goto <D.18897>; else goto <D.18898>;
  <D.18897>:
  CloseHandle (sem);
  <D.18898>:
  <D.18889>:
  if (ms != 4294967295) goto <D.18899>; else goto <D.18900>;
  <D.18899>:
  then = mono_msec_ticks ();
  if (ms <= 99) goto <D.18901>; else goto <D.18902>;
  <D.18901>:
  waitms = ms;
  goto <D.18903>;
  <D.18902>:
  waitms = 100;
  <D.18903>:
  goto <D.18904>;
  <D.18900>:
  waitms = 100;
  <D.18904>:
  D.18905 = &mon->entry_count;
  InterlockedIncrement (D.18905);
  mono_perfcounters.5 = mono_perfcounters;
  D.18906 = mono_perfcounters.5->thread_queue_len;
  D.18907 = D.18906 + 1;
  mono_perfcounters.5->thread_queue_len = D.18907;
  mono_perfcounters.5 = mono_perfcounters;
  D.18908 = mono_perfcounters.5->thread_queue_max;
  D.18909 = D.18908 + 1;
  mono_perfcounters.5->thread_queue_max = D.18909;
  thread = mono_thread_internal_current ();
  mono_thread_set_state (thread, 32);
  D.18887 = mon->entry_sem;
  ret = WaitForSingleObjectEx (D.18887, waitms, 1);
  mono_thread_clr_state (thread, 32);
  D.18910 = &mon->entry_count;
  InterlockedDecrement (D.18910);
  mono_perfcounters.5 = mono_perfcounters;
  D.18906 = mono_perfcounters.5->thread_queue_len;
  D.18911 = D.18906 + 4294967295;
  mono_perfcounters.5->thread_queue_len = D.18911;
  if (ms != 4294967295) goto <D.18912>; else goto <D.18913>;
  <D.18912>:
  now = mono_msec_ticks ();
  if (now < then) goto <D.18914>; else goto <D.18915>;
  <D.18914>:
  D.18916 = now - then;
  now = D.18916 + 4294967295;
  then = 0;
  <D.18915>:
  delta = now - then;
  if (delta >= ms) goto <D.18917>; else goto <D.18918>;
  <D.18917>:
  ms = 0;
  goto <D.18919>;
  <D.18918>:
  ms = ms - delta;
  <D.18919>:
  if (ret == 258) goto <D.18920>; else goto <D.18922>;
  <D.18922>:
  if (ret == 192) goto <D.18923>; else goto <D.18921>;
  <D.18923>:
  if (allow_interruption == 0) goto <D.18920>; else goto <D.18921>;
  <D.18920>:
  if (ms != 0) goto retry_contended; else goto <D.18924>;
  <D.18924>:
  <D.18921>:
  goto <D.18925>;
  <D.18913>:
  if (ret == 258) goto <D.18926>; else goto <D.18928>;
  <D.18928>:
  if (ret == 192) goto <D.18929>; else goto <D.18927>;
  <D.18929>:
  if (allow_interruption == 0) goto <D.18926>; else goto <D.18927>;
  <D.18926>:
  if (ret == 192) goto <D.18930>; else goto <D.18931>;
  <D.18930>:
  D.18932 = mono_thread_internal_current ();
  D.18933 = mono_thread_test_state (D.18932, 3);
  if (D.18933 != 0) goto <D.18934>; else goto <D.18935>;
  <D.18934>:
  mono_profiler_monitor_event (obj, 3);
  D.18743 = -1;
  return D.18743;
  <D.18935>:
  <D.18931>:
  goto retry_contended;
  <D.18927>:
  <D.18925>:
  if (ret == 0) goto retry_contended; else goto <D.18936>;
  <D.18936>:
  mono_profiler_monitor_event (obj, 3);
  if (ret == 192) goto <D.18937>; else goto <D.18938>;
  <D.18937>:
  D.18743 = -1;
  return D.18743;
  <D.18938>:
  D.18743 = 0;
  return D.18743;
}


mon_new (gsize id)
{
  struct MonoThreadsSync * monitor_freelist.6;
  void * D.18949;
  struct GSList * D.18952;
  void * D.18955;
  struct GSList * D.18956;
  void * * D.18957;
  int D.18958;
  int array_size.7;
  long unsigned int D.18963;
  long unsigned int D.18964;
  long unsigned int D.18965;
  int D.18966;
  int D.18967;
  struct MonoThreadsSync * D.18968;
  int D.18969;
  struct MonoThreadsSync * D.18970;
  struct MonitorArray * monitor_allocated.8;
  struct MonitorArray * D.18975;
  void * D.18976;
  struct MonoPerfCounters * mono_perfcounters.9;
  unsigned int D.18978;
  unsigned int D.18979;
  struct MonoThreadsSync * D.18980;
  struct MonoThreadsSync * new;

  monitor_freelist.6 = monitor_freelist;
  if (monitor_freelist.6 == 0B) goto <D.18947>; else goto <D.18948>;
  <D.18947>:
  {
    struct MonitorArray * marray;
    int i;

    new = 0B;
    marray = monitor_allocated;
    goto <D.18467>;
    <D.18466>:
    i = 0;
    goto <D.18463>;
    <D.18462>:
    D.18949 = marray->monitors[i].data;
    if (D.18949 == 0B) goto <D.18950>; else goto <D.18951>;
    <D.18950>:
    new = &marray->monitors[i];
    D.18952 = new->wait_list;
    if (D.18952 != 0B) goto <D.18953>; else goto <D.18954>;
    <D.18953>:
    goto <D.18460>;
    <D.18459>:
    D.18952 = new->wait_list;
    D.18955 = D.18952->data;
    CloseHandle (D.18955);
    D.18952 = new->wait_list;
    D.18952 = new->wait_list;
    D.18955 = D.18952->data;
    D.18956 = monoeg_g_slist_remove (D.18952, D.18955);
    new->wait_list = D.18956;
    <D.18460>:
    D.18952 = new->wait_list;
    if (D.18952 != 0B) goto <D.18459>; else goto <D.18461>;
    <D.18461>:
    <D.18954>:
    D.18957 = &new->data;
    mono_gc_weak_link_remove (D.18957, 0);
    monitor_freelist.6 = monitor_freelist;
    new->data = monitor_freelist.6;
    monitor_freelist = new;
    <D.18951>:
    i = i + 1;
    <D.18463>:
    D.18958 = marray->num_monitors;
    if (D.18958 > i) goto <D.18462>; else goto <D.18464>;
    <D.18464>:
    if (new != 0B) goto <D.18465>; else goto <D.18959>;
    <D.18959>:
    marray = marray->next;
    <D.18467>:
    if (marray != 0B) goto <D.18466>; else goto <D.18465>;
    <D.18465>:
    monitor_freelist.6 = monitor_freelist;
    if (monitor_freelist.6 == 0B) goto <D.18960>; else goto <D.18961>;
    <D.18960>:
    {
      struct MonitorArray * last;

      array_size.7 = array_size;
      D.18963 = (long unsigned int) array_size.7;
      D.18964 = D.18963 * 48;
      D.18965 = D.18964 + 32;
      marray = monoeg_malloc0 (D.18965);
      array_size.7 = array_size;
      marray->num_monitors = array_size.7;
      array_size.7 = array_size;
      D.18966 = array_size.7 * 2;
      array_size = D.18966;
      i = 0;
      goto <D.18470>;
      <D.18469>:
      D.18967 = i + 1;
      D.18968 = &marray->monitors[D.18967];
      marray->monitors[i].data = D.18968;
      i = i + 1;
      <D.18470>:
      D.18958 = marray->num_monitors;
      D.18969 = D.18958 + -1;
      if (D.18969 > i) goto <D.18469>; else goto <D.18471>;
      <D.18471>:
      marray->monitors[i].data = 0B;
      D.18970 = &marray->monitors[0];
      monitor_freelist = D.18970;
      monitor_allocated.8 = monitor_allocated;
      if (monitor_allocated.8 == 0B) goto <D.18972>; else goto <D.18973>;
      <D.18972>:
      monitor_allocated = marray;
      goto <D.18974>;
      <D.18973>:
      last = monitor_allocated;
      goto <D.18473>;
      <D.18472>:
      last = last->next;
      <D.18473>:
      D.18975 = last->next;
      if (D.18975 != 0B) goto <D.18472>; else goto <D.18474>;
      <D.18474>:
      last->next = marray;
      <D.18974>:
    }
    <D.18961>:
  }
  <D.18948>:
  new = monitor_freelist;
  D.18976 = new->data;
  monitor_freelist = D.18976;
  new->owner = id;
  new->nest = 1;
  new->data = 0B;
  mono_perfcounters.9 = mono_perfcounters;
  D.18978 = mono_perfcounters.9->gc_sync_blocks;
  D.18979 = D.18978 + 1;
  mono_perfcounters.9->gc_sync_blocks = D.18979;
  D.18980 = new;
  return D.18980;
}


mon_finalize (struct MonoThreadsSync * mon)
{
  void * D.18982;
  struct GSList * D.18985;
  _Bool D.18986;
  long int D.18987;
  long int D.18988;
  struct MonoThreadsSync * monitor_freelist.10;
  struct MonoPerfCounters * mono_perfcounters.11;
  unsigned int D.18993;
  unsigned int D.18994;

  D.18982 = mon->entry_sem;
  if (D.18982 != 0B) goto <D.18983>; else goto <D.18984>;
  <D.18983>:
  D.18982 = mon->entry_sem;
  CloseHandle (D.18982);
  mon->entry_sem = 0B;
  <D.18984>:
  D.18985 = mon->wait_list;
  D.18986 = D.18985 != 0B;
  D.18987 = (long int) D.18986;
  D.18988 = __builtin_expect (D.18987, 0);
  if (D.18988 != 0) goto <D.18989>; else goto <D.18990>;
  <D.18989>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 239, "mon->wait_list == NULL");
  <D.18990>:
  mon->entry_count = 0;
  monitor_freelist.10 = monitor_freelist;
  mon->data = monitor_freelist.10;
  monitor_freelist = mon;
  mono_perfcounters.11 = mono_perfcounters;
  D.18993 = mono_perfcounters.11->gc_sync_blocks;
  D.18994 = D.18993 + 4294967295;
  mono_perfcounters.11->gc_sync_blocks = D.18994;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.18995;
  unsigned int D.18996;

  D.18996 = __sync_add_and_fetch_4 (val, 1);
  D.18995 = (gint32) D.18996;
  return D.18995;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.18998;
  unsigned int D.18999;

  D.18999 = __sync_sub_and_fetch_4 (val, 1);
  D.18998 = (gint32) D.18999;
  return D.18998;
}


mono_monitor_try_enter (struct MonoObject * obj, guint32 ms)
{
  mono_bool D.19001;
  int D.19002;
  _Bool D.19003;

  D.19002 = mono_monitor_try_enter_internal (obj, ms, 0);
  D.19003 = D.19002 == 1;
  D.19001 = (mono_bool) D.19003;
  return D.19001;
}


mono_monitor_exit (struct MonoObject * obj)
{
  _Bool D.19005;
  long int D.19006;
  long int D.19007;
  struct MonoException * D.19010;
  long unsigned int D.19011;
  long unsigned int D.19012;
  long unsigned int D.19015;
  _Bool D.19016;
  long int D.19017;
  long int D.19018;
  long unsigned int D.19021;
  long unsigned int tls_pthread_self.12;
  _Bool D.19023;
  long int D.19024;
  long int D.19025;
  unsigned int D.19028;
  int D.19031;
  void * D.19034;
  struct MonoThreadsSync * mon;
  guint32 nest;

  D.19005 = obj == 0B;
  D.19006 = (long int) D.19005;
  D.19007 = __builtin_expect (D.19006, 0);
  if (D.19007 != 0) goto <D.19008>; else goto <D.19009>;
  <D.19008>:
  D.19010 = mono_get_exception_argument_null ("obj");
  mono_raise_exception (D.19010);
  return;
  <D.19009>:
  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.19011 = lw.lock_word;
        D.19012 = D.19011 & 1;
        if (D.19012 != 0) goto <D.19013>; else goto <D.19014>;
        <D.19013>:
        return;
        <D.19014>:
        D.19011 = lw.lock_word;
        D.19015 = D.19011 & 18446744073709551612;
        lw.lock_word = D.19015;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  D.19016 = mon == 0B;
  D.19017 = (long int) D.19016;
  D.19018 = __builtin_expect (D.19017, 0);
  if (D.19018 != 0) goto <D.19019>; else goto <D.19020>;
  <D.19019>:
  return;
  <D.19020>:
  D.19021 = mon->owner;
  tls_pthread_self.12 = tls_pthread_self;
  D.19023 = D.19021 != tls_pthread_self.12;
  D.19024 = (long int) D.19023;
  D.19025 = __builtin_expect (D.19024, 0);
  if (D.19025 != 0) goto <D.19026>; else goto <D.19027>;
  <D.19026>:
  return;
  <D.19027>:
  D.19028 = mon->nest;
  nest = D.19028 + 4294967295;
  if (nest == 0) goto <D.19029>; else goto <D.19030>;
  <D.19029>:
  mon->owner = 0;
  D.19031 = mon->entry_count;
  if (D.19031 > 0) goto <D.19032>; else goto <D.19033>;
  <D.19032>:
  D.19034 = mon->entry_sem;
  ReleaseSemaphore (D.19034, 1, 0B);
  <D.19033>:
  goto <D.19035>;
  <D.19030>:
  mon->nest = nest;
  <D.19035>:
}


__attribute__((visibility ("hidden")))
mono_monitor_get_object_monitor_weak_link (struct MonoObject * object)
{
  struct MonoThreadsSync * D.19039;
  long unsigned int D.19040;
  long unsigned int D.19041;
  long unsigned int D.19044;
  long unsigned int D.19046;
  void * D.19051;
  void * * D.19054;
  union LockWord lw;
  struct MonoThreadsSync * sync;

  try
    {
      sync = 0B;
      D.19039 = object->synchronisation;
      lw.sync = D.19039;
      D.19040 = lw.lock_word;
      D.19041 = D.19040 & 2;
      if (D.19041 != 0) goto <D.19042>; else goto <D.19043>;
      <D.19042>:
      D.19040 = lw.lock_word;
      D.19044 = D.19040 & 18446744073709551612;
      lw.lock_word = D.19044;
      sync = lw.sync;
      goto <D.19045>;
      <D.19043>:
      D.19040 = lw.lock_word;
      D.19046 = D.19040 & 1;
      if (D.19046 == 0) goto <D.19047>; else goto <D.19048>;
      <D.19047>:
      sync = lw.sync;
      <D.19048>:
      <D.19045>:
      if (sync != 0B) goto <D.19049>; else goto <D.19050>;
      <D.19049>:
      D.19051 = sync->data;
      if (D.19051 != 0B) goto <D.19052>; else goto <D.19053>;
      <D.19052>:
      D.19054 = &sync->data;
      return D.19054;
      <D.19053>:
      <D.19050>:
      D.19054 = 0B;
      return D.19054;
    }
  finally
    {
      lw = {CLOBBER};
    }
}


__attribute__((visibility ("hidden")))
mono_monitor_is_il_fastpath_wrapper (struct MonoMethod * method)
{
  struct MonoMethod * D.19057;
  gboolean D.19060;
  int i;

  i = 0;
  goto <D.18552>;
  <D.18551>:
  D.19057 = monitor_il_fastpaths[i];
  if (D.19057 == method) goto <D.19058>; else goto <D.19059>;
  <D.19058>:
  D.19060 = 1;
  return D.19060;
  <D.19059>:
  i = i + 1;
  <D.18552>:
  if (i <= 2) goto <D.18551>; else goto <D.18553>;
  <D.18553>:
  D.19060 = 0;
  return D.19060;
}


__attribute__((visibility ("hidden")))
mono_monitor_get_fast_path (struct MonoMethod * enter_or_exit)
{
  const char * D.19062;
  int D.19063;
  struct MonoMethod * D.19066;
  int D.19067;

  D.19062 = enter_or_exit->name;
  D.19063 = strcmp (D.19062, "Enter");
  if (D.19063 == 0) goto <D.19064>; else goto <D.19065>;
  <D.19064>:
  D.19066 = mono_monitor_get_fast_enter_method (enter_or_exit);
  return D.19066;
  <D.19065>:
  D.19062 = enter_or_exit->name;
  D.19067 = strcmp (D.19062, "Exit");
  if (D.19067 == 0) goto <D.19068>; else goto <D.19069>;
  <D.19068>:
  D.19066 = mono_monitor_get_fast_exit_method (enter_or_exit);
  return D.19066;
  <D.19069>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "monitor.c", 1227);
  D.19066 = 0B;
  return D.19066;
}


mono_monitor_get_fast_enter_method (struct MonoMethod * monitor_enter_method)
{
  struct MonoMethodSignature * D.19071;
  short unsigned int D.19072;
  _Bool D.19073;
  _Bool D.19074;
  _Bool D.19075;
  long int D.19076;
  long int D.19077;
  struct MonoMethod * D.19082;
  struct MonoMethod * D.19083;
  struct MonoMethod * compare_exchange_method.13;
  struct MonoImage * D.19089;
  struct MonoMethod * compare_exchange_method.14;
  struct MonoClass * D.19093;
  const char * iftmp.15;
  struct MonoMethod * D.19098;
  struct MonoClass * D.19099;
  struct MonoType * D.19100;
  int * iftmp.16;
  unsigned int tid_loc.17;
  unsigned int syncp_loc.18;
  unsigned int owner_loc.19;
  unsigned int D.19108;
  unsigned int D.19109;
  unsigned int tid_branch.20;
  unsigned int D.19113;
  int thin_hash_branch.21;
  unsigned int thin_hash_branch.22;
  int obj_null_branch.23;
  unsigned int obj_null_branch.24;
  int syncp_null_branch.25;
  unsigned int syncp_null_branch.26;
  unsigned int has_owner_branch.27;
  unsigned int other_owner_branch.28;
  int true_locktaken_branch.29;
  unsigned int true_locktaken_branch.30;
  struct MonoMethodSignature * D.19132;
  struct MonoMethod * D.19133;
  WrapperSubtype iftmp.31;
  struct MonoMethodBuilder * mb;
  struct MonoMethod * res;
  static struct MonoMethod * compare_exchange_method;
  int obj_null_branch;
  int true_locktaken_branch;
  int syncp_null_branch;
  int has_owner_branch;
  int other_owner_branch;
  int tid_branch;
  int thin_hash_branch;
  int tid_loc;
  int syncp_loc;
  int owner_loc;
  int thread_tls_offset;
  gboolean is_v4;
  int fast_path_idx;
  struct WrapperInfo * info;

  try
    {
      true_locktaken_branch = 0;
      D.19071 = mono_method_signature (monitor_enter_method);
      D.19072 = D.19071->param_count;
      D.19073 = D.19072 == 2;
      is_v4 = (gboolean) D.19073;
      D.19074 = is_v4 != 0;
      fast_path_idx = (int) D.19074;
      D.19075 = is_v4 == 0;
      D.19076 = (long int) D.19075;
      D.19077 = __builtin_expect (D.19076, 0);
      if (D.19077 != 0) goto <D.19078>; else goto <D.19079>;
      <D.19078>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 898, "is_v4");
      <D.19079>:
      thread_tls_offset = mono_thread_get_tls_offset ();
      if (thread_tls_offset == -1) goto <D.19080>; else goto <D.19081>;
      <D.19080>:
      D.19082 = 0B;
      return D.19082;
      <D.19081>:
      D.19083 = monitor_il_fastpaths[fast_path_idx];
      if (D.19083 != 0B) goto <D.19084>; else goto <D.19085>;
      <D.19084>:
      D.19082 = monitor_il_fastpaths[fast_path_idx];
      return D.19082;
      <D.19085>:
      compare_exchange_method.13 = compare_exchange_method;
      if (compare_exchange_method.13 == 0B) goto <D.19087>; else goto <D.19088>;
      <D.19087>:
      {
        struct MonoMethodDesc * desc;
        struct MonoClass * class;

        desc = mono_method_desc_new ("Interlocked:CompareExchange(intptr&,intptr,intptr)", 0);
        D.19089 = mono_defaults.corlib;
        class = mono_class_from_name (D.19089, "System.Threading", "Interlocked");
        compare_exchange_method.14 = mono_method_desc_search_in_class (desc, class);
        compare_exchange_method = compare_exchange_method.14;
        mono_method_desc_free (desc);
        compare_exchange_method.13 = compare_exchange_method;
        if (compare_exchange_method.13 == 0B) goto <D.19091>; else goto <D.19092>;
        <D.19091>:
        D.19082 = 0B;
        return D.19082;
        <D.19092>:
      }
      <D.19088>:
      D.19093 = mono_defaults.monitor_class;
      if (is_v4 != 0) goto <D.19095>; else goto <D.19096>;
      <D.19095>:
      iftmp.15 = "FastMonitorEnterV4";
      goto <D.19097>;
      <D.19096>:
      iftmp.15 = "FastMonitorEnter";
      <D.19097>:
      mb = mono_mb_new (D.19093, iftmp.15, 25);
      D.19098 = mb->method;
      D.19098->slot = -1;
      D.19098 = mb->method;
      D.19098->flags = 182;
      D.19099 = mono_defaults.int_class;
      D.19100 = &D.19099->byval_arg;
      tid_loc = mono_mb_add_local (mb, D.19100);
      D.19099 = mono_defaults.int_class;
      D.19100 = &D.19099->byval_arg;
      syncp_loc = mono_mb_add_local (mb, D.19100);
      D.19099 = mono_defaults.int_class;
      D.19100 = &D.19099->byval_arg;
      owner_loc = mono_mb_add_local (mb, D.19100);
      if (is_v4 != 0) goto <D.19102>; else goto <D.19103>;
      <D.19102>:
      iftmp.16 = &true_locktaken_branch;
      goto <D.19104>;
      <D.19103>:
      iftmp.16 = 0B;
      <D.19104>:
      emit_obj_syncp_check (mb, syncp_loc, &obj_null_branch, iftmp.16, &syncp_null_branch, &thin_hash_branch, 0);
      mono_mb_emit_byte (mb, 240);
      mono_mb_emit_byte (mb, 13);
      mono_mb_emit_i4 (mb, 0);
      mono_mb_emit_icon (mb, 72);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      tid_loc.17 = (unsigned int) tid_loc;
      mono_mb_emit_stloc (mb, tid_loc.17);
      syncp_loc.18 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.18);
      mono_mb_emit_icon (mb, 0);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      owner_loc.19 = (unsigned int) owner_loc;
      mono_mb_emit_stloc (mb, owner_loc.19);
      owner_loc.19 = (unsigned int) owner_loc;
      mono_mb_emit_ldloc (mb, owner_loc.19);
      D.19108 = mono_mb_emit_short_branch (mb, 45);
      tid_branch = (int) D.19108;
      syncp_loc.18 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.18);
      mono_mb_emit_icon (mb, 0);
      mono_mb_emit_byte (mb, 88);
      tid_loc.17 = (unsigned int) tid_loc;
      mono_mb_emit_ldloc (mb, tid_loc.17);
      mono_mb_emit_byte (mb, 22);
      compare_exchange_method.13 = compare_exchange_method;
      mono_mb_emit_managed_call (mb, compare_exchange_method.13, 0B);
      D.19109 = mono_mb_emit_short_branch (mb, 45);
      has_owner_branch = (int) D.19109;
      if (is_v4 != 0) goto <D.19110>; else goto <D.19111>;
      <D.19110>:
      mono_mb_emit_byte (mb, 3);
      mono_mb_emit_byte (mb, 23);
      mono_mb_emit_byte (mb, 82);
      <D.19111>:
      mono_mb_emit_byte (mb, 42);
      tid_branch.20 = (unsigned int) tid_branch;
      mono_mb_patch_short_branch (mb, tid_branch.20);
      owner_loc.19 = (unsigned int) owner_loc;
      mono_mb_emit_ldloc (mb, owner_loc.19);
      tid_loc.17 = (unsigned int) tid_loc;
      mono_mb_emit_ldloc (mb, tid_loc.17);
      D.19113 = mono_mb_emit_short_branch (mb, 51);
      other_owner_branch = (int) D.19113;
      syncp_loc.18 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.18);
      mono_mb_emit_icon (mb, 8);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 37);
      mono_mb_emit_byte (mb, 74);
      mono_mb_emit_byte (mb, 23);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 84);
      if (is_v4 != 0) goto <D.19114>; else goto <D.19115>;
      <D.19114>:
      mono_mb_emit_byte (mb, 3);
      mono_mb_emit_byte (mb, 23);
      mono_mb_emit_byte (mb, 82);
      <D.19115>:
      mono_mb_emit_byte (mb, 42);
      thin_hash_branch.21 = thin_hash_branch;
      if (thin_hash_branch.21 != 0) goto <D.19117>; else goto <D.19118>;
      <D.19117>:
      thin_hash_branch.21 = thin_hash_branch;
      thin_hash_branch.22 = (unsigned int) thin_hash_branch.21;
      mono_mb_patch_short_branch (mb, thin_hash_branch.22);
      <D.19118>:
      obj_null_branch.23 = obj_null_branch;
      obj_null_branch.24 = (unsigned int) obj_null_branch.23;
      mono_mb_patch_short_branch (mb, obj_null_branch.24);
      syncp_null_branch.25 = syncp_null_branch;
      syncp_null_branch.26 = (unsigned int) syncp_null_branch.25;
      mono_mb_patch_short_branch (mb, syncp_null_branch.26);
      has_owner_branch.27 = (unsigned int) has_owner_branch;
      mono_mb_patch_short_branch (mb, has_owner_branch.27);
      other_owner_branch.28 = (unsigned int) other_owner_branch;
      mono_mb_patch_short_branch (mb, other_owner_branch.28);
      true_locktaken_branch.29 = true_locktaken_branch;
      if (true_locktaken_branch.29 != 0) goto <D.19127>; else goto <D.19128>;
      <D.19127>:
      true_locktaken_branch.29 = true_locktaken_branch;
      true_locktaken_branch.30 = (unsigned int) true_locktaken_branch.29;
      mono_mb_patch_short_branch (mb, true_locktaken_branch.30);
      <D.19128>:
      mono_mb_emit_byte (mb, 2);
      if (is_v4 != 0) goto <D.19130>; else goto <D.19131>;
      <D.19130>:
      mono_mb_emit_byte (mb, 3);
      <D.19131>:
      mono_mb_emit_managed_call (mb, monitor_enter_method, 0B);
      mono_mb_emit_byte (mb, 42);
      D.19132 = mono_signature_no_pinvoke (monitor_enter_method);
      D.19133 = mono_mb_create_method (mb, D.19132, 5);
      res = register_fastpath (D.19133, fast_path_idx);
      D.19089 = mono_defaults.corlib;
      info = mono_image_alloc0 (D.19089, 24);
      if (is_v4 != 0) goto <D.19135>; else goto <D.19136>;
      <D.19135>:
      iftmp.31 = 5;
      goto <D.19137>;
      <D.19136>:
      iftmp.31 = 4;
      <D.19137>:
      info->subtype = iftmp.31;
      mono_marshal_set_wrapper_info (res, info);
      mono_mb_free (mb);
      D.19082 = res;
      return D.19082;
    }
  finally
    {
      obj_null_branch = {CLOBBER};
      true_locktaken_branch = {CLOBBER};
      syncp_null_branch = {CLOBBER};
      thin_hash_branch = {CLOBBER};
    }
}


emit_obj_syncp_check (struct MonoMethodBuilder * mb, int syncp_loc, int * obj_null_branch, int * true_locktaken_branch, int * syncp_true_false_branch, int * thin_hash_branch, gboolean branch_on_true)
{
  unsigned int D.19140;
  int D.19141;
  unsigned int D.19144;
  int D.19145;
  unsigned int syncp_loc.32;
  int D.19147;
  unsigned int D.19150;
  int D.19151;
  guint8 iftmp.33;
  unsigned int D.19157;
  int D.19158;

  mono_mb_emit_byte (mb, 2);
  D.19140 = mono_mb_emit_short_branch (mb, 44);
  D.19141 = (int) D.19140;
  *obj_null_branch = D.19141;
  if (true_locktaken_branch != 0B) goto <D.19142>; else goto <D.19143>;
  <D.19142>:
  mono_mb_emit_byte (mb, 3);
  mono_mb_emit_byte (mb, 70);
  D.19144 = mono_mb_emit_short_branch (mb, 45);
  D.19145 = (int) D.19144;
  *true_locktaken_branch = D.19145;
  <D.19143>:
  mono_mb_emit_byte (mb, 2);
  mono_mb_emit_byte (mb, 211);
  mono_mb_emit_icon (mb, 8);
  mono_mb_emit_byte (mb, 88);
  mono_mb_emit_byte (mb, 77);
  syncp_loc.32 = (unsigned int) syncp_loc;
  mono_mb_emit_stloc (mb, syncp_loc.32);
  D.19147 = mono_gc_is_moving ();
  if (D.19147 != 0) goto <D.19148>; else goto <D.19149>;
  <D.19148>:
  syncp_loc.32 = (unsigned int) syncp_loc;
  mono_mb_emit_ldloc (mb, syncp_loc.32);
  mono_mb_emit_icon (mb, 1);
  mono_mb_emit_byte (mb, 211);
  mono_mb_emit_byte (mb, 95);
  D.19150 = mono_mb_emit_short_branch (mb, 45);
  D.19151 = (int) D.19150;
  *thin_hash_branch = D.19151;
  syncp_loc.32 = (unsigned int) syncp_loc;
  mono_mb_emit_ldloc (mb, syncp_loc.32);
  mono_mb_emit_icon (mb, -4);
  mono_mb_emit_byte (mb, 211);
  mono_mb_emit_byte (mb, 95);
  syncp_loc.32 = (unsigned int) syncp_loc;
  mono_mb_emit_stloc (mb, syncp_loc.32);
  goto <D.19152>;
  <D.19149>:
  *thin_hash_branch = 0;
  <D.19152>:
  syncp_loc.32 = (unsigned int) syncp_loc;
  mono_mb_emit_ldloc (mb, syncp_loc.32);
  if (branch_on_true != 0) goto <D.19154>; else goto <D.19155>;
  <D.19154>:
  iftmp.33 = 45;
  goto <D.19156>;
  <D.19155>:
  iftmp.33 = 44;
  <D.19156>:
  D.19157 = mono_mb_emit_short_branch (mb, iftmp.33);
  D.19158 = (int) D.19157;
  *syncp_true_false_branch = D.19158;
}


register_fastpath (struct MonoMethod * method, int idx)
{
  struct MonoMethod * D.19159;

  mono_memory_barrier ();
  monitor_il_fastpaths[idx] = method;
  D.19159 = method;
  return D.19159;
}


mono_memory_barrier ()
{
  __sync_synchronize ();
}


__attribute__((__gnu_inline__, nothrow, leaf, pure))
strcmp (const char * __s1, const char * __s2)
{
  int iftmp.34;
  int iftmp.35;
  int D.19169;
  char * __p1;
  char * __p2;
  int __ret;

  __p1 = __s1;
  __p2 = __s2;
  __asm__ __volatile__("   slr   0,0
0: clst  %1,%2
   jo    0b
   ipm   %0
   srl   %0,28" : "=d" __ret, "=&a" __p1, "=&a" __p2 : "1" __p1, "2" __p2 : "0", "memory", "cc");
  if (__ret != 0) goto <D.19162>; else goto <D.19163>;
  <D.19162>:
  if (__ret == 1) goto <D.19165>; else goto <D.19166>;
  <D.19165>:
  iftmp.35 = -1;
  goto <D.19167>;
  <D.19166>:
  iftmp.35 = 1;
  <D.19167>:
  iftmp.34 = iftmp.35;
  goto <D.19168>;
  <D.19163>:
  iftmp.34 = 0;
  <D.19168>:
  __ret = iftmp.34;
  D.19169 = __ret;
  return D.19169;
}


mono_monitor_get_fast_exit_method (struct MonoMethod * monitor_exit_method)
{
  struct MonoMethod * D.19173;
  struct MonoMethod * D.19174;
  struct MonoClass * D.19177;
  struct MonoMethod * D.19178;
  struct MonoClass * D.19179;
  struct MonoType * D.19180;
  int has_syncp_branch.36;
  unsigned int has_syncp_branch.37;
  unsigned int syncp_loc.38;
  unsigned int D.19184;
  unsigned int owned_branch.39;
  unsigned int D.19186;
  unsigned int D.19187;
  unsigned int nested_branch.40;
  int thin_hash_branch.41;
  unsigned int thin_hash_branch.42;
  int obj_null_branch.43;
  unsigned int obj_null_branch.44;
  unsigned int has_waiting_branch.45;
  struct MonoMethodSignature * D.19196;
  struct MonoMethod * D.19197;
  struct MonoImage * D.19198;
  struct MonoMethodBuilder * mb;
  struct MonoMethod * res;
  int obj_null_branch;
  int has_waiting_branch;
  int has_syncp_branch;
  int owned_branch;
  int nested_branch;
  int thin_hash_branch;
  int thread_tls_offset;
  int syncp_loc;
  struct WrapperInfo * info;

  try
    {
      thread_tls_offset = mono_thread_get_tls_offset ();
      if (thread_tls_offset == -1) goto <D.19171>; else goto <D.19172>;
      <D.19171>:
      D.19173 = 0B;
      return D.19173;
      <D.19172>:
      D.19174 = monitor_il_fastpaths[2];
      if (D.19174 != 0B) goto <D.19175>; else goto <D.19176>;
      <D.19175>:
      D.19173 = monitor_il_fastpaths[2];
      return D.19173;
      <D.19176>:
      D.19177 = mono_defaults.monitor_class;
      mb = mono_mb_new (D.19177, "FastMonitorExit", 25);
      D.19178 = mb->method;
      D.19178->slot = -1;
      D.19178 = mb->method;
      D.19178->flags = 182;
      D.19179 = mono_defaults.int_class;
      D.19180 = &D.19179->byval_arg;
      syncp_loc = mono_mb_add_local (mb, D.19180);
      emit_obj_syncp_check (mb, syncp_loc, &obj_null_branch, 0B, &has_syncp_branch, &thin_hash_branch, 1);
      mono_mb_emit_byte (mb, 42);
      has_syncp_branch.36 = has_syncp_branch;
      has_syncp_branch.37 = (unsigned int) has_syncp_branch.36;
      mono_mb_patch_short_branch (mb, has_syncp_branch.37);
      syncp_loc.38 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.38);
      mono_mb_emit_icon (mb, 0);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      mono_mb_emit_byte (mb, 240);
      mono_mb_emit_byte (mb, 13);
      mono_mb_emit_i4 (mb, 0);
      mono_mb_emit_icon (mb, 72);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      D.19184 = mono_mb_emit_short_branch (mb, 46);
      owned_branch = (int) D.19184;
      mono_mb_emit_byte (mb, 42);
      owned_branch.39 = (unsigned int) owned_branch;
      mono_mb_patch_short_branch (mb, owned_branch.39);
      syncp_loc.38 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.38);
      mono_mb_emit_icon (mb, 8);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 37);
      mono_mb_emit_byte (mb, 74);
      mono_mb_emit_byte (mb, 37);
      mono_mb_emit_byte (mb, 23);
      D.19186 = mono_mb_emit_short_branch (mb, 53);
      nested_branch = (int) D.19186;
      mono_mb_emit_byte (mb, 38);
      mono_mb_emit_byte (mb, 38);
      syncp_loc.38 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.38);
      mono_mb_emit_icon (mb, 16);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 74);
      D.19187 = mono_mb_emit_short_branch (mb, 45);
      has_waiting_branch = (int) D.19187;
      syncp_loc.38 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.38);
      mono_mb_emit_icon (mb, 0);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 20);
      mono_mb_emit_byte (mb, 223);
      mono_mb_emit_byte (mb, 42);
      nested_branch.40 = (unsigned int) nested_branch;
      mono_mb_patch_short_branch (mb, nested_branch.40);
      mono_mb_emit_byte (mb, 23);
      mono_mb_emit_byte (mb, 89);
      mono_mb_emit_byte (mb, 84);
      mono_mb_emit_byte (mb, 42);
      thin_hash_branch.41 = thin_hash_branch;
      if (thin_hash_branch.41 != 0) goto <D.19190>; else goto <D.19191>;
      <D.19190>:
      thin_hash_branch.41 = thin_hash_branch;
      thin_hash_branch.42 = (unsigned int) thin_hash_branch.41;
      mono_mb_patch_short_branch (mb, thin_hash_branch.42);
      <D.19191>:
      obj_null_branch.43 = obj_null_branch;
      obj_null_branch.44 = (unsigned int) obj_null_branch.43;
      mono_mb_patch_short_branch (mb, obj_null_branch.44);
      has_waiting_branch.45 = (unsigned int) has_waiting_branch;
      mono_mb_patch_short_branch (mb, has_waiting_branch.45);
      mono_mb_emit_byte (mb, 2);
      mono_mb_emit_managed_call (mb, monitor_exit_method, 0B);
      mono_mb_emit_byte (mb, 42);
      D.19196 = mono_signature_no_pinvoke (monitor_exit_method);
      D.19197 = mono_mb_create_method (mb, D.19196, 5);
      res = register_fastpath (D.19197, 2);
      mono_mb_free (mb);
      D.19198 = mono_defaults.corlib;
      info = mono_image_alloc0 (D.19198, 24);
      info->subtype = 6;
      mono_marshal_set_wrapper_info (res, info);
      D.19173 = res;
      return D.19173;
    }
  finally
    {
      obj_null_branch = {CLOBBER};
      has_syncp_branch = {CLOBBER};
      thin_hash_branch = {CLOBBER};
    }
}


__attribute__((visibility ("hidden")))
mono_monitor_threads_sync_members_offset (int * owner_offset, int * nest_offset, int * entry_count_offset)
{
  struct MonoThreadsSync ts;

  try
    {
      *owner_offset = 8;
      *nest_offset = 2052;
      *entry_count_offset = 4100;
    }
  finally
    {
      ts = {CLOBBER};
    }
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_try_enter (struct MonoObject * obj, guint32 ms)
{
  gboolean D.19203;
  _Bool D.19204;
  gint32 res;

  <D.18612>:
  res = mono_monitor_try_enter_internal (obj, ms, 1);
  if (res == -1) goto <D.19201>; else goto <D.19202>;
  <D.19201>:
  mono_thread_interruption_checkpoint ();
  <D.19202>:
  if (res == -1) goto <D.18612>; else goto <D.18613>;
  <D.18613>:
  D.19204 = res == 1;
  D.19203 = (gboolean) D.19204;
  return D.19203;
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (struct MonoObject * obj, guint32 ms, char * lockTaken)
{
  _Bool D.19208;
  char D.19209;
  gint32 res;

  <D.18620>:
  res = mono_monitor_try_enter_internal (obj, ms, 1);
  if (res == -1) goto <D.19206>; else goto <D.19207>;
  <D.19206>:
  mono_thread_interruption_checkpoint ();
  <D.19207>:
  if (res == -1) goto <D.18620>; else goto <D.18621>;
  <D.18621>:
  D.19208 = res == 1;
  D.19209 = (char) D.19208;
  *lockTaken = D.19209;
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_test_owner (struct MonoObject * obj)
{
  long unsigned int D.19210;
  long unsigned int D.19211;
  gboolean D.19214;
  long unsigned int D.19215;
  long unsigned int D.19218;
  long unsigned int tls_pthread_self.46;
  struct MonoThreadsSync * mon;

  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.19210 = lw.lock_word;
        D.19211 = D.19210 & 1;
        if (D.19211 != 0) goto <D.19212>; else goto <D.19213>;
        <D.19212>:
        D.19214 = 0;
        return D.19214;
        <D.19213>:
        D.19210 = lw.lock_word;
        D.19215 = D.19210 & 18446744073709551612;
        lw.lock_word = D.19215;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.19216>; else goto <D.19217>;
  <D.19216>:
  D.19214 = 0;
  return D.19214;
  <D.19217>:
  D.19218 = mon->owner;
  tls_pthread_self.46 = tls_pthread_self;
  if (D.19218 == tls_pthread_self.46) goto <D.19220>; else goto <D.19221>;
  <D.19220>:
  D.19214 = 1;
  return D.19214;
  <D.19221>:
  D.19214 = 0;
  return D.19214;
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_test_synchronised (struct MonoObject * obj)
{
  long unsigned int D.19225;
  long unsigned int D.19226;
  gboolean D.19229;
  long unsigned int D.19230;
  long unsigned int D.19233;
  struct MonoThreadsSync * mon;

  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.19225 = lw.lock_word;
        D.19226 = D.19225 & 1;
        if (D.19226 != 0) goto <D.19227>; else goto <D.19228>;
        <D.19227>:
        D.19229 = 0;
        return D.19229;
        <D.19228>:
        D.19225 = lw.lock_word;
        D.19230 = D.19225 & 18446744073709551612;
        lw.lock_word = D.19230;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.19231>; else goto <D.19232>;
  <D.19231>:
  D.19229 = 0;
  return D.19229;
  <D.19232>:
  D.19233 = mon->owner;
  if (D.19233 != 0) goto <D.19234>; else goto <D.19235>;
  <D.19234>:
  D.19229 = 1;
  return D.19229;
  <D.19235>:
  D.19229 = 0;
  return D.19229;
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_pulse (struct MonoObject * obj)
{
  long unsigned int D.19239;
  long unsigned int D.19240;
  struct MonoException * D.19243;
  long unsigned int D.19244;
  struct MonoException * D.19247;
  long unsigned int D.19248;
  long unsigned int tls_pthread_self.47;
  struct MonoException * D.19252;
  struct GSList * D.19253;
  void * D.19256;
  struct GSList * D.19257;
  struct MonoThreadsSync * mon;

  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.19239 = lw.lock_word;
        D.19240 = D.19239 & 1;
        if (D.19240 != 0) goto <D.19241>; else goto <D.19242>;
        <D.19241>:
        D.19243 = mono_get_exception_synchronization_lock ("Not locked");
        mono_raise_exception (D.19243);
        return;
        <D.19242>:
        D.19239 = lw.lock_word;
        D.19244 = D.19239 & 18446744073709551612;
        lw.lock_word = D.19244;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.19245>; else goto <D.19246>;
  <D.19245>:
  D.19247 = mono_get_exception_synchronization_lock ("Not locked");
  mono_raise_exception (D.19247);
  return;
  <D.19246>:
  D.19248 = mon->owner;
  tls_pthread_self.47 = tls_pthread_self;
  if (D.19248 != tls_pthread_self.47) goto <D.19250>; else goto <D.19251>;
  <D.19250>:
  D.19252 = mono_get_exception_synchronization_lock ("Not locked by this thread");
  mono_raise_exception (D.19252);
  return;
  <D.19251>:
  D.19253 = mon->wait_list;
  if (D.19253 != 0B) goto <D.19254>; else goto <D.19255>;
  <D.19254>:
  D.19253 = mon->wait_list;
  D.19256 = D.19253->data;
  SetEvent (D.19256);
  D.19253 = mon->wait_list;
  D.19253 = mon->wait_list;
  D.19256 = D.19253->data;
  D.19257 = monoeg_g_slist_remove (D.19253, D.19256);
  mon->wait_list = D.19257;
  <D.19255>:
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_pulse_all (struct MonoObject * obj)
{
  long unsigned int D.19261;
  long unsigned int D.19262;
  struct MonoException * D.19265;
  long unsigned int D.19266;
  struct MonoException * D.19269;
  long unsigned int D.19270;
  long unsigned int tls_pthread_self.48;
  struct MonoException * D.19274;
  struct GSList * D.19275;
  void * D.19276;
  struct GSList * D.19277;
  struct MonoThreadsSync * mon;

  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.19261 = lw.lock_word;
        D.19262 = D.19261 & 1;
        if (D.19262 != 0) goto <D.19263>; else goto <D.19264>;
        <D.19263>:
        D.19265 = mono_get_exception_synchronization_lock ("Not locked");
        mono_raise_exception (D.19265);
        return;
        <D.19264>:
        D.19261 = lw.lock_word;
        D.19266 = D.19261 & 18446744073709551612;
        lw.lock_word = D.19266;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.19267>; else goto <D.19268>;
  <D.19267>:
  D.19269 = mono_get_exception_synchronization_lock ("Not locked");
  mono_raise_exception (D.19269);
  return;
  <D.19268>:
  D.19270 = mon->owner;
  tls_pthread_self.48 = tls_pthread_self;
  if (D.19270 != tls_pthread_self.48) goto <D.19272>; else goto <D.19273>;
  <D.19272>:
  D.19274 = mono_get_exception_synchronization_lock ("Not locked by this thread");
  mono_raise_exception (D.19274);
  return;
  <D.19273>:
  goto <D.18643>;
  <D.18642>:
  D.19275 = mon->wait_list;
  D.19276 = D.19275->data;
  SetEvent (D.19276);
  D.19275 = mon->wait_list;
  D.19275 = mon->wait_list;
  D.19276 = D.19275->data;
  D.19277 = monoeg_g_slist_remove (D.19275, D.19276);
  mon->wait_list = D.19277;
  <D.18643>:
  D.19275 = mon->wait_list;
  if (D.19275 != 0B) goto <D.18642>; else goto <D.18644>;
  <D.18644>:
}


__attribute__((visibility ("hidden")))
ves_icall_System_Threading_Monitor_Monitor_wait (struct MonoObject * obj, guint32 ms)
{
  long unsigned int D.19281;
  long unsigned int D.19282;
  struct MonoException * D.19285;
  gboolean D.19286;
  long unsigned int D.19287;
  struct MonoException * D.19290;
  long unsigned int D.19291;
  long unsigned int tls_pthread_self.49;
  struct MonoException * D.19295;
  struct MonoException * D.19298;
  struct GSList * D.19299;
  struct GSList * D.19300;
  int D.19301;
  struct MonoException * D.19308;
  struct GSList * D.19314;
  struct MonoThreadsSync * mon;
  void * event;
  guint32 nest;
  guint32 ret;
  gboolean success;
  gint32 regain;
  struct MonoInternalThread * thread;

  success = 0;
  thread = mono_thread_internal_current ();
  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.19281 = lw.lock_word;
        D.19282 = D.19281 & 1;
        if (D.19282 != 0) goto <D.19283>; else goto <D.19284>;
        <D.19283>:
        D.19285 = mono_get_exception_synchronization_lock ("Not locked");
        mono_raise_exception (D.19285);
        D.19286 = 0;
        return D.19286;
        <D.19284>:
        D.19281 = lw.lock_word;
        D.19287 = D.19281 & 18446744073709551612;
        lw.lock_word = D.19287;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.19288>; else goto <D.19289>;
  <D.19288>:
  D.19290 = mono_get_exception_synchronization_lock ("Not locked");
  mono_raise_exception (D.19290);
  D.19286 = 0;
  return D.19286;
  <D.19289>:
  D.19291 = mon->owner;
  tls_pthread_self.49 = tls_pthread_self;
  if (D.19291 != tls_pthread_self.49) goto <D.19293>; else goto <D.19294>;
  <D.19293>:
  D.19295 = mono_get_exception_synchronization_lock ("Not locked by this thread");
  mono_raise_exception (D.19295);
  D.19286 = 0;
  return D.19286;
  <D.19294>:
  mono_thread_current_check_pending_interrupt ();
  event = CreateEvent (0B, 0, 0, 0B);
  if (event == 0B) goto <D.19296>; else goto <D.19297>;
  <D.19296>:
  D.19298 = mono_get_exception_synchronization_lock ("Failed to set up wait event");
  mono_raise_exception (D.19298);
  D.19286 = 0;
  return D.19286;
  <D.19297>:
  mono_thread_current_check_pending_interrupt ();
  mono_thread_set_state (thread, 32);
  D.19299 = mon->wait_list;
  D.19300 = monoeg_g_slist_append (D.19299, event);
  mon->wait_list = D.19300;
  nest = mon->nest;
  mon->nest = 1;
  mono_monitor_exit (obj);
  ret = WaitForSingleObjectEx (event, ms, 1);
  mono_thread_clr_state (thread, 32);
  D.19301 = mono_thread_interruption_requested ();
  if (D.19301 != 0) goto <D.19302>; else goto <D.19303>;
  <D.19302>:
  D.19286 = 0;
  return D.19286;
  <D.19303>:
  <D.18657>:
  regain = mono_monitor_try_enter_internal (obj, 4294967295, 1);
  if (regain == -1) goto <D.19304>; else goto <D.19305>;
  <D.19304>:
  mono_thread_interruption_checkpoint ();
  <D.19305>:
  if (regain == -1) goto <D.18657>; else goto <D.18658>;
  <D.18658>:
  if (regain == 0) goto <D.19306>; else goto <D.19307>;
  <D.19306>:
  CloseHandle (event);
  D.19308 = mono_get_exception_synchronization_lock ("Failed to regain lock");
  mono_raise_exception (D.19308);
  D.19286 = 0;
  return D.19286;
  <D.19307>:
  mon->nest = nest;
  if (ret == 258) goto <D.19309>; else goto <D.19310>;
  <D.19309>:
  ret = WaitForSingleObjectEx (event, 0, 0);
  <D.19310>:
  if (ret == 0) goto <D.19311>; else goto <D.19312>;
  <D.19311>:
  success = 1;
  goto <D.19313>;
  <D.19312>:
  D.19299 = mon->wait_list;
  D.19314 = monoeg_g_slist_remove (D.19299, event);
  mon->wait_list = D.19314;
  <D.19313>:
  CloseHandle (event);
  D.19286 = success;
  return D.19286;
}


