mono_monitor_init ()
{
  InitializeCriticalSection (&monitor_mutex);
}


mono_monitor_cleanup ()
{
  struct MonoThreadsSync * mon;

  mon = monitor_freelist;
  goto <D.17889>;
  <D.17888>:
  mon->wait_list = 4294967295B;
  mon = mon->data;
  <D.17889>:
  if (mon != 0B) goto <D.17888>; else goto <D.17890>;
  <D.17890>:
}


mono_monitor_init_tls ()
{
  long unsigned int tls_pthread_self.0;

  tls_pthread_self.0 = pthread_self ();
  tls_pthread_self = tls_pthread_self.0;
}


mono_locks_dump (gboolean include_untaken)
{
  int D.18151;
  void * D.18152;
  int D.18155;
  int D.18159;
  void * * D.18162;
  unsigned int D.18163;
  void * D.18166;
  unsigned int D.18167;
  void * D.18168;
  int D.18171;
  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.17913>;
  <D.17912>:
  on_freelist = on_freelist + 1;
  mon = mon->data;
  <D.17913>:
  if (mon != 0B) goto <D.17912>; else goto <D.17914>;
  <D.17914>:
  marray = monitor_allocated;
  goto <D.17920>;
  <D.17919>:
  D.18151 = marray->num_monitors;
  total = D.18151 + total;
  num_arrays = num_arrays + 1;
  i = 0;
  goto <D.17917>;
  <D.17916>:
  mon = &marray->monitors[i];
  D.18152 = mon->data;
  if (D.18152 == 0B) goto <D.18153>; else goto <D.18154>;
  <D.18153>:
  D.18151 = marray->num_monitors;
  D.18155 = D.18151 + -1;
  if (D.18155 > i) goto <D.18156>; else goto <D.18157>;
  <D.18156>:
  to_recycle = to_recycle + 1;
  <D.18157>:
  goto <D.18158>;
  <D.18154>:
  D.18152 = mon->data;
  D.18159 = monitor_is_on_freelist (D.18152);
  if (D.18159 == 0) goto <D.18160>; else goto <D.18161>;
  <D.18160>:
  {
    struct MonoObject * holder;

    D.18162 = &mon->data;
    holder = mono_gc_weak_link_get (D.18162);
    D.18163 = mon->owner;
    if (D.18163 != 0) goto <D.18164>; else goto <D.18165>;
    <D.18164>:
    D.18163 = mon->owner;
    D.18166 = (void *) D.18163;
    D.18167 = mon->nest;
    monoeg_g_print ("Lock %p in object %p held by thread %p, nest level: %d\n", mon, holder, D.18166, D.18167);
    D.18168 = mon->entry_sem;
    if (D.18168 != 0B) goto <D.18169>; else goto <D.18170>;
    <D.18169>:
    D.18168 = mon->entry_sem;
    D.18171 = mon->entry_count;
    monoeg_g_print ("\tWaiting on semaphore %p: %d\n", D.18168, D.18171);
    <D.18170>:
    goto <D.18172>;
    <D.18165>:
    if (include_untaken != 0) goto <D.18173>; else goto <D.18174>;
    <D.18173>:
    monoeg_g_print ("Lock %p in object %p untaken\n", mon, holder);
    <D.18174>:
    <D.18172>:
    used = used + 1;
  }
  <D.18161>:
  <D.18158>:
  i = i + 1;
  <D.17917>:
  D.18151 = marray->num_monitors;
  if (D.18151 > i) goto <D.17916>; else goto <D.17918>;
  <D.17918>:
  marray = marray->next;
  <D.17920>:
  if (marray != 0B) goto <D.17919>; else goto <D.17921>;
  <D.17921>:
  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.18175;
  int D.18178;
  struct MonoThreadsSync * D.18179;
  int D.18182;
  struct MonitorArray * marray;

  marray = monitor_allocated;
  goto <D.17899>;
  <D.17898>:
  D.18175 = &marray->monitors;
  if (D.18175 <= mon) goto <D.18176>; else goto <D.18177>;
  <D.18176>:
  D.18178 = marray->num_monitors;
  D.18179 = &marray->monitors[D.18178];
  if (D.18179 > mon) goto <D.18180>; else goto <D.18181>;
  <D.18180>:
  D.18182 = 1;
  return D.18182;
  <D.18181>:
  <D.18177>:
  marray = marray->next;
  <D.17899>:
  if (marray != 0B) goto <D.17898>; else goto <D.17900>;
  <D.17900>:
  D.18182 = 0;
  return D.18182;
}


mono_object_hash (struct MonoObject * obj)
{
  int D.18186;
  struct MonoThreadsSync * D.18187;
  unsigned int D.18188;
  unsigned int D.18189;
  unsigned int D.18192;
  unsigned int D.18193;
  unsigned int D.18196;
  struct MonoThreadsSync * D.18197;
  unsigned int obj.1;
  unsigned int D.18199;
  int hash.2;
  unsigned int D.18203;
  unsigned int D.18205;
  unsigned int D.18206;
  struct MonoThreadsSync * * D.18207;
  void * D.18208;
  union LockWord lw;
  unsigned int hash;

  try
    {
      if (obj == 0B) goto <D.18184>; else goto <D.18185>;
      <D.18184>:
      D.18186 = 0;
      return D.18186;
      <D.18185>:
      D.18187 = obj->synchronisation;
      lw.sync = D.18187;
      D.18188 = lw.lock_word;
      D.18189 = D.18188 & 1;
      if (D.18189 != 0) goto <D.18190>; else goto <D.18191>;
      <D.18190>:
      D.18188 = lw.lock_word;
      D.18192 = D.18188 >> 2;
      D.18186 = (int) D.18192;
      return D.18186;
      <D.18191>:
      D.18188 = lw.lock_word;
      D.18193 = D.18188 & 2;
      if (D.18193 != 0) goto <D.18194>; else goto <D.18195>;
      <D.18194>:
      D.18188 = lw.lock_word;
      D.18196 = D.18188 & 4294967292;
      lw.lock_word = D.18196;
      D.18197 = lw.sync;
      D.18186 = D.18197->hash_code;
      return D.18186;
      <D.18195>:
      obj.1 = (unsigned int) obj;
      D.18199 = obj.1 >> 3;
      hash = D.18199 * 2654435761;
      hash = hash & 1073741823;
      D.18197 = lw.sync;
      if (D.18197 != 0B) goto <D.18200>; else goto <D.18201>;
      <D.18200>:
      D.18197 = lw.sync;
      hash.2 = (int) hash;
      D.18197->hash_code = hash.2;
      D.18188 = lw.lock_word;
      D.18203 = D.18188 | 2;
      lw.lock_word = D.18203;
      D.18197 = lw.sync;
      obj->synchronisation = D.18197;
      goto <D.18204>;
      <D.18201>:
      D.18205 = hash << 2;
      D.18206 = D.18205 | 1;
      lw.lock_word = D.18206;
      D.18207 = &obj->synchronisation;
      D.18197 = lw.sync;
      D.18208 = InterlockedCompareExchangePointer (D.18207, D.18197, 0B);
      if (D.18208 == 0B) goto <D.18209>; else goto <D.18210>;
      <D.18209>:
      D.18186 = (int) hash;
      return D.18186;
      <D.18210>:
      D.18187 = obj->synchronisation;
      lw.sync = D.18187;
      D.18188 = lw.lock_word;
      D.18189 = D.18188 & 1;
      if (D.18189 != 0) goto <D.18211>; else goto <D.18212>;
      <D.18211>:
      D.18186 = (int) hash;
      return D.18186;
      <D.18212>:
      D.18188 = lw.lock_word;
      D.18196 = D.18188 & 4294967292;
      lw.lock_word = D.18196;
      D.18197 = lw.sync;
      hash.2 = (int) hash;
      D.18197->hash_code = hash.2;
      D.18188 = lw.lock_word;
      D.18203 = D.18188 | 2;
      lw.lock_word = D.18203;
      D.18197 = lw.sync;
      obj->synchronisation = D.18197;
      <D.18204>:
      D.18186 = (int) hash;
      return D.18186;
    }
  finally
    {
      lw = {CLOBBER};
    }
}


InterlockedCompareExchangePointer (void * volatile * dest, void * exch, void * comp)
{
  void * D.18215;
  unsigned int comp.3;
  unsigned int exch.4;
  unsigned int D.18218;

  comp.3 = (unsigned int) comp;
  exch.4 = (unsigned int) exch;
  D.18218 = __sync_val_compare_and_swap_4 (dest, comp.3, exch.4);
  D.18215 = (void *) D.18218;
  return D.18215;
}


mono_monitor_enter (struct MonoObject * obj)
{
  mono_bool D.18220;
  int D.18221;
  _Bool D.18222;

  D.18221 = mono_monitor_try_enter_internal (obj, 4294967295, 0);
  D.18222 = D.18221 == 1;
  D.18220 = (mono_bool) D.18222;
  return D.18220;
}


