mono_thread_pool_remove_socket (int sock)
{
  int D.21296;
  _Bool D.21301;
  long int D.21302;
  long int D.21303;
  struct MonoGHashTable * D.21306;
  _Bool D.21311;
  long int D.21312;
  long int D.21313;
  const void * sock.0;
  void * list.1;
  struct MonoMList * list.2;
  _Bool D.21323;
  long int D.21324;
  long int D.21325;
  int D.21328;
  struct MonoMList * list;
  struct MonoSocketAsyncResult * state;
  struct MonoObject * ares;

  try
    {
      D.21296 = socket_io_data.inited;
      if (D.21296 == 0) goto <D.21297>; else goto <D.21298>;
      <D.21297>:
      return;
      <D.21298>:
      {
        int ret;

        ret = pthread_mutex_lock (&socket_io_data.io_lock.mutex);
        if (ret != 0) goto <D.21299>; else goto <D.21300>;
        <D.21299>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.21300>:
        D.21301 = ret != 0;
        D.21302 = (long int) D.21301;
        D.21303 = __builtin_expect (D.21302, 0);
        if (D.21303 != 0) goto <D.21304>; else goto <D.21305>;
        <D.21304>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 446, "ret == 0");
        <D.21305>:
      }
      D.21306 = socket_io_data.sock_to_state;
      if (D.21306 == 0B) goto <D.21307>; else goto <D.21308>;
      <D.21307>:
      {
        int ret;

        ret = pthread_mutex_unlock (&socket_io_data.io_lock.mutex);
        if (ret != 0) goto <D.21309>; else goto <D.21310>;
        <D.21309>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.21310>:
        D.21311 = ret != 0;
        D.21312 = (long int) D.21311;
        D.21313 = __builtin_expect (D.21312, 0);
        if (D.21313 != 0) goto <D.21314>; else goto <D.21315>;
        <D.21314>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 448, "ret == 0");
        <D.21315>:
      }
      return;
      <D.21308>:
      D.21306 = socket_io_data.sock_to_state;
      sock.0 = (const void *) sock;
      list.1 = mono_g_hash_table_lookup (D.21306, sock.0);
      list = list.1;
      list.2 = list;
      if (list.2 != 0B) goto <D.21319>; else goto <D.21320>;
      <D.21319>:
      D.21306 = socket_io_data.sock_to_state;
      sock.0 = (const void *) sock;
      mono_g_hash_table_remove (D.21306, sock.0);
      <D.21320>:
      {
        int ret;

        ret = pthread_mutex_unlock (&socket_io_data.io_lock.mutex);
        if (ret != 0) goto <D.21321>; else goto <D.21322>;
        <D.21321>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.21322>:
        D.21323 = ret != 0;
        D.21324 = (long int) D.21323;
        D.21325 = __builtin_expect (D.21324, 0);
        if (D.21325 != 0) goto <D.21326>; else goto <D.21327>;
        <D.21326>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 454, "ret == 0");
        <D.21327>:
      }
      goto <D.20917>;
      <D.20916>:
      list.2 = list;
      state = mono_mlist_get_data (list.2);
      D.21328 = state->operation;
      if (D.21328 == 2) goto <D.21329>; else goto <D.21330>;
      <D.21329>:
      state->operation = 6;
      goto <D.21331>;
      <D.21330>:
      D.21328 = state->operation;
      if (D.21328 == 4) goto <D.21332>; else goto <D.21333>;
      <D.21332>:
      state->operation = 7;
      <D.21333>:
      <D.21331>:
      ares = get_io_event (&list, 1);
      threadpool_append_job (&async_io_tp, ares);
      list.2 = list;
      if (list.2 != 0B) goto <D.21334>; else goto <D.21335>;
      <D.21334>:
      ares = get_io_event (&list, 4);
      threadpool_append_job (&async_io_tp, ares);
      <D.21335>:
      <D.20917>:
      list.2 = list;
      if (list.2 != 0B) goto <D.20916>; else goto <D.20918>;
      <D.20918>:
    }
  finally
    {
      list = {CLOBBER};
    }
}


get_io_event (struct MonoMList * * list, gint event)
{
  int D.21339;
  struct MonoMList * D.21345;
  struct MonoMList * D.21347;
  struct MonoMList * D.21348;
  struct MonoObject * D.21349;
  struct MonoObject * state;
  struct MonoMList * current;
  struct MonoMList * prev;

  current = *list;
  prev = 0B;
  state = 0B;
  goto <D.20906>;
  <D.20905>:
  state = mono_mlist_get_data (current);
  D.21339 = get_event_from_state (state);
  if (D.21339 == event) goto <D.20904>; else goto <D.21340>;
  <D.21340>:
  state = 0B;
  prev = current;
  current = mono_mlist_next (current);
  <D.20906>:
  if (current != 0B) goto <D.20905>; else goto <D.20904>;
  <D.20904>:
  if (current != 0B) goto <D.21341>; else goto <D.21342>;
  <D.21341>:
  if (prev != 0B) goto <D.21343>; else goto <D.21344>;
  <D.21343>:
  D.21345 = mono_mlist_next (current);
  mono_mlist_set_next (prev, D.21345);
  goto <D.21346>;
  <D.21344>:
  D.21347 = *list;
  D.21348 = mono_mlist_next (D.21347);
  *list = D.21348;
  <D.21346>:
  <D.21342>:
  D.21349 = state;
  return D.21349;
}


get_event_from_state (struct MonoSocketAsyncResult * state)
{
  int D.21351;
  int D.21352;

  D.21351 = state->operation;
  switch (D.21351) <default: <D.20880>, case 0: <D.20867>, case 1: <D.20877>, case 2: <D.20868>, case 3: <D.20870>, case 4: <D.20874>, case 5: <D.20876>, case 6: <D.20869>, case 7: <D.20875>, case 8: <D.20871>, case 10: <D.20879>, case 11: <D.20872>, case 12: <D.20873>, case 13: <D.20878>>
  <D.20867>:
  <D.20868>:
  <D.20869>:
  <D.20870>:
  <D.20871>:
  <D.20872>:
  <D.20873>:
  D.21352 = 1;
  return D.21352;
  <D.20874>:
  <D.20875>:
  <D.20876>:
  <D.20877>:
  <D.20878>:
  <D.20879>:
  D.21352 = 4;
  return D.21352;
  <D.20880>:
  monoeg_g_log (0B, 32, "get_event_from_state: unknown value in switch!!!");
  D.21352 = 0;
  return D.21352;
}


threadpool_append_job (struct ThreadPool * tp, struct MonoObject * ar)
{
  threadpool_append_jobs (tp, &ar, 1);
}


threadpool_append_jobs (struct ThreadPool * tp, struct MonoObject * * jobs, gint njobs)
{
  int D.21354;
  int D.21357;
  volatile gint * D.21360;
  int D.21361;
  int D.21364;
  struct MonoDomain * D.21367;
  int D.21368;
  struct MonoDomain * D.21371;
  unsigned int i.3;
  unsigned int D.21373;
  struct MonoObject * * D.21374;
  struct MonoVTable * D.21378;
  struct MonoDomain * D.21379;
  int D.21380;
  int D.21383;
  int D.21384;
  long long int D.21387;
  void * D.21388;
  int D.21391;
  struct MonoCQ * D.21394;
  int D.21395;
  int iftmp.4;
  int D.21398;
  static int job_counter;
  struct MonoObject * ar;
  gint i;

  D.21354 = mono_runtime_is_shutting_down ();
  if (D.21354 != 0) goto <D.21355>; else goto <D.21356>;
  <D.21355>:
  return;
  <D.21356>:
  D.21357 = tp->pool_status;
  if (D.21357 == 0) goto <D.21358>; else goto <D.21359>;
  <D.21358>:
  D.21360 = &tp->pool_status;
  D.21361 = InterlockedCompareExchange (D.21360, 1, 0);
  if (D.21361 == 0) goto <D.21362>; else goto <D.21363>;
  <D.21362>:
  D.21364 = tp->is_io;
  if (D.21364 == 0) goto <D.21365>; else goto <D.21366>;
  <D.21365>:
  D.21367 = mono_get_root_domain ();
  mono_thread_create_internal (D.21367, monitor_thread, 0B, 1, 0, 131072);
  threadpool_start_thread (tp);
  <D.21366>:
  D.21368 = mono_config_is_server_mode ();
  if (D.21368 != 0) goto <D.21369>; else goto <D.21370>;
  <D.21369>:
  D.21371 = mono_get_root_domain ();
  mono_thread_create_internal (D.21371, threadpool_start_idle_threads, tp, 1, 0, 131072);
  <D.21370>:
  <D.21363>:
  <D.21359>:
  i = 0;
  goto <D.21090>;
  <D.21089>:
  i.3 = (unsigned int) i;
  D.21373 = i.3 * 4;
  D.21374 = jobs + D.21373;
  ar = *D.21374;
  if (ar == 0B) goto <D.21375>; else goto <D.21377>;
  <D.21377>:
  D.21378 = ar->vtable;
  D.21379 = D.21378->domain;
  D.21380 = mono_domain_is_unloading (D.21379);
  if (D.21380 != 0) goto <D.21375>; else goto <D.21376>;
  <D.21375>:
  // predicted unlikely by continue predictor.
  goto <D.21087>;
  <D.21376>:
  D.21364 = tp->is_io;
  if (D.21364 == 0) goto <D.21381>; else goto <D.21382>;
  <D.21381>:
  D.21383 = InterlockedIncrement (&job_counter);
  D.21384 = D.21383 % 10;
  if (D.21384 == 0) goto <D.21385>; else goto <D.21386>;
  <D.21385>:
  {
    struct MonoAsyncResult * o;

    o = ar;
    D.21387 = mono_100ns_ticks ();
    o->add_time = D.21387;
  }
  <D.21386>:
  <D.21382>:
  threadpool_jobs_inc (ar);
  D.21388 = tp->pc_nitems;
  mono_perfcounter_update_value (D.21388, 1, 1);
  D.21364 = tp->is_io;
  if (D.21364 == 0) goto <D.21389>; else goto <D.21390>;
  <D.21389>:
  D.21391 = mono_wsq_local_push (ar);
  if (D.21391 != 0) goto <D.21392>; else goto <D.21393>;
  <D.21392>:
  // predicted unlikely by continue predictor.
  goto <D.21087>;
  <D.21393>:
  <D.21390>:
  D.21394 = tp->queue;
  mono_cq_enqueue (D.21394, ar);
  <D.21087>:
  i = i + 1;
  <D.21090>:
  if (i < njobs) goto <D.21089>; else goto <D.21091>;
  <D.21091>:
  i = 0;
  goto <D.21093>;
  <D.21092>:
  pulse_on_new_job (tp);
  i = i + 1;
  <D.21093>:
  D.21395 = tp->waiting;
  if (D.21395 > 0) goto <D.21396>; else goto <D.21094>;
  <D.21396>:
  D.21398 = tp->max_threads;
  if (D.21398 <= njobs) goto <D.21399>; else goto <D.21400>;
  <D.21399>:
  iftmp.4 = tp->max_threads;
  goto <D.21401>;
  <D.21400>:
  iftmp.4 = njobs;
  <D.21401>:
  if (iftmp.4 > i) goto <D.21092>; else goto <D.21094>;
  <D.21094>:
}


threadpool_start_idle_threads (struct ThreadPool * tp)
{
  unsigned int iftmp.5;
  int D.21404;
  int D.21408;
  volatile gint * D.21411;
  int D.21412;
  int D.21413;
  void * D.21415;
  struct MonoDomain * D.21416;
  void (*<T15c0>) (void *) D.21417;
  int n;
  guint32 stack_size;

  D.21404 = tp->is_io;
  if (D.21404 == 0) goto <D.21405>; else goto <D.21406>;
  <D.21405>:
  iftmp.5 = 0;
  goto <D.21407>;
  <D.21406>:
  iftmp.5 = 131072;
  <D.21407>:
  stack_size = iftmp.5;
  <D.20968>:
  <D.20967>:
  n = tp->nthreads;
  D.21408 = tp->min_threads;
  if (D.21408 <= n) goto <D.21409>; else goto <D.21410>;
  <D.21409>:
  return;
  <D.21410>:
  D.21411 = &tp->nthreads;
  D.21412 = n + 1;
  D.21413 = InterlockedCompareExchange (D.21411, D.21412, n);
  if (D.21413 == n) goto <D.20966>; else goto <D.21414>;
  <D.21414>:
  goto <D.20967>;
  <D.20966>:
  D.21415 = tp->pc_nthreads;
  mono_perfcounter_update_value (D.21415, 1, 1);
  D.21416 = mono_get_root_domain ();
  D.21417 = tp->async_invoke;
  mono_thread_create_internal (D.21416, D.21417, tp, 1, 0, stack_size);
  SleepEx (100, 1);
  goto <D.20968>;
}


monitor_thread (void * unused)
{
  struct MonoDomain * D.21419;
  struct MonoString * D.21420;
  unsigned int D.21421;
  unsigned int D.21423;
  unsigned int D.21424;
  int D.21425;
  unsigned int D.21427;
  unsigned int D.21428;
  int i.6;
  int D.21433;
  int suspended.7;
  int D.21438;
  struct MonoCQ * D.21441;
  int D.21442;
  _Bool D.21443;
  int D.21446;
  _Bool D.21451;
  long int D.21452;
  long int D.21453;
  struct GPtrArray * wsqs.8;
  void * * D.21457;
  unsigned int i.9;
  unsigned int D.21459;
  void * * D.21460;
  int D.21461;
  unsigned int i.10;
  unsigned int D.21466;
  _Bool D.21469;
  long int D.21470;
  long int D.21471;
  struct ThreadPool * pools[2];
  struct MonoInternalThread * thread;
  guint32 ms;
  gboolean need_one;
  int i;

  try
    {
      pools[0] = &async_tp;
      pools[1] = &async_io_tp;
      thread = mono_thread_internal_current ();
      D.21419 = mono_domain_get ();
      D.21420 = mono_string_new (D.21419, "Threadpool monitor");
      ves_icall_System_Threading_Thread_SetName_internal (thread, D.21420);
      <D.21010>:
      ms = 500;
      i = 10;
      <D.20996>:
      {
        guint32 ts;

        ts = mono_msec_ticks ();
        D.21421 = SleepEx (ms, 1);
        if (D.21421 == 0) goto <D.20995>; else goto <D.21422>;
        <D.21422>:
        D.21423 = mono_msec_ticks ();
        D.21424 = D.21423 - ts;
        ms = ms - D.21424;
        D.21425 = mono_runtime_is_shutting_down ();
        if (D.21425 != 0) goto <D.20995>; else goto <D.21426>;
        <D.21426>:
        D.21427 = thread->state;
        D.21428 = D.21427 & 3;
        if (D.21428 != 0) goto <D.21429>; else goto <D.21430>;
        <D.21429>:
        mono_thread_interruption_checkpoint ();
        <D.21430>:
      }
      if (ms != 0) goto <D.21431>; else goto <D.20995>;
      <D.21431>:
      i.6 = i;
      i = i.6 + -1;
      if (i.6 != 0) goto <D.20996>; else goto <D.20995>;
      <D.20995>:
      D.21433 = mono_runtime_is_shutting_down ();
      if (D.21433 != 0) goto <D.20997>; else goto <D.21434>;
      <D.21434>:
      suspended.7 = suspended;
      if (suspended.7 != 0) goto <D.21436>; else goto <D.21437>;
      <D.21436>:
      // predicted unlikely by continue predictor.
      goto <D.20998>;
      <D.21437>:
      i = 0;
      goto <D.21008>;
      <D.21007>:
      {
        struct ThreadPool * tp;

        tp = pools[i];
        D.21438 = tp->waiting;
        if (D.21438 > 0) goto <D.21439>; else goto <D.21440>;
        <D.21439>:
        // predicted unlikely by continue predictor.
        goto <D.21000>;
        <D.21440>:
        D.21441 = tp->queue;
        D.21442 = mono_cq_count (D.21441);
        D.21443 = D.21442 > 0;
        need_one = (gboolean) D.21443;
        if (need_one == 0) goto <D.21444>; else goto <D.21445>;
        <D.21444>:
        D.21446 = tp->is_io;
        if (D.21446 == 0) goto <D.21447>; else goto <D.21448>;
        <D.21447>:
        {
          int ret;

          ret = pthread_mutex_lock (&wsqs_lock.mutex);
          if (ret != 0) goto <D.21449>; else goto <D.21450>;
          <D.21449>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
          <D.21450>:
          D.21451 = ret != 0;
          D.21452 = (long int) D.21451;
          D.21453 = __builtin_expect (D.21452, 0);
          if (D.21453 != 0) goto <D.21454>; else goto <D.21455>;
          <D.21454>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 801, "ret == 0");
          <D.21455>:
        }
        i = 0;
        goto <D.21005>;
        <D.21004>:
        {
          struct MonoWSQ * wsq;

          wsqs.8 = wsqs;
          D.21457 = wsqs.8->pdata;
          i.9 = (unsigned int) i;
          D.21459 = i.9 * 4;
          D.21460 = D.21457 + D.21459;
          wsq = *D.21460;
          D.21461 = mono_wsq_count (wsq);
          if (D.21461 != 0) goto <D.21462>; else goto <D.21463>;
          <D.21462>:
          need_one = 1;
          goto <D.21003>;
          <D.21463>:
        }
        i = i + 1;
        <D.21005>:
        wsqs.8 = wsqs;
        if (wsqs.8 != 0B) goto <D.21464>; else goto <D.21003>;
        <D.21464>:
        i.10 = (unsigned int) i;
        wsqs.8 = wsqs;
        D.21466 = wsqs.8->len;
        if (i.10 < D.21466) goto <D.21004>; else goto <D.21003>;
        <D.21003>:
        {
          int ret;

          ret = pthread_mutex_unlock (&wsqs_lock.mutex);
          if (ret != 0) goto <D.21467>; else goto <D.21468>;
          <D.21467>:
          monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
          <D.21468>:
          D.21469 = ret != 0;
          D.21470 = (long int) D.21469;
          D.21471 = __builtin_expect (D.21470, 0);
          if (D.21471 != 0) goto <D.21472>; else goto <D.21473>;
          <D.21472>:
          monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 810, "ret == 0");
          <D.21473>:
        }
        <D.21448>:
        <D.21445>:
        if (need_one != 0) goto <D.21474>; else goto <D.21475>;
        <D.21474>:
        threadpool_start_thread (tp);
        <D.21475>:
      }
      <D.21000>:
      i = i + 1;
      <D.21008>:
      if (i <= 1) goto <D.21007>; else goto <D.21009>;
      <D.21009>:
      <D.20998>:
      goto <D.21010>;
      <D.20997>:
    }
  finally
    {
      pools = {CLOBBER};
    }
}


InterlockedCompareExchange (volatile gint32 * dest, gint32 exch, gint32 comp)
{
  gint32 D.21476;
  unsigned int comp.11;
  unsigned int exch.12;
  unsigned int D.21479;

  comp.11 = (unsigned int) comp;
  exch.12 = (unsigned int) exch;
  D.21479 = __sync_val_compare_and_swap_4 (dest, comp.11, exch.12);
  D.21476 = (gint32) D.21479;
  return D.21476;
}


threadpool_start_thread (struct ThreadPool * tp)
{
  unsigned int iftmp.13;
  int D.21482;
  volatile gint * D.21486;
  int D.21487;
  int D.21488;
  void * D.21491;
  struct MonoDomain * D.21492;
  void (*<T15c0>) (void *) D.21493;
  gboolean D.21494;
  int D.21495;
  int D.21497;
  gint n;
  guint32 stack_size;

  D.21482 = tp->is_io;
  if (D.21482 == 0) goto <D.21483>; else goto <D.21484>;
  <D.21483>:
  iftmp.13 = 0;
  goto <D.21485>;
  <D.21484>:
  iftmp.13 = 131072;
  <D.21485>:
  stack_size = iftmp.13;
  goto <D.21067>;
  <D.21066>:
  D.21486 = &tp->nthreads;
  D.21487 = n + 1;
  D.21488 = InterlockedCompareExchange (D.21486, D.21487, n);
  if (D.21488 == n) goto <D.21489>; else goto <D.21490>;
  <D.21489>:
  D.21491 = tp->pc_nthreads;
  mono_perfcounter_update_value (D.21491, 1, 1);
  D.21492 = mono_get_root_domain ();
  D.21493 = tp->async_invoke;
  mono_thread_create_internal (D.21492, D.21493, tp, 1, 0, stack_size);
  D.21494 = 1;
  return D.21494;
  <D.21490>:
  <D.21067>:
  D.21495 = mono_runtime_is_shutting_down ();
  if (D.21495 == 0) goto <D.21496>; else goto <D.21068>;
  <D.21496>:
  n = tp->nthreads;
  D.21497 = tp->max_threads;
  if (n < D.21497) goto <D.21066>; else goto <D.21068>;
  <D.21068>:
  D.21494 = 0;
  return D.21494;
}


InterlockedIncrement (volatile gint32 * val)
{
  gint32 D.21499;
  unsigned int D.21500;

  D.21500 = __sync_add_and_fetch_4 (val, 1);
  D.21499 = (gint32) D.21500;
  return D.21499;
}


threadpool_jobs_inc (struct MonoObject * obj)
{
  struct MonoVTable * D.21504;
  struct MonoDomain * D.21505;
  volatile int * D.21506;

  if (obj != 0B) goto <D.21502>; else goto <D.21503>;
  <D.21502>:
  D.21504 = obj->vtable;
  D.21505 = D.21504->domain;
  D.21506 = &D.21505->threadpool_jobs;
  InterlockedIncrement (D.21506);
  <D.21503>:
}


pulse_on_new_job (struct ThreadPool * tp)
{
  int D.21507;
  union MonoSemType * D.21510;

  D.21507 = tp->waiting;
  if (D.21507 != 0) goto <D.21508>; else goto <D.21509>;
  <D.21508>:
  D.21510 = &tp->new_job;
  mono_sem_post (D.21510);
  <D.21509>:
}


mono_thread_pool_init_tls ()
{
  mono_wsq_init ();
}


mono_thread_pool_init ()
{
  int tp_inited.14;
  int tp_inited.15;
  int D.21519;
  const gchar * D.21522;
  const gchar * D.21525;
  int D.21528;
  int D.21529;
  int D.21530;
  int D.21531;
  int D.21532;
  struct MonoImage * D.21533;
  struct MonoClass * async_call_klass.16;
  struct MonoClass * async_call_klass.17;
  _Bool D.21536;
  long int D.21537;
  long int D.21538;
  unsigned int D.21541;
  struct GPtrArray * wsqs.18;
  void * D.21543;
  void * D.21544;
  _Bool D.21545;
  long int D.21546;
  long int D.21547;
  void * D.21550;
  void * D.21551;
  _Bool D.21552;
  long int D.21553;
  long int D.21554;
  void * D.21557;
  void * D.21558;
  _Bool D.21559;
  long int D.21560;
  long int D.21561;
  void * D.21564;
  void * D.21565;
  _Bool D.21566;
  long int D.21567;
  long int D.21568;
  gint threads_per_cpu;
  gint thread_count;
  gint cpu_count;
  int result;

  threads_per_cpu = 1;
  cpu_count = mono_cpu_count ();
  tp_inited.14 = tp_inited;
  if (tp_inited.14 == 2) goto <D.21512>; else goto <D.21513>;
  <D.21512>:
  return;
  <D.21513>:
  result = InterlockedCompareExchange (&tp_inited, 1, 0);
  if (result == 1) goto <D.21514>; else goto <D.21515>;
  <D.21514>:
  <D.21021>:
  SleepEx (1, 0);
  tp_inited.15 = tp_inited;
  if (tp_inited.15 == 2) goto <D.21517>; else goto <D.21518>;
  <D.21517>:
  return;
  <D.21518>:
  goto <D.21021>;
  <D.21515>:
  D.21519 = mono_gc_is_moving ();
  if (D.21519 == 0) goto <D.21520>; else goto <D.21521>;
  <D.21520>:
  mono_gc_register_root (&socket_io_data.sock_to_state, 4, 0B);
  <D.21521>:
  InitializeCriticalSection (&socket_io_data.io_lock);
  D.21522 = monoeg_g_getenv ("MONO_THREADS_PER_CPU");
  if (D.21522 != 0B) goto <D.21523>; else goto <D.21524>;
  <D.21523>:
  D.21525 = monoeg_g_getenv ("MONO_THREADS_PER_CPU");
  threads_per_cpu = atoi (D.21525);
  if (threads_per_cpu <= 0) goto <D.21526>; else goto <D.21527>;
  <D.21526>:
  threads_per_cpu = 1;
  <D.21527>:
  <D.21524>:
  D.21528 = cpu_count * 100;
  D.21529 = cpu_count * threads_per_cpu;
  thread_count = MIN_EXPR <D.21528, D.21529>;
  D.21528 = cpu_count * 100;
  D.21530 = MAX_EXPR <D.21528, thread_count>;
  threadpool_init (&async_tp, thread_count, D.21530, async_invoke_thread);
  D.21531 = cpu_count * 2;
  D.21532 = cpu_count * 4;
  threadpool_init (&async_io_tp, D.21531, D.21532, async_invoke_thread);
  async_io_tp.is_io = 1;
  D.21533 = mono_defaults.corlib;
  async_call_klass.16 = mono_class_from_name (D.21533, "System", "MonoAsyncCall");
  async_call_klass = async_call_klass.16;
  async_call_klass.17 = async_call_klass;
  D.21536 = async_call_klass.17 == 0B;
  D.21537 = (long int) D.21536;
  D.21538 = __builtin_expect (D.21537, 0);
  if (D.21538 != 0) goto <D.21539>; else goto <D.21540>;
  <D.21539>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 858, "async_call_klass");
  <D.21540>:
  InitializeCriticalSection (&wsqs_lock);
  D.21528 = cpu_count * 100;
  D.21530 = MAX_EXPR <D.21528, thread_count>;
  D.21541 = (unsigned int) D.21530;
  wsqs.18 = monoeg_g_ptr_array_sized_new (D.21541);
  wsqs = wsqs.18;
  D.21543 = init_perf_counter ("Mono Threadpool", "Work Items Added");
  async_tp.pc_nitems = D.21543;
  D.21544 = async_tp.pc_nitems;
  D.21545 = D.21544 == 0B;
  D.21546 = (long int) D.21545;
  D.21547 = __builtin_expect (D.21546, 0);
  if (D.21547 != 0) goto <D.21548>; else goto <D.21549>;
  <D.21548>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 865, "async_tp.pc_nitems");
  <D.21549>:
  D.21550 = init_perf_counter ("Mono Threadpool", "IO Work Items Added");
  async_io_tp.pc_nitems = D.21550;
  D.21551 = async_io_tp.pc_nitems;
  D.21552 = D.21551 == 0B;
  D.21553 = (long int) D.21552;
  D.21554 = __builtin_expect (D.21553, 0);
  if (D.21554 != 0) goto <D.21555>; else goto <D.21556>;
  <D.21555>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 868, "async_io_tp.pc_nitems");
  <D.21556>:
  D.21557 = init_perf_counter ("Mono Threadpool", "# of Threads");
  async_tp.pc_nthreads = D.21557;
  D.21558 = async_tp.pc_nthreads;
  D.21559 = D.21558 == 0B;
  D.21560 = (long int) D.21559;
  D.21561 = __builtin_expect (D.21560, 0);
  if (D.21561 != 0) goto <D.21562>; else goto <D.21563>;
  <D.21562>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 871, "async_tp.pc_nthreads");
  <D.21563>:
  D.21564 = init_perf_counter ("Mono Threadpool", "# of IO Threads");
  async_io_tp.pc_nthreads = D.21564;
  D.21565 = async_io_tp.pc_nthreads;
  D.21566 = D.21565 == 0B;
  D.21567 = (long int) D.21566;
  D.21568 = __builtin_expect (D.21567, 0);
  if (D.21568 != 0) goto <D.21569>; else goto <D.21570>;
  <D.21569>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 874, "async_io_tp.pc_nthreads");
  <D.21570>:
  tp_inited = 2;
}


async_invoke_thread (void * data)
{
  int D.21572;
  void (*<T15c0>) (void *) tp_start_func.19;
  void * tp_hooks_user_data.20;
  volatile gint * D.21581;
  struct MonoVTable * D.21582;
  void * data.21;
  struct MonoVTable * D.21584;
  int D.21585;
  _Bool D.21586;
  int D.21589;
  void * D.21590;
  unsigned int D.21591;
  struct MonoArray * D.21592;
  int D.21593;
  int D.21594;
  int D.21595;
  gint * D.21596;
  int D.21597;
  int D.21598;
  _Bool D.21600;
  long int D.21601;
  long int D.21602;
  int D.21608;
  int D.21610;
  volatile gint * D.21611;
  int D.21612;
  volatile gint * D.21615;
  int D.21616;
  void (*<T15c0>) (void *) tp_item_begin_func.22;
  void * tp_item_user_data.23;
  long long int D.21625;
  void (*<T15c0>) (void *) tp_item_end_func.24;
  unsigned char D.21637;
  struct MonoDelegate * D.21640;
  struct MonoDomain * D.21643;
  volatile gint * D.21644;
  int D.21650;
  volatile gint * D.21651;
  volatile gint * D.21654;
  int D.21655;
  struct MonoCQ * D.21657;
  int D.21658;
  union MonoSemType * D.21660;
  volatile gint * D.21661;
  int D.21662;
  int D.21670;
  volatile gint * D.21677;
  int D.21682;
  volatile gint * D.21687;
  int D.21688;
  int D.21689;
  void * D.21690;
  void (*<T15c0>) (void *) tp_finish_func.25;
  struct MonoDomain * domain;
  struct MonoWSQ * wsq;
  struct ThreadPool * tp;
  gboolean must_die;

  tp = data;
  wsq = 0B;
  D.21572 = tp->is_io;
  if (D.21572 == 0) goto <D.21573>; else goto <D.21574>;
  <D.21573>:
  wsq = add_wsq ();
  <D.21574>:
  set_tp_thread_info (tp);
  tp_start_func.19 = tp_start_func;
  if (tp_start_func.19 != 0B) goto <D.21576>; else goto <D.21577>;
  <D.21576>:
  tp_start_func.19 = tp_start_func;
  tp_hooks_user_data.20 = tp_hooks_user_data;
  tp_start_func.19 (tp_hooks_user_data.20);
  <D.21577>:
  data = 0B;
  <D.21246>:
  {
    struct MonoAsyncResult * ar;
    struct MonoClass * klass;
    gboolean is_io_task;
    gboolean is_socket;
    int n_naps;

    n_naps = 0;
    is_io_task = 0;
    ar = data;
    if (ar != 0B) goto <D.21579>; else goto <D.21580>;
    <D.21579>:
    D.21581 = &tp->busy_threads;
    InterlockedIncrement (D.21581);
    D.21582 = MEM[(struct MonoObject *)ar].vtable;
    domain = D.21582->domain;
    data.21 = data;
    D.21584 = MEM[(struct MonoObject *)data.21].vtable;
    klass = D.21584->klass;
    D.21585 = is_corlib_asyncresult (domain, klass);
    D.21586 = D.21585 == 0;
    is_io_task = (gboolean) D.21586;
    is_socket = 0;
    if (is_io_task != 0) goto <D.21587>; else goto <D.21588>;
    <D.21587>:
    {
      struct MonoSocketAsyncResult * state;

      state = data;
      is_socket = is_socketasyncresult (domain, klass);
      ar = state->ares;
      D.21589 = state->operation;
      switch (D.21589) <default: <D.21599>, case 2: <D.21228>, case 4: <D.21230>>
      <D.21228>:
      D.21590 = state->handle;
      D.21591 = (unsigned int) D.21590;
      D.21592 = state->buffer;
      D.21593 = state->offset;
      D.21594 = state->size;
      D.21595 = state->socket_flags;
      D.21596 = &state->error;
      D.21597 = ves_icall_System_Net_Sockets_Socket_Receive_internal (D.21591, D.21592, D.21593, D.21594, D.21595, D.21596);
      state->total = D.21597;
      goto <D.21229>;
      <D.21230>:
      D.21590 = state->handle;
      D.21591 = (unsigned int) D.21590;
      D.21592 = state->buffer;
      D.21593 = state->offset;
      D.21594 = state->size;
      D.21595 = state->socket_flags;
      D.21596 = &state->error;
      D.21598 = ves_icall_System_Net_Sockets_Socket_Send_internal (D.21591, D.21592, D.21593, D.21594, D.21595, D.21596);
      state->total = D.21598;
      goto <D.21229>;
      <D.21599>:
      <D.21229>:
    }
    <D.21588>:
    D.21600 = domain == 0B;
    D.21601 = (long int) D.21600;
    D.21602 = __builtin_expect (D.21601, 0);
    if (D.21602 != 0) goto <D.21603>; else goto <D.21604>;
    <D.21603>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1492, "domain");
    <D.21604>:
    D.21608 = mono_domain_is_unloading (domain);
    if (D.21608 != 0) goto <D.21605>; else goto <D.21609>;
    <D.21609>:
    D.21610 = mono_runtime_is_shutting_down ();
    if (D.21610 != 0) goto <D.21605>; else goto <D.21606>;
    <D.21605>:
    threadpool_jobs_dec (ar);
    data = 0B;
    ar = 0B;
    D.21611 = &tp->busy_threads;
    InterlockedDecrement (D.21611);
    goto <D.21607>;
    <D.21606>:
    mono_thread_push_appdomain_ref (domain);
    D.21612 = threadpool_jobs_dec (ar);
    if (D.21612 != 0) goto <D.21613>; else goto <D.21614>;
    <D.21613>:
    data = 0B;
    ar = 0B;
    mono_thread_pop_appdomain_ref ();
    D.21615 = &tp->busy_threads;
    InterlockedDecrement (D.21615);
    // predicted unlikely by continue predictor.
    goto <D.21231>;
    <D.21614>:
    D.21616 = mono_domain_set (domain, 0);
    if (D.21616 != 0) goto <D.21617>; else goto <D.21618>;
    <D.21617>:
    {
      struct MonoObject * exc;

      tp_item_begin_func.22 = tp_item_begin_func;
      if (tp_item_begin_func.22 != 0B) goto <D.21620>; else goto <D.21621>;
      <D.21620>:
      tp_item_begin_func.22 = tp_item_begin_func;
      tp_item_user_data.23 = tp_item_user_data;
      tp_item_begin_func.22 (tp_item_user_data.23);
      <D.21621>:
      if (is_io_task == 0) goto <D.21623>; else goto <D.21624>;
      <D.21623>:
      D.21625 = ar->add_time;
      if (D.21625 > 0) goto <D.21626>; else goto <D.21627>;
      <D.21626>:
      D.21625 = ar->add_time;
      process_idle_times (tp, D.21625);
      <D.21627>:
      <D.21624>:
      exc = mono_async_invoke (tp, ar);
      tp_item_end_func.24 = tp_item_end_func;
      if (tp_item_end_func.24 != 0B) goto <D.21629>; else goto <D.21630>;
      <D.21629>:
      tp_item_end_func.24 = tp_item_end_func;
      tp_item_user_data.23 = tp_item_user_data;
      tp_item_end_func.24 (tp_item_user_data.23);
      <D.21630>:
      if (exc != 0B) goto <D.21631>; else goto <D.21632>;
      <D.21631>:
      mono_internal_thread_unhandled_exception (exc);
      <D.21632>:
      if (is_socket != 0) goto <D.21633>; else goto <D.21634>;
      <D.21633>:
      D.21572 = tp->is_io;
      if (D.21572 != 0) goto <D.21635>; else goto <D.21636>;
      <D.21635>:
      {
        struct MonoSocketAsyncResult * state;

        state = data;
        D.21637 = state->completed;
        if (D.21637 != 0) goto <D.21638>; else goto <D.21639>;
        <D.21638>:
        D.21640 = state->callback;
        if (D.21640 != 0B) goto <D.21641>; else goto <D.21642>;
        <D.21641>:
        {
          struct MonoAsyncResult * cb_ares;

          D.21640 = state->callback;
          cb_ares = create_simple_asyncresult (D.21640, state);
          icall_append_job (cb_ares);
        }
        <D.21642>:
        <D.21639>:
      }
      <D.21636>:
      <D.21634>:
      D.21643 = mono_get_root_domain ();
      mono_domain_set (D.21643, 1);
    }
    <D.21618>:
    mono_thread_pop_appdomain_ref ();
    D.21644 = &tp->busy_threads;
    InterlockedDecrement (D.21644);
    clear_thread_state ();
    <D.21607>:
    <D.21580>:
    ar = 0B;
    data = 0B;
    must_die = should_i_die (tp);
    if (must_die == 0) goto <D.21647>; else goto <D.21648>;
    <D.21647>:
    D.21572 = tp->is_io;
    if (D.21572 != 0) goto <D.21645>; else goto <D.21649>;
    <D.21649>:
    D.21650 = mono_wsq_local_pop (&data);
    if (D.21650 == 0) goto <D.21645>; else goto <D.21646>;
    <D.21645>:
    dequeue_or_steal (tp, &data, wsq);
    <D.21646>:
    <D.21648>:
    n_naps = 0;
    goto <D.21241>;
    <D.21240>:
    {
      gboolean res;

      D.21651 = &tp->waiting;
      InterlockedIncrement (D.21651);
      dequeue_or_steal (tp, &data, wsq);
      data.21 = data;
      if (data.21 != 0B) goto <D.21652>; else goto <D.21653>;
      <D.21652>:
      D.21654 = &tp->waiting;
      InterlockedDecrement (D.21654);
      goto <D.21236>;
      <D.21653>:
      mono_gc_set_skip_thread (1);
      goto <D.21239>;
      <D.21238>:
      D.21655 = mono_runtime_is_shutting_down ();
      if (D.21655 != 0) goto <D.21237>; else goto <D.21656>;
      <D.21656>:
      check_for_interruption_critical ();
      <D.21239>:
      D.21657 = tp->queue;
      D.21658 = mono_cq_count (D.21657);
      if (D.21658 == 0) goto <D.21659>; else goto <D.21237>;
      <D.21659>:
      D.21660 = &tp->new_job;
      res = mono_sem_timedwait (D.21660, 2000, 1);
      if (res == -1) goto <D.21238>; else goto <D.21237>;
      <D.21237>:
      D.21661 = &tp->waiting;
      InterlockedDecrement (D.21661);
      mono_gc_set_skip_thread (0);
      D.21662 = mono_runtime_is_shutting_down ();
      if (D.21662 != 0) goto <D.21236>; else goto <D.21663>;
      <D.21663>:
      must_die = should_i_die (tp);
      dequeue_or_steal (tp, &data, wsq);
      n_naps = n_naps + 1;
    }
    <D.21241>:
    if (must_die == 0) goto <D.21664>; else goto <D.21236>;
    <D.21664>:
    data.21 = data;
    if (data.21 == 0B) goto <D.21665>; else goto <D.21236>;
    <D.21665>:
    if (n_naps <= 3) goto <D.21240>; else goto <D.21236>;
    <D.21236>:
    data.21 = data;
    if (data.21 == 0B) goto <D.21666>; else goto <D.21667>;
    <D.21666>:
    D.21572 = tp->is_io;
    if (D.21572 == 0) goto <D.21668>; else goto <D.21669>;
    <D.21668>:
    D.21670 = mono_runtime_is_shutting_down ();
    if (D.21670 == 0) goto <D.21671>; else goto <D.21672>;
    <D.21671>:
    mono_wsq_local_pop (&data);
    data.21 = data;
    if (data.21 != 0B) goto <D.21673>; else goto <D.21674>;
    <D.21673>:
    if (must_die != 0) goto <D.21675>; else goto <D.21676>;
    <D.21675>:
    D.21677 = &tp->destroy_thread;
    InterlockedCompareExchange (D.21677, 1, 0);
    pulse_on_new_job (tp);
    <D.21676>:
    <D.21674>:
    <D.21672>:
    <D.21669>:
    <D.21667>:
    data.21 = data;
    if (data.21 == 0B) goto <D.21678>; else goto <D.21679>;
    <D.21678>:
    {
      gint nt;
      gboolean down;

      <D.21245>:
      nt = tp->nthreads;
      down = mono_runtime_is_shutting_down ();
      if (down == 0) goto <D.21680>; else goto <D.21681>;
      <D.21680>:
      D.21682 = tp->min_threads;
      if (D.21682 >= nt) goto <D.21244>; else goto <D.21683>;
      <D.21683>:
      <D.21681>:
      if (down != 0) goto <D.21684>; else goto <D.21686>;
      <D.21686>:
      D.21687 = &tp->nthreads;
      D.21688 = nt + -1;
      D.21689 = InterlockedCompareExchange (D.21687, D.21688, nt);
      if (D.21689 == nt) goto <D.21684>; else goto <D.21685>;
      <D.21684>:
      D.21690 = tp->pc_nthreads;
      mono_perfcounter_update_value (D.21690, 1, -1);
      D.21572 = tp->is_io;
      if (D.21572 == 0) goto <D.21691>; else goto <D.21692>;
      <D.21691>:
      remove_wsq (wsq);
      <D.21692>:
      fire_profiler_thread_end ();
      tp_finish_func.25 = tp_finish_func;
      if (tp_finish_func.25 != 0B) goto <D.21694>; else goto <D.21695>;
      <D.21694>:
      tp_finish_func.25 = tp_finish_func;
      tp_hooks_user_data.20 = tp_hooks_user_data;
      tp_finish_func.25 (tp_hooks_user_data.20);
      <D.21695>:
      return;
      <D.21685>:
      goto <D.21245>;
      <D.21244>:
    }
    <D.21679>:
  }
  <D.21231>:
  goto <D.21246>;
  monoeg_assertion_message ("* Assertion: should not be reached at %s:%d\n", "threadpool.c", 1616);
}


add_wsq ()
{
  _Bool D.21699;
  long int D.21700;
  long int D.21701;
  struct GPtrArray * wsqs.26;
  _Bool D.21709;
  long int D.21710;
  long int D.21711;
  struct MonoWSQ * D.21714;
  void * * D.21715;
  unsigned int i.27;
  unsigned int D.21717;
  void * * D.21718;
  void * D.21719;
  _Bool D.21724;
  long int D.21725;
  long int D.21726;
  unsigned int i.28;
  unsigned int D.21730;
  _Bool D.21733;
  long int D.21734;
  long int D.21735;
  int i;
  struct MonoWSQ * wsq;

  {
    int ret;

    ret = pthread_mutex_lock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.21697>; else goto <D.21698>;
    <D.21697>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.21698>:
    D.21699 = ret != 0;
    D.21700 = (long int) D.21699;
    D.21701 = __builtin_expect (D.21700, 0);
    if (D.21701 != 0) goto <D.21702>; else goto <D.21703>;
    <D.21702>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1221, "ret == 0");
    <D.21703>:
  }
  wsq = mono_wsq_create ();
  wsqs.26 = wsqs;
  if (wsqs.26 == 0B) goto <D.21705>; else goto <D.21706>;
  <D.21705>:
  {
    int ret;

    ret = pthread_mutex_unlock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.21707>; else goto <D.21708>;
    <D.21707>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21708>:
    D.21709 = ret != 0;
    D.21710 = (long int) D.21709;
    D.21711 = __builtin_expect (D.21710, 0);
    if (D.21711 != 0) goto <D.21712>; else goto <D.21713>;
    <D.21712>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1224, "ret == 0");
    <D.21713>:
  }
  D.21714 = 0B;
  return D.21714;
  <D.21706>:
  i = 0;
  goto <D.21146>;
  <D.21145>:
  wsqs.26 = wsqs;
  D.21715 = wsqs.26->pdata;
  i.27 = (unsigned int) i;
  D.21717 = i.27 * 4;
  D.21718 = D.21715 + D.21717;
  D.21719 = *D.21718;
  if (D.21719 == 0B) goto <D.21720>; else goto <D.21721>;
  <D.21720>:
  wsqs.26 = wsqs;
  D.21715 = wsqs.26->pdata;
  i.27 = (unsigned int) i;
  D.21717 = i.27 * 4;
  D.21718 = D.21715 + D.21717;
  *D.21718 = wsq;
  {
    int ret;

    ret = pthread_mutex_unlock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.21722>; else goto <D.21723>;
    <D.21722>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21723>:
    D.21724 = ret != 0;
    D.21725 = (long int) D.21724;
    D.21726 = __builtin_expect (D.21725, 0);
    if (D.21726 != 0) goto <D.21727>; else goto <D.21728>;
    <D.21727>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1230, "ret == 0");
    <D.21728>:
  }
  D.21714 = wsq;
  return D.21714;
  <D.21721>:
  i = i + 1;
  <D.21146>:
  i.28 = (unsigned int) i;
  wsqs.26 = wsqs;
  D.21730 = wsqs.26->len;
  if (i.28 < D.21730) goto <D.21145>; else goto <D.21147>;
  <D.21147>:
  wsqs.26 = wsqs;
  monoeg_g_ptr_array_add (wsqs.26, wsq);
  {
    int ret;

    ret = pthread_mutex_unlock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.21731>; else goto <D.21732>;
    <D.21731>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.21732>:
    D.21733 = ret != 0;
    D.21734 = (long int) D.21733;
    D.21735 = __builtin_expect (D.21734, 0);
    if (D.21735 != 0) goto <D.21736>; else goto <D.21737>;
    <D.21736>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1235, "ret == 0");
    <D.21737>:
  }
  D.21714 = wsq;
  return D.21714;
}


set_tp_thread_info (struct ThreadPool * tp)
{
  long long unsigned int D.21739;
  unsigned int D.21740;
  const gchar * iftmp.29;
  int D.21742;
  struct MonoDomain * D.21746;
  struct MonoString * D.21747;
  const gchar * name;
  struct MonoInternalThread * thread;

  thread = mono_thread_internal_current ();
  D.21739 = thread->tid;
  D.21740 = (unsigned int) D.21739;
  mono_profiler_thread_start (D.21740);
  D.21742 = tp->is_io;
  if (D.21742 != 0) goto <D.21743>; else goto <D.21744>;
  <D.21743>:
  iftmp.29 = "IO Threadpool worker";
  goto <D.21745>;
  <D.21744>:
  iftmp.29 = "Threadpool worker";
  <D.21745>:
  name = iftmp.29;
  D.21746 = mono_domain_get ();
  D.21747 = mono_string_new (D.21746, name);
  mono_thread_set_name_internal (thread, D.21747, 0);
}