mono_monitor_try_enter_internal (struct MonoObject * obj, guint32 ms, gboolean allow_interruption)
{
  _Bool D.18224;
  long int D.18225;
  long int D.18226;
  struct MonoException * D.18229;
  gint32 D.18230;
  _Bool D.18231;
  long int D.18232;
  long int D.18233;
  _Bool D.18238;
  long int D.18239;
  long int D.18240;
  struct MonoThreadsSync * * D.18243;
  void * D.18244;
  void * * D.18247;
  _Bool D.18250;
  long int D.18251;
  long int D.18252;
  struct MonoThreadsSync * D.18255;
  unsigned int D.18256;
  unsigned int D.18257;
  unsigned int D.18260;
  int D.18261;
  unsigned int D.18262;
  struct MonoThreadsSync * D.18263;
  void * D.18264;
  _Bool D.18269;
  long int D.18270;
  long int D.18271;
  _Bool D.18276;
  long int D.18277;
  long int D.18278;
  unsigned int D.18281;
  _Bool D.18286;
  long int D.18287;
  long int D.18288;
  unsigned int D.18291;
  _Bool D.18295;
  long int D.18296;
  long int D.18297;
  unsigned int D.18301;
  unsigned int D.18302;
  _Bool D.18307;
  long int D.18308;
  long int D.18309;
  unsigned int D.18312;
  int D.18313;
  unsigned int D.18314;
  struct MonoThreadsSync * D.18315;
  void * D.18316;
  _Bool D.18321;
  long int D.18322;
  long int D.18323;
  _Bool D.18328;
  long int D.18329;
  long int D.18330;
  unsigned int D.18333;
  unsigned int D.18334;
  unsigned int D.18335;
  _Bool D.18336;
  long int D.18337;
  long int D.18338;
  gsize * D.18341;
  void * id.5;
  void * D.18343;
  _Bool D.18344;
  long int D.18345;
  long int D.18346;
  unsigned int D.18348;
  _Bool D.18349;
  long int D.18350;
  long int D.18351;
  unsigned int D.18356;
  struct MonoPerfCounters * mono_perfcounters.6;
  unsigned int D.18358;
  unsigned int D.18359;
  void * D.18364;
  _Bool D.18365;
  long int D.18366;
  long int D.18367;
  void * D.18374;
  _Bool D.18377;
  long int D.18378;
  long int D.18379;
  void * * D.18382;
  void * D.18383;
  volatile gint32 * D.18392;
  unsigned int D.18393;
  unsigned int D.18394;
  unsigned int D.18395;
  unsigned int D.18396;
  volatile gint32 * D.18397;
  unsigned int D.18398;
  unsigned int D.18403;
  struct MonoInternalThread * D.18419;
  int D.18420;
  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.18224 = obj == 0B;
  D.18225 = (long int) D.18224;
  D.18226 = __builtin_expect (D.18225, 0);
  if (D.18226 != 0) goto <D.18227>; else goto <D.18228>;
  <D.18227>:
  D.18229 = mono_get_exception_argument_null ("obj");
  mono_raise_exception (D.18229);
  D.18230 = 0;
  return D.18230;
  <D.18228>:
  retry:
  mon = obj->synchronisation;
  D.18231 = mon == 0B;
  D.18232 = (long int) D.18231;
  D.18233 = __builtin_expect (D.18232, 0);
  if (D.18233 != 0) goto <D.18234>; else goto <D.18235>;
  <D.18234>:
  {
    int ret;

    ret = pthread_mutex_lock (&monitor_mutex.mutex);
    if (ret != 0) goto <D.18236>; else goto <D.18237>;
    <D.18236>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.18237>:
    D.18238 = ret != 0;
    D.18239 = (long int) D.18238;
    D.18240 = __builtin_expect (D.18239, 0);
    if (D.18240 != 0) goto <D.18241>; else goto <D.18242>;
    <D.18241>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 439, "ret == 0");
    <D.18242>:
  }
  mon = mon_new (id);
  D.18243 = &obj->synchronisation;
  D.18244 = InterlockedCompareExchangePointer (D.18243, mon, 0B);
  if (D.18244 == 0B) goto <D.18245>; else goto <D.18246>;
  <D.18245>:
  D.18247 = &mon->data;
  mono_gc_weak_link_add (D.18247, obj, 0);
  {
    int ret;

    ret = pthread_mutex_unlock (&monitor_mutex.mutex);
    if (ret != 0) goto <D.18248>; else goto <D.18249>;
    <D.18248>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.18249>:
    D.18250 = ret != 0;
    D.18251 = (long int) D.18250;
    D.18252 = __builtin_expect (D.18251, 0);
    if (D.18252 != 0) goto <D.18253>; else goto <D.18254>;
    <D.18253>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 443, "ret == 0");
    <D.18254>:
  }
  D.18230 = 1;
  return D.18230;
  <D.18246>:
  {
    union LockWord lw;

    try
      {
        D.18255 = obj->synchronisation;
        lw.sync = D.18255;
        D.18256 = lw.lock_word;
        D.18257 = D.18256 & 1;
        if (D.18257 != 0) goto <D.18258>; else goto <D.18259>;
        <D.18258>:
        {
          struct MonoThreadsSync * oldlw;

          oldlw = lw.sync;
          D.18256 = lw.lock_word;
          D.18260 = D.18256 >> 2;
          D.18261 = (int) D.18260;
          mon->hash_code = D.18261;
          lw.sync = mon;
          D.18256 = lw.lock_word;
          D.18262 = D.18256 | 2;
          lw.lock_word = D.18262;
          D.18243 = &obj->synchronisation;
          D.18263 = lw.sync;
          D.18264 = InterlockedCompareExchangePointer (D.18243, D.18263, oldlw);
          if (D.18264 == oldlw) goto <D.18265>; else goto <D.18266>;
          <D.18265>:
          D.18247 = &mon->data;
          mono_gc_weak_link_add (D.18247, obj, 0);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18267>; else goto <D.18268>;
            <D.18267>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18268>:
            D.18269 = ret != 0;
            D.18270 = (long int) D.18269;
            D.18271 = __builtin_expect (D.18270, 0);
            if (D.18271 != 0) goto <D.18272>; else goto <D.18273>;
            <D.18272>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 458, "ret == 0");
            <D.18273>:
          }
          D.18230 = 1;
          return D.18230;
          <D.18266>:
          mon_finalize (mon);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18274>; else goto <D.18275>;
            <D.18274>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18275>:
            D.18276 = ret != 0;
            D.18277 = (long int) D.18276;
            D.18278 = __builtin_expect (D.18277, 0);
            if (D.18278 != 0) goto <D.18279>; else goto <D.18280>;
            <D.18279>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 463, "ret == 0");
            <D.18280>:
          }
          goto retry;
        }
        <D.18259>:
        D.18256 = lw.lock_word;
        D.18281 = D.18256 & 2;
        if (D.18281 != 0) goto <D.18282>; else goto <D.18283>;
        <D.18282>:
        mon_finalize (mon);
        {
          int ret;

          ret = pthread_mutex_unlock (&monitor_mutex.mutex);
          if (ret != 0) goto <D.18284>; else goto <D.18285>;
          <D.18284>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.18285>:
          D.18286 = ret != 0;
          D.18287 = (long int) D.18286;
          D.18288 = __builtin_expect (D.18287, 0);
          if (D.18288 != 0) goto <D.18289>; else goto <D.18290>;
          <D.18289>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 468, "ret == 0");
          <D.18290>:
        }
        D.18256 = lw.lock_word;
        D.18291 = D.18256 & 4294967292;
        lw.lock_word = D.18291;
        mon = lw.sync;
        goto <D.18292>;
        <D.18283>:
        mon_finalize (mon);
        {
          int ret;

          ret = pthread_mutex_unlock (&monitor_mutex.mutex);
          if (ret != 0) goto <D.18293>; else goto <D.18294>;
          <D.18293>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.18294>:
          D.18295 = ret != 0;
          D.18296 = (long int) D.18295;
          D.18297 = __builtin_expect (D.18296, 0);
          if (D.18297 != 0) goto <D.18298>; else goto <D.18299>;
          <D.18298>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 474, "ret == 0");
          <D.18299>:
        }
        mon = obj->synchronisation;
        <D.18292>:
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  goto <D.18300>;
  <D.18235>:
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.18301 = lw.lock_word;
        D.18302 = D.18301 & 1;
        if (D.18302 != 0) goto <D.18303>; else goto <D.18304>;
        <D.18303>:
        {
          struct MonoThreadsSync * oldlw;

          oldlw = lw.sync;
          {
            int ret;

            ret = pthread_mutex_lock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18305>; else goto <D.18306>;
            <D.18305>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
            <D.18306>:
            D.18307 = ret != 0;
            D.18308 = (long int) D.18307;
            D.18309 = __builtin_expect (D.18308, 0);
            if (D.18309 != 0) goto <D.18310>; else goto <D.18311>;
            <D.18310>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 489, "ret == 0");
            <D.18311>:
          }
          mon = mon_new (id);
          D.18301 = lw.lock_word;
          D.18312 = D.18301 >> 2;
          D.18313 = (int) D.18312;
          mon->hash_code = D.18313;
          lw.sync = mon;
          D.18301 = lw.lock_word;
          D.18314 = D.18301 | 2;
          lw.lock_word = D.18314;
          D.18243 = &obj->synchronisation;
          D.18315 = lw.sync;
          D.18316 = InterlockedCompareExchangePointer (D.18243, D.18315, oldlw);
          if (D.18316 == oldlw) goto <D.18317>; else goto <D.18318>;
          <D.18317>:
          D.18247 = &mon->data;
          mono_gc_weak_link_add (D.18247, obj, 1);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18319>; else goto <D.18320>;
            <D.18319>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18320>:
            D.18321 = ret != 0;
            D.18322 = (long int) D.18321;
            D.18323 = __builtin_expect (D.18322, 0);
            if (D.18323 != 0) goto <D.18324>; else goto <D.18325>;
            <D.18324>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 497, "ret == 0");
            <D.18325>:
          }
          D.18230 = 1;
          return D.18230;
          <D.18318>:
          mon_finalize (mon);
          {
            int ret;

            ret = pthread_mutex_unlock (&monitor_mutex.mutex);
            if (ret != 0) goto <D.18326>; else goto <D.18327>;
            <D.18326>:
            monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
            <D.18327>:
            D.18328 = ret != 0;
            D.18329 = (long int) D.18328;
            D.18330 = __builtin_expect (D.18329, 0);
            if (D.18330 != 0) goto <D.18331>; else goto <D.18332>;
            <D.18331>:
            monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 502, "ret == 0");
            <D.18332>:
          }
          goto retry;
        }
        <D.18304>:
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  <D.18300>:
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.18333 = lw.lock_word;
        D.18334 = D.18333 & 4294967292;
        lw.lock_word = D.18334;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  D.18335 = mon->owner;
  D.18336 = D.18335 == 0;
  D.18337 = (long int) D.18336;
  D.18338 = __builtin_expect (D.18337, 1);
  if (D.18338 != 0) goto <D.18339>; else goto <D.18340>;
  <D.18339>:
  D.18341 = &mon->owner;
  id.5 = (void *) id;
  D.18343 = InterlockedCompareExchangePointer (D.18341, id.5, 0B);
  D.18344 = D.18343 == 0B;
  D.18345 = (long int) D.18344;
  D.18346 = __builtin_expect (D.18345, 1);
  if (D.18346 != 0) goto <D.18347>; else goto retry;
  <D.18347>:
  D.18348 = mon->nest;
  D.18349 = D.18348 != 1;
  D.18350 = (long int) D.18349;
  D.18351 = __builtin_expect (D.18350, 0);
  if (D.18351 != 0) goto <D.18352>; else goto <D.18353>;
  <D.18352>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 530, "mon->nest == 1");
  <D.18353>:
  D.18230 = 1;
  return D.18230;
  <D.18340>:
  D.18335 = mon->owner;
  if (D.18335 == id) goto <D.18354>; else goto <D.18355>;
  <D.18354>:
  D.18348 = mon->nest;
  D.18356 = D.18348 + 1;
  mon->nest = D.18356;
  D.18230 = 1;
  return D.18230;
  <D.18355>:
  mono_perfcounters.6 = mono_perfcounters;
  D.18358 = mono_perfcounters.6->thread_contentions;
  D.18359 = D.18358 + 1;
  mono_perfcounters.6->thread_contentions = D.18359;
  if (ms == 0) goto <D.18360>; else goto <D.18361>;
  <D.18360>:
  D.18230 = 0;
  return D.18230;
  <D.18361>:
  mono_profiler_monitor_event (obj, 1);
  retry_contended:
  D.18335 = mon->owner;
  D.18336 = D.18335 == 0;
  D.18337 = (long int) D.18336;
  D.18338 = __builtin_expect (D.18337, 1);
  if (D.18338 != 0) goto <D.18362>; else goto <D.18363>;
  <D.18362>:
  D.18341 = &mon->owner;
  id.5 = (void *) id;
  D.18364 = InterlockedCompareExchangePointer (D.18341, id.5, 0B);
  D.18365 = D.18364 == 0B;
  D.18366 = (long int) D.18365;
  D.18367 = __builtin_expect (D.18366, 1);
  if (D.18367 != 0) goto <D.18368>; else goto <D.18369>;
  <D.18368>:
  D.18348 = mon->nest;
  D.18349 = D.18348 != 1;
  D.18350 = (long int) D.18349;
  D.18351 = __builtin_expect (D.18350, 0);
  if (D.18351 != 0) goto <D.18370>; else goto <D.18371>;
  <D.18370>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 574, "mon->nest == 1");
  <D.18371>:
  mono_profiler_monitor_event (obj, 2);
  D.18230 = 1;
  return D.18230;
  <D.18369>:
  <D.18363>:
  D.18335 = mon->owner;
  if (D.18335 == id) goto <D.18372>; else goto <D.18373>;
  <D.18372>:
  D.18348 = mon->nest;
  D.18356 = D.18348 + 1;
  mon->nest = D.18356;
  mono_profiler_monitor_event (obj, 2);
  D.18230 = 1;
  return D.18230;
  <D.18373>:
  D.18374 = mon->entry_sem;
  if (D.18374 == 0B) goto <D.18375>; else goto <D.18376>;
  <D.18375>:
  sem = CreateSemaphore (0B, 0, 2147483647, 0B);
  D.18377 = sem == 0B;
  D.18378 = (long int) D.18377;
  D.18379 = __builtin_expect (D.18378, 0);
  if (D.18379 != 0) goto <D.18380>; else goto <D.18381>;
  <D.18380>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 593, "sem != NULL");
  <D.18381>:
  D.18382 = &mon->entry_sem;
  D.18383 = InterlockedCompareExchangePointer (D.18382, sem, 0B);
  if (D.18383 != 0B) goto <D.18384>; else goto <D.18385>;
  <D.18384>:
  CloseHandle (sem);
  <D.18385>:
  <D.18376>:
  if (ms != 4294967295) goto <D.18386>; else goto <D.18387>;
  <D.18386>:
  then = mono_msec_ticks ();
  if (ms <= 99) goto <D.18388>; else goto <D.18389>;
  <D.18388>:
  waitms = ms;
  goto <D.18390>;
  <D.18389>:
  waitms = 100;
  <D.18390>:
  goto <D.18391>;
  <D.18387>:
  waitms = 100;
  <D.18391>:
  D.18392 = &mon->entry_count;
  InterlockedIncrement (D.18392);
  mono_perfcounters.6 = mono_perfcounters;
  D.18393 = mono_perfcounters.6->thread_queue_len;
  D.18394 = D.18393 + 1;
  mono_perfcounters.6->thread_queue_len = D.18394;
  mono_perfcounters.6 = mono_perfcounters;
  D.18395 = mono_perfcounters.6->thread_queue_max;
  D.18396 = D.18395 + 1;
  mono_perfcounters.6->thread_queue_max = D.18396;
  thread = mono_thread_internal_current ();
  mono_thread_set_state (thread, 32);
  D.18374 = mon->entry_sem;
  ret = WaitForSingleObjectEx (D.18374, waitms, 1);
  mono_thread_clr_state (thread, 32);
  D.18397 = &mon->entry_count;
  InterlockedDecrement (D.18397);
  mono_perfcounters.6 = mono_perfcounters;
  D.18393 = mono_perfcounters.6->thread_queue_len;
  D.18398 = D.18393 + 4294967295;
  mono_perfcounters.6->thread_queue_len = D.18398;
  if (ms != 4294967295) goto <D.18399>; else goto <D.18400>;
  <D.18399>:
  now = mono_msec_ticks ();
  if (now < then) goto <D.18401>; else goto <D.18402>;
  <D.18401>:
  D.18403 = now - then;
  now = D.18403 - 1;
  then = 0;
  <D.18402>:
  delta = now - then;
  if (delta >= ms) goto <D.18404>; else goto <D.18405>;
  <D.18404>:
  ms = 0;
  goto <D.18406>;
  <D.18405>:
  ms = ms - delta;
  <D.18406>:
  if (ret == 258) goto <D.18407>; else goto <D.18409>;
  <D.18409>:
  if (ret == 192) goto <D.18410>; else goto <D.18408>;
  <D.18410>:
  if (allow_interruption == 0) goto <D.18407>; else goto <D.18408>;
  <D.18407>:
  if (ms != 0) goto retry_contended; else goto <D.18411>;
  <D.18411>:
  <D.18408>:
  goto <D.18412>;
  <D.18400>:
  if (ret == 258) goto <D.18413>; else goto <D.18415>;
  <D.18415>:
  if (ret == 192) goto <D.18416>; else goto <D.18414>;
  <D.18416>:
  if (allow_interruption == 0) goto <D.18413>; else goto <D.18414>;
  <D.18413>:
  if (ret == 192) goto <D.18417>; else goto <D.18418>;
  <D.18417>:
  D.18419 = mono_thread_internal_current ();
  D.18420 = mono_thread_test_state (D.18419, 3);
  if (D.18420 != 0) goto <D.18421>; else goto <D.18422>;
  <D.18421>:
  mono_profiler_monitor_event (obj, 3);
  D.18230 = -1;
  return D.18230;
  <D.18422>:
  <D.18418>:
  goto retry_contended;
  <D.18414>:
  <D.18412>:
  if (ret == 0) goto retry_contended; else goto <D.18423>;
  <D.18423>:
  mono_profiler_monitor_event (obj, 3);
  if (ret == 192) goto <D.18424>; else goto <D.18425>;
  <D.18424>:
  D.18230 = -1;
  return D.18230;
  <D.18425>:
  D.18230 = 0;
  return D.18230;
}