is_corlib_asyncresult (struct MonoDomain * domain, struct MonoClass * klass)
{
  struct MonoClass * D.21748;
  gboolean D.21751;
  _Bool D.21752;
  int D.21753;
  int D.20743;
  int iftmp.30;
  int D.20739;
  const char[12] * D.21759;
  unsigned char D.21760;
  int D.21761;
  unsigned char D.21762;
  int D.21763;
  _Bool D.21764;
  _Bool D.21765;
  _Bool D.21766;
  const unsigned char * D.21769;
  unsigned char D.21770;
  int D.21771;
  const unsigned char * D.21772;
  unsigned char D.21773;
  int D.21774;
  _Bool D.21775;
  _Bool D.21776;
  const unsigned char * D.21779;
  unsigned char D.21780;
  int D.21781;
  const unsigned char * D.21782;
  unsigned char D.21783;
  int D.21784;
  _Bool D.21785;
  _Bool D.21786;
  const unsigned char * D.21789;
  unsigned char D.21790;
  int D.21791;
  const unsigned char * D.21792;
  unsigned char D.21793;
  int D.21794;
  const char * D.21796;
  int D.20752;
  int iftmp.31;
  int D.20748;
  const char[34] * D.21802;
  unsigned char D.21803;
  int D.21804;
  unsigned char D.21805;
  int D.21806;
  _Bool D.21807;
  _Bool D.21808;
  _Bool D.21809;
  const unsigned char * D.21812;
  unsigned char D.21813;
  int D.21814;
  const unsigned char * D.21815;
  unsigned char D.21816;
  int D.21817;
  _Bool D.21818;
  _Bool D.21819;
  const unsigned char * D.21822;
  unsigned char D.21823;
  int D.21824;
  const unsigned char * D.21825;
  unsigned char D.21826;
  int D.21827;
  _Bool D.21828;
  _Bool D.21829;
  const unsigned char * D.21832;
  unsigned char D.21833;
  int D.21834;
  const unsigned char * D.21835;
  unsigned char D.21836;
  int D.21837;
  const char * D.21839;

  D.21748 = domain->corlib_asyncresult_class;
  if (D.21748 != 0B) goto <D.21749>; else goto <D.21750>;
  <D.21749>:
  D.21748 = domain->corlib_asyncresult_class;
  D.21752 = D.21748 == klass;
  D.21751 = (gboolean) D.21752;
  return D.21751;
  <D.21750>:
  D.21753 = is_corlib_type (domain, klass);
  if (D.21753 != 0) goto <D.21754>; else goto <D.21755>;
  <D.21754>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 11;
    if (__s1_len <= 3) goto <D.21757>; else goto <D.21758>;
    <D.21757>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.21759 = "AsyncResult";
      D.21760 = MEM[(const unsigned char *)D.21759];
      D.21761 = (int) D.21760;
      D.21762 = *__s2;
      D.21763 = (int) D.21762;
      __result = D.21761 - D.21763;
      {
        D.21764 = __s1_len != 0;
        D.21765 = __result == 0;
        D.21766 = D.21764 & D.21765;
        if (D.21766 != 0) goto <D.21767>; else goto <D.21768>;
        <D.21767>:
        D.21769 = &MEM[(void *)"AsyncResult" + 1B];
        D.21770 = *D.21769;
        D.21771 = (int) D.21770;
        D.21772 = __s2 + 1;
        D.21773 = *D.21772;
        D.21774 = (int) D.21773;
        __result = D.21771 - D.21774;
        D.21775 = __s1_len > 1;
        D.21765 = __result == 0;
        D.21776 = D.21775 & D.21765;
        if (D.21776 != 0) goto <D.21777>; else goto <D.21778>;
        <D.21777>:
        D.21779 = &MEM[(void *)"AsyncResult" + 2B];
        D.21780 = *D.21779;
        D.21781 = (int) D.21780;
        D.21782 = __s2 + 2;
        D.21783 = *D.21782;
        D.21784 = (int) D.21783;
        __result = D.21781 - D.21784;
        D.21785 = __s1_len > 2;
        D.21765 = __result == 0;
        D.21786 = D.21785 & D.21765;
        if (D.21786 != 0) goto <D.21787>; else goto <D.21788>;
        <D.21787>:
        D.21789 = &MEM[(void *)"AsyncResult" + 3B];
        D.21790 = *D.21789;
        D.21791 = (int) D.21790;
        D.21792 = __s2 + 3;
        D.21793 = *D.21792;
        D.21794 = (int) D.21793;
        __result = D.21791 - D.21794;
        <D.21788>:
        <D.21778>:
        <D.21768>:
      }
      D.20739 = __result;
    }
    iftmp.30 = D.20739;
    goto <D.21795>;
    <D.21758>:
    D.21796 = klass->name;
    iftmp.30 = __builtin_strcmp ("AsyncResult", D.21796);
    <D.21795>:
    D.20743 = iftmp.30;
  }
  if (D.20743 == 0) goto <D.21797>; else goto <D.21798>;
  <D.21797>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 33;
    if (__s1_len <= 3) goto <D.21800>; else goto <D.21801>;
    <D.21800>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name_space;
      D.21802 = "System.Runtime.Remoting.Messaging";
      D.21803 = MEM[(const unsigned char *)D.21802];
      D.21804 = (int) D.21803;
      D.21805 = *__s2;
      D.21806 = (int) D.21805;
      __result = D.21804 - D.21806;
      {
        D.21807 = __s1_len != 0;
        D.21808 = __result == 0;
        D.21809 = D.21807 & D.21808;
        if (D.21809 != 0) goto <D.21810>; else goto <D.21811>;
        <D.21810>:
        D.21812 = &MEM[(void *)"System.Runtime.Remoting.Messaging" + 1B];
        D.21813 = *D.21812;
        D.21814 = (int) D.21813;
        D.21815 = __s2 + 1;
        D.21816 = *D.21815;
        D.21817 = (int) D.21816;
        __result = D.21814 - D.21817;
        D.21818 = __s1_len > 1;
        D.21808 = __result == 0;
        D.21819 = D.21818 & D.21808;
        if (D.21819 != 0) goto <D.21820>; else goto <D.21821>;
        <D.21820>:
        D.21822 = &MEM[(void *)"System.Runtime.Remoting.Messaging" + 2B];
        D.21823 = *D.21822;
        D.21824 = (int) D.21823;
        D.21825 = __s2 + 2;
        D.21826 = *D.21825;
        D.21827 = (int) D.21826;
        __result = D.21824 - D.21827;
        D.21828 = __s1_len > 2;
        D.21808 = __result == 0;
        D.21829 = D.21828 & D.21808;
        if (D.21829 != 0) goto <D.21830>; else goto <D.21831>;
        <D.21830>:
        D.21832 = &MEM[(void *)"System.Runtime.Remoting.Messaging" + 3B];
        D.21833 = *D.21832;
        D.21834 = (int) D.21833;
        D.21835 = __s2 + 3;
        D.21836 = *D.21835;
        D.21837 = (int) D.21836;
        __result = D.21834 - D.21837;
        <D.21831>:
        <D.21821>:
        <D.21811>:
      }
      D.20748 = __result;
    }
    iftmp.31 = D.20748;
    goto <D.21838>;
    <D.21801>:
    D.21839 = klass->name_space;
    iftmp.31 = __builtin_strcmp ("System.Runtime.Remoting.Messaging", D.21839);
    <D.21838>:
    D.20752 = iftmp.31;
  }
  if (D.20752 == 0) goto <D.21840>; else goto <D.21841>;
  <D.21840>:
  domain->corlib_asyncresult_class = klass;
  D.21751 = 1;
  return D.21751;
  <D.21841>:
  <D.21798>:
  <D.21755>:
  D.21751 = 0;
  return D.21751;
}


is_corlib_type (struct MonoDomain * domain, struct MonoClass * klass)
{
  gboolean D.21843;
  struct MonoImage * D.21844;
  struct MonoImage * D.21845;
  _Bool D.21846;

  D.21844 = klass->image;
  D.21845 = mono_defaults.corlib;
  D.21846 = D.21844 == D.21845;
  D.21843 = (gboolean) D.21846;
  return D.21843;
}


is_socketasyncresult (struct MonoDomain * domain, struct MonoClass * klass)
{
  gboolean D.21848;
  int iftmp.32;
  struct MonoClass * D.21852;
  int D.21854;
  int D.20787;
  int iftmp.33;
  int D.20786;
  const char[18] * D.21859;
  unsigned char D.21860;
  int D.21861;
  unsigned char D.21862;
  int D.21863;
  _Bool D.21864;
  _Bool D.21865;
  _Bool D.21866;
  const unsigned char * D.21869;
  unsigned char D.21870;
  int D.21871;
  const unsigned char * D.21872;
  unsigned char D.21873;
  int D.21874;
  _Bool D.21875;
  _Bool D.21876;
  const unsigned char * D.21879;
  unsigned char D.21880;
  int D.21881;
  const unsigned char * D.21882;
  unsigned char D.21883;
  int D.21884;
  _Bool D.21885;
  _Bool D.21886;
  const unsigned char * D.21889;
  unsigned char D.21890;
  int D.21891;
  const unsigned char * D.21892;
  unsigned char D.21893;
  int D.21894;
  const char * D.21896;

  D.21852 = klass->nested_in;
  if (D.21852 != 0B) goto <D.21853>; else goto <D.21850>;
  <D.21853>:
  D.21852 = klass->nested_in;
  D.21854 = is_socket (domain, D.21852);
  if (D.21854 != 0) goto <D.21855>; else goto <D.21850>;
  <D.21855>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 17;
    if (__s2_len <= 3) goto <D.21857>; else goto <D.21858>;
    <D.21857>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.21859 = "SocketAsyncResult";
      D.21860 = MEM[(const unsigned char *)D.21859];
      D.21861 = (int) D.21860;
      D.21862 = *__s2;
      D.21863 = (int) D.21862;
      __result = D.21861 - D.21863;
      {
        D.21864 = __s2_len != 0;
        D.21865 = __result == 0;
        D.21866 = D.21864 & D.21865;
        if (D.21866 != 0) goto <D.21867>; else goto <D.21868>;
        <D.21867>:
        D.21869 = &MEM[(void *)"SocketAsyncResult" + 1B];
        D.21870 = *D.21869;
        D.21871 = (int) D.21870;
        D.21872 = __s2 + 1;
        D.21873 = *D.21872;
        D.21874 = (int) D.21873;
        __result = D.21871 - D.21874;
        D.21875 = __s2_len > 1;
        D.21865 = __result == 0;
        D.21876 = D.21875 & D.21865;
        if (D.21876 != 0) goto <D.21877>; else goto <D.21878>;
        <D.21877>:
        D.21879 = &MEM[(void *)"SocketAsyncResult" + 2B];
        D.21880 = *D.21879;
        D.21881 = (int) D.21880;
        D.21882 = __s2 + 2;
        D.21883 = *D.21882;
        D.21884 = (int) D.21883;
        __result = D.21881 - D.21884;
        D.21885 = __s2_len > 2;
        D.21865 = __result == 0;
        D.21886 = D.21885 & D.21865;
        if (D.21886 != 0) goto <D.21887>; else goto <D.21888>;
        <D.21887>:
        D.21889 = &MEM[(void *)"SocketAsyncResult" + 3B];
        D.21890 = *D.21889;
        D.21891 = (int) D.21890;
        D.21892 = __s2 + 3;
        D.21893 = *D.21892;
        D.21894 = (int) D.21893;
        __result = D.21891 - D.21894;
        <D.21888>:
        <D.21878>:
        <D.21868>:
      }
      D.20786 = __result;
    }
    iftmp.33 = -D.20786;
    goto <D.21895>;
    <D.21858>:
    D.21896 = klass->name;
    iftmp.33 = __builtin_strcmp (D.21896, "SocketAsyncResult");
    <D.21895>:
    D.20787 = iftmp.33;
  }
  if (D.20787 == 0) goto <D.21897>; else goto <D.21850>;
  <D.21897>:
  iftmp.32 = 1;
  goto <D.21851>;
  <D.21850>:
  iftmp.32 = 0;
  <D.21851>:
  D.21848 = iftmp.32;
  return D.21848;
}


is_socket (struct MonoDomain * domain, struct MonoClass * klass)
{
  struct MonoClass * D.21899;
  gboolean D.21902;
  _Bool D.21903;
  int D.21904;
  int D.20765;
  int iftmp.34;
  int D.20761;
  const char[7] * D.21910;
  unsigned char D.21911;
  int D.21912;
  unsigned char D.21913;
  int D.21914;
  _Bool D.21915;
  _Bool D.21916;
  _Bool D.21917;
  const unsigned char * D.21920;
  unsigned char D.21921;
  int D.21922;
  const unsigned char * D.21923;
  unsigned char D.21924;
  int D.21925;
  _Bool D.21926;
  _Bool D.21927;
  const unsigned char * D.21930;
  unsigned char D.21931;
  int D.21932;
  const unsigned char * D.21933;
  unsigned char D.21934;
  int D.21935;
  _Bool D.21936;
  _Bool D.21937;
  const unsigned char * D.21940;
  unsigned char D.21941;
  int D.21942;
  const unsigned char * D.21943;
  unsigned char D.21944;
  int D.21945;
  const char * D.21947;
  int D.20774;
  int iftmp.35;
  int D.20770;
  const char[19] * D.21953;
  unsigned char D.21954;
  int D.21955;
  unsigned char D.21956;
  int D.21957;
  _Bool D.21958;
  _Bool D.21959;
  _Bool D.21960;
  const unsigned char * D.21963;
  unsigned char D.21964;
  int D.21965;
  const unsigned char * D.21966;
  unsigned char D.21967;
  int D.21968;
  _Bool D.21969;
  _Bool D.21970;
  const unsigned char * D.21973;
  unsigned char D.21974;
  int D.21975;
  const unsigned char * D.21976;
  unsigned char D.21977;
  int D.21978;
  _Bool D.21979;
  _Bool D.21980;
  const unsigned char * D.21983;
  unsigned char D.21984;
  int D.21985;
  const unsigned char * D.21986;
  unsigned char D.21987;
  int D.21988;
  const char * D.21990;

  D.21899 = domain->socket_class;
  if (D.21899 != 0B) goto <D.21900>; else goto <D.21901>;
  <D.21900>:
  D.21899 = domain->socket_class;
  D.21903 = D.21899 == klass;
  D.21902 = (gboolean) D.21903;
  return D.21902;
  <D.21901>:
  D.21904 = is_socket_type (domain, klass);
  if (D.21904 != 0) goto <D.21905>; else goto <D.21906>;
  <D.21905>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 6;
    if (__s1_len <= 3) goto <D.21908>; else goto <D.21909>;
    <D.21908>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.21910 = "Socket";
      D.21911 = MEM[(const unsigned char *)D.21910];
      D.21912 = (int) D.21911;
      D.21913 = *__s2;
      D.21914 = (int) D.21913;
      __result = D.21912 - D.21914;
      {
        D.21915 = __s1_len != 0;
        D.21916 = __result == 0;
        D.21917 = D.21915 & D.21916;
        if (D.21917 != 0) goto <D.21918>; else goto <D.21919>;
        <D.21918>:
        D.21920 = &MEM[(void *)"Socket" + 1B];
        D.21921 = *D.21920;
        D.21922 = (int) D.21921;
        D.21923 = __s2 + 1;
        D.21924 = *D.21923;
        D.21925 = (int) D.21924;
        __result = D.21922 - D.21925;
        D.21926 = __s1_len > 1;
        D.21916 = __result == 0;
        D.21927 = D.21926 & D.21916;
        if (D.21927 != 0) goto <D.21928>; else goto <D.21929>;
        <D.21928>:
        D.21930 = &MEM[(void *)"Socket" + 2B];
        D.21931 = *D.21930;
        D.21932 = (int) D.21931;
        D.21933 = __s2 + 2;
        D.21934 = *D.21933;
        D.21935 = (int) D.21934;
        __result = D.21932 - D.21935;
        D.21936 = __s1_len > 2;
        D.21916 = __result == 0;
        D.21937 = D.21936 & D.21916;
        if (D.21937 != 0) goto <D.21938>; else goto <D.21939>;
        <D.21938>:
        D.21940 = &MEM[(void *)"Socket" + 3B];
        D.21941 = *D.21940;
        D.21942 = (int) D.21941;
        D.21943 = __s2 + 3;
        D.21944 = *D.21943;
        D.21945 = (int) D.21944;
        __result = D.21942 - D.21945;
        <D.21939>:
        <D.21929>:
        <D.21919>:
      }
      D.20761 = __result;
    }
    iftmp.34 = D.20761;
    goto <D.21946>;
    <D.21909>:
    D.21947 = klass->name;
    iftmp.34 = __builtin_strcmp ("Socket", D.21947);
    <D.21946>:
    D.20765 = iftmp.34;
  }
  if (D.20765 == 0) goto <D.21948>; else goto <D.21949>;
  <D.21948>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 18;
    if (__s1_len <= 3) goto <D.21951>; else goto <D.21952>;
    <D.21951>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name_space;
      D.21953 = "System.Net.Sockets";
      D.21954 = MEM[(const unsigned char *)D.21953];
      D.21955 = (int) D.21954;
      D.21956 = *__s2;
      D.21957 = (int) D.21956;
      __result = D.21955 - D.21957;
      {
        D.21958 = __s1_len != 0;
        D.21959 = __result == 0;
        D.21960 = D.21958 & D.21959;
        if (D.21960 != 0) goto <D.21961>; else goto <D.21962>;
        <D.21961>:
        D.21963 = &MEM[(void *)"System.Net.Sockets" + 1B];
        D.21964 = *D.21963;
        D.21965 = (int) D.21964;
        D.21966 = __s2 + 1;
        D.21967 = *D.21966;
        D.21968 = (int) D.21967;
        __result = D.21965 - D.21968;
        D.21969 = __s1_len > 1;
        D.21959 = __result == 0;
        D.21970 = D.21969 & D.21959;
        if (D.21970 != 0) goto <D.21971>; else goto <D.21972>;
        <D.21971>:
        D.21973 = &MEM[(void *)"System.Net.Sockets" + 2B];
        D.21974 = *D.21973;
        D.21975 = (int) D.21974;
        D.21976 = __s2 + 2;
        D.21977 = *D.21976;
        D.21978 = (int) D.21977;
        __result = D.21975 - D.21978;
        D.21979 = __s1_len > 2;
        D.21959 = __result == 0;
        D.21980 = D.21979 & D.21959;
        if (D.21980 != 0) goto <D.21981>; else goto <D.21982>;
        <D.21981>:
        D.21983 = &MEM[(void *)"System.Net.Sockets" + 3B];
        D.21984 = *D.21983;
        D.21985 = (int) D.21984;
        D.21986 = __s2 + 3;
        D.21987 = *D.21986;
        D.21988 = (int) D.21987;
        __result = D.21985 - D.21988;
        <D.21982>:
        <D.21972>:
        <D.21962>:
      }
      D.20770 = __result;
    }
    iftmp.35 = D.20770;
    goto <D.21989>;
    <D.21952>:
    D.21990 = klass->name_space;
    iftmp.35 = __builtin_strcmp ("System.Net.Sockets", D.21990);
    <D.21989>:
    D.20774 = iftmp.35;
  }
  if (D.20774 == 0) goto <D.21991>; else goto <D.21992>;
  <D.21991>:
  domain->socket_class = klass;
  D.21902 = 1;
  return D.21902;
  <D.21992>:
  <D.21949>:
  <D.21906>:
  D.21902 = 0;
  return D.21902;
}


is_socket_type (struct MonoDomain * domain, struct MonoClass * klass)
{
  gboolean D.21994;

  D.21994 = is_system_type (domain, klass);
  return D.21994;
}


is_system_type (struct MonoDomain * domain, struct MonoClass * klass)
{
  struct MonoImage * D.21996;
  struct MonoImage * D.21999;
  gboolean D.22000;
  struct MonoImage * D.22001;
  _Bool D.22002;

  D.21996 = domain->system_image;
  if (D.21996 == 0B) goto <D.21997>; else goto <D.21998>;
  <D.21997>:
  D.21999 = mono_image_loaded ("System");
  domain->system_image = D.21999;
  <D.21998>:
  D.22001 = klass->image;
  D.21996 = domain->system_image;
  D.22002 = D.22001 == D.21996;
  D.22000 = (gboolean) D.22002;
  return D.22000;
}


threadpool_jobs_dec (struct MonoObject * obj)
{
  gboolean D.22006;
  struct MonoVTable * D.22007;
  volatile int * D.22008;
  void * D.22011;
  struct MonoDomain * domain;
  int remaining_jobs;

  if (obj == 0B) goto <D.22004>; else goto <D.22005>;
  <D.22004>:
  D.22006 = 0;
  return D.22006;
  <D.22005>:
  D.22007 = obj->vtable;
  domain = D.22007->domain;
  D.22008 = &domain->threadpool_jobs;
  remaining_jobs = InterlockedDecrement (D.22008);
  if (remaining_jobs == 0) goto <D.22009>; else goto <D.22010>;
  <D.22009>:
  D.22011 = domain->cleanup_semaphore;
  if (D.22011 != 0B) goto <D.22012>; else goto <D.22013>;
  <D.22012>:
  D.22011 = domain->cleanup_semaphore;
  ReleaseSemaphore (D.22011, 1, 0B);
  D.22006 = 1;
  return D.22006;
  <D.22013>:
  <D.22010>:
  D.22006 = 0;
  return D.22006;
}


process_idle_times (struct ThreadPool * tp, gint64 t)
{
  int D.22017;
  volatile gint * D.22019;
  int D.22020;
  int D.22022;
  long long int D.22025;
  long long int D.22026;
  int D.22027;
  int D.22028;
  long long int D.22029;
  long long int D.22033;
  long long int D.22036;
  long long int D.22037;
  long long int D.22042;
  int D.22043;
  long long int D.22044;
  long long int D.22045;
  long long int D.22049;
  long long int D.22050;
  long long int D.22051;
  long long int D.22056;
  int D.22066;
  int D.22069;
  int D.22074;
  volatile gint * D.22077;
  int D.22078;
  gint64 ticks;
  gint64 avg;
  gboolean compute_avg;
  gint new_threads;
  gint64 per1;

  D.22017 = tp->ignore_times;
  if (D.22017 != 0) goto <D.22015>; else goto <D.22018>;
  <D.22018>:
  if (t <= 0) goto <D.22015>; else goto <D.22016>;
  <D.22015>:
  return;
  <D.22016>:
  compute_avg = 0;
  ticks = mono_100ns_ticks ();
  t = ticks - t;
  <D.21191>:
  D.22019 = &tp->sp_lock;
  D.22020 = InterlockedCompareExchange (D.22019, 1, 0);
  if (D.22020 == 0) goto <D.21190>; else goto <D.22021>;
  <D.22021>:
  goto <D.21191>;
  <D.21190>:
  D.22022 = tp->ignore_times;
  if (D.22022 != 0) goto <D.22023>; else goto <D.22024>;
  <D.22023>:
  tp->sp_lock = 0;
  return;
  <D.22024>:
  D.22025 = tp->time_sum;
  D.22026 = D.22025 + t;
  tp->time_sum = D.22026;
  D.22027 = tp->n_sum;
  D.22028 = D.22027 + 1;
  tp->n_sum = D.22028;
  D.22029 = tp->last_check;
  if (D.22029 == 0) goto <D.22030>; else goto <D.22031>;
  <D.22030>:
  tp->last_check = ticks;
  goto <D.22032>;
  <D.22031>:
  D.22033 = tp->last_check;
  if (D.22033 > 0) goto <D.22034>; else goto <D.22035>;
  <D.22034>:
  D.22036 = tp->last_check;
  D.22037 = ticks - D.22036;
  if (D.22037 > 5000000) goto <D.22038>; else goto <D.22039>;
  <D.22038>:
  tp->ignore_times = 1;
  compute_avg = 1;
  <D.22039>:
  <D.22035>:
  <D.22032>:
  tp->sp_lock = 0;
  if (compute_avg == 0) goto <D.22040>; else goto <D.22041>;
  <D.22040>:
  return;
  <D.22041>:
  tp->last_check = ticks;
  new_threads = 0;
  D.22042 = tp->time_sum;
  D.22043 = tp->n_sum;
  D.22044 = (long long int) D.22043;
  avg = D.22042 / D.22044;
  D.22045 = tp->averages[1];
  if (D.22045 == 0) goto <D.22046>; else goto <D.22047>;
  <D.22046>:
  tp->averages[1] = avg;
  goto <D.22048>;
  <D.22047>:
  D.22045 = tp->averages[1];
  D.22049 = avg - D.22045;
  D.22050 = ABS_EXPR <D.22049>;
  D.22051 = D.22050 * 100;
  D.22045 = tp->averages[1];
  per1 = D.22051 / D.22045;
  if (per1 > 5) goto <D.22052>; else goto <D.22053>;
  <D.22052>:
  D.22045 = tp->averages[1];
  if (D.22045 < avg) goto <D.22054>; else goto <D.22055>;
  <D.22054>:
  D.22045 = tp->averages[1];
  D.22056 = tp->averages[0];
  if (D.22045 < D.22056) goto <D.22057>; else goto <D.22058>;
  <D.22057>:
  new_threads = -1;
  goto <D.22059>;
  <D.22058>:
  new_threads = 1;
  <D.22059>:
  goto <D.22060>;
  <D.22055>:
  D.22045 = tp->averages[1];
  if (D.22045 > avg) goto <D.22061>; else goto <D.22062>;
  <D.22061>:
  D.22045 = tp->averages[1];
  D.22056 = tp->averages[0];
  if (D.22045 < D.22056) goto <D.22063>; else goto <D.22064>;
  <D.22063>:
  new_threads = 1;
  <D.22064>:
  <D.22062>:
  <D.22060>:
  goto <D.22065>;
  <D.22053>:
  {
    int min;
    int n;

    min = tp->min_threads;
    n = tp->nthreads;
    D.22066 = n - min;
    if (D.22066 < min) goto <D.22067>; else goto <D.22068>;
    <D.22067>:
    D.22069 = tp->busy_threads;
    if (D.22069 == n) goto <D.22070>; else goto <D.22071>;
    <D.22070>:
    new_threads = 1;
    <D.22071>:
    <D.22068>:
  }
  <D.22065>:
  <D.22048>:
  tp->time_sum = 0;
  tp->n_sum = 0;
  D.22045 = tp->averages[1];
  tp->averages[0] = D.22045;
  tp->averages[1] = avg;
  tp->ignore_times = 0;
  if (new_threads == -1) goto <D.22072>; else goto <D.22073>;
  <D.22072>:
  D.22074 = tp->destroy_thread;
  if (D.22074 == 0) goto <D.22075>; else goto <D.22076>;
  <D.22075>:
  D.22077 = &tp->destroy_thread;
  D.22078 = InterlockedCompareExchange (D.22077, 1, 0);
  if (D.22078 == 0) goto <D.22079>; else goto <D.22080>;
  <D.22079>:
  pulse_on_new_job (tp);
  <D.22080>:
  <D.22076>:
  <D.22073>:
}


mono_async_invoke (struct ThreadPool * tp, struct MonoAsyncResult * ares)
{
  struct MonoAsyncResult * ares.36;
  struct MonoObject * D.22083;
  struct MonoObject * * D.22086;
  struct MonoObject * D.22087;
  struct MonoObject * pa.37;
  struct MonoObject * D.22092;
  struct MonoMethod * D.22093;
  struct MonoMethodMessage * D.22095;
  struct MonoObject * * D.22096;
  struct MonoObject * * D.22097;
  struct MonoObject * exc.38;
  struct MonoArray * * D.22099;
  struct MonoArray * out_args.39;
  struct MonoObject * D.22101;
  struct MonoMethod * D.22109;
  struct MonoDelegate * D.22111;
  struct MonoObject * cb_exc.40;
  struct MonoObject * D.22113;
  struct MonoObject * D.22116;
  struct ASyncCall * ac;
  struct MonoObject * res;
  struct MonoObject * exc;
  struct MonoArray * out_args;
  void * wait_event;
  struct MonoInternalThread * thread;

  try
    {
      ares.36 = ares;
      ac = ares.36->object_data;
      exc = 0B;
      out_args = 0B;
      wait_event = 0B;
      thread = mono_thread_internal_current ();
      ares.36 = ares;
      D.22083 = ares.36->execution_context;
      if (D.22083 != 0B) goto <D.22084>; else goto <D.22085>;
      <D.22084>:
      ares.36 = ares;
      ares.36 = ares;
      D.22086 = &ares.36->original_context;
      D.22087 = mono_thread_get_execution_context ();
      mono_gc_wbarrier_set_field (ares.36, D.22086, D.22087);
      ares.36 = ares;
      D.22083 = ares.36->execution_context;
      mono_thread_set_execution_context (D.22083);
      goto <D.22088>;
      <D.22085>:
      ares.36 = ares;
      ares.36->original_context = 0B;
      <D.22088>:
      if (ac == 0B) goto <D.22089>; else goto <D.22090>;
      <D.22089>:
      {
        void * pa;

        try
          {
            ares.36 = ares;
            pa.37 = ares.36->async_state;
            pa = pa.37;
            ares.36 = ares;
            D.22092 = ares.36->async_delegate;
            D.22093 = MEM[(struct MonoDelegate *)D.22092].method;
            thread->async_invoke_method = D.22093;
            ares.36 = ares;
            D.22092 = ares.36->async_delegate;
            res = mono_runtime_delegate_invoke (D.22092, &pa, &exc);
            thread->async_invoke_method = 0B;
          }
        finally
          {
            pa = {CLOBBER};
          }
      }
      goto <D.22094>;
      <D.22090>:
      {
        struct MonoObject * cb_exc;

        try
          {
            cb_exc = 0B;
            D.22095 = ac->msg;
            D.22095->exc = 0B;
            ares.36 = ares;
            D.22092 = ares.36->async_delegate;
            D.22095 = ac->msg;
            res = mono_message_invoke (D.22092, D.22095, &exc, &out_args);
            D.22096 = &ac->res;
            mono_gc_wbarrier_set_field (ac, D.22096, res);
            D.22095 = ac->msg;
            D.22097 = &D.22095->exc;
            exc.38 = exc;
            mono_gc_wbarrier_set_field (ac, D.22097, exc.38);
            D.22099 = &ac->out_args;
            out_args.39 = out_args;
            mono_gc_wbarrier_set_field (ac, D.22099, out_args.39);
            ares.36 = ares;
            mono_monitor_enter (ares.36);
            ares.36 = ares;
            ares.36->completed = 1;
            ares.36 = ares;
            D.22101 = ares.36->handle;
            if (D.22101 != 0B) goto <D.22102>; else goto <D.22103>;
            <D.22102>:
            ares.36 = ares;
            D.22101 = ares.36->handle;
            wait_event = mono_wait_handle_get_handle (D.22101);
            <D.22103>:
            ares.36 = ares;
            mono_monitor_exit (ares.36);
            if (wait_event != 0B) goto <D.22104>; else goto <D.22105>;
            <D.22104>:
            SetEvent (wait_event);
            <D.22105>:
            if (ac != 0B) goto <D.22108>; else goto <D.22106>;
            <D.22108>:
            D.22109 = ac->cb_method;
            if (D.22109 != 0B) goto <D.22110>; else goto <D.22106>;
            <D.22110>:
            {
              void * pa;

              pa = &ares;
              cb_exc = 0B;
              D.22109 = ac->cb_method;
              thread->async_invoke_method = D.22109;
              D.22109 = ac->cb_method;
              D.22111 = ac->cb_target;
              mono_runtime_invoke (D.22109, D.22111, pa, &cb_exc);
              thread->async_invoke_method = 0B;
              cb_exc.40 = cb_exc;
              exc = cb_exc.40;
            }
            goto <D.22107>;
            <D.22106>:
            exc = 0B;
            <D.22107>:
          }
        finally
          {
            cb_exc = {CLOBBER};
          }
      }
      <D.22094>:
      ares.36 = ares;
      D.22113 = ares.36->original_context;
      if (D.22113 != 0B) goto <D.22114>; else goto <D.22115>;
      <D.22114>:
      ares.36 = ares;
      D.22113 = ares.36->original_context;
      mono_thread_set_execution_context (D.22113);
      ares.36 = ares;
      ares.36->original_context = 0B;
      <D.22115>:
      D.22116 = exc;
      return D.22116;
    }
  finally
    {
      exc = {CLOBBER};
      out_args = {CLOBBER};
    }
}


create_simple_asyncresult (struct MonoObject * target, struct MonoObject * state)
{
  struct MonoClass * D.22119;
  struct MonoObject * * D.22120;
  struct MonoObject * * D.22121;
  struct MonoAsyncResult * D.22122;
  struct MonoDomain * domain;
  struct MonoAsyncResult * ares;

  domain = mono_domain_get ();
  D.22119 = mono_defaults.asyncresult_class;
  ares = mono_object_new (domain, D.22119);
  D.22120 = &ares->async_delegate;
  mono_gc_wbarrier_set_field (ares, D.22120, target);
  D.22121 = &ares->async_state;
  mono_gc_wbarrier_set_field (ares, D.22121, state);
  D.22122 = ares;
  return D.22122;
}


clear_thread_state ()
{
  int D.22124;
  struct MonoInternalThread * thread;

  thread = mono_thread_internal_current ();
  mono_thread_clr_state (thread, 4294967291);
  D.22124 = mono_thread_test_state (thread, 4);
  if (D.22124 == 0) goto <D.22125>; else goto <D.22126>;
  <D.22125>:
  ves_icall_System_Threading_Thread_SetState (thread, 4);
  <D.22126>:
}


check_for_interruption_critical ()
{
  unsigned int D.22127;
  unsigned int D.22128;
  struct MonoInternalThread * thread;

  mono_gc_set_skip_thread (0);
  thread = mono_thread_internal_current ();
  D.22127 = thread->state;
  D.22128 = D.22127 & 3;
  if (D.22128 != 0) goto <D.22129>; else goto <D.22130>;
  <D.22129>:
  mono_thread_interruption_checkpoint ();
  <D.22130>:
  mono_gc_set_skip_thread (1);
}


InterlockedDecrement (volatile gint32 * val)
{
  gint32 D.22131;
  unsigned int D.22132;

  D.22132 = __sync_sub_and_fetch_4 (val, 1);
  D.22131 = (gint32) D.22132;
  return D.22131;
}


should_i_die (struct ThreadPool * tp)
{
  int D.22134;
  volatile gint * D.22137;
  int D.22138;
  int D.22141;
  int D.22142;
  _Bool D.22143;
  gboolean D.22144;
  gboolean result;

  result = 0;
  D.22134 = tp->destroy_thread;
  if (D.22134 == 1) goto <D.22135>; else goto <D.22136>;
  <D.22135>:
  D.22137 = &tp->destroy_thread;
  D.22138 = InterlockedCompareExchange (D.22137, 0, 1);
  if (D.22138 == 1) goto <D.22139>; else goto <D.22140>;
  <D.22139>:
  D.22141 = tp->nthreads;
  D.22142 = tp->min_threads;
  D.22143 = D.22141 > D.22142;
  result = (gboolean) D.22143;
  <D.22140>:
  <D.22136>:
  D.22144 = result;
  return D.22144;
}


dequeue_or_steal (struct ThreadPool * tp, void * * data, struct MonoWSQ * local_wsq)
{
  int D.22146;
  gboolean D.22149;
  struct MonoCQ * D.22150;
  int D.22151;
  void * D.22154;
  _Bool D.22157;

  D.22146 = mono_runtime_is_shutting_down ();
  if (D.22146 != 0) goto <D.22147>; else goto <D.22148>;
  <D.22147>:
  D.22149 = 0;
  return D.22149;
  <D.22148>:
  D.22150 = tp->queue;
  mono_cq_dequeue (D.22150, data);
  D.22151 = tp->is_io;
  if (D.22151 == 0) goto <D.22152>; else goto <D.22153>;
  <D.22152>:
  D.22154 = *data;
  if (D.22154 == 0B) goto <D.22155>; else goto <D.22156>;
  <D.22155>:
  try_steal (local_wsq, data, 0);
  <D.22156>:
  <D.22153>:
  D.22154 = *data;
  D.22157 = D.22154 != 0B;
  D.22149 = (gboolean) D.22157;
  return D.22149;
}


try_steal (struct MonoWSQ * local_wsq, void * * data, gboolean retry)
{
  struct GPtrArray * wsqs.41;
  void * D.22164;
  int D.22165;
  _Bool D.22170;
  long int D.22171;
  long int D.22172;
  void * * D.22175;
  unsigned int i.42;
  unsigned int D.22177;
  void * * D.22178;
  int D.22182;
  void * D.22183;
  unsigned int ms.43;
  _Bool D.22189;
  long int D.22190;
  long int D.22191;
  unsigned int i.44;
  unsigned int D.22196;
  _Bool D.22199;
  long int D.22200;
  long int D.22201;
  _Bool D.22204;
  _Bool D.22205;
  _Bool D.22206;
  int i;
  int ms;

  wsqs.41 = wsqs;
  if (wsqs.41 == 0B) goto <D.22159>; else goto <D.22162>;
  <D.22162>:
  if (data == 0B) goto <D.22159>; else goto <D.22163>;
  <D.22163>:
  D.22164 = *data;
  if (D.22164 != 0B) goto <D.22159>; else goto <D.22160>;
  <D.22159>:
  return;
  <D.22160>:
  ms = 0;
  <D.21174>:
  D.22165 = mono_runtime_is_shutting_down ();
  if (D.22165 != 0) goto <D.22166>; else goto <D.22167>;
  <D.22166>:
  return;
  <D.22167>:
  {
    int ret;

    ret = pthread_mutex_lock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.22168>; else goto <D.22169>;
    <D.22168>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.22169>:
    D.22170 = ret != 0;
    D.22171 = (long int) D.22170;
    D.22172 = __builtin_expect (D.22171, 0);
    if (D.22172 != 0) goto <D.22173>; else goto <D.22174>;
    <D.22173>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1282, "ret == 0");
    <D.22174>:
  }
  i = 0;
  goto <D.21171>;
  <D.21170>:
  {
    struct MonoWSQ * wsq;

    wsqs.41 = wsqs;
    D.22175 = wsqs.41->pdata;
    i.42 = (unsigned int) i;
    D.22177 = i.42 * 4;
    D.22178 = D.22175 + D.22177;
    wsq = *D.22178;
    if (wsq == local_wsq) goto <D.22179>; else goto <D.22181>;
    <D.22181>:
    D.22182 = mono_wsq_count (wsq);
    if (D.22182 == 0) goto <D.22179>; else goto <D.22180>;
    <D.22179>:
    // predicted unlikely by continue predictor.
    goto <D.21168>;
    <D.22180>:
    wsqs.41 = wsqs;
    D.22175 = wsqs.41->pdata;
    i.42 = (unsigned int) i;
    D.22177 = i.42 * 4;
    D.22178 = D.22175 + D.22177;
    D.22183 = *D.22178;
    ms.43 = (unsigned int) ms;
    mono_wsq_try_steal (D.22183, data, ms.43);
    D.22164 = *data;
    if (D.22164 != 0B) goto <D.22185>; else goto <D.22186>;
    <D.22185>:
    {
      int ret;

      ret = pthread_mutex_unlock (&wsqs_lock.mutex);
      if (ret != 0) goto <D.22187>; else goto <D.22188>;
      <D.22187>:
      monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
      <D.22188>:
      D.22189 = ret != 0;
      D.22190 = (long int) D.22189;
      D.22191 = __builtin_expect (D.22190, 0);
      if (D.22191 != 0) goto <D.22192>; else goto <D.22193>;
      <D.22192>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1291, "ret == 0");
      <D.22193>:
    }
    return;
    <D.22186>:
  }
  <D.21168>:
  i = i + 1;
  <D.21171>:
  wsqs.41 = wsqs;
  if (wsqs.41 != 0B) goto <D.22194>; else goto <D.21172>;
  <D.22194>:
  i.44 = (unsigned int) i;
  wsqs.41 = wsqs;
  D.22196 = wsqs.41->len;
  if (i.44 < D.22196) goto <D.21170>; else goto <D.21172>;
  <D.21172>:
  {
    int ret;

    ret = pthread_mutex_unlock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.22197>; else goto <D.22198>;
    <D.22197>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.22198>:
    D.22199 = ret != 0;
    D.22200 = (long int) D.22199;
    D.22201 = __builtin_expect (D.22200, 0);
    if (D.22201 != 0) goto <D.22202>; else goto <D.22203>;
    <D.22202>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1295, "ret == 0");
    <D.22203>:
  }
  ms = ms + 10;
  D.22204 = retry != 0;
  D.22205 = ms <= 10;
  D.22206 = D.22204 & D.22205;
  if (D.22206 != 0) goto <D.21174>; else goto <D.21175>;
  <D.21175>:
}


remove_wsq (struct MonoWSQ * wsq)
{
  _Bool D.22212;
  long int D.22213;
  long int D.22214;
  struct GPtrArray * wsqs.45;
  _Bool D.22222;
  long int D.22223;
  long int D.22224;
  int D.22227;
  void * data.46;
  int D.22231;
  _Bool D.22234;
  long int D.22235;
  long int D.22236;
  void * data;

  try
    {
      if (wsq == 0B) goto <D.22208>; else goto <D.22209>;
      <D.22208>:
      return;
      <D.22209>:
      {
        int ret;

        ret = pthread_mutex_lock (&wsqs_lock.mutex);
        if (ret != 0) goto <D.22210>; else goto <D.22211>;
        <D.22210>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.22211>:
        D.22212 = ret != 0;
        D.22213 = (long int) D.22212;
        D.22214 = __builtin_expect (D.22213, 0);
        if (D.22214 != 0) goto <D.22215>; else goto <D.22216>;
        <D.22215>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1247, "ret == 0");
        <D.22216>:
      }
      wsqs.45 = wsqs;
      if (wsqs.45 == 0B) goto <D.22218>; else goto <D.22219>;
      <D.22218>:
      {
        int ret;

        ret = pthread_mutex_unlock (&wsqs_lock.mutex);
        if (ret != 0) goto <D.22220>; else goto <D.22221>;
        <D.22220>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22221>:
        D.22222 = ret != 0;
        D.22223 = (long int) D.22222;
        D.22224 = __builtin_expect (D.22223, 0);
        if (D.22224 != 0) goto <D.22225>; else goto <D.22226>;
        <D.22225>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1249, "ret == 0");
        <D.22226>:
      }
      return;
      <D.22219>:
      wsqs.45 = wsqs;
      monoeg_g_ptr_array_remove_fast (wsqs.45, wsq);
      data = 0B;
      D.22227 = mono_runtime_is_shutting_down ();
      if (D.22227 != 0) goto <D.22228>; else goto <D.22229>;
      <D.22228>:
      goto <D.21156>;
      <D.21155>:
      data.46 = data;
      threadpool_jobs_dec (data.46);
      data = 0B;
      <D.21156>:
      D.22231 = mono_wsq_local_pop (&data);
      if (D.22231 != 0) goto <D.21155>; else goto <D.21157>;
      <D.21157>:
      <D.22229>:
      mono_wsq_destroy (wsq);
      {
        int ret;

        ret = pthread_mutex_unlock (&wsqs_lock.mutex);
        if (ret != 0) goto <D.22232>; else goto <D.22233>;
        <D.22232>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22233>:
        D.22234 = ret != 0;
        D.22235 = (long int) D.22234;
        D.22236 = __builtin_expect (D.22235, 0);
        if (D.22236 != 0) goto <D.22237>; else goto <D.22238>;
        <D.22237>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1265, "ret == 0");
        <D.22238>:
      }
    }
  finally
    {
      data = {CLOBBER};
    }
}


fire_profiler_thread_end ()
{
  long long unsigned int D.22242;
  unsigned int D.22243;
  struct MonoInternalThread * thread;

  thread = mono_thread_internal_current ();
  D.22242 = thread->tid;
  D.22243 = (unsigned int) D.22242;
  mono_profiler_thread_end (D.22243);
}


atoi (const char * __nptr)
{
  int D.22244;

  D.22244 = strtol (__nptr, 0B, 10);
  return D.22244;
}


threadpool_init (struct ThreadPool * tp, int min_threads, int max_threads, void (*<T15c0>) (void *) async_invoke)
{
  struct MonoCQ * D.22246;
  union MonoSemType * D.22247;

  memset (tp, 0, 136);
  tp->min_threads = min_threads;
  tp->max_threads = max_threads;
  tp->async_invoke = async_invoke;
  D.22246 = mono_cq_create ();
  tp->queue = D.22246;
  D.22247 = &tp->new_job;
  sem_init (D.22247, 0, 0);
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.22250;
  int D.22255;
  void * D.22257;
  unsigned int D.22258;

  D.22250 = __builtin_constant_p (__len);
  if (D.22250 != 0) goto <D.22251>; else goto <D.22252>;
  <D.22251>:
  if (__len == 0) goto <D.22253>; else goto <D.22254>;
  <D.22253>:
  D.22255 = __builtin_constant_p (__ch);
  if (D.22255 == 0) goto <D.22248>; else goto <D.22256>;
  <D.22256>:
  if (__ch != 0) goto <D.22248>; else goto <D.22249>;
  <D.22248>:
  __warn_memset_zero_len ();
  D.22257 = __dest;
  return D.22257;
  <D.22249>:
  <D.22254>:
  <D.22252>:
  D.22258 = __builtin_object_size (__dest, 0);
  D.22257 = __builtin___memset_chk (__dest, __ch, __len, D.22258);
  return D.22257;
}


init_perf_counter (const char * category, const char * counter)
{
  _Bool D.22260;
  _Bool D.22261;
  _Bool D.22262;
  void * D.22265;
  struct MonoString * category_str;
  struct MonoString * counter_str;
  struct MonoString * machine;
  struct MonoDomain * root;
  MonoBoolean custom;
  int type;

  try
    {
      D.22260 = category == 0B;
      D.22261 = counter == 0B;
      D.22262 = D.22260 | D.22261;
      if (D.22262 != 0) goto <D.22263>; else goto <D.22264>;
      <D.22263>:
      D.22265 = 0B;
      return D.22265;
      <D.22264>:
      root = mono_get_root_domain ();
      category_str = mono_string_new (root, category);
      counter_str = mono_string_new (root, counter);
      machine = mono_string_new (root, ".");
      D.22265 = mono_perfcounter_get_impl (category_str, counter_str, 0B, machine, &type, &custom);
      return D.22265;
    }
  finally
    {
      custom = {CLOBBER};
      type = {CLOBBER};
    }
}


icall_append_io_job (struct MonoObject * target, struct MonoSocketAsyncResult * state)
{
  struct MonoAsyncResult * ares;

  ares = create_simple_asyncresult (target, state);
  socket_io_add (ares, state);
}


socket_io_add (struct MonoAsyncResult * ares, struct MonoSocketAsyncResult * state)
{
  int D.22270;
  int D.22272;
  struct MonoGHashTable * D.22274;
  int D.22275;
  struct MonoAsyncResult * * D.22278;
  void * D.22279;
  union mono_mutex_t * D.22280;
  _Bool D.22283;
  long int D.22284;
  long int D.22285;
  _Bool D.22292;
  long int D.22293;
  long int D.22294;
  const void * fd.47;
  void (*<T394d>) (void *, int, int, int, gboolean) D.22301;
  int D.22302;
  struct MonoMList * list;
  struct SocketIOData * data;
  int fd;
  gboolean is_new;
  int ievt;

  data = &socket_io_data;
  socket_io_init (&socket_io_data);
  D.22270 = mono_runtime_is_shutting_down ();
  if (D.22270 != 0) goto <D.22268>; else goto <D.22271>;
  <D.22271>:
  D.22272 = data->inited;
  if (D.22272 == 3) goto <D.22268>; else goto <D.22273>;
  <D.22273>:
  D.22274 = data->sock_to_state;
  if (D.22274 == 0B) goto <D.22268>; else goto <D.22269>;
  <D.22268>:
  return;
  <D.22269>:
  D.22275 = async_tp.pool_status;
  if (D.22275 == 2) goto <D.22276>; else goto <D.22277>;
  <D.22276>:
  return;
  <D.22277>:
  D.22278 = &state->ares;
  mono_gc_wbarrier_set_field (state, D.22278, ares);
  D.22279 = state->handle;
  fd = (int) D.22279;
  {
    int ret;

    D.22280 = &data->io_lock.mutex;
    ret = pthread_mutex_lock (D.22280);
    if (ret != 0) goto <D.22281>; else goto <D.22282>;
    <D.22281>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.22282>:
    D.22283 = ret != 0;
    D.22284 = (long int) D.22283;
    D.22285 = __builtin_expect (D.22284, 0);
    if (D.22285 != 0) goto <D.22286>; else goto <D.22287>;
    <D.22286>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 546, "ret == 0");
    <D.22287>:
  }
  D.22274 = data->sock_to_state;
  if (D.22274 == 0B) goto <D.22288>; else goto <D.22289>;
  <D.22288>:
  {
    int ret;

    D.22280 = &data->io_lock.mutex;
    ret = pthread_mutex_unlock (D.22280);
    if (ret != 0) goto <D.22290>; else goto <D.22291>;
    <D.22290>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.22291>:
    D.22292 = ret != 0;
    D.22293 = (long int) D.22292;
    D.22294 = __builtin_expect (D.22293, 0);
    if (D.22294 != 0) goto <D.22295>; else goto <D.22296>;
    <D.22295>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 548, "ret == 0");
    <D.22296>:
  }
  return;
  <D.22289>:
  D.22274 = data->sock_to_state;
  fd.47 = (const void *) fd;
  list = mono_g_hash_table_lookup (D.22274, fd.47);
  if (list == 0B) goto <D.22298>; else goto <D.22299>;
  <D.22298>:
  list = mono_mlist_alloc (state);
  is_new = 1;
  goto <D.22300>;
  <D.22299>:
  list = mono_mlist_append (list, state);
  is_new = 0;
  <D.22300>:
  D.22274 = data->sock_to_state;
  D.22279 = state->handle;
  mono_g_hash_table_replace (D.22274, D.22279, list);
  ievt = get_events_from_list (list);
  D.22301 = data->modify;
  D.22302 = state->operation;
  D.22301 (data, fd, D.22302, ievt, is_new);
}