mon_new (gsize id)
{
  struct MonoThreadsSync * monitor_freelist.7;
  void * D.18436;
  struct GSList * D.18439;
  void * D.18442;
  struct GSList * D.18443;
  void * * D.18444;
  int D.18445;
  int array_size.8;
  unsigned int array_size.9;
  unsigned int D.18451;
  unsigned int D.18452;
  int array_size.10;
  int D.18454;
  struct MonoThreadsSync * D.18455;
  int D.18456;
  struct MonoThreadsSync * monitor_freelist.11;
  struct MonitorArray * monitor_allocated.12;
  struct MonitorArray * D.18462;
  void * monitor_freelist.13;
  struct MonoPerfCounters * mono_perfcounters.14;
  unsigned int D.18465;
  unsigned int D.18466;
  struct MonoThreadsSync * D.18467;
  struct MonoThreadsSync * new;

  monitor_freelist.7 = monitor_freelist;
  if (monitor_freelist.7 == 0B) goto <D.18434>; else goto <D.18435>;
  <D.18434>:
  {
    struct MonitorArray * marray;
    int i;

    new = 0B;
    marray = monitor_allocated;
    goto <D.17939>;
    <D.17938>:
    i = 0;
    goto <D.17935>;
    <D.17934>:
    D.18436 = marray->monitors[i].data;
    if (D.18436 == 0B) goto <D.18437>; else goto <D.18438>;
    <D.18437>:
    new = &marray->monitors[i];
    D.18439 = new->wait_list;
    if (D.18439 != 0B) goto <D.18440>; else goto <D.18441>;
    <D.18440>:
    goto <D.17932>;
    <D.17931>:
    D.18439 = new->wait_list;
    D.18442 = D.18439->data;
    CloseHandle (D.18442);
    D.18439 = new->wait_list;
    D.18439 = new->wait_list;
    D.18442 = D.18439->data;
    D.18443 = monoeg_g_slist_remove (D.18439, D.18442);
    new->wait_list = D.18443;
    <D.17932>:
    D.18439 = new->wait_list;
    if (D.18439 != 0B) goto <D.17931>; else goto <D.17933>;
    <D.17933>:
    <D.18441>:
    D.18444 = &new->data;
    mono_gc_weak_link_remove (D.18444, 0);
    monitor_freelist.7 = monitor_freelist;
    new->data = monitor_freelist.7;
    monitor_freelist = new;
    <D.18438>:
    i = i + 1;
    <D.17935>:
    D.18445 = marray->num_monitors;
    if (D.18445 > i) goto <D.17934>; else goto <D.17936>;
    <D.17936>:
    if (new != 0B) goto <D.17937>; else goto <D.18446>;
    <D.18446>:
    marray = marray->next;
    <D.17939>:
    if (marray != 0B) goto <D.17938>; else goto <D.17937>;
    <D.17937>:
    monitor_freelist.7 = monitor_freelist;
    if (monitor_freelist.7 == 0B) goto <D.18447>; else goto <D.18448>;
    <D.18447>:
    {
      struct MonitorArray * last;

      array_size.8 = array_size;
      array_size.9 = (unsigned int) array_size.8;
      D.18451 = array_size.9 * 28;
      D.18452 = D.18451 + 16;
      marray = monoeg_malloc0 (D.18452);
      array_size.8 = array_size;
      marray->num_monitors = array_size.8;
      array_size.8 = array_size;
      array_size.10 = array_size.8 * 2;
      array_size = array_size.10;
      i = 0;
      goto <D.17942>;
      <D.17941>:
      D.18454 = i + 1;
      D.18455 = &marray->monitors[D.18454];
      marray->monitors[i].data = D.18455;
      i = i + 1;
      <D.17942>:
      D.18445 = marray->num_monitors;
      D.18456 = D.18445 + -1;
      if (D.18456 > i) goto <D.17941>; else goto <D.17943>;
      <D.17943>:
      marray->monitors[i].data = 0B;
      monitor_freelist.11 = &marray->monitors[0];
      monitor_freelist = monitor_freelist.11;
      monitor_allocated.12 = monitor_allocated;
      if (monitor_allocated.12 == 0B) goto <D.18459>; else goto <D.18460>;
      <D.18459>:
      monitor_allocated = marray;
      goto <D.18461>;
      <D.18460>:
      last = monitor_allocated;
      goto <D.17945>;
      <D.17944>:
      last = last->next;
      <D.17945>:
      D.18462 = last->next;
      if (D.18462 != 0B) goto <D.17944>; else goto <D.17946>;
      <D.17946>:
      last->next = marray;
      <D.18461>:
    }
    <D.18448>:
  }
  <D.18435>:
  new = monitor_freelist;
  monitor_freelist.13 = new->data;
  monitor_freelist = monitor_freelist.13;
  new->owner = id;
  new->nest = 1;
  new->data = 0B;
  mono_perfcounters.14 = mono_perfcounters;
  D.18465 = mono_perfcounters.14->gc_sync_blocks;
  D.18466 = D.18465 + 1;
  mono_perfcounters.14->gc_sync_blocks = D.18466;
  D.18467 = new;
  return D.18467;
}


mon_finalize (struct MonoThreadsSync * mon)
{
  void * D.18469;
  struct GSList * D.18472;
  _Bool D.18473;
  long int D.18474;
  long int D.18475;
  struct MonoThreadsSync * monitor_freelist.15;
  struct MonoPerfCounters * mono_perfcounters.16;
  unsigned int D.18480;
  unsigned int D.18481;

  D.18469 = mon->entry_sem;
  if (D.18469 != 0B) goto <D.18470>; else goto <D.18471>;
  <D.18470>:
  D.18469 = mon->entry_sem;
  CloseHandle (D.18469);
  mon->entry_sem = 0B;
  <D.18471>:
  D.18472 = mon->wait_list;
  D.18473 = D.18472 != 0B;
  D.18474 = (long int) D.18473;
  D.18475 = __builtin_expect (D.18474, 0);
  if (D.18475 != 0) goto <D.18476>; else goto <D.18477>;
  <D.18476>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 239, "mon->wait_list == NULL");
  <D.18477>:
  mon->entry_count = 0;
  monitor_freelist.15 = monitor_freelist;
  mon->data = monitor_freelist.15;
  monitor_freelist = mon;
  mono_perfcounters.16 = mono_perfcounters;
  D.18480 = mono_perfcounters.16->gc_sync_blocks;
  D.18481 = D.18480 + 4294967295;
  mono_perfcounters.16->gc_sync_blocks = D.18481;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.18482;
  unsigned int D.18483;

  D.18483 = __sync_add_and_fetch_4 (val, 1);
  D.18482 = (gint32) D.18483;
  return D.18482;
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.18485;
  unsigned int D.18486;

  D.18486 = __sync_sub_and_fetch_4 (val, 1);
  D.18485 = (gint32) D.18486;
  return D.18485;
}


mono_monitor_try_enter (struct MonoObject * obj, guint32 ms)
{
  mono_bool D.18488;
  int D.18489;
  _Bool D.18490;

  D.18489 = mono_monitor_try_enter_internal (obj, ms, 0);
  D.18490 = D.18489 == 1;
  D.18488 = (mono_bool) D.18490;
  return D.18488;
}