socket_io_init (struct SocketIOData * data)
{
  int D.22304;
  int * D.22307;
  union mono_mutex_t * D.22312;
  _Bool D.22315;
  long int D.22316;
  long int D.22317;
  struct MonoGHashTable * D.22320;
  const gchar * D.22321;
  struct MonoDomain * D.22324;
  void (*<T15c0>) (void *) D.22325;
  _Bool D.22328;
  long int D.22329;
  long int D.22330;
  int inited;

  D.22304 = data->inited;
  if (D.22304 > 1) goto <D.22305>; else goto <D.22306>;
  <D.22305>:
  return;
  <D.22306>:
  D.22307 = &data->inited;
  inited = InterlockedCompareExchange (D.22307, 1, 0);
  if (inited > 0) goto <D.22308>; else goto <D.22309>;
  <D.22308>:
  <D.20926>:
  D.22304 = data->inited;
  if (D.22304 > 1) goto <D.22310>; else goto <D.22311>;
  <D.22310>:
  return;
  <D.22311>:
  SleepEx (1, 0);
  goto <D.20926>;
  <D.22309>:
  {
    int ret;

    D.22312 = &data->io_lock.mutex;
    ret = pthread_mutex_lock (D.22312);
    if (ret != 0) goto <D.22313>; else goto <D.22314>;
    <D.22313>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.22314>:
    D.22315 = ret != 0;
    D.22316 = (long int) D.22315;
    D.22317 = __builtin_expect (D.22316, 0);
    if (D.22317 != 0) goto <D.22318>; else goto <D.22319>;
    <D.22318>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 509, "ret == 0");
    <D.22319>:
  }
  D.22320 = mono_g_hash_table_new_type (monoeg_g_direct_hash, monoeg_g_direct_equal, 2);
  data->sock_to_state = D.22320;
  data->event_system = 1;
  D.22321 = monoeg_g_getenv ("MONO_DISABLE_AIO");
  if (D.22321 != 0B) goto <D.22322>; else goto <D.22323>;
  <D.22322>:
  data->event_system = 0;
  <D.22323>:
  init_event_system (data);
  D.22324 = mono_get_root_domain ();
  D.22325 = data->wait;
  mono_thread_create_internal (D.22324, D.22325, data, 1, 0, 131072);
  {
    int ret;

    D.22312 = &data->io_lock.mutex;
    ret = pthread_mutex_unlock (D.22312);
    if (ret != 0) goto <D.22326>; else goto <D.22327>;
    <D.22326>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.22327>:
    D.22328 = ret != 0;
    D.22329 = (long int) D.22328;
    D.22330 = __builtin_expect (D.22329, 0);
    if (D.22330 != 0) goto <D.22331>; else goto <D.22332>;
    <D.22331>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 523, "ret == 0");
    <D.22332>:
  }
  data->inited = 2;
  threadpool_start_thread (&async_io_tp);
}


init_event_system (struct SocketIOData * data)
{
  int D.22334;
  void * D.22337;
  void * D.22338;
  const gchar * D.22341;
  void * D.22346;

  D.22334 = data->event_system;
  if (D.22334 == 1) goto <D.22335>; else goto <D.22336>;
  <D.22335>:
  D.22337 = tp_epoll_init (data);
  data->event_data = D.22337;
  D.22338 = data->event_data;
  if (D.22338 == 0B) goto <D.22339>; else goto <D.22340>;
  <D.22339>:
  D.22341 = monoeg_g_getenv ("MONO_DEBUG");
  if (D.22341 != 0B) goto <D.22342>; else goto <D.22343>;
  <D.22342>:
  monoeg_g_log (0B, 32, "Falling back to poll()");
  <D.22343>:
  data->event_system = 0;
  <D.22340>:
  <D.22336>:
  D.22334 = data->event_system;
  if (D.22334 == 0) goto <D.22344>; else goto <D.22345>;
  <D.22344>:
  D.22346 = tp_poll_init (data);
  data->event_data = D.22346;
  <D.22345>:
}


tp_epoll_init (struct SocketIOData * data)
{
  int D.22347;
  int D.22348;
  int * D.22351;
  const gchar * D.22352;
  const gchar * D.22355;
  void * D.22356;
  struct tp_epoll_data * result;

  result = monoeg_malloc0 (4);
  D.22347 = epoll_create1 (524288);
  result->epollfd = D.22347;
  D.22348 = result->epollfd;
  if (D.22348 == -1) goto <D.22349>; else goto <D.22350>;
  <D.22349>:
  {
    int err;

    D.22351 = __errno_location ();
    err = *D.22351;
    D.22352 = monoeg_g_getenv ("MONO_DEBUG");
    if (D.22352 != 0B) goto <D.22353>; else goto <D.22354>;
    <D.22353>:
    D.22355 = monoeg_g_strerror (err);
    monoeg_g_log (0B, 32, "epoll_create1(EPOLL_CLOEXEC) failed: %d %s", err, D.22355);
    <D.22354>:
    D.22356 = 0B;
    return D.22356;
  }
  <D.22350>:
  data->shutdown = tp_epoll_shutdown;
  data->modify = tp_epoll_modify;
  data->wait = tp_epoll_wait;
  D.22356 = result;
  return D.22356;
}


tp_epoll_wait (void * p)
{
  int * D.22361;
  int D.22362;
  const gchar * D.22367;
  union mono_mutex_t * D.22368;
  _Bool D.22371;
  long int D.22372;
  long int D.22373;
  int D.22376;
  _Bool D.22381;
  long int D.22382;
  long int D.22383;
  unsigned int i.48;
  unsigned int D.22387;
  struct MonoGHashTable * D.22388;
  const void * fd.49;
  void * list.50;
  struct MonoMList * list.51;
  unsigned int D.22394;
  unsigned int D.22395;
  int nresults.52;
  unsigned int D.22403;
  int nresults.53;
  void * fd.54;
  unsigned int p.55;
  unsigned int D.22413;
  unsigned int D.22414;
  unsigned int D.22415;
  int D.22416;
  int D.22419;
  const gchar * D.22422;
  _Bool D.22426;
  long int D.22427;
  long int D.22428;
  unsigned int nresults.56;
  unsigned int D.22432;
  struct SocketIOData * socket_io_data;
  int epollfd;
  struct epoll_event * events;
  struct epoll_event * evt;
  int ready;
  int i;
  void * async_results[256];
  gint nresults;
  struct tp_epoll_data * data;

  try
    {
      ready = 0;
      socket_io_data = p;
      data = socket_io_data->event_data;
      epollfd = data->epollfd;
      events = monoeg_malloc0 (2048);
      <D.20718>:
      mono_gc_set_skip_thread (1);
      <D.20704>:
      if (ready == -1) goto <D.22358>; else goto <D.22359>;
      <D.22358>:
      check_for_interruption_critical ();
      <D.22359>:
      ready = epoll_wait (epollfd, events, 128, -1);
      if (ready == -1) goto <D.22360>; else goto <D.20705>;
      <D.22360>:
      D.22361 = __errno_location ();
      D.22362 = *D.22361;
      if (D.22362 == 4) goto <D.20704>; else goto <D.20705>;
      <D.20705>:
      mono_gc_set_skip_thread (0);
      if (ready == -1) goto <D.22363>; else goto <D.22364>;
      <D.22363>:
      {
        int err;

        D.22361 = __errno_location ();
        err = *D.22361;
        monoeg_g_free (events);
        if (err != 9) goto <D.22365>; else goto <D.22366>;
        <D.22365>:
        D.22367 = monoeg_g_strerror (err);
        monoeg_g_log (0B, 16, "epoll_wait: %d %s", err, D.22367);
        <D.22366>:
        return;
      }
      <D.22364>:
      {
        int ret;

        D.22368 = &socket_io_data->io_lock.mutex;
        ret = pthread_mutex_lock (D.22368);
        if (ret != 0) goto <D.22369>; else goto <D.22370>;
        <D.22369>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
        <D.22370>:
        D.22371 = ret != 0;
        D.22372 = (long int) D.22371;
        D.22373 = __builtin_expect (D.22372, 0);
        if (D.22373 != 0) goto <D.22374>; else goto <D.22375>;
        <D.22374>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-epoll.c", 132, "ret == 0");
        <D.22375>:
      }
      D.22376 = socket_io_data->inited;
      if (D.22376 == 3) goto <D.22377>; else goto <D.22378>;
      <D.22377>:
      monoeg_g_free (events);
      {
        int ret;

        D.22368 = &socket_io_data->io_lock.mutex;
        ret = pthread_mutex_unlock (D.22368);
        if (ret != 0) goto <D.22379>; else goto <D.22380>;
        <D.22379>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22380>:
        D.22381 = ret != 0;
        D.22382 = (long int) D.22381;
        D.22383 = __builtin_expect (D.22382, 0);
        if (D.22383 != 0) goto <D.22384>; else goto <D.22385>;
        <D.22384>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-epoll.c", 135, "ret == 0");
        <D.22385>:
      }
      return;
      <D.22378>:
      nresults = 0;
      i = 0;
      goto <D.20715>;
      <D.20714>:
      {
        int fd;
        struct MonoMList * list;
        struct MonoObject * ares;

        try
          {
            i.48 = (unsigned int) i;
            D.22387 = i.48 * 16;
            evt = events + D.22387;
            fd = evt->data.fd;
            D.22388 = socket_io_data->sock_to_state;
            fd.49 = (const void *) fd;
            list.50 = mono_g_hash_table_lookup (D.22388, fd.49);
            list = list.50;
            list.51 = list;
            if (list.51 != 0B) goto <D.22392>; else goto <D.22393>;
            <D.22392>:
            D.22394 = evt->events;
            D.22395 = D.22394 & 25;
            if (D.22395 != 0) goto <D.22396>; else goto <D.22397>;
            <D.22396>:
            ares = get_io_event (&list, 1);
            if (ares != 0B) goto <D.22398>; else goto <D.22399>;
            <D.22398>:
            nresults.52 = nresults;
            nresults = nresults.52 + 1;
            async_results[nresults.52] = ares;
            <D.22399>:
            <D.22397>:
            <D.22393>:
            list.51 = list;
            if (list.51 != 0B) goto <D.22401>; else goto <D.22402>;
            <D.22401>:
            D.22394 = evt->events;
            D.22403 = D.22394 & 28;
            if (D.22403 != 0) goto <D.22404>; else goto <D.22405>;
            <D.22404>:
            ares = get_io_event (&list, 4);
            if (ares != 0B) goto <D.22406>; else goto <D.22407>;
            <D.22406>:
            nresults.53 = nresults;
            nresults = nresults.53 + 1;
            async_results[nresults.53] = ares;
            <D.22407>:
            <D.22405>:
            <D.22402>:
            list.51 = list;
            if (list.51 != 0B) goto <D.22409>; else goto <D.22410>;
            <D.22409>:
            {
              int p;

              D.22388 = socket_io_data->sock_to_state;
              fd.54 = (void *) fd;
              list.51 = list;
              mono_g_hash_table_replace (D.22388, fd.54, list.51);
              list.51 = list;
              p = get_events_from_list (list.51);
              p.55 = (unsigned int) p;
              D.22413 = p.55 & 4;
              evt->events = D.22413;
              D.22394 = evt->events;
              p.55 = (unsigned int) p;
              D.22414 = p.55 & 1;
              D.22415 = D.22394 | D.22414;
              evt->events = D.22415;
              D.22416 = epoll_ctl (epollfd, 3, fd, evt);
              if (D.22416 == -1) goto <D.22417>; else goto <D.22418>;
              <D.22417>:
              D.22419 = epoll_ctl (epollfd, 1, fd, evt);
              if (D.22419 == -1) goto <D.22420>; else goto <D.22421>;
              <D.22420>:
              {
                int err;

                D.22361 = __errno_location ();
                err = *D.22361;
                D.22422 = monoeg_g_strerror (err);
                monoeg_g_log (0B, 32, "epoll(ADD): %d %s", err, D.22422);
              }
              <D.22421>:
              <D.22418>:
            }
            goto <D.22423>;
            <D.22410>:
            D.22388 = socket_io_data->sock_to_state;
            fd.49 = (const void *) fd;
            mono_g_hash_table_remove (D.22388, fd.49);
            epoll_ctl (epollfd, 2, fd, evt);
            <D.22423>:
          }
        finally
          {
            list = {CLOBBER};
          }
      }
      i = i + 1;
      <D.20715>:
      if (i < ready) goto <D.20714>; else goto <D.20716>;
      <D.20716>:
      {
        int ret;

        D.22368 = &socket_io_data->io_lock.mutex;
        ret = pthread_mutex_unlock (D.22368);
        if (ret != 0) goto <D.22424>; else goto <D.22425>;
        <D.22424>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22425>:
        D.22426 = ret != 0;
        D.22427 = (long int) D.22426;
        D.22428 = __builtin_expect (D.22427, 0);
        if (D.22428 != 0) goto <D.22429>; else goto <D.22430>;
        <D.22429>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-epoll.c", 178, "ret == 0");
        <D.22430>:
      }
      threadpool_append_jobs (&async_io_tp, &async_results, nresults);
      nresults.56 = (unsigned int) nresults;
      D.22432 = nresults.56 * 4;
      mono_gc_bzero_aligned (&async_results, D.22432);
      goto <D.20718>;
    }
  finally
    {
      async_results = {CLOBBER};
    }
}


tp_epoll_modify (void * p, int fd, int operation, int events, gboolean is_new)
{
  int D.22435;
  unsigned int D.22438;
  unsigned int D.22439;
  int D.22440;
  unsigned int D.22443;
  int iftmp.57;
  int D.22448;
  int D.22449;
  int * D.22452;
  _Bool D.22453;
  _Bool D.22454;
  _Bool D.22455;
  int D.22458;
  const gchar * D.22461;
  union mono_mutex_t * D.22462;
  _Bool D.22465;
  long int D.22466;
  long int D.22467;
  struct SocketIOData * socket_io_data;
  struct tp_epoll_data * data;
  struct epoll_event evt;
  int epoll_op;

  try
    {
      socket_io_data = p;
      data = socket_io_data->event_data;
      memset (&evt, 0, 16);
      evt.data.fd = fd;
      D.22435 = events & 1;
      if (D.22435 != 0) goto <D.22436>; else goto <D.22437>;
      <D.22436>:
      D.22438 = evt.events;
      D.22439 = D.22438 | 1;
      evt.events = D.22439;
      <D.22437>:
      D.22440 = events & 4;
      if (D.22440 != 0) goto <D.22441>; else goto <D.22442>;
      <D.22441>:
      D.22438 = evt.events;
      D.22443 = D.22438 | 4;
      evt.events = D.22443;
      <D.22442>:
      if (is_new != 0) goto <D.22445>; else goto <D.22446>;
      <D.22445>:
      iftmp.57 = 1;
      goto <D.22447>;
      <D.22446>:
      iftmp.57 = 3;
      <D.22447>:
      epoll_op = iftmp.57;
      D.22448 = data->epollfd;
      D.22449 = epoll_ctl (D.22448, epoll_op, fd, &evt);
      if (D.22449 == -1) goto <D.22450>; else goto <D.22451>;
      <D.22450>:
      {
        int err;

        D.22452 = __errno_location ();
        err = *D.22452;
        D.22453 = epoll_op == 1;
        D.22454 = err == 17;
        D.22455 = D.22453 & D.22454;
        if (D.22455 != 0) goto <D.22456>; else goto <D.22457>;
        <D.22456>:
        epoll_op = 3;
        D.22448 = data->epollfd;
        D.22458 = epoll_ctl (D.22448, epoll_op, fd, &evt);
        if (D.22458 == -1) goto <D.22459>; else goto <D.22460>;
        <D.22459>:
        D.22461 = monoeg_g_strerror (err);
        monoeg_g_log (0B, 32, "epoll_ctl(MOD): %d %s", err, D.22461);
        <D.22460>:
        <D.22457>:
      }
      <D.22451>:
      {
        int ret;

        D.22462 = &socket_io_data->io_lock.mutex;
        ret = pthread_mutex_unlock (D.22462);
        if (ret != 0) goto <D.22463>; else goto <D.22464>;
        <D.22463>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22464>:
        D.22465 = ret != 0;
        D.22466 = (long int) D.22465;
        D.22467 = __builtin_expect (D.22466, 0);
        if (D.22467 != 0) goto <D.22468>; else goto <D.22469>;
        <D.22468>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-epoll.c", 81, "ret == 0");
        <D.22469>:
      }
    }
  finally
    {
      evt = {CLOBBER};
    }
}


tp_epoll_shutdown (void * event_data)
{
  int D.22470;
  struct tp_epoll_data * data;

  data = event_data;
  D.22470 = data->epollfd;
  close (D.22470);
  monoeg_g_free (data);
}


tp_poll_init (struct SocketIOData * data)
{
  int[2] * D.22471;
  int D.22472;
  int * D.22475;
  _Bool D.22476;
  long int D.22477;
  long int D.22478;
  union MonoSemType * D.22481;
  void * D.22482;
  struct tp_poll_data * result;

  result = monoeg_malloc0 (32);
  D.22471 = &result->pipe;
  D.22472 = pipe (D.22471);
  if (D.22472 != 0) goto <D.22473>; else goto <D.22474>;
  <D.22473>:
  {
    int err;

    D.22475 = __errno_location ();
    err = *D.22475;
    perror ("mono");
    D.22476 = err == 0;
    D.22477 = (long int) D.22476;
    D.22478 = __builtin_expect (D.22477, 0);
    if (D.22478 != 0) goto <D.22479>; else goto <D.22480>;
    <D.22479>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-poll.c", 41, "err");
    <D.22480>:
  }
  <D.22474>:
  D.22481 = &result->new_sem;
  sem_init (D.22481, 0, 1);
  data->shutdown = tp_poll_shutdown;
  data->modify = tp_poll_modify;
  data->wait = tp_poll_wait;
  D.22482 = result;
  return D.22482;
}