mono_monitor_exit (struct MonoObject * obj)
{
  _Bool D.18492;
  long int D.18493;
  long int D.18494;
  struct MonoException * D.18497;
  unsigned int D.18498;
  unsigned int D.18499;
  unsigned int D.18502;
  _Bool D.18503;
  long int D.18504;
  long int D.18505;
  unsigned int D.18508;
  unsigned int tls_pthread_self.17;
  _Bool D.18510;
  long int D.18511;
  long int D.18512;
  unsigned int D.18515;
  int D.18518;
  void * D.18521;
  struct MonoThreadsSync * mon;
  guint32 nest;

  D.18492 = obj == 0B;
  D.18493 = (long int) D.18492;
  D.18494 = __builtin_expect (D.18493, 0);
  if (D.18494 != 0) goto <D.18495>; else goto <D.18496>;
  <D.18495>:
  D.18497 = mono_get_exception_argument_null ("obj");
  mono_raise_exception (D.18497);
  return;
  <D.18496>:
  mon = obj->synchronisation;
  {
    union LockWord lw;

    try
      {
        lw.sync = mon;
        D.18498 = lw.lock_word;
        D.18499 = D.18498 & 1;
        if (D.18499 != 0) goto <D.18500>; else goto <D.18501>;
        <D.18500>:
        return;
        <D.18501>:
        D.18498 = lw.lock_word;
        D.18502 = D.18498 & 4294967292;
        lw.lock_word = D.18502;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  D.18503 = mon == 0B;
  D.18504 = (long int) D.18503;
  D.18505 = __builtin_expect (D.18504, 0);
  if (D.18505 != 0) goto <D.18506>; else goto <D.18507>;
  <D.18506>:
  return;
  <D.18507>:
  D.18508 = mon->owner;
  tls_pthread_self.17 = tls_pthread_self;
  D.18510 = D.18508 != tls_pthread_self.17;
  D.18511 = (long int) D.18510;
  D.18512 = __builtin_expect (D.18511, 0);
  if (D.18512 != 0) goto <D.18513>; else goto <D.18514>;
  <D.18513>:
  return;
  <D.18514>:
  D.18515 = mon->nest;
  nest = D.18515 + 4294967295;
  if (nest == 0) goto <D.18516>; else goto <D.18517>;
  <D.18516>:
  mon->owner = 0;
  D.18518 = mon->entry_count;
  if (D.18518 > 0) goto <D.18519>; else goto <D.18520>;
  <D.18519>:
  D.18521 = mon->entry_sem;
  ReleaseSemaphore (D.18521, 1, 0B);
  <D.18520>:
  goto <D.18522>;
  <D.18517>:
  mon->nest = nest;
  <D.18522>:
}


mono_monitor_get_object_monitor_weak_link (struct MonoObject * object)
{
  struct MonoThreadsSync * D.18526;
  unsigned int D.18527;
  unsigned int D.18528;
  unsigned int D.18531;
  unsigned int D.18533;
  void * D.18538;
  void * * D.18541;
  union LockWord lw;
  struct MonoThreadsSync * sync;

  try
    {
      sync = 0B;
      D.18526 = object->synchronisation;
      lw.sync = D.18526;
      D.18527 = lw.lock_word;
      D.18528 = D.18527 & 2;
      if (D.18528 != 0) goto <D.18529>; else goto <D.18530>;
      <D.18529>:
      D.18527 = lw.lock_word;
      D.18531 = D.18527 & 4294967292;
      lw.lock_word = D.18531;
      sync = lw.sync;
      goto <D.18532>;
      <D.18530>:
      D.18527 = lw.lock_word;
      D.18533 = D.18527 & 1;
      if (D.18533 == 0) goto <D.18534>; else goto <D.18535>;
      <D.18534>:
      sync = lw.sync;
      <D.18535>:
      <D.18532>:
      if (sync != 0B) goto <D.18536>; else goto <D.18537>;
      <D.18536>:
      D.18538 = sync->data;
      if (D.18538 != 0B) goto <D.18539>; else goto <D.18540>;
      <D.18539>:
      D.18541 = &sync->data;
      return D.18541;
      <D.18540>:
      <D.18537>:
      D.18541 = 0B;
      return D.18541;
    }
  finally
    {
      lw = {CLOBBER};
    }
}


mono_monitor_is_il_fastpath_wrapper (struct MonoMethod * method)
{
  struct MonoMethod * D.18544;
  gboolean D.18547;
  int i;

  i = 0;
  goto <D.18024>;
  <D.18023>:
  D.18544 = monitor_il_fastpaths[i];
  if (D.18544 == method) goto <D.18545>; else goto <D.18546>;
  <D.18545>:
  D.18547 = 1;
  return D.18547;
  <D.18546>:
  i = i + 1;
  <D.18024>:
  if (i <= 2) goto <D.18023>; else goto <D.18025>;
  <D.18025>:
  D.18547 = 0;
  return D.18547;
}


mono_monitor_get_fast_path (struct MonoMethod * enter_or_exit)
{
  int D.18081;
  int iftmp.18;
  int D.18080;
  const char[6] * D.18552;
  unsigned char D.18553;
  int D.18554;
  unsigned char D.18555;
  int D.18556;
  const unsigned char * D.18561;
  unsigned char D.18562;
  int D.18563;
  const unsigned char * D.18564;
  unsigned char D.18565;
  int D.18566;
  const unsigned char * D.18571;
  unsigned char D.18572;
  int D.18573;
  const unsigned char * D.18574;
  unsigned char D.18575;
  int D.18576;
  const unsigned char * D.18581;
  unsigned char D.18582;
  int D.18583;
  const unsigned char * D.18584;
  unsigned char D.18585;
  int D.18586;
  const char * D.18588;
  struct MonoMethod * D.18591;
  int D.18090;
  int iftmp.19;
  int D.18089;
  const char[5] * D.18595;
  unsigned char D.18596;
  int D.18597;
  unsigned char D.18598;
  int D.18599;
  const unsigned char * D.18604;
  unsigned char D.18605;
  int D.18606;
  const unsigned char * D.18607;
  unsigned char D.18608;
  int D.18609;
  const unsigned char * D.18614;
  unsigned char D.18615;
  int D.18616;
  const unsigned char * D.18617;
  unsigned char D.18618;
  int D.18619;
  const unsigned char * D.18624;
  unsigned char D.18625;
  int D.18626;
  const unsigned char * D.18627;
  unsigned char D.18628;
  int D.18629;

  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 5;
    if (__s2_len <= 3) goto <D.18550>; else goto <D.18551>;
    <D.18550>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = enter_or_exit->name;
      D.18552 = "Enter";
      D.18553 = MEM[(const unsigned char *)D.18552];
      D.18554 = (int) D.18553;
      D.18555 = *__s2;
      D.18556 = (int) D.18555;
      __result = D.18554 - D.18556;
      {
        if (__s2_len != 0) goto <D.18557>; else goto <D.18558>;
        <D.18557>:
        if (__result == 0) goto <D.18559>; else goto <D.18560>;
        <D.18559>:
        D.18561 = &MEM[(void *)"Enter" + 1B];
        D.18562 = *D.18561;
        D.18563 = (int) D.18562;
        D.18564 = __s2 + 1;
        D.18565 = *D.18564;
        D.18566 = (int) D.18565;
        __result = D.18563 - D.18566;
        if (__s2_len > 1) goto <D.18567>; else goto <D.18568>;
        <D.18567>:
        if (__result == 0) goto <D.18569>; else goto <D.18570>;
        <D.18569>:
        D.18571 = &MEM[(void *)"Enter" + 2B];
        D.18572 = *D.18571;
        D.18573 = (int) D.18572;
        D.18574 = __s2 + 2;
        D.18575 = *D.18574;
        D.18576 = (int) D.18575;
        __result = D.18573 - D.18576;
        if (__s2_len > 2) goto <D.18577>; else goto <D.18578>;
        <D.18577>:
        if (__result == 0) goto <D.18579>; else goto <D.18580>;
        <D.18579>:
        D.18581 = &MEM[(void *)"Enter" + 3B];
        D.18582 = *D.18581;
        D.18583 = (int) D.18582;
        D.18584 = __s2 + 3;
        D.18585 = *D.18584;
        D.18586 = (int) D.18585;
        __result = D.18583 - D.18586;
        <D.18580>:
        <D.18578>:
        <D.18570>:
        <D.18568>:
        <D.18560>:
        <D.18558>:
      }
      D.18080 = __result;
    }
    iftmp.18 = -D.18080;
    goto <D.18587>;
    <D.18551>:
    D.18588 = enter_or_exit->name;
    iftmp.18 = __builtin_strcmp (D.18588, "Enter");
    <D.18587>:
    D.18081 = iftmp.18;
  }
  if (D.18081 == 0) goto <D.18589>; else goto <D.18590>;
  <D.18589>:
  D.18591 = mono_monitor_get_fast_enter_method (enter_or_exit);
  return D.18591;
  <D.18590>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 4;
    if (__s2_len <= 3) goto <D.18593>; else goto <D.18594>;
    <D.18593>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = enter_or_exit->name;
      D.18595 = "Exit";
      D.18596 = MEM[(const unsigned char *)D.18595];
      D.18597 = (int) D.18596;
      D.18598 = *__s2;
      D.18599 = (int) D.18598;
      __result = D.18597 - D.18599;
      {
        if (__s2_len != 0) goto <D.18600>; else goto <D.18601>;
        <D.18600>:
        if (__result == 0) goto <D.18602>; else goto <D.18603>;
        <D.18602>:
        D.18604 = &MEM[(void *)"Exit" + 1B];
        D.18605 = *D.18604;
        D.18606 = (int) D.18605;
        D.18607 = __s2 + 1;
        D.18608 = *D.18607;
        D.18609 = (int) D.18608;
        __result = D.18606 - D.18609;
        if (__s2_len > 1) goto <D.18610>; else goto <D.18611>;
        <D.18610>:
        if (__result == 0) goto <D.18612>; else goto <D.18613>;
        <D.18612>:
        D.18614 = &MEM[(void *)"Exit" + 2B];
        D.18615 = *D.18614;
        D.18616 = (int) D.18615;
        D.18617 = __s2 + 2;
        D.18618 = *D.18617;
        D.18619 = (int) D.18618;
        __result = D.18616 - D.18619;
        if (__s2_len > 2) goto <D.18620>; else goto <D.18621>;
        <D.18620>:
        if (__result == 0) goto <D.18622>; else goto <D.18623>;
        <D.18622>:
        D.18624 = &MEM[(void *)"Exit" + 3B];
        D.18625 = *D.18624;
        D.18626 = (int) D.18625;
        D.18627 = __s2 + 3;
        D.18628 = *D.18627;
        D.18629 = (int) D.18628;
        __result = D.18626 - D.18629;
        <D.18623>:
        <D.18621>:
        <D.18613>:
        <D.18611>:
        <D.18603>:
        <D.18601>:
      }
      D.18089 = __result;
    }
    iftmp.19 = -D.18089;
    goto <D.18630>;
    <D.18594>:
    D.18588 = enter_or_exit->name;
    iftmp.19 = __builtin_strcmp (D.18588, "Exit");
    <D.18630>:
    D.18090 = iftmp.19;
  }
  if (D.18090 == 0) goto <D.18631>; else goto <D.18632>;
  <D.18631>:
  D.18591 = mono_monitor_get_fast_exit_method (enter_or_exit);
  return D.18591;
  <D.18632>:
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "monitor.c", 1227);
  D.18591 = 0B;
  return D.18591;
}


mono_monitor_get_fast_enter_method (struct MonoMethod * monitor_enter_method)
{
  struct MonoMethodSignature * D.18634;
  short unsigned int D.18635;
  _Bool D.18636;
  _Bool D.18637;
  _Bool D.18638;
  long int D.18639;
  long int D.18640;
  struct MonoMethod * D.18645;
  struct MonoMethod * D.18646;
  struct MonoMethod * compare_exchange_method.20;
  struct MonoImage * D.18652;
  struct MonoMethod * compare_exchange_method.21;
  struct MonoClass * D.18656;
  const char * iftmp.22;
  struct MonoMethod * D.18661;
  struct MonoClass * D.18662;
  struct MonoType * D.18663;
  int * iftmp.23;
  unsigned int tid_loc.24;
  unsigned int syncp_loc.25;
  unsigned int owner_loc.26;
  unsigned int D.18671;
  unsigned int D.18672;
  unsigned int tid_branch.27;
  unsigned int D.18676;
  int thin_hash_branch.28;
  unsigned int thin_hash_branch.29;
  int obj_null_branch.30;
  unsigned int obj_null_branch.31;
  int syncp_null_branch.32;
  unsigned int syncp_null_branch.33;
  unsigned int has_owner_branch.34;
  unsigned int other_owner_branch.35;
  int true_locktaken_branch.36;
  unsigned int true_locktaken_branch.37;
  struct MonoMethodSignature * D.18695;
  struct MonoMethod * D.18696;
  WrapperSubtype iftmp.38;
  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.18634 = mono_method_signature (monitor_enter_method);
      D.18635 = D.18634->param_count;
      D.18636 = D.18635 == 2;
      is_v4 = (gboolean) D.18636;
      D.18637 = is_v4 != 0;
      fast_path_idx = (int) D.18637;
      D.18638 = is_v4 == 0;
      D.18639 = (long int) D.18638;
      D.18640 = __builtin_expect (D.18639, 0);
      if (D.18640 != 0) goto <D.18641>; else goto <D.18642>;
      <D.18641>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "monitor.c", 898, "is_v4");
      <D.18642>:
      thread_tls_offset = mono_thread_get_tls_offset ();
      if (thread_tls_offset == -1) goto <D.18643>; else goto <D.18644>;
      <D.18643>:
      D.18645 = 0B;
      return D.18645;
      <D.18644>:
      D.18646 = monitor_il_fastpaths[fast_path_idx];
      if (D.18646 != 0B) goto <D.18647>; else goto <D.18648>;
      <D.18647>:
      D.18645 = monitor_il_fastpaths[fast_path_idx];
      return D.18645;
      <D.18648>:
      compare_exchange_method.20 = compare_exchange_method;
      if (compare_exchange_method.20 == 0B) goto <D.18650>; else goto <D.18651>;
      <D.18650>:
      {
        struct MonoMethodDesc * desc;
        struct MonoClass * class;

        desc = mono_method_desc_new ("Interlocked:CompareExchange(intptr&,intptr,intptr)", 0);
        D.18652 = mono_defaults.corlib;
        class = mono_class_from_name (D.18652, "System.Threading", "Interlocked");
        compare_exchange_method.21 = mono_method_desc_search_in_class (desc, class);
        compare_exchange_method = compare_exchange_method.21;
        mono_method_desc_free (desc);
        compare_exchange_method.20 = compare_exchange_method;
        if (compare_exchange_method.20 == 0B) goto <D.18654>; else goto <D.18655>;
        <D.18654>:
        D.18645 = 0B;
        return D.18645;
        <D.18655>:
      }
      <D.18651>:
      D.18656 = mono_defaults.monitor_class;
      if (is_v4 != 0) goto <D.18658>; else goto <D.18659>;
      <D.18658>:
      iftmp.22 = "FastMonitorEnterV4";
      goto <D.18660>;
      <D.18659>:
      iftmp.22 = "FastMonitorEnter";
      <D.18660>:
      mb = mono_mb_new (D.18656, iftmp.22, 25);
      D.18661 = mb->method;
      D.18661->slot = -1;
      D.18661 = mb->method;
      D.18661->flags = 182;
      D.18662 = mono_defaults.int_class;
      D.18663 = &D.18662->byval_arg;
      tid_loc = mono_mb_add_local (mb, D.18663);
      D.18662 = mono_defaults.int_class;
      D.18663 = &D.18662->byval_arg;
      syncp_loc = mono_mb_add_local (mb, D.18663);
      D.18662 = mono_defaults.int_class;
      D.18663 = &D.18662->byval_arg;
      owner_loc = mono_mb_add_local (mb, D.18663);
      if (is_v4 != 0) goto <D.18665>; else goto <D.18666>;
      <D.18665>:
      iftmp.23 = &true_locktaken_branch;
      goto <D.18667>;
      <D.18666>:
      iftmp.23 = 0B;
      <D.18667>:
      emit_obj_syncp_check (mb, syncp_loc, &obj_null_branch, iftmp.23, &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, 40);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      tid_loc.24 = (unsigned int) tid_loc;
      mono_mb_emit_stloc (mb, tid_loc.24);
      syncp_loc.25 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.25);
      mono_mb_emit_icon (mb, 0);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      owner_loc.26 = (unsigned int) owner_loc;
      mono_mb_emit_stloc (mb, owner_loc.26);
      owner_loc.26 = (unsigned int) owner_loc;
      mono_mb_emit_ldloc (mb, owner_loc.26);
      D.18671 = mono_mb_emit_short_branch (mb, 45);
      tid_branch = (int) D.18671;
      syncp_loc.25 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.25);
      mono_mb_emit_icon (mb, 0);
      mono_mb_emit_byte (mb, 88);
      tid_loc.24 = (unsigned int) tid_loc;
      mono_mb_emit_ldloc (mb, tid_loc.24);
      mono_mb_emit_byte (mb, 22);
      compare_exchange_method.20 = compare_exchange_method;
      mono_mb_emit_managed_call (mb, compare_exchange_method.20, 0B);
      D.18672 = mono_mb_emit_short_branch (mb, 45);
      has_owner_branch = (int) D.18672;
      if (is_v4 != 0) goto <D.18673>; else goto <D.18674>;
      <D.18673>:
      mono_mb_emit_byte (mb, 3);
      mono_mb_emit_byte (mb, 23);
      mono_mb_emit_byte (mb, 82);
      <D.18674>:
      mono_mb_emit_byte (mb, 42);
      tid_branch.27 = (unsigned int) tid_branch;
      mono_mb_patch_short_branch (mb, tid_branch.27);
      owner_loc.26 = (unsigned int) owner_loc;
      mono_mb_emit_ldloc (mb, owner_loc.26);
      tid_loc.24 = (unsigned int) tid_loc;
      mono_mb_emit_ldloc (mb, tid_loc.24);
      D.18676 = mono_mb_emit_short_branch (mb, 51);
      other_owner_branch = (int) D.18676;
      syncp_loc.25 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.25);
      mono_mb_emit_icon (mb, 4);
      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.18677>; else goto <D.18678>;
      <D.18677>:
      mono_mb_emit_byte (mb, 3);
      mono_mb_emit_byte (mb, 23);
      mono_mb_emit_byte (mb, 82);
      <D.18678>:
      mono_mb_emit_byte (mb, 42);
      thin_hash_branch.28 = thin_hash_branch;
      if (thin_hash_branch.28 != 0) goto <D.18680>; else goto <D.18681>;
      <D.18680>:
      thin_hash_branch.28 = thin_hash_branch;
      thin_hash_branch.29 = (unsigned int) thin_hash_branch.28;
      mono_mb_patch_short_branch (mb, thin_hash_branch.29);
      <D.18681>:
      obj_null_branch.30 = obj_null_branch;
      obj_null_branch.31 = (unsigned int) obj_null_branch.30;
      mono_mb_patch_short_branch (mb, obj_null_branch.31);
      syncp_null_branch.32 = syncp_null_branch;
      syncp_null_branch.33 = (unsigned int) syncp_null_branch.32;
      mono_mb_patch_short_branch (mb, syncp_null_branch.33);
      has_owner_branch.34 = (unsigned int) has_owner_branch;
      mono_mb_patch_short_branch (mb, has_owner_branch.34);
      other_owner_branch.35 = (unsigned int) other_owner_branch;
      mono_mb_patch_short_branch (mb, other_owner_branch.35);
      true_locktaken_branch.36 = true_locktaken_branch;
      if (true_locktaken_branch.36 != 0) goto <D.18690>; else goto <D.18691>;
      <D.18690>:
      true_locktaken_branch.36 = true_locktaken_branch;
      true_locktaken_branch.37 = (unsigned int) true_locktaken_branch.36;
      mono_mb_patch_short_branch (mb, true_locktaken_branch.37);
      <D.18691>:
      mono_mb_emit_byte (mb, 2);
      if (is_v4 != 0) goto <D.18693>; else goto <D.18694>;
      <D.18693>:
      mono_mb_emit_byte (mb, 3);
      <D.18694>:
      mono_mb_emit_managed_call (mb, monitor_enter_method, 0B);
      mono_mb_emit_byte (mb, 42);
      D.18695 = mono_signature_no_pinvoke (monitor_enter_method);
      D.18696 = mono_mb_create_method (mb, D.18695, 5);
      res = register_fastpath (D.18696, fast_path_idx);
      D.18652 = mono_defaults.corlib;
      info = mono_image_alloc0 (D.18652, 12);
      if (is_v4 != 0) goto <D.18698>; else goto <D.18699>;
      <D.18698>:
      iftmp.38 = 5;
      goto <D.18700>;
      <D.18699>:
      iftmp.38 = 4;
      <D.18700>:
      info->subtype = iftmp.38;
      mono_marshal_set_wrapper_info (res, info);
      mono_mb_free (mb);
      D.18645 = res;
      return D.18645;
    }
  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.18703;
  int D.18704;
  unsigned int D.18707;
  int D.18708;
  unsigned int syncp_loc.39;
  int D.18710;
  unsigned int D.18713;
  int D.18714;
  int iftmp.40;
  unsigned int D.18720;
  int D.18721;

  mono_mb_emit_byte (mb, 2);
  D.18703 = mono_mb_emit_short_branch (mb, 44);
  D.18704 = (int) D.18703;
  *obj_null_branch = D.18704;
  if (true_locktaken_branch != 0B) goto <D.18705>; else goto <D.18706>;
  <D.18705>:
  mono_mb_emit_byte (mb, 3);
  mono_mb_emit_byte (mb, 70);
  D.18707 = mono_mb_emit_short_branch (mb, 45);
  D.18708 = (int) D.18707;
  *true_locktaken_branch = D.18708;
  <D.18706>:
  mono_mb_emit_byte (mb, 2);
  mono_mb_emit_byte (mb, 211);
  mono_mb_emit_icon (mb, 4);
  mono_mb_emit_byte (mb, 88);
  mono_mb_emit_byte (mb, 77);
  syncp_loc.39 = (unsigned int) syncp_loc;
  mono_mb_emit_stloc (mb, syncp_loc.39);
  D.18710 = mono_gc_is_moving ();
  if (D.18710 != 0) goto <D.18711>; else goto <D.18712>;
  <D.18711>:
  syncp_loc.39 = (unsigned int) syncp_loc;
  mono_mb_emit_ldloc (mb, syncp_loc.39);
  mono_mb_emit_icon (mb, 1);
  mono_mb_emit_byte (mb, 211);
  mono_mb_emit_byte (mb, 95);
  D.18713 = mono_mb_emit_short_branch (mb, 45);
  D.18714 = (int) D.18713;
  *thin_hash_branch = D.18714;
  syncp_loc.39 = (unsigned int) syncp_loc;
  mono_mb_emit_ldloc (mb, syncp_loc.39);
  mono_mb_emit_icon (mb, -4);
  mono_mb_emit_byte (mb, 211);
  mono_mb_emit_byte (mb, 95);
  syncp_loc.39 = (unsigned int) syncp_loc;
  mono_mb_emit_stloc (mb, syncp_loc.39);
  goto <D.18715>;
  <D.18712>:
  *thin_hash_branch = 0;
  <D.18715>:
  syncp_loc.39 = (unsigned int) syncp_loc;
  mono_mb_emit_ldloc (mb, syncp_loc.39);
  if (branch_on_true != 0) goto <D.18717>; else goto <D.18718>;
  <D.18717>:
  iftmp.40 = 45;
  goto <D.18719>;
  <D.18718>:
  iftmp.40 = 44;
  <D.18719>:
  D.18720 = mono_mb_emit_short_branch (mb, iftmp.40);
  D.18721 = (int) D.18720;
  *syncp_true_false_branch = D.18721;
}


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

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