tp_poll_wait (void * p)
{
  unsigned int allocated.58;
  unsigned int D.22485;
  int D.22486;
  int D.22487;
  void * iftmp.59;
  void * D.22491;
  int D.22493;
  unsigned int i.60;
  unsigned int D.22495;
  struct mono_pollfd * D.22496;
  unsigned int maxfd.61;
  int * D.22501;
  int D.22502;
  short int D.22507;
  unsigned short D.22508;
  int D.22509;
  int D.22510;
  int D.22513;
  void * * D.22516;
  int D.22517;
  int D.22520;
  int D.22521;
  short int D.22533;
  struct mono_pollfd * D.22534;
  union MonoSemType * D.22535;
  union mono_mutex_t * D.22540;
  _Bool D.22543;
  long int D.22544;
  long int D.22545;
  int D.22548;
  _Bool D.22555;
  long int D.22556;
  long int D.22557;
  unsigned int D.22560;
  unsigned int D.22561;
  short int D.22565;
  struct MonoGHashTable * D.22566;
  const void * D.22567;
  void * list.62;
  struct MonoMList * list.63;
  unsigned short D.22572;
  int D.22573;
  int D.22574;
  int D.22579;
  unsigned int D.22582;
  int D.22583;
  void * D.22584;
  int D.22587;
  int D.22588;
  unsigned int D.22589;
  unsigned int D.22590;
  void * * D.22591;
  int D.22594;
  void * D.22601;
  int D.22604;
  int D.22605;
  unsigned int D.22606;
  unsigned int D.22607;
  void * * D.22608;
  void * D.22611;
  int D.22612;
  short int D.22613;
  int D.22615;
  _Bool D.22618;
  _Bool D.22619;
  _Bool D.22620;
  _Bool D.22623;
  long int D.22624;
  long int D.22625;
  struct mono_pollfd * pfds;
  gint maxfd;
  gint allocated;
  gint i;
  struct tp_poll_data * data;
  struct SocketIOData * socket_io_data;
  struct MonoPtrArray async_results;
  gint nresults;

  try
    {
      maxfd = 1;
      socket_io_data = p;
      data = socket_io_data->event_data;
      allocated = 1024;
      allocated.58 = (unsigned int) allocated;
      D.22485 = allocated.58 * 8;
      pfds = monoeg_malloc0 (D.22485);
      async_results.size = 0;
      D.22486 = allocated * 2;
      D.22487 = MAX_EXPR <D.22486, 16>;
      async_results.capacity = D.22487;
      D.22486 = allocated * 2;
      if (D.22486 > 16) goto <D.22489>; else goto <D.22490>;
      <D.22489>:
      allocated.58 = (unsigned int) allocated;
      D.22485 = allocated.58 * 8;
      D.22486 = allocated * 2;
      D.22491 = mono_gc_make_root_descr_all_refs (D.22486);
      iftmp.59 = mono_gc_alloc_fixed (D.22485, D.22491);
      goto <D.22492>;
      <D.22490>:
      iftmp.59 = __builtin_alloca (64);
      <D.22492>:
      async_results.data = iftmp.59;
      D.22493 = data->pipe[0];
      pfds->fd = D.22493;
      pfds->events = 1;
      pfds->revents = 0;
      i = 1;
      goto <D.20625>;
      <D.20624>:
      i.60 = (unsigned int) i;
      D.22495 = i.60 * 8;
      D.22496 = pfds + D.22495;
      D.22496->fd = -1;
      i.60 = (unsigned int) i;
      D.22495 = i.60 * 8;
      D.22496 = pfds + D.22495;
      D.22496->events = 0;
      i.60 = (unsigned int) i;
      D.22495 = i.60 * 8;
      D.22496 = pfds + D.22495;
      D.22496->revents = 0;
      i = i + 1;
      <D.20625>:
      if (i < allocated) goto <D.20624>; else goto <D.20626>;
      <D.20626>:
      <D.20656>:
      {
        int nsock;
        struct mono_pollfd * pfd;
        char one[1];
        struct MonoMList * list;
        struct MonoObject * ares;

        try
          {
            nsock = 0;
            mono_gc_set_skip_thread (1);
            <D.20632>:
            if (nsock == -1) goto <D.22497>; else goto <D.22498>;
            <D.22497>:
            check_for_interruption_critical ();
            <D.22498>:
            maxfd.61 = (unsigned int) maxfd;
            nsock = mono_poll (pfds, maxfd.61, -1);
            if (nsock == -1) goto <D.22500>; else goto <D.20633>;
            <D.22500>:
            D.22501 = __errno_location ();
            D.22502 = *D.22501;
            if (D.22502 == 4) goto <D.20632>; else goto <D.20633>;
            <D.20633>:
            mono_gc_set_skip_thread (0);
            if (nsock == -1) goto <D.22503>; else goto <D.22504>;
            <D.22503>:
            D.22501 = __errno_location ();
            D.22502 = *D.22501;
            if (D.22502 == 9) goto <D.22505>; else goto <D.22506>;
            <D.22505>:
            pfds->revents = 0;
            nsock = mark_bad_fds (pfds, maxfd);
            <D.22506>:
            <D.22504>:
            D.22507 = pfds->revents;
            D.22508 = (unsigned short) D.22507;
            D.22509 = (int) D.22508;
            D.22510 = D.22509 & 56;
            if (D.22510 != 0) goto <D.22511>; else goto <D.22512>;
            <D.22511>:
            monoeg_g_free (pfds);
            D.22513 = async_results.capacity;
            if (D.22513 > 16) goto <D.22514>; else goto <D.22515>;
            <D.22514>:
            D.22516 = async_results.data;
            mono_gc_free_fixed (D.22516);
            <D.22515>:
            socket_io_cleanup (socket_io_data);
            return;
            <D.22512>:
            D.22507 = pfds->revents;
            D.22508 = (unsigned short) D.22507;
            D.22509 = (int) D.22508;
            D.22517 = D.22509 & 1;
            if (D.22517 != 0) goto <D.22518>; else goto <D.22519>;
            <D.22518>:
            {
              int nread;
              gboolean found;

              found = 0;
              i = 1;
              goto <D.20638>;
              <D.20637>:
              i.60 = (unsigned int) i;
              D.22495 = i.60 * 8;
              pfd = pfds + D.22495;
              D.22520 = pfd->fd;
              D.22521 = data->newpfd.fd;
              if (D.22520 == D.22521) goto <D.22522>; else goto <D.22523>;
              <D.22522>:
              found = 1;
              goto <D.20636>;
              <D.22523>:
              i = i + 1;
              <D.20638>:
              if (i < allocated) goto <D.20637>; else goto <D.20636>;
              <D.20636>:
              if (found == 0) goto <D.22524>; else goto <D.22525>;
              <D.22524>:
              i = 1;
              goto <D.20641>;
              <D.20640>:
              i.60 = (unsigned int) i;
              D.22495 = i.60 * 8;
              pfd = pfds + D.22495;
              D.22520 = pfd->fd;
              if (D.22520 == -1) goto <D.20639>; else goto <D.22526>;
              <D.22526>:
              i = i + 1;
              <D.20641>:
              if (i < allocated) goto <D.20640>; else goto <D.20639>;
              <D.20639>:
              <D.22525>:
              if (i == allocated) goto <D.22527>; else goto <D.22528>;
              <D.22527>:
              {
                struct mono_pollfd * oldfd;

                oldfd = pfds;
                i = allocated;
                allocated = allocated * 2;
                allocated.58 = (unsigned int) allocated;
                D.22485 = allocated.58 * 8;
                pfds = monoeg_realloc (oldfd, D.22485);
                monoeg_g_free (oldfd);
                goto <D.20644>;
                <D.20643>:
                i.60 = (unsigned int) i;
                D.22495 = i.60 * 8;
                D.22496 = pfds + D.22495;
                D.22496->fd = -1;
                i.60 = (unsigned int) i;
                D.22495 = i.60 * 8;
                D.22496 = pfds + D.22495;
                D.22496->events = 0;
                i.60 = (unsigned int) i;
                D.22495 = i.60 * 8;
                D.22496 = pfds + D.22495;
                D.22496->revents = 0;
                i = i + 1;
                <D.20644>:
                if (i < allocated) goto <D.20643>; else goto <D.20645>;
                <D.20645>:
              }
              <D.22528>:
              D.22493 = data->pipe[0];
              nread = read (D.22493, &one, 1);
              if (nread <= 0) goto <D.22529>; else goto <D.22530>;
              <D.22529>:
              monoeg_g_free (pfds);
              D.22513 = async_results.capacity;
              if (D.22513 > 16) goto <D.22531>; else goto <D.22532>;
              <D.22531>:
              D.22516 = async_results.data;
              mono_gc_free_fixed (D.22516);
              <D.22532>:
              return;
              <D.22530>:
              i.60 = (unsigned int) i;
              D.22495 = i.60 * 8;
              D.22496 = pfds + D.22495;
              D.22521 = data->newpfd.fd;
              D.22496->fd = D.22521;
              i.60 = (unsigned int) i;
              D.22495 = i.60 * 8;
              D.22496 = pfds + D.22495;
              D.22533 = data->newpfd.events;
              D.22496->events = D.22533;
              i.60 = (unsigned int) i;
              D.22495 = i.60 * 8;
              D.22496 = pfds + D.22495;
              D.22496->revents = 0;
              D.22534 = &data->newpfd;
              memset (D.22534, 0, 8);
              D.22535 = &data->new_sem;
              mono_sem_post (D.22535);
              if (i >= maxfd) goto <D.22536>; else goto <D.22537>;
              <D.22536>:
              maxfd = i + 1;
              <D.22537>:
              nsock = nsock + -1;
            }
            <D.22519>:
            if (nsock == 0) goto <D.22538>; else goto <D.22539>;
            <D.22538>:
            // predicted unlikely by continue predictor.
            goto <D.20646>;
            <D.22539>:
            {
              int ret;

              D.22540 = &socket_io_data->io_lock.mutex;
              ret = pthread_mutex_lock (D.22540);
              if (ret != 0) goto <D.22541>; else goto <D.22542>;
              <D.22541>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
              <D.22542>:
              D.22543 = ret != 0;
              D.22544 = (long int) D.22543;
              D.22545 = __builtin_expect (D.22544, 0);
              if (D.22545 != 0) goto <D.22546>; else goto <D.22547>;
              <D.22546>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-poll.c", 273, "ret == 0");
              <D.22547>:
            }
            D.22548 = socket_io_data->inited;
            if (D.22548 == 3) goto <D.22549>; else goto <D.22550>;
            <D.22549>:
            monoeg_g_free (pfds);
            D.22513 = async_results.capacity;
            if (D.22513 > 16) goto <D.22551>; else goto <D.22552>;
            <D.22551>:
            D.22516 = async_results.data;
            mono_gc_free_fixed (D.22516);
            <D.22552>:
            {
              int ret;

              D.22540 = &socket_io_data->io_lock.mutex;
              ret = pthread_mutex_unlock (D.22540);
              if (ret != 0) goto <D.22553>; else goto <D.22554>;
              <D.22553>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
              <D.22554>:
              D.22555 = ret != 0;
              D.22556 = (long int) D.22555;
              D.22557 = __builtin_expect (D.22556, 0);
              if (D.22557 != 0) goto <D.22558>; else goto <D.22559>;
              <D.22558>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-poll.c", 277, "ret == 0");
              <D.22559>:
            }
            return;
            <D.22550>:
            nresults = 0;
            async_results.size = 0;
            D.22516 = async_results.data;
            D.22513 = async_results.capacity;
            D.22560 = (unsigned int) D.22513;
            D.22561 = D.22560 * 4;
            mono_gc_bzero_aligned (D.22516, D.22561);
            i = 1;
            goto <D.20653>;
            <D.20652>:
            i.60 = (unsigned int) i;
            D.22495 = i.60 * 8;
            pfd = pfds + D.22495;
            D.22520 = pfd->fd;
            if (D.22520 == -1) goto <D.22562>; else goto <D.22564>;
            <D.22564>:
            D.22565 = pfd->revents;
            if (D.22565 == 0) goto <D.22562>; else goto <D.22563>;
            <D.22562>:
            // predicted unlikely by continue predictor.
            goto <D.20649>;
            <D.22563>:
            nsock = nsock + -1;
            D.22566 = socket_io_data->sock_to_state;
            D.22520 = pfd->fd;
            D.22567 = (const void *) D.22520;
            list.62 = mono_g_hash_table_lookup (D.22566, D.22567);
            list = list.62;
            list.63 = list;
            if (list.63 != 0B) goto <D.22570>; else goto <D.22571>;
            <D.22570>:
            D.22565 = pfd->revents;
            D.22572 = (unsigned short) D.22565;
            D.22573 = (int) D.22572;
            D.22574 = D.22573 & 57;
            if (D.22574 != 0) goto <D.22575>; else goto <D.22576>;
            <D.22575>:
            ares = get_io_event (&list, 1);
            if (ares != 0B) goto <D.22577>; else goto <D.22578>;
            <D.22577>:
            D.22579 = async_results.size;
            D.22513 = async_results.capacity;
            if (D.22579 >= D.22513) goto <D.22580>; else goto <D.22581>;
            <D.22580>:
            {
              void * __tmp;

              D.22513 = async_results.capacity;
              D.22560 = (unsigned int) D.22513;
              D.22582 = D.22560 * 8;
              D.22513 = async_results.capacity;
              D.22583 = D.22513 * 2;
              D.22584 = mono_gc_make_root_descr_all_refs (D.22583);
              __tmp = mono_gc_alloc_fixed (D.22582, D.22584);
              D.22516 = async_results.data;
              D.22513 = async_results.capacity;
              D.22560 = (unsigned int) D.22513;
              D.22561 = D.22560 * 4;
              mono_gc_memmove_aligned (__tmp, D.22516, D.22561);
              D.22513 = async_results.capacity;
              if (D.22513 > 16) goto <D.22585>; else goto <D.22586>;
              <D.22585>:
              D.22516 = async_results.data;
              mono_gc_free_fixed (D.22516);
              <D.22586>:
              async_results.data = __tmp;
              D.22513 = async_results.capacity;
              D.22583 = D.22513 * 2;
              async_results.capacity = D.22583;
            }
            <D.22581>:
            D.22516 = async_results.data;
            D.22579 = async_results.size;
            D.22587 = D.22579;
            D.22588 = D.22587 + 1;
            async_results.size = D.22588;
            D.22589 = (unsigned int) D.22587;
            D.22590 = D.22589 * 4;
            D.22591 = D.22516 + D.22590;
            *D.22591 = ares;
            nresults = nresults + 1;
            <D.22578>:
            <D.22576>:
            <D.22571>:
            list.63 = list;
            if (list.63 != 0B) goto <D.22592>; else goto <D.22593>;
            <D.22592>:
            D.22565 = pfd->revents;
            D.22572 = (unsigned short) D.22565;
            D.22573 = (int) D.22572;
            D.22594 = D.22573 & 60;
            if (D.22594 != 0) goto <D.22595>; else goto <D.22596>;
            <D.22595>:
            ares = get_io_event (&list, 4);
            if (ares != 0B) goto <D.22597>; else goto <D.22598>;
            <D.22597>:
            D.22579 = async_results.size;
            D.22513 = async_results.capacity;
            if (D.22579 >= D.22513) goto <D.22599>; else goto <D.22600>;
            <D.22599>:
            {
              void * __tmp;

              D.22513 = async_results.capacity;
              D.22560 = (unsigned int) D.22513;
              D.22582 = D.22560 * 8;
              D.22513 = async_results.capacity;
              D.22583 = D.22513 * 2;
              D.22601 = mono_gc_make_root_descr_all_refs (D.22583);
              __tmp = mono_gc_alloc_fixed (D.22582, D.22601);
              D.22516 = async_results.data;
              D.22513 = async_results.capacity;
              D.22560 = (unsigned int) D.22513;
              D.22561 = D.22560 * 4;
              mono_gc_memmove_aligned (__tmp, D.22516, D.22561);
              D.22513 = async_results.capacity;
              if (D.22513 > 16) goto <D.22602>; else goto <D.22603>;
              <D.22602>:
              D.22516 = async_results.data;
              mono_gc_free_fixed (D.22516);
              <D.22603>:
              async_results.data = __tmp;
              D.22513 = async_results.capacity;
              D.22583 = D.22513 * 2;
              async_results.capacity = D.22583;
            }
            <D.22600>:
            D.22516 = async_results.data;
            D.22579 = async_results.size;
            D.22604 = D.22579;
            D.22605 = D.22604 + 1;
            async_results.size = D.22605;
            D.22606 = (unsigned int) D.22604;
            D.22607 = D.22606 * 4;
            D.22608 = D.22516 + D.22607;
            *D.22608 = ares;
            nresults = nresults + 1;
            <D.22598>:
            <D.22596>:
            <D.22593>:
            list.63 = list;
            if (list.63 != 0B) goto <D.22609>; else goto <D.22610>;
            <D.22609>:
            D.22566 = socket_io_data->sock_to_state;
            D.22520 = pfd->fd;
            D.22611 = (void *) D.22520;
            list.63 = list;
            mono_g_hash_table_replace (D.22566, D.22611, list.63);
            list.63 = list;
            D.22612 = get_events_from_list (list.63);
            D.22613 = (short int) D.22612;
            pfd->events = D.22613;
            goto <D.22614>;
            <D.22610>:
            D.22566 = socket_io_data->sock_to_state;
            D.22520 = pfd->fd;
            D.22567 = (const void *) D.22520;
            mono_g_hash_table_remove (D.22566, D.22567);
            pfd->fd = -1;
            D.22615 = maxfd + -1;
            if (D.22615 == i) goto <D.22616>; else goto <D.22617>;
            <D.22616>:
            maxfd = maxfd + -1;
            <D.22617>:
            <D.22614>:
            <D.20649>:
            i = i + 1;
            <D.20653>:
            D.22618 = i < maxfd;
            D.22619 = nsock > 0;
            D.22620 = D.22618 & D.22619;
            if (D.22620 != 0) goto <D.20652>; else goto <D.20654>;
            <D.20654>:
            {
              int ret;

              D.22540 = &socket_io_data->io_lock.mutex;
              ret = pthread_mutex_unlock (D.22540);
              if (ret != 0) goto <D.22621>; else goto <D.22622>;
              <D.22621>:
              monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
              <D.22622>:
              D.22623 = ret != 0;
              D.22624 = (long int) D.22623;
              D.22625 = __builtin_expect (D.22624, 0);
              if (D.22625 != 0) goto <D.22626>; else goto <D.22627>;
              <D.22626>:
              monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-poll.c", 317, "ret == 0");
              <D.22627>:
            }
            D.22516 = async_results.data;
            threadpool_append_jobs (&async_io_tp, D.22516, nresults);
            async_results.size = 0;
            D.22516 = async_results.data;
            D.22513 = async_results.capacity;
            D.22560 = (unsigned int) D.22513;
            D.22561 = D.22560 * 4;
            mono_gc_bzero_aligned (D.22516, D.22561);
          }
        finally
          {
            one = {CLOBBER};
            list = {CLOBBER};
          }
      }
      <D.20646>:
      goto <D.20656>;
    }
  finally
    {
      async_results = {CLOBBER};
    }
}


mark_bad_fds (struct mono_pollfd * pfds, int nfds)
{
  unsigned int i.64;
  unsigned int D.22634;
  int D.22635;
  int * D.22641;
  int D.22642;
  short int D.22644;
  short int D.22645;
  int D.22648;
  int i;
  int ret;
  struct mono_pollfd * pfd;
  int count;

  count = 0;
  i = 0;
  goto <D.20611>;
  <D.20610>:
  i.64 = (unsigned int) i;
  D.22634 = i.64 * 8;
  pfd = pfds + D.22634;
  D.22635 = pfd->fd;
  if (D.22635 == -1) goto <D.22636>; else goto <D.22637>;
  <D.22636>:
  // predicted unlikely by continue predictor.
  goto <D.20609>;
  <D.22637>:
  ret = mono_poll (pfd, 1, 0);
  if (ret == -1) goto <D.22640>; else goto <D.22638>;
  <D.22640>:
  D.22641 = __errno_location ();
  D.22642 = *D.22641;
  if (D.22642 == 9) goto <D.22643>; else goto <D.22638>;
  <D.22643>:
  D.22644 = pfd->revents;
  D.22645 = D.22644 | 32;
  pfd->revents = D.22645;
  count = count + 1;
  goto <D.22639>;
  <D.22638>:
  if (ret == 1) goto <D.22646>; else goto <D.22647>;
  <D.22646>:
  count = count + 1;
  <D.22647>:
  <D.22639>:
  <D.20609>:
  i = i + 1;
  <D.20611>:
  if (i < nfds) goto <D.20610>; else goto <D.20612>;
  <D.20612>:
  D.22648 = count;
  return D.22648;
}


socket_io_cleanup (struct SocketIOData * data)
{
  union mono_mutex_t * D.22650;
  _Bool D.22653;
  long int D.22654;
  long int D.22655;
  int D.22658;
  _Bool D.22663;
  long int D.22664;
  long int D.22665;
  void (*<T15c0>) (void *) D.22668;
  void * D.22669;
  _Bool D.22672;
  long int D.22673;
  long int D.22674;

  {
    int ret;

    D.22650 = &data->io_lock.mutex;
    ret = pthread_mutex_lock (D.22650);
    if (ret != 0) goto <D.22651>; else goto <D.22652>;
    <D.22651>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.22652>:
    D.22653 = ret != 0;
    D.22654 = (long int) D.22653;
    D.22655 = __builtin_expect (D.22654, 0);
    if (D.22655 != 0) goto <D.22656>; else goto <D.22657>;
    <D.22656>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 317, "ret == 0");
    <D.22657>:
  }
  D.22658 = data->inited;
  if (D.22658 != 2) goto <D.22659>; else goto <D.22660>;
  <D.22659>:
  {
    int ret;

    D.22650 = &data->io_lock.mutex;
    ret = pthread_mutex_unlock (D.22650);
    if (ret != 0) goto <D.22661>; else goto <D.22662>;
    <D.22661>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.22662>:
    D.22663 = ret != 0;
    D.22664 = (long int) D.22663;
    D.22665 = __builtin_expect (D.22664, 0);
    if (D.22665 != 0) goto <D.22666>; else goto <D.22667>;
    <D.22666>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 319, "ret == 0");
    <D.22667>:
  }
  return;
  <D.22660>:
  data->inited = 3;
  D.22668 = data->shutdown;
  D.22669 = data->event_data;
  D.22668 (D.22669);
  {
    int ret;

    D.22650 = &data->io_lock.mutex;
    ret = pthread_mutex_unlock (D.22650);
    if (ret != 0) goto <D.22670>; else goto <D.22671>;
    <D.22670>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.22671>:
    D.22672 = ret != 0;
    D.22673 = (long int) D.22672;
    D.22674 = __builtin_expect (D.22673, 0);
    if (D.22674 != 0) goto <D.22675>; else goto <D.22676>;
    <D.22675>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 324, "ret == 0");
    <D.22676>:
  }
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.22678;
  int D.22681;
  ssize_t D.22684;
  unsigned int D.22685;
  unsigned int D.22686;
  unsigned int D.22689;

  D.22678 = __builtin_object_size (__buf, 0);
  if (D.22678 != 4294967295) goto <D.22679>; else goto <D.22680>;
  <D.22679>:
  D.22681 = __builtin_constant_p (__nbytes);
  if (D.22681 == 0) goto <D.22682>; else goto <D.22683>;
  <D.22682>:
  D.22685 = __builtin_object_size (__buf, 0);
  D.22684 = __read_chk (__fd, __buf, __nbytes, D.22685);
  return D.22684;
  <D.22683>:
  D.22686 = __builtin_object_size (__buf, 0);
  if (D.22686 < __nbytes) goto <D.22687>; else goto <D.22688>;
  <D.22687>:
  D.22689 = __builtin_object_size (__buf, 0);
  D.22684 = __read_chk_warn (__fd, __buf, __nbytes, D.22689);
  return D.22684;
  <D.22688>:
  <D.22680>:
  D.22684 = __read_alias (__fd, __buf, __nbytes);
  return D.22684;
}


tp_poll_modify (void * p, int fd, int operation, int events, gboolean is_new)
{
  union mono_mutex_t * D.22691;
  _Bool D.22694;
  long int D.22695;
  long int D.22696;
  union MonoSemType * D.22699;
  short int D.22700;
  char D.22701;
  int D.22702;
  struct SocketIOData * socket_io_data;
  struct tp_poll_data * data;
  char msg[1];
  int unused;

  try
    {
      socket_io_data = p;
      data = socket_io_data->event_data;
      {
        int ret;

        D.22691 = &socket_io_data->io_lock.mutex;
        ret = pthread_mutex_unlock (D.22691);
        if (ret != 0) goto <D.22692>; else goto <D.22693>;
        <D.22692>:
        monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
        <D.22693>:
        D.22694 = ret != 0;
        D.22695 = (long int) D.22694;
        D.22696 = __builtin_expect (D.22695, 0);
        if (D.22696 != 0) goto <D.22697>; else goto <D.22698>;
        <D.22697>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "../../mono/metadata/tpool-poll.c", 87, "ret == 0");
        <D.22698>:
      }
      D.22699 = &data->new_sem;
      mono_sem_wait (D.22699, 0);
      data->newpfd.fd = fd;
      D.22700 = (short int) events;
      data->newpfd.events = D.22700;
      data->newpfd.revents = 0;
      D.22701 = (char) operation;
      msg[0] = D.22701;
      D.22702 = data->pipe[1];
      unused = write (D.22702, &msg, 1);
    }
  finally
    {
      msg = {CLOBBER};
    }
}


tp_poll_shutdown (void * event_data)
{
  int D.22703;
  int D.22706;
  union MonoSemType * D.22709;
  struct tp_poll_data * data;

  data = event_data;
  D.22703 = data->pipe[0];
  if (D.22703 >= 0) goto <D.22704>; else goto <D.22705>;
  <D.22704>:
  D.22703 = data->pipe[0];
  close (D.22703);
  <D.22705>:
  D.22706 = data->pipe[1];
  if (D.22706 >= 0) goto <D.22707>; else goto <D.22708>;
  <D.22707>:
  D.22706 = data->pipe[1];
  close (D.22706);
  <D.22708>:
  data->pipe[0] = -1;
  data->pipe[1] = -1;
  D.22709 = &data->new_sem;
  sem_destroy (D.22709);
}


get_events_from_list (struct MonoMList * list)
{
  int D.22710;
  int D.22712;
  struct MonoSocketAsyncResult * state;
  int events;

  events = 0;
  goto <D.20887>;
  <D.20886>:
  D.22710 = get_event_from_state (state);
  events = D.22710 | events;
  list = mono_mlist_next (list);
  <D.20887>:
  if (list != 0B) goto <D.22711>; else goto <D.20888>;
  <D.22711>:
  state = mono_mlist_get_data (list);
  if (state != 0B) goto <D.20886>; else goto <D.20888>;
  <D.20888>:
  D.22712 = events;
  return D.22712;
}


mono_thread_pool_add (struct MonoObject * target, struct MonoMethodMessage * msg, struct MonoDelegate * async_callback, struct MonoObject * state)
{
  struct MonoClass * async_call_klass.65;
  struct MonoMethodMessage * * D.22715;
  struct MonoObject * * D.22716;
  struct MonoVTable * D.22719;
  struct MonoClass * D.22720;
  struct MonoMethod * D.22721;
  struct MonoDelegate * * D.22722;
  struct MonoObject * D.22723;
  struct MonoObject * * D.22724;
  int D.22725;
  struct MonoAsyncResult * D.22728;
  struct MonoDomain * domain;
  struct MonoAsyncResult * ares;
  struct ASyncCall * ac;

  domain = mono_domain_get ();
  async_call_klass.65 = async_call_klass;
  ac = mono_object_new (domain, async_call_klass.65);
  D.22715 = &ac->msg;
  mono_gc_wbarrier_set_field (ac, D.22715, msg);
  D.22716 = &ac->state;
  mono_gc_wbarrier_set_field (ac, D.22716, state);
  if (async_callback != 0B) goto <D.22717>; else goto <D.22718>;
  <D.22717>:
  D.22719 = MEM[(struct MonoObject *)async_callback].vtable;
  D.22720 = D.22719->klass;
  D.22721 = mono_get_delegate_invoke (D.22720);
  ac->cb_method = D.22721;
  D.22722 = &ac->cb_target;
  mono_gc_wbarrier_set_field (ac, D.22722, async_callback);
  <D.22718>:
  D.22723 = ac->state;
  ares = mono_async_result_new (domain, 0B, D.22723, 0B, ac);
  D.22724 = &ares->async_delegate;
  mono_gc_wbarrier_set_field (ares, D.22724, target);
  D.22725 = socket_io_filter (target, state);
  if (D.22725 != 0) goto <D.22726>; else goto <D.22727>;
  <D.22726>:
  socket_io_add (ares, state);
  D.22728 = ares;
  return D.22728;
  <D.22727>:
  threadpool_append_job (&async_tp, ares);
  D.22728 = ares;
  return D.22728;
}