mono_memory_barrier ()
{
  __sync_synchronize ();
}


mono_monitor_get_fast_exit_method (struct MonoMethod * monitor_exit_method)
{
  struct MonoMethod * D.18726;
  struct MonoMethod * D.18727;
  struct MonoClass * D.18730;
  struct MonoMethod * D.18731;
  struct MonoClass * D.18732;
  struct MonoType * D.18733;
  int has_syncp_branch.41;
  unsigned int has_syncp_branch.42;
  unsigned int syncp_loc.43;
  unsigned int D.18737;
  unsigned int owned_branch.44;
  unsigned int D.18739;
  unsigned int D.18740;
  unsigned int nested_branch.45;
  int thin_hash_branch.46;
  unsigned int thin_hash_branch.47;
  int obj_null_branch.48;
  unsigned int obj_null_branch.49;
  unsigned int has_waiting_branch.50;
  struct MonoMethodSignature * D.18749;
  struct MonoMethod * D.18750;
  struct MonoImage * D.18751;
  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.18724>; else goto <D.18725>;
      <D.18724>:
      D.18726 = 0B;
      return D.18726;
      <D.18725>:
      D.18727 = monitor_il_fastpaths[2];
      if (D.18727 != 0B) goto <D.18728>; else goto <D.18729>;
      <D.18728>:
      D.18726 = monitor_il_fastpaths[2];
      return D.18726;
      <D.18729>:
      D.18730 = mono_defaults.monitor_class;
      mb = mono_mb_new (D.18730, "FastMonitorExit", 25);
      D.18731 = mb->method;
      D.18731->slot = -1;
      D.18731 = mb->method;
      D.18731->flags = 182;
      D.18732 = mono_defaults.int_class;
      D.18733 = &D.18732->byval_arg;
      syncp_loc = mono_mb_add_local (mb, D.18733);
      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.41 = has_syncp_branch;
      has_syncp_branch.42 = (unsigned int) has_syncp_branch.41;
      mono_mb_patch_short_branch (mb, has_syncp_branch.42);
      syncp_loc.43 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.43);
      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, 40);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 77);
      D.18737 = mono_mb_emit_short_branch (mb, 46);
      owned_branch = (int) D.18737;
      mono_mb_emit_byte (mb, 42);
      owned_branch.44 = (unsigned int) owned_branch;
      mono_mb_patch_short_branch (mb, owned_branch.44);
      syncp_loc.43 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.43);
      mono_mb_emit_icon (mb, 4);
      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.18739 = mono_mb_emit_short_branch (mb, 53);
      nested_branch = (int) D.18739;
      mono_mb_emit_byte (mb, 38);
      mono_mb_emit_byte (mb, 38);
      syncp_loc.43 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.43);
      mono_mb_emit_icon (mb, 12);
      mono_mb_emit_byte (mb, 88);
      mono_mb_emit_byte (mb, 74);
      D.18740 = mono_mb_emit_short_branch (mb, 45);
      has_waiting_branch = (int) D.18740;
      syncp_loc.43 = (unsigned int) syncp_loc;
      mono_mb_emit_ldloc (mb, syncp_loc.43);
      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.45 = (unsigned int) nested_branch;
      mono_mb_patch_short_branch (mb, nested_branch.45);
      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.46 = thin_hash_branch;
      if (thin_hash_branch.46 != 0) goto <D.18743>; else goto <D.18744>;
      <D.18743>:
      thin_hash_branch.46 = thin_hash_branch;
      thin_hash_branch.47 = (unsigned int) thin_hash_branch.46;
      mono_mb_patch_short_branch (mb, thin_hash_branch.47);
      <D.18744>:
      obj_null_branch.48 = obj_null_branch;
      obj_null_branch.49 = (unsigned int) obj_null_branch.48;
      mono_mb_patch_short_branch (mb, obj_null_branch.49);
      has_waiting_branch.50 = (unsigned int) has_waiting_branch;
      mono_mb_patch_short_branch (mb, has_waiting_branch.50);
      mono_mb_emit_byte (mb, 2);
      mono_mb_emit_managed_call (mb, monitor_exit_method, 0B);
      mono_mb_emit_byte (mb, 42);
      D.18749 = mono_signature_no_pinvoke (monitor_exit_method);
      D.18750 = mono_mb_create_method (mb, D.18749, 5);
      res = register_fastpath (D.18750, 2);
      mono_mb_free (mb);
      D.18751 = mono_defaults.corlib;
      info = mono_image_alloc0 (D.18751, 12);
      info->subtype = 6;
      mono_marshal_set_wrapper_info (res, info);
      D.18726 = res;
      return D.18726;
    }
  finally
    {
      obj_null_branch = {CLOBBER};
      has_syncp_branch = {CLOBBER};
      thin_hash_branch = {CLOBBER};
    }
}


mono_monitor_threads_sync_members_offset (int * owner_offset, int * nest_offset, int * entry_count_offset)
{
  struct MonoThreadsSync ts;

  try
    {
      *owner_offset = 4;
      *nest_offset = 1028;
      *entry_count_offset = 3076;
    }
  finally
    {
      ts = {CLOBBER};
    }
}


ves_icall_System_Threading_Monitor_Monitor_try_enter (struct MonoObject * obj, guint32 ms)
{
  gboolean D.18756;
  _Bool D.18757;
  gint32 res;

  <D.18102>:
  res = mono_monitor_try_enter_internal (obj, ms, 1);
  if (res == -1) goto <D.18754>; else goto <D.18755>;
  <D.18754>:
  mono_thread_interruption_checkpoint ();
  <D.18755>:
  if (res == -1) goto <D.18102>; else goto <D.18103>;
  <D.18103>:
  D.18757 = res == 1;
  D.18756 = (gboolean) D.18757;
  return D.18756;
}


ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (struct MonoObject * obj, guint32 ms, char * lockTaken)
{
  _Bool D.18761;
  char D.18762;
  gint32 res;

  <D.18110>:
  res = mono_monitor_try_enter_internal (obj, ms, 1);
  if (res == -1) goto <D.18759>; else goto <D.18760>;
  <D.18759>:
  mono_thread_interruption_checkpoint ();
  <D.18760>:
  if (res == -1) goto <D.18110>; else goto <D.18111>;
  <D.18111>:
  D.18761 = res == 1;
  D.18762 = (char) D.18761;
  *lockTaken = D.18762;
}