socket_io_filter (struct MonoObject * target, struct MonoObject * state)
{
  _Bool D.22730;
  _Bool D.22731;
  _Bool D.22732;
  gboolean D.22735;
  struct MonoVTable * D.22736;
  struct MonoClass * socket_async_call_klass.66;
  int D.22740;
  struct MonoClass * process_async_call_klass.67;
  int D.22746;
  unsigned int op.68;
  gint op;
  struct MonoSocketAsyncResult * sock_res;
  struct MonoClass * klass;
  struct MonoDomain * domain;

  D.22730 = target == 0B;
  D.22731 = state == 0B;
  D.22732 = D.22730 | D.22731;
  if (D.22732 != 0) goto <D.22733>; else goto <D.22734>;
  <D.22733>:
  D.22735 = 0;
  return D.22735;
  <D.22734>:
  D.22736 = target->vtable;
  domain = D.22736->domain;
  D.22736 = target->vtable;
  klass = D.22736->klass;
  socket_async_call_klass.66 = socket_async_call_klass;
  if (socket_async_call_klass.66 == 0B) goto <D.22738>; else goto <D.22739>;
  <D.22738>:
  D.22740 = is_socketasynccall (domain, klass);
  if (D.22740 != 0) goto <D.22741>; else goto <D.22742>;
  <D.22741>:
  socket_async_call_klass = klass;
  <D.22742>:
  <D.22739>:
  process_async_call_klass.67 = process_async_call_klass;
  if (process_async_call_klass.67 == 0B) goto <D.22744>; else goto <D.22745>;
  <D.22744>:
  D.22746 = is_sdp_asyncreadhandler (domain, klass);
  if (D.22746 != 0) goto <D.22747>; else goto <D.22748>;
  <D.22747>:
  process_async_call_klass = klass;
  <D.22748>:
  <D.22745>:
  socket_async_call_klass.66 = socket_async_call_klass;
  if (klass != socket_async_call_klass.66) goto <D.22749>; else goto <D.22750>;
  <D.22749>:
  process_async_call_klass.67 = process_async_call_klass;
  if (klass != process_async_call_klass.67) goto <D.22751>; else goto <D.22752>;
  <D.22751>:
  D.22735 = 0;
  return D.22735;
  <D.22752>:
  <D.22750>:
  sock_res = state;
  op = sock_res->operation;
  op.68 = (unsigned int) op;
  if (op.68 > 13) goto <D.22754>; else goto <D.22755>;
  <D.22754>:
  D.22735 = 0;
  return D.22735;
  <D.22755>:
  D.22735 = 1;
  return D.22735;
}


is_socketasynccall (struct MonoDomain * domain, struct MonoClass * klass)
{
  gboolean D.22757;
  int iftmp.69;
  struct MonoClass * D.22761;
  int D.22763;
  int D.20800;
  int iftmp.70;
  int D.20799;
  const char[16] * D.22768;
  unsigned char D.22769;
  int D.22770;
  unsigned char D.22771;
  int D.22772;
  _Bool D.22773;
  _Bool D.22774;
  _Bool D.22775;
  const unsigned char * D.22778;
  unsigned char D.22779;
  int D.22780;
  const unsigned char * D.22781;
  unsigned char D.22782;
  int D.22783;
  _Bool D.22784;
  _Bool D.22785;
  const unsigned char * D.22788;
  unsigned char D.22789;
  int D.22790;
  const unsigned char * D.22791;
  unsigned char D.22792;
  int D.22793;
  _Bool D.22794;
  _Bool D.22795;
  const unsigned char * D.22798;
  unsigned char D.22799;
  int D.22800;
  const unsigned char * D.22801;
  unsigned char D.22802;
  int D.22803;
  const char * D.22805;

  D.22761 = klass->nested_in;
  if (D.22761 != 0B) goto <D.22762>; else goto <D.22759>;
  <D.22762>:
  D.22761 = klass->nested_in;
  D.22763 = is_socket (domain, D.22761);
  if (D.22763 != 0) goto <D.22764>; else goto <D.22759>;
  <D.22764>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 15;
    if (__s2_len <= 3) goto <D.22766>; else goto <D.22767>;
    <D.22766>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.22768 = "SocketAsyncCall";
      D.22769 = MEM[(const unsigned char *)D.22768];
      D.22770 = (int) D.22769;
      D.22771 = *__s2;
      D.22772 = (int) D.22771;
      __result = D.22770 - D.22772;
      {
        D.22773 = __s2_len != 0;
        D.22774 = __result == 0;
        D.22775 = D.22773 & D.22774;
        if (D.22775 != 0) goto <D.22776>; else goto <D.22777>;
        <D.22776>:
        D.22778 = &MEM[(void *)"SocketAsyncCall" + 1B];
        D.22779 = *D.22778;
        D.22780 = (int) D.22779;
        D.22781 = __s2 + 1;
        D.22782 = *D.22781;
        D.22783 = (int) D.22782;
        __result = D.22780 - D.22783;
        D.22784 = __s2_len > 1;
        D.22774 = __result == 0;
        D.22785 = D.22784 & D.22774;
        if (D.22785 != 0) goto <D.22786>; else goto <D.22787>;
        <D.22786>:
        D.22788 = &MEM[(void *)"SocketAsyncCall" + 2B];
        D.22789 = *D.22788;
        D.22790 = (int) D.22789;
        D.22791 = __s2 + 2;
        D.22792 = *D.22791;
        D.22793 = (int) D.22792;
        __result = D.22790 - D.22793;
        D.22794 = __s2_len > 2;
        D.22774 = __result == 0;
        D.22795 = D.22794 & D.22774;
        if (D.22795 != 0) goto <D.22796>; else goto <D.22797>;
        <D.22796>:
        D.22798 = &MEM[(void *)"SocketAsyncCall" + 3B];
        D.22799 = *D.22798;
        D.22800 = (int) D.22799;
        D.22801 = __s2 + 3;
        D.22802 = *D.22801;
        D.22803 = (int) D.22802;
        __result = D.22800 - D.22803;
        <D.22797>:
        <D.22787>:
        <D.22777>:
      }
      D.20799 = __result;
    }
    iftmp.70 = -D.20799;
    goto <D.22804>;
    <D.22767>:
    D.22805 = klass->name;
    iftmp.70 = __builtin_strcmp (D.22805, "SocketAsyncCall");
    <D.22804>:
    D.20800 = iftmp.70;
  }
  if (D.20800 == 0) goto <D.22806>; else goto <D.22759>;
  <D.22806>:
  iftmp.69 = 1;
  goto <D.22760>;
  <D.22759>:
  iftmp.69 = 0;
  <D.22760>:
  D.22757 = iftmp.69;
  return D.22757;
}


is_sdp_asyncreadhandler (struct MonoDomain * domain, struct MonoClass * klass)
{
  gboolean D.22808;
  int iftmp.71;
  struct MonoClass * D.22812;
  int D.22814;
  int D.20857;
  int iftmp.72;
  int D.20856;
  const char[17] * D.22819;
  unsigned char D.22820;
  int D.22821;
  unsigned char D.22822;
  int D.22823;
  _Bool D.22824;
  _Bool D.22825;
  _Bool D.22826;
  const unsigned char * D.22829;
  unsigned char D.22830;
  int D.22831;
  const unsigned char * D.22832;
  unsigned char D.22833;
  int D.22834;
  _Bool D.22835;
  _Bool D.22836;
  const unsigned char * D.22839;
  unsigned char D.22840;
  int D.22841;
  const unsigned char * D.22842;
  unsigned char D.22843;
  int D.22844;
  _Bool D.22845;
  _Bool D.22846;
  const unsigned char * D.22849;
  unsigned char D.22850;
  int D.22851;
  const unsigned char * D.22852;
  unsigned char D.22853;
  int D.22854;
  const char * D.22856;

  D.22812 = klass->nested_in;
  if (D.22812 != 0B) goto <D.22813>; else goto <D.22810>;
  <D.22813>:
  D.22812 = klass->nested_in;
  D.22814 = is_sd_process (domain, D.22812);
  if (D.22814 != 0) goto <D.22815>; else goto <D.22810>;
  <D.22815>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 16;
    if (__s2_len <= 3) goto <D.22817>; else goto <D.22818>;
    <D.22817>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.22819 = "AsyncReadHandler";
      D.22820 = MEM[(const unsigned char *)D.22819];
      D.22821 = (int) D.22820;
      D.22822 = *__s2;
      D.22823 = (int) D.22822;
      __result = D.22821 - D.22823;
      {
        D.22824 = __s2_len != 0;
        D.22825 = __result == 0;
        D.22826 = D.22824 & D.22825;
        if (D.22826 != 0) goto <D.22827>; else goto <D.22828>;
        <D.22827>:
        D.22829 = &MEM[(void *)"AsyncReadHandler" + 1B];
        D.22830 = *D.22829;
        D.22831 = (int) D.22830;
        D.22832 = __s2 + 1;
        D.22833 = *D.22832;
        D.22834 = (int) D.22833;
        __result = D.22831 - D.22834;
        D.22835 = __s2_len > 1;
        D.22825 = __result == 0;
        D.22836 = D.22835 & D.22825;
        if (D.22836 != 0) goto <D.22837>; else goto <D.22838>;
        <D.22837>:
        D.22839 = &MEM[(void *)"AsyncReadHandler" + 2B];
        D.22840 = *D.22839;
        D.22841 = (int) D.22840;
        D.22842 = __s2 + 2;
        D.22843 = *D.22842;
        D.22844 = (int) D.22843;
        __result = D.22841 - D.22844;
        D.22845 = __s2_len > 2;
        D.22825 = __result == 0;
        D.22846 = D.22845 & D.22825;
        if (D.22846 != 0) goto <D.22847>; else goto <D.22848>;
        <D.22847>:
        D.22849 = &MEM[(void *)"AsyncReadHandler" + 3B];
        D.22850 = *D.22849;
        D.22851 = (int) D.22850;
        D.22852 = __s2 + 3;
        D.22853 = *D.22852;
        D.22854 = (int) D.22853;
        __result = D.22851 - D.22854;
        <D.22848>:
        <D.22838>:
        <D.22828>:
      }
      D.20856 = __result;
    }
    iftmp.72 = -D.20856;
    goto <D.22855>;
    <D.22818>:
    D.22856 = klass->name;
    iftmp.72 = __builtin_strcmp (D.22856, "AsyncReadHandler");
    <D.22855>:
    D.20857 = iftmp.72;
  }
  if (D.20857 == 0) goto <D.22857>; else goto <D.22810>;
  <D.22857>:
  iftmp.71 = 1;
  goto <D.22811>;
  <D.22810>:
  iftmp.71 = 0;
  <D.22811>:
  D.22808 = iftmp.71;
  return D.22808;
}


is_sd_process (struct MonoDomain * domain, struct MonoClass * klass)
{
  struct MonoClass * D.22859;
  gboolean D.22862;
  _Bool D.22863;
  int D.22864;
  int D.20835;
  int iftmp.73;
  int D.20831;
  const char[8] * D.22870;
  unsigned char D.22871;
  int D.22872;
  unsigned char D.22873;
  int D.22874;
  _Bool D.22875;
  _Bool D.22876;
  _Bool D.22877;
  const unsigned char * D.22880;
  unsigned char D.22881;
  int D.22882;
  const unsigned char * D.22883;
  unsigned char D.22884;
  int D.22885;
  _Bool D.22886;
  _Bool D.22887;
  const unsigned char * D.22890;
  unsigned char D.22891;
  int D.22892;
  const unsigned char * D.22893;
  unsigned char D.22894;
  int D.22895;
  _Bool D.22896;
  _Bool D.22897;
  const unsigned char * D.22900;
  unsigned char D.22901;
  int D.22902;
  const unsigned char * D.22903;
  unsigned char D.22904;
  int D.22905;
  const char * D.22907;
  int D.20844;
  int iftmp.74;
  int D.20840;
  const char[19] * D.22913;
  unsigned char D.22914;
  int D.22915;
  unsigned char D.22916;
  int D.22917;
  _Bool D.22918;
  _Bool D.22919;
  _Bool D.22920;
  const unsigned char * D.22923;
  unsigned char D.22924;
  int D.22925;
  const unsigned char * D.22926;
  unsigned char D.22927;
  int D.22928;
  _Bool D.22929;
  _Bool D.22930;
  const unsigned char * D.22933;
  unsigned char D.22934;
  int D.22935;
  const unsigned char * D.22936;
  unsigned char D.22937;
  int D.22938;
  _Bool D.22939;
  _Bool D.22940;
  const unsigned char * D.22943;
  unsigned char D.22944;
  int D.22945;
  const unsigned char * D.22946;
  unsigned char D.22947;
  int D.22948;
  const char * D.22950;

  D.22859 = domain->process_class;
  if (D.22859 != 0B) goto <D.22860>; else goto <D.22861>;
  <D.22860>:
  D.22859 = domain->process_class;
  D.22863 = D.22859 == klass;
  D.22862 = (gboolean) D.22863;
  return D.22862;
  <D.22861>:
  D.22864 = is_system_type (domain, klass);
  if (D.22864 != 0) goto <D.22865>; else goto <D.22866>;
  <D.22865>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 7;
    if (__s1_len <= 3) goto <D.22868>; else goto <D.22869>;
    <D.22868>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.22870 = "Process";
      D.22871 = MEM[(const unsigned char *)D.22870];
      D.22872 = (int) D.22871;
      D.22873 = *__s2;
      D.22874 = (int) D.22873;
      __result = D.22872 - D.22874;
      {
        D.22875 = __s1_len != 0;
        D.22876 = __result == 0;
        D.22877 = D.22875 & D.22876;
        if (D.22877 != 0) goto <D.22878>; else goto <D.22879>;
        <D.22878>:
        D.22880 = &MEM[(void *)"Process" + 1B];
        D.22881 = *D.22880;
        D.22882 = (int) D.22881;
        D.22883 = __s2 + 1;
        D.22884 = *D.22883;
        D.22885 = (int) D.22884;
        __result = D.22882 - D.22885;
        D.22886 = __s1_len > 1;
        D.22876 = __result == 0;
        D.22887 = D.22886 & D.22876;
        if (D.22887 != 0) goto <D.22888>; else goto <D.22889>;
        <D.22888>:
        D.22890 = &MEM[(void *)"Process" + 2B];
        D.22891 = *D.22890;
        D.22892 = (int) D.22891;
        D.22893 = __s2 + 2;
        D.22894 = *D.22893;
        D.22895 = (int) D.22894;
        __result = D.22892 - D.22895;
        D.22896 = __s1_len > 2;
        D.22876 = __result == 0;
        D.22897 = D.22896 & D.22876;
        if (D.22897 != 0) goto <D.22898>; else goto <D.22899>;
        <D.22898>:
        D.22900 = &MEM[(void *)"Process" + 3B];
        D.22901 = *D.22900;
        D.22902 = (int) D.22901;
        D.22903 = __s2 + 3;
        D.22904 = *D.22903;
        D.22905 = (int) D.22904;
        __result = D.22902 - D.22905;
        <D.22899>:
        <D.22889>:
        <D.22879>:
      }
      D.20831 = __result;
    }
    iftmp.73 = D.20831;
    goto <D.22906>;
    <D.22869>:
    D.22907 = klass->name;
    iftmp.73 = __builtin_strcmp ("Process", D.22907);
    <D.22906>:
    D.20835 = iftmp.73;
  }
  if (D.20835 == 0) goto <D.22908>; else goto <D.22909>;
  <D.22908>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 18;
    if (__s1_len <= 3) goto <D.22911>; else goto <D.22912>;
    <D.22911>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name_space;
      D.22913 = "System.Diagnostics";
      D.22914 = MEM[(const unsigned char *)D.22913];
      D.22915 = (int) D.22914;
      D.22916 = *__s2;
      D.22917 = (int) D.22916;
      __result = D.22915 - D.22917;
      {
        D.22918 = __s1_len != 0;
        D.22919 = __result == 0;
        D.22920 = D.22918 & D.22919;
        if (D.22920 != 0) goto <D.22921>; else goto <D.22922>;
        <D.22921>:
        D.22923 = &MEM[(void *)"System.Diagnostics" + 1B];
        D.22924 = *D.22923;
        D.22925 = (int) D.22924;
        D.22926 = __s2 + 1;
        D.22927 = *D.22926;
        D.22928 = (int) D.22927;
        __result = D.22925 - D.22928;
        D.22929 = __s1_len > 1;
        D.22919 = __result == 0;
        D.22930 = D.22929 & D.22919;
        if (D.22930 != 0) goto <D.22931>; else goto <D.22932>;
        <D.22931>:
        D.22933 = &MEM[(void *)"System.Diagnostics" + 2B];
        D.22934 = *D.22933;
        D.22935 = (int) D.22934;
        D.22936 = __s2 + 2;
        D.22937 = *D.22936;
        D.22938 = (int) D.22937;
        __result = D.22935 - D.22938;
        D.22939 = __s1_len > 2;
        D.22919 = __result == 0;
        D.22940 = D.22939 & D.22919;
        if (D.22940 != 0) goto <D.22941>; else goto <D.22942>;
        <D.22941>:
        D.22943 = &MEM[(void *)"System.Diagnostics" + 3B];
        D.22944 = *D.22943;
        D.22945 = (int) D.22944;
        D.22946 = __s2 + 3;
        D.22947 = *D.22946;
        D.22948 = (int) D.22947;
        __result = D.22945 - D.22948;
        <D.22942>:
        <D.22932>:
        <D.22922>:
      }
      D.20840 = __result;
    }
    iftmp.74 = D.20840;
    goto <D.22949>;
    <D.22912>:
    D.22950 = klass->name_space;
    iftmp.74 = __builtin_strcmp ("System.Diagnostics", D.22950);
    <D.22949>:
    D.20844 = iftmp.74;
  }
  if (D.20844 == 0) goto <D.22951>; else goto <D.22952>;
  <D.22951>:
  domain->process_class = klass;
  D.22862 = 1;
  return D.22862;
  <D.22952>:
  <D.22909>:
  <D.22866>:
  D.22862 = 0;
  return D.22862;
}


mono_thread_pool_finish (struct MonoAsyncResult * ares, struct MonoArray * * out_args, struct MonoObject * * exc)
{
  unsigned char D.22954;
  struct MonoException * D.22957;
  struct MonoObject * D.22958;
  unsigned char D.22959;
  struct MonoObject * D.22962;
  _Bool D.22965;
  long int D.22966;
  long int D.22967;
  struct MonoObject * * D.22970;
  struct MonoVTable * D.22971;
  struct MonoDomain * D.22972;
  struct MonoWaitHandle * D.22973;
  _Bool D.22976;
  long int D.22977;
  long int D.22978;
  struct MonoMethodMessage * D.22981;
  struct MonoObject * D.22982;
  struct MonoArray * D.22983;
  struct ASyncCall * ac;
  void * wait_event;

  *exc = 0B;
  *out_args = 0B;
  mono_monitor_enter (ares);
  D.22954 = ares->endinvoke_called;
  if (D.22954 != 0) goto <D.22955>; else goto <D.22956>;
  <D.22955>:
  D.22957 = mono_get_exception_invalid_operation (0B);
  *exc = D.22957;
  mono_monitor_exit (ares);
  D.22958 = 0B;
  return D.22958;
  <D.22956>:
  ares->endinvoke_called = 1;
  D.22959 = ares->completed;
  if (D.22959 == 0) goto <D.22960>; else goto <D.22961>;
  <D.22960>:
  D.22962 = ares->handle;
  if (D.22962 == 0B) goto <D.22963>; else goto <D.22964>;
  <D.22963>:
  wait_event = CreateEvent (0B, 1, 0, 0B);
  D.22965 = wait_event == 0B;
  D.22966 = (long int) D.22965;
  D.22967 = __builtin_expect (D.22966, 0);
  if (D.22967 != 0) goto <D.22968>; else goto <D.22969>;
  <D.22968>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 958, "wait_event != 0");
  <D.22969>:
  D.22970 = &ares->handle;
  D.22971 = MEM[(struct MonoObject *)ares].vtable;
  D.22972 = D.22971->domain;
  D.22973 = mono_wait_handle_new (D.22972, wait_event);
  mono_gc_wbarrier_set_field (ares, D.22970, D.22973);
  goto <D.22974>;
  <D.22964>:
  D.22962 = ares->handle;
  wait_event = mono_wait_handle_get_handle (D.22962);
  <D.22974>:
  mono_monitor_exit (ares);
  WaitForSingleObjectEx (wait_event, 4294967295, 1);
  goto <D.22975>;
  <D.22961>:
  mono_monitor_exit (ares);
  <D.22975>:
  ac = ares->object_data;
  D.22976 = ac == 0B;
  D.22977 = (long int) D.22976;
  D.22978 = __builtin_expect (D.22977, 0);
  if (D.22978 != 0) goto <D.22979>; else goto <D.22980>;
  <D.22979>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 970, "ac != NULL");
  <D.22980>:
  D.22981 = ac->msg;
  D.22982 = D.22981->exc;
  *exc = D.22982;
  D.22983 = ac->out_args;
  *out_args = D.22983;
  D.22958 = ac->res;
  return D.22958;
}


mono_thread_pool_cleanup ()
{
  int D.22985;
  struct MonoCQ * D.22988;
  int D.22991;
  struct GPtrArray * wsqs.75;
  _Bool D.22999;
  long int D.23000;
  long int D.23001;
  _Bool D.23008;
  long int D.23009;
  long int D.23010;

  D.22985 = InterlockedExchange (&async_io_tp.pool_status, 2);
  if (D.22985 == 1) goto <D.22986>; else goto <D.22987>;
  <D.22986>:
  socket_io_cleanup (&socket_io_data);
  threadpool_kill_idle_threads (&async_io_tp);
  <D.22987>:
  D.22988 = async_io_tp.queue;
  if (D.22988 != 0B) goto <D.22989>; else goto <D.22990>;
  <D.22989>:
  sem_destroy (&async_io_tp.new_job);
  threadpool_free_queue (&async_io_tp);
  <D.22990>:
  D.22991 = InterlockedExchange (&async_tp.pool_status, 2);
  if (D.22991 == 1) goto <D.22992>; else goto <D.22993>;
  <D.22992>:
  threadpool_kill_idle_threads (&async_tp);
  threadpool_free_queue (&async_tp);
  <D.22993>:
  wsqs.75 = wsqs;
  if (wsqs.75 != 0B) goto <D.22995>; else goto <D.22996>;
  <D.22995>:
  {
    int ret;

    ret = pthread_mutex_lock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.22997>; else goto <D.22998>;
    <D.22997>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.22998>:
    D.22999 = ret != 0;
    D.23000 = (long int) D.22999;
    D.23001 = __builtin_expect (D.23000, 0);
    if (D.23001 != 0) goto <D.23002>; else goto <D.23003>;
    <D.23002>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1009, "ret == 0");
    <D.23003>:
  }
  mono_wsq_cleanup ();
  wsqs.75 = wsqs;
  if (wsqs.75 != 0B) goto <D.23004>; else goto <D.23005>;
  <D.23004>:
  wsqs.75 = wsqs;
  monoeg_g_ptr_array_free (wsqs.75, 1);
  <D.23005>:
  wsqs = 0B;
  {
    int ret;

    ret = pthread_mutex_unlock (&wsqs_lock.mutex);
    if (ret != 0) goto <D.23006>; else goto <D.23007>;
    <D.23006>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23007>:
    D.23008 = ret != 0;
    D.23009 = (long int) D.23008;
    D.23010 = __builtin_expect (D.23009, 0);
    if (D.23010 != 0) goto <D.23011>; else goto <D.23012>;
    <D.23011>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1014, "ret == 0");
    <D.23012>:
  }
  sem_destroy (&async_tp.new_job);
  <D.22996>:
}