ves_icall_System_Threading_Monitor_Monitor_test_owner (struct MonoObject * obj)
{
  unsigned int D.18763;
  unsigned int D.18764;
  gboolean D.18767;
  unsigned int D.18768;
  unsigned int D.18771;
  unsigned int tls_pthread_self.51;
  struct MonoThreadsSync * mon;

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

    try
      {
        lw.sync = mon;
        D.18763 = lw.lock_word;
        D.18764 = D.18763 & 1;
        if (D.18764 != 0) goto <D.18765>; else goto <D.18766>;
        <D.18765>:
        D.18767 = 0;
        return D.18767;
        <D.18766>:
        D.18763 = lw.lock_word;
        D.18768 = D.18763 & 4294967292;
        lw.lock_word = D.18768;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.18769>; else goto <D.18770>;
  <D.18769>:
  D.18767 = 0;
  return D.18767;
  <D.18770>:
  D.18771 = mon->owner;
  tls_pthread_self.51 = tls_pthread_self;
  if (D.18771 == tls_pthread_self.51) goto <D.18773>; else goto <D.18774>;
  <D.18773>:
  D.18767 = 1;
  return D.18767;
  <D.18774>:
  D.18767 = 0;
  return D.18767;
}


ves_icall_System_Threading_Monitor_Monitor_test_synchronised (struct MonoObject * obj)
{
  unsigned int D.18778;
  unsigned int D.18779;
  gboolean D.18782;
  unsigned int D.18783;
  unsigned int D.18786;
  struct MonoThreadsSync * mon;

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

    try
      {
        lw.sync = mon;
        D.18778 = lw.lock_word;
        D.18779 = D.18778 & 1;
        if (D.18779 != 0) goto <D.18780>; else goto <D.18781>;
        <D.18780>:
        D.18782 = 0;
        return D.18782;
        <D.18781>:
        D.18778 = lw.lock_word;
        D.18783 = D.18778 & 4294967292;
        lw.lock_word = D.18783;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.18784>; else goto <D.18785>;
  <D.18784>:
  D.18782 = 0;
  return D.18782;
  <D.18785>:
  D.18786 = mon->owner;
  if (D.18786 != 0) goto <D.18787>; else goto <D.18788>;
  <D.18787>:
  D.18782 = 1;
  return D.18782;
  <D.18788>:
  D.18782 = 0;
  return D.18782;
}


ves_icall_System_Threading_Monitor_Monitor_pulse (struct MonoObject * obj)
{
  unsigned int D.18792;
  unsigned int D.18793;
  struct MonoException * D.18796;
  unsigned int D.18797;
  struct MonoException * D.18800;
  unsigned int D.18801;
  unsigned int tls_pthread_self.52;
  struct MonoException * D.18805;
  struct GSList * D.18806;
  void * D.18809;
  struct GSList * D.18810;
  struct MonoThreadsSync * mon;

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

    try
      {
        lw.sync = mon;
        D.18792 = lw.lock_word;
        D.18793 = D.18792 & 1;
        if (D.18793 != 0) goto <D.18794>; else goto <D.18795>;
        <D.18794>:
        D.18796 = mono_get_exception_synchronization_lock ("Not locked");
        mono_raise_exception (D.18796);
        return;
        <D.18795>:
        D.18792 = lw.lock_word;
        D.18797 = D.18792 & 4294967292;
        lw.lock_word = D.18797;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.18798>; else goto <D.18799>;
  <D.18798>:
  D.18800 = mono_get_exception_synchronization_lock ("Not locked");
  mono_raise_exception (D.18800);
  return;
  <D.18799>:
  D.18801 = mon->owner;
  tls_pthread_self.52 = tls_pthread_self;
  if (D.18801 != tls_pthread_self.52) goto <D.18803>; else goto <D.18804>;
  <D.18803>:
  D.18805 = mono_get_exception_synchronization_lock ("Not locked by this thread");
  mono_raise_exception (D.18805);
  return;
  <D.18804>:
  D.18806 = mon->wait_list;
  if (D.18806 != 0B) goto <D.18807>; else goto <D.18808>;
  <D.18807>:
  D.18806 = mon->wait_list;
  D.18809 = D.18806->data;
  SetEvent (D.18809);
  D.18806 = mon->wait_list;
  D.18806 = mon->wait_list;
  D.18809 = D.18806->data;
  D.18810 = monoeg_g_slist_remove (D.18806, D.18809);
  mon->wait_list = D.18810;
  <D.18808>:
}


ves_icall_System_Threading_Monitor_Monitor_pulse_all (struct MonoObject * obj)
{
  unsigned int D.18814;
  unsigned int D.18815;
  struct MonoException * D.18818;
  unsigned int D.18819;
  struct MonoException * D.18822;
  unsigned int D.18823;
  unsigned int tls_pthread_self.53;
  struct MonoException * D.18827;
  struct GSList * D.18828;
  void * D.18829;
  struct GSList * D.18830;
  struct MonoThreadsSync * mon;

  mon = obj->synchronisation;
  {
    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>:
        D.18818 = mono_get_exception_synchronization_lock ("Not locked");
        mono_raise_exception (D.18818);
        return;
        <D.18817>:
        D.18814 = lw.lock_word;
        D.18819 = D.18814 & 4294967292;
        lw.lock_word = D.18819;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.18820>; else goto <D.18821>;
  <D.18820>:
  D.18822 = mono_get_exception_synchronization_lock ("Not locked");
  mono_raise_exception (D.18822);
  return;
  <D.18821>:
  D.18823 = mon->owner;
  tls_pthread_self.53 = tls_pthread_self;
  if (D.18823 != tls_pthread_self.53) goto <D.18825>; else goto <D.18826>;
  <D.18825>:
  D.18827 = mono_get_exception_synchronization_lock ("Not locked by this thread");
  mono_raise_exception (D.18827);
  return;
  <D.18826>:
  goto <D.18133>;
  <D.18132>:
  D.18828 = mon->wait_list;
  D.18829 = D.18828->data;
  SetEvent (D.18829);
  D.18828 = mon->wait_list;
  D.18828 = mon->wait_list;
  D.18829 = D.18828->data;
  D.18830 = monoeg_g_slist_remove (D.18828, D.18829);
  mon->wait_list = D.18830;
  <D.18133>:
  D.18828 = mon->wait_list;
  if (D.18828 != 0B) goto <D.18132>; else goto <D.18134>;
  <D.18134>:
}


ves_icall_System_Threading_Monitor_Monitor_wait (struct MonoObject * obj, guint32 ms)
{
  unsigned int D.18834;
  unsigned int D.18835;
  struct MonoException * D.18838;
  gboolean D.18839;
  unsigned int D.18840;
  struct MonoException * D.18843;
  unsigned int D.18844;
  unsigned int tls_pthread_self.54;
  struct MonoException * D.18848;
  struct MonoException * D.18851;
  struct GSList * D.18852;
  struct GSList * D.18853;
  int D.18854;
  struct MonoException * D.18861;
  struct GSList * D.18867;
  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.18834 = lw.lock_word;
        D.18835 = D.18834 & 1;
        if (D.18835 != 0) goto <D.18836>; else goto <D.18837>;
        <D.18836>:
        D.18838 = mono_get_exception_synchronization_lock ("Not locked");
        mono_raise_exception (D.18838);
        D.18839 = 0;
        return D.18839;
        <D.18837>:
        D.18834 = lw.lock_word;
        D.18840 = D.18834 & 4294967292;
        lw.lock_word = D.18840;
        mon = lw.sync;
      }
    finally
      {
        lw = {CLOBBER};
      }
  }
  if (mon == 0B) goto <D.18841>; else goto <D.18842>;
  <D.18841>:
  D.18843 = mono_get_exception_synchronization_lock ("Not locked");
  mono_raise_exception (D.18843);
  D.18839 = 0;
  return D.18839;
  <D.18842>:
  D.18844 = mon->owner;
  tls_pthread_self.54 = tls_pthread_self;
  if (D.18844 != tls_pthread_self.54) goto <D.18846>; else goto <D.18847>;
  <D.18846>:
  D.18848 = mono_get_exception_synchronization_lock ("Not locked by this thread");
  mono_raise_exception (D.18848);
  D.18839 = 0;
  return D.18839;
  <D.18847>:
  mono_thread_current_check_pending_interrupt ();
  event = CreateEvent (0B, 0, 0, 0B);
  if (event == 0B) goto <D.18849>; else goto <D.18850>;
  <D.18849>:
  D.18851 = mono_get_exception_synchronization_lock ("Failed to set up wait event");
  mono_raise_exception (D.18851);
  D.18839 = 0;
  return D.18839;
  <D.18850>:
  mono_thread_current_check_pending_interrupt ();
  mono_thread_set_state (thread, 32);
  D.18852 = mon->wait_list;
  D.18853 = monoeg_g_slist_append (D.18852, event);
  mon->wait_list = D.18853;
  nest = mon->nest;
  mon->nest = 1;
  mono_monitor_exit (obj);
  ret = WaitForSingleObjectEx (event, ms, 1);
  mono_thread_clr_state (thread, 32);
  D.18854 = mono_thread_interruption_requested ();
  if (D.18854 != 0) goto <D.18855>; else goto <D.18856>;
  <D.18855>:
  D.18839 = 0;
  return D.18839;
  <D.18856>:
  <D.18147>:
  regain = mono_monitor_try_enter_internal (obj, 4294967295, 1);
  if (regain == -1) goto <D.18857>; else goto <D.18858>;
  <D.18857>:
  mono_thread_interruption_checkpoint ();
  <D.18858>:
  if (regain == -1) goto <D.18147>; else goto <D.18148>;
  <D.18148>:
  if (regain == 0) goto <D.18859>; else goto <D.18860>;
  <D.18859>:
  CloseHandle (event);
  D.18861 = mono_get_exception_synchronization_lock ("Failed to regain lock");
  mono_raise_exception (D.18861);
  D.18839 = 0;
  return D.18839;
  <D.18860>:
  mon->nest = nest;
  if (ret == 258) goto <D.18862>; else goto <D.18863>;
  <D.18862>:
  ret = WaitForSingleObjectEx (event, 0, 0);
  <D.18863>:
  if (ret == 0) goto <D.18864>; else goto <D.18865>;
  <D.18864>:
  success = 1;
  goto <D.18866>;
  <D.18865>:
  D.18852 = mon->wait_list;
  D.18867 = monoeg_g_slist_remove (D.18852, event);
  mon->wait_list = D.18867;
  <D.18866>:
  CloseHandle (event);
  D.18839 = success;
  return D.18839;
}