InterlockedExchange (volatile gint32 * val, gint32 new_val)
{
  unsigned int old_val.76;
  unsigned int new_val.77;
  unsigned int D.23015;
  int D.23016;
  gint32 D.23017;
  gint32 old_val;

  <D.19492>:
  old_val = *val;
  old_val.76 = (unsigned int) old_val;
  new_val.77 = (unsigned int) new_val;
  D.23015 = __sync_val_compare_and_swap_4 (val, old_val.76, new_val.77);
  D.23016 = (int) D.23015;
  if (D.23016 != old_val) goto <D.19492>; else goto <D.19493>;
  <D.19493>:
  D.23017 = old_val;
  return D.23017;
}


threadpool_kill_idle_threads (struct ThreadPool * tp)
{
  volatile gint * D.23019;
  union MonoSemType * D.23020;
  gint n;

  D.23019 = &tp->max_threads;
  n = InterlockedCompareExchange (D.23019, 0, -1);
  goto <D.21054>;
  <D.21053>:
  n = n + -1;
  D.23020 = &tp->new_job;
  mono_sem_post (D.23020);
  <D.21054>:
  if (n != 0) goto <D.21053>; else goto <D.21055>;
  <D.21055>:
}


threadpool_free_queue (struct ThreadPool * tp)
{
  struct MonoCQ * D.23021;

  D.23021 = tp->queue;
  mono_cq_destroy (D.23021);
  tp->queue = 0B;
}


icall_append_job (struct MonoObject * ar)
{
  threadpool_append_jobs (&async_tp, &ar, 1);
}


mono_thread_pool_remove_domain_jobs (struct MonoDomain * domain, int timeout)
{
  unsigned int D.23022;
  _Bool D.23023;
  long int D.23024;
  long int D.23025;
  _Bool D.23030;
  long int D.23031;
  long int D.23032;
  struct MonoGHashTable * D.23035;
  _Bool D.23040;
  long int D.23041;
  long int D.23042;
  int D.23045;
  unsigned int timeout.78;
  unsigned int D.23053;
  unsigned int D.23054;
  int D.23057;
  gboolean D.23058;
  void * sem_handle;
  int result;
  guint32 start_time;

  result = 1;
  start_time = 0;
  D.23022 = domain->state;
  D.23023 = D.23022 != 2;
  D.23024 = (long int) D.23023;
  D.23025 = __builtin_expect (D.23024, 0);
  if (D.23025 != 0) goto <D.23026>; else goto <D.23027>;
  <D.23026>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1159, "domain->state == MONO_APPDOMAIN_UNLOADING");
  <D.23027>:
  threadpool_clear_queue (&async_tp, domain);
  threadpool_clear_queue (&async_io_tp, domain);
  {
    int ret;

    ret = pthread_mutex_lock (&socket_io_data.io_lock.mutex);
    if (ret != 0) goto <D.23028>; else goto <D.23029>;
    <D.23028>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_lock result %d", ret);
    <D.23029>:
    D.23030 = ret != 0;
    D.23031 = (long int) D.23030;
    D.23032 = __builtin_expect (D.23031, 0);
    if (D.23032 != 0) goto <D.23033>; else goto <D.23034>;
    <D.23033>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1164, "ret == 0");
    <D.23034>:
  }
  D.23035 = socket_io_data.sock_to_state;
  if (D.23035 != 0B) goto <D.23036>; else goto <D.23037>;
  <D.23036>:
  D.23035 = socket_io_data.sock_to_state;
  mono_g_hash_table_foreach_remove (D.23035, remove_sockstate_for_domain, domain);
  <D.23037>:
  {
    int ret;

    ret = pthread_mutex_unlock (&socket_io_data.io_lock.mutex);
    if (ret != 0) goto <D.23038>; else goto <D.23039>;
    <D.23038>:
    monoeg_g_log (0B, 16, "Bad call to mono_mutex_unlock result %d", ret);
    <D.23039>:
    D.23040 = ret != 0;
    D.23041 = (long int) D.23040;
    D.23042 = __builtin_expect (D.23041, 0);
    if (D.23042 != 0) goto <D.23043>; else goto <D.23044>;
    <D.23043>:
    monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "threadpool.c", 1168, "ret == 0");
    <D.23044>:
  }
  sem_handle = CreateSemaphore (0B, 0, 1, 0B);
  domain->cleanup_semaphore = sem_handle;
  mono_memory_write_barrier ();
  D.23045 = domain->threadpool_jobs;
  if (D.23045 != 0) goto <D.23046>; else goto <D.23047>;
  <D.23046>:
  if (timeout != -1) goto <D.23048>; else goto <D.23049>;
  <D.23048>:
  start_time = mono_msec_ticks ();
  <D.23049>:
  <D.23047>:
  goto <D.21130>;
  <D.21129>:
  timeout.78 = (unsigned int) timeout;
  WaitForSingleObject (sem_handle, timeout.78);
  if (timeout != -1) goto <D.23051>; else goto <D.23052>;
  <D.23051>:
  D.23053 = mono_msec_ticks ();
  D.23054 = D.23053 - start_time;
  timeout.78 = (unsigned int) timeout;
  if (D.23054 > timeout.78) goto <D.23055>; else goto <D.23056>;
  <D.23055>:
  result = 0;
  goto <D.21128>;
  <D.23056>:
  <D.23052>:
  <D.21130>:
  D.23057 = domain->threadpool_jobs;
  if (D.23057 != 0) goto <D.21129>; else goto <D.21128>;
  <D.21128>:
  domain->cleanup_semaphore = 0B;
  CloseHandle (sem_handle);
  D.23058 = result;
  return D.23058;
}


remove_sockstate_for_domain (void * key, void * value, void * user_data)
{
  struct MonoVTable * D.23060;
  struct MonoDomain * D.23061;
  gboolean D.23064;
  struct MonoMList * list;
  gboolean remove;

  list = value;
  remove = 0;
  goto <D.21117>;
  <D.21116>:
  {
    struct MonoObject * data;

    data = mono_mlist_get_data (list);
    D.23060 = data->vtable;
    D.23061 = D.23060->domain;
    if (D.23061 == user_data) goto <D.23062>; else goto <D.23063>;
    <D.23062>:
    remove = 1;
    mono_mlist_set_data (list, 0B);
    <D.23063>:
    list = mono_mlist_next (list);
  }
  <D.21117>:
  if (list != 0B) goto <D.21116>; else goto <D.21118>;
  <D.21118>:
  D.23064 = remove;
  return D.23064;
}


threadpool_clear_queue (struct ThreadPool * tp, struct MonoDomain * domain)
{
  struct MonoObject * obj.79;
  struct MonoVTable * D.23071;
  struct MonoDomain * D.23072;
  int D.23075;
  int D.23076;
  struct MonoObject * D.23079;
  struct MonoObject * obj;
  struct MonoMList * other;
  struct MonoCQ * queue;

  try
    {
      other = 0B;
      queue = tp->queue;
      if (queue == 0B) goto <D.23066>; else goto <D.23067>;
      <D.23066>:
      return;
      <D.23067>:
      goto <D.21102>;
      <D.21103>:
      obj.79 = obj;
      if (obj.79 == 0B) goto <D.23069>; else goto <D.23070>;
      <D.23069>:
      // predicted unlikely by continue predictor.
      goto <D.21102>;
      <D.23070>:
      obj.79 = obj;
      D.23071 = obj.79->vtable;
      D.23072 = D.23071->domain;
      if (D.23072 != domain) goto <D.23073>; else goto <D.23074>;
      <D.23073>:
      obj.79 = obj;
      other = mono_mlist_prepend (other, obj.79);
      <D.23074>:
      obj.79 = obj;
      threadpool_jobs_dec (obj.79);
      <D.21102>:
      D.23075 = mono_cq_dequeue (queue, &obj);
      if (D.23075 != 0) goto <D.21103>; else goto <D.21104>;
      <D.21104>:
      D.23076 = mono_runtime_is_shutting_down ();
      if (D.23076 != 0) goto <D.23077>; else goto <D.23078>;
      <D.23077>:
      return;
      <D.23078>:
      goto <D.21106>;
      <D.21105>:
      D.23079 = mono_mlist_get_data (other);
      threadpool_append_job (tp, D.23079);
      other = mono_mlist_next (other);
      <D.21106>:
      if (other != 0B) goto <D.21105>; else goto <D.21107>;
      <D.21107>:
    }
  finally
    {
      obj = {CLOBBER};
    }
}


mono_memory_write_barrier ()
{
  mono_memory_barrier ();
}


mono_memory_barrier ()
{
  __sync_synchronize ();
}


mono_thread_pool_is_queue_array (struct MonoArray * o)
{
  gboolean D.23083;

  D.23083 = 0;
  return D.23083;
}


ves_icall_System_Threading_ThreadPool_GetAvailableThreads (gint * workerThreads, gint * completionPortThreads)
{
  int D.23085;
  int D.23086;
  int D.23087;
  int D.23088;
  int D.23089;
  int D.23090;

  D.23085 = async_tp.max_threads;
  D.23086 = async_tp.busy_threads;
  D.23087 = D.23085 - D.23086;
  *workerThreads = D.23087;
  D.23088 = async_io_tp.max_threads;
  D.23089 = async_io_tp.busy_threads;
  D.23090 = D.23088 - D.23089;
  *completionPortThreads = D.23090;
}


ves_icall_System_Threading_ThreadPool_GetMaxThreads (gint * workerThreads, gint * completionPortThreads)
{
  int D.23091;
  int D.23092;

  D.23091 = async_tp.max_threads;
  *workerThreads = D.23091;
  D.23092 = async_io_tp.max_threads;
  *completionPortThreads = D.23092;
}


ves_icall_System_Threading_ThreadPool_GetMinThreads (gint * workerThreads, gint * completionPortThreads)
{
  int D.23093;
  int D.23094;

  D.23093 = async_tp.min_threads;
  *workerThreads = D.23093;
  D.23094 = async_io_tp.min_threads;
  *completionPortThreads = D.23094;
}


ves_icall_System_Threading_ThreadPool_SetMinThreads (gint workerThreads, gint completionPortThreads)
{
  _Bool D.23095;
  _Bool D.23096;
  _Bool D.23097;
  MonoBoolean D.23100;
  _Bool D.23101;
  _Bool D.23102;
  _Bool D.23103;
  int D.23106;
  struct MonoDomain * D.23109;
  int D.23110;
  struct MonoDomain * D.23113;
  gint max_threads;
  gint max_io_threads;

  max_threads = async_tp.max_threads;
  D.23095 = workerThreads <= 0;
  D.23096 = workerThreads > max_threads;
  D.23097 = D.23095 | D.23096;
  if (D.23097 != 0) goto <D.23098>; else goto <D.23099>;
  <D.23098>:
  D.23100 = 0;
  return D.23100;
  <D.23099>:
  max_io_threads = async_io_tp.max_threads;
  D.23101 = completionPortThreads <= 0;
  D.23102 = completionPortThreads > max_io_threads;
  D.23103 = D.23101 | D.23102;
  if (D.23103 != 0) goto <D.23104>; else goto <D.23105>;
  <D.23104>:
  D.23100 = 0;
  return D.23100;
  <D.23105>:
  InterlockedExchange (&async_tp.min_threads, workerThreads);
  InterlockedExchange (&async_io_tp.min_threads, completionPortThreads);
  D.23106 = async_tp.nthreads;
  if (D.23106 < workerThreads) goto <D.23107>; else goto <D.23108>;
  <D.23107>:
  D.23109 = mono_get_root_domain ();
  mono_thread_create_internal (D.23109, threadpool_start_idle_threads, &async_tp, 1, 0, 131072);
  <D.23108>:
  D.23110 = async_io_tp.nthreads;
  if (D.23110 < completionPortThreads) goto <D.23111>; else goto <D.23112>;
  <D.23111>:
  D.23113 = mono_get_root_domain ();
  mono_thread_create_internal (D.23113, threadpool_start_idle_threads, &async_io_tp, 1, 0, 131072);
  <D.23112>:
  D.23100 = 1;
  return D.23100;
}


ves_icall_System_Threading_ThreadPool_SetMaxThreads (gint workerThreads, gint completionPortThreads)
{
  _Bool D.23115;
  _Bool D.23116;
  _Bool D.23117;
  MonoBoolean D.23120;
  _Bool D.23121;
  _Bool D.23122;
  _Bool D.23123;
  gint min_threads;
  gint min_io_threads;
  gint cpu_count;

  cpu_count = mono_cpu_count ();
  min_threads = async_tp.min_threads;
  D.23115 = workerThreads < min_threads;
  D.23116 = workerThreads < cpu_count;
  D.23117 = D.23115 | D.23116;
  if (D.23117 != 0) goto <D.23118>; else goto <D.23119>;
  <D.23118>:
  D.23120 = 0;
  return D.23120;
  <D.23119>:
  min_io_threads = async_io_tp.min_threads;
  D.23121 = completionPortThreads < min_io_threads;
  D.23122 = completionPortThreads < cpu_count;
  D.23123 = D.23121 | D.23122;
  if (D.23123 != 0) goto <D.23124>; else goto <D.23125>;
  <D.23124>:
  D.23120 = 0;
  return D.23120;
  <D.23125>:
  InterlockedExchange (&async_tp.max_threads, workerThreads);
  InterlockedExchange (&async_io_tp.max_threads, completionPortThreads);
  D.23120 = 1;
  return D.23120;
}


mono_install_threadpool_thread_hooks (void (*MonoThreadPoolFunc) (void *) start_func, void (*MonoThreadPoolFunc) (void *) finish_func, void * user_data)
{
  tp_start_func = start_func;
  tp_finish_func = finish_func;
  tp_hooks_user_data = user_data;
}


mono_install_threadpool_item_hooks (void (*MonoThreadPoolItemFunc) (void *) begin_func, void (*MonoThreadPoolItemFunc) (void *) end_func, void * user_data)
{
  tp_item_begin_func = begin_func;
  tp_item_end_func = end_func;
  tp_item_user_data = user_data;
}


mono_internal_thread_unhandled_exception (struct MonoObject * exc)
{
  <unnamed type> D.23127;
  struct MonoVTable * D.23130;
  struct MonoDomain * D.23131;
  struct MonoClass * D.23134;
  int D.23137;
  struct MonoInternalThread * D.23142;

  D.23127 = mono_runtime_unhandled_exception_policy_get ();
  if (D.23127 == 1) goto <D.23128>; else goto <D.23129>;
  <D.23128>:
  {
    gboolean unloaded;
    struct MonoClass * klass;

    D.23130 = exc->vtable;
    klass = D.23130->klass;
    D.23130 = exc->vtable;
    D.23131 = D.23130->domain;
    unloaded = is_appdomainunloaded_exception (D.23131, klass);
    if (unloaded == 0) goto <D.23132>; else goto <D.23133>;
    <D.23132>:
    D.23134 = mono_defaults.threadabortexception_class;
    if (D.23134 != klass) goto <D.23135>; else goto <D.23136>;
    <D.23135>:
    mono_unhandled_exception (exc);
    D.23137 = mono_environment_exitcode_get ();
    if (D.23137 == 1) goto <D.23138>; else goto <D.23139>;
    <D.23138>:
    exit (255);
    <D.23139>:
    <D.23136>:
    <D.23133>:
    D.23134 = mono_defaults.threadabortexception_class;
    if (D.23134 == klass) goto <D.23140>; else goto <D.23141>;
    <D.23140>:
    D.23142 = mono_thread_internal_current ();
    mono_thread_internal_reset_abort (D.23142);
    <D.23141>:
  }
  <D.23129>:
}


is_appdomainunloaded_exception (struct MonoDomain * domain, struct MonoClass * klass)
{
  struct MonoClass * D.23143;
  gboolean D.23146;
  _Bool D.23147;
  int D.23148;
  int D.20813;
  int iftmp.80;
  int D.20809;
  const char[27] * D.23154;
  unsigned char D.23155;
  int D.23156;
  unsigned char D.23157;
  int D.23158;
  _Bool D.23159;
  _Bool D.23160;
  _Bool D.23161;
  const unsigned char * D.23164;
  unsigned char D.23165;
  int D.23166;
  const unsigned char * D.23167;
  unsigned char D.23168;
  int D.23169;
  _Bool D.23170;
  _Bool D.23171;
  const unsigned char * D.23174;
  unsigned char D.23175;
  int D.23176;
  const unsigned char * D.23177;
  unsigned char D.23178;
  int D.23179;
  _Bool D.23180;
  _Bool D.23181;
  const unsigned char * D.23184;
  unsigned char D.23185;
  int D.23186;
  const unsigned char * D.23187;
  unsigned char D.23188;
  int D.23189;
  const char * D.23191;
  int D.20822;
  int iftmp.81;
  int D.20818;
  const char[7] * D.23197;
  unsigned char D.23198;
  int D.23199;
  unsigned char D.23200;
  int D.23201;
  _Bool D.23202;
  _Bool D.23203;
  _Bool D.23204;
  const unsigned char * D.23207;
  unsigned char D.23208;
  int D.23209;
  const unsigned char * D.23210;
  unsigned char D.23211;
  int D.23212;
  _Bool D.23213;
  _Bool D.23214;
  const unsigned char * D.23217;
  unsigned char D.23218;
  int D.23219;
  const unsigned char * D.23220;
  unsigned char D.23221;
  int D.23222;
  _Bool D.23223;
  _Bool D.23224;
  const unsigned char * D.23227;
  unsigned char D.23228;
  int D.23229;
  const unsigned char * D.23230;
  unsigned char D.23231;
  int D.23232;
  const char * D.23234;

  D.23143 = domain->ad_unloaded_ex_class;
  if (D.23143 != 0B) goto <D.23144>; else goto <D.23145>;
  <D.23144>:
  D.23143 = domain->ad_unloaded_ex_class;
  D.23147 = D.23143 == klass;
  D.23146 = (gboolean) D.23147;
  return D.23146;
  <D.23145>:
  D.23148 = is_corlib_type (domain, klass);
  if (D.23148 != 0) goto <D.23149>; else goto <D.23150>;
  <D.23149>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 26;
    if (__s1_len <= 3) goto <D.23152>; else goto <D.23153>;
    <D.23152>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name;
      D.23154 = "AppDomainUnloadedException";
      D.23155 = MEM[(const unsigned char *)D.23154];
      D.23156 = (int) D.23155;
      D.23157 = *__s2;
      D.23158 = (int) D.23157;
      __result = D.23156 - D.23158;
      {
        D.23159 = __s1_len != 0;
        D.23160 = __result == 0;
        D.23161 = D.23159 & D.23160;
        if (D.23161 != 0) goto <D.23162>; else goto <D.23163>;
        <D.23162>:
        D.23164 = &MEM[(void *)"AppDomainUnloadedException" + 1B];
        D.23165 = *D.23164;
        D.23166 = (int) D.23165;
        D.23167 = __s2 + 1;
        D.23168 = *D.23167;
        D.23169 = (int) D.23168;
        __result = D.23166 - D.23169;
        D.23170 = __s1_len > 1;
        D.23160 = __result == 0;
        D.23171 = D.23170 & D.23160;
        if (D.23171 != 0) goto <D.23172>; else goto <D.23173>;
        <D.23172>:
        D.23174 = &MEM[(void *)"AppDomainUnloadedException" + 2B];
        D.23175 = *D.23174;
        D.23176 = (int) D.23175;
        D.23177 = __s2 + 2;
        D.23178 = *D.23177;
        D.23179 = (int) D.23178;
        __result = D.23176 - D.23179;
        D.23180 = __s1_len > 2;
        D.23160 = __result == 0;
        D.23181 = D.23180 & D.23160;
        if (D.23181 != 0) goto <D.23182>; else goto <D.23183>;
        <D.23182>:
        D.23184 = &MEM[(void *)"AppDomainUnloadedException" + 3B];
        D.23185 = *D.23184;
        D.23186 = (int) D.23185;
        D.23187 = __s2 + 3;
        D.23188 = *D.23187;
        D.23189 = (int) D.23188;
        __result = D.23186 - D.23189;
        <D.23183>:
        <D.23173>:
        <D.23163>:
      }
      D.20809 = __result;
    }
    iftmp.80 = D.20809;
    goto <D.23190>;
    <D.23153>:
    D.23191 = klass->name;
    iftmp.80 = __builtin_strcmp ("AppDomainUnloadedException", D.23191);
    <D.23190>:
    D.20813 = iftmp.80;
  }
  if (D.20813 == 0) goto <D.23192>; else goto <D.23193>;
  <D.23192>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s1_len = 6;
    if (__s1_len <= 3) goto <D.23195>; else goto <D.23196>;
    <D.23195>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = klass->name_space;
      D.23197 = "System";
      D.23198 = MEM[(const unsigned char *)D.23197];
      D.23199 = (int) D.23198;
      D.23200 = *__s2;
      D.23201 = (int) D.23200;
      __result = D.23199 - D.23201;
      {
        D.23202 = __s1_len != 0;
        D.23203 = __result == 0;
        D.23204 = D.23202 & D.23203;
        if (D.23204 != 0) goto <D.23205>; else goto <D.23206>;
        <D.23205>:
        D.23207 = &MEM[(void *)"System" + 1B];
        D.23208 = *D.23207;
        D.23209 = (int) D.23208;
        D.23210 = __s2 + 1;
        D.23211 = *D.23210;
        D.23212 = (int) D.23211;
        __result = D.23209 - D.23212;
        D.23213 = __s1_len > 1;
        D.23203 = __result == 0;
        D.23214 = D.23213 & D.23203;
        if (D.23214 != 0) goto <D.23215>; else goto <D.23216>;
        <D.23215>:
        D.23217 = &MEM[(void *)"System" + 2B];
        D.23218 = *D.23217;
        D.23219 = (int) D.23218;
        D.23220 = __s2 + 2;
        D.23221 = *D.23220;
        D.23222 = (int) D.23221;
        __result = D.23219 - D.23222;
        D.23223 = __s1_len > 2;
        D.23203 = __result == 0;
        D.23224 = D.23223 & D.23203;
        if (D.23224 != 0) goto <D.23225>; else goto <D.23226>;
        <D.23225>:
        D.23227 = &MEM[(void *)"System" + 3B];
        D.23228 = *D.23227;
        D.23229 = (int) D.23228;
        D.23230 = __s2 + 3;
        D.23231 = *D.23230;
        D.23232 = (int) D.23231;
        __result = D.23229 - D.23232;
        <D.23226>:
        <D.23216>:
        <D.23206>:
      }
      D.20818 = __result;
    }
    iftmp.81 = D.20818;
    goto <D.23233>;
    <D.23196>:
    D.23234 = klass->name_space;
    iftmp.81 = __builtin_strcmp ("System", D.23234);
    <D.23233>:
    D.20822 = iftmp.81;
  }
  if (D.20822 == 0) goto <D.23235>; else goto <D.23236>;
  <D.23235>:
  domain->ad_unloaded_ex_class = klass;
  D.23146 = 1;
  return D.23146;
  <D.23236>:
  <D.23193>:
  <D.23150>:
  D.23146 = 0;
  return D.23146;
}


mono_thread_pool_suspend ()
{
  suspended = 1;
}


mono_thread_pool_resume ()
{
  suspended = 0;
}


