mono_attach_parse_options (char * options)
{
  int D.18564;
  int iftmp.0;
  int D.18563;
  const char[8] * D.18654;
  unsigned char D.18655;
  int D.18656;
  unsigned char D.18657;
  int D.18658;
  const unsigned char * D.18663;
  unsigned char D.18664;
  int D.18665;
  const unsigned char * D.18666;
  unsigned char D.18667;
  int D.18668;
  const unsigned char * D.18673;
  unsigned char D.18674;
  int D.18675;
  const unsigned char * D.18676;
  unsigned char D.18677;
  int D.18678;
  const unsigned char * D.18683;
  unsigned char D.18684;
  int D.18685;
  const unsigned char * D.18686;
  unsigned char D.18687;
  int D.18688;

  if (options == 0B) goto <D.18649>; else goto <D.18650>;
  <D.18649>:
  return;
  <D.18650>:
  {
    size_t __s1_len;
    size_t __s2_len;

    __s2_len = 7;
    if (__s2_len <= 3) goto <D.18652>; else goto <D.18653>;
    <D.18652>:
    {
      const unsigned char * __s2;
      int __result;

      __s2 = options;
      D.18654 = "disable";
      D.18655 = MEM[(const unsigned char *)D.18654];
      D.18656 = (int) D.18655;
      D.18657 = *__s2;
      D.18658 = (int) D.18657;
      __result = D.18656 - D.18658;
      {
        if (__s2_len != 0) goto <D.18659>; else goto <D.18660>;
        <D.18659>:
        if (__result == 0) goto <D.18661>; else goto <D.18662>;
        <D.18661>:
        D.18663 = &MEM[(void *)"disable" + 1B];
        D.18664 = *D.18663;
        D.18665 = (int) D.18664;
        D.18666 = __s2 + 1;
        D.18667 = *D.18666;
        D.18668 = (int) D.18667;
        __result = D.18665 - D.18668;
        if (__s2_len > 1) goto <D.18669>; else goto <D.18670>;
        <D.18669>:
        if (__result == 0) goto <D.18671>; else goto <D.18672>;
        <D.18671>:
        D.18673 = &MEM[(void *)"disable" + 2B];
        D.18674 = *D.18673;
        D.18675 = (int) D.18674;
        D.18676 = __s2 + 2;
        D.18677 = *D.18676;
        D.18678 = (int) D.18677;
        __result = D.18675 - D.18678;
        if (__s2_len > 2) goto <D.18679>; else goto <D.18680>;
        <D.18679>:
        if (__result == 0) goto <D.18681>; else goto <D.18682>;
        <D.18681>:
        D.18683 = &MEM[(void *)"disable" + 3B];
        D.18684 = *D.18683;
        D.18685 = (int) D.18684;
        D.18686 = __s2 + 3;
        D.18687 = *D.18686;
        D.18688 = (int) D.18687;
        __result = D.18685 - D.18688;
        <D.18682>:
        <D.18680>:
        <D.18672>:
        <D.18670>:
        <D.18662>:
        <D.18660>:
      }
      D.18563 = __result;
    }
    iftmp.0 = -D.18563;
    goto <D.18689>;
    <D.18653>:
    iftmp.0 = __builtin_strcmp (options, "disable");
    <D.18689>:
    D.18564 = iftmp.0;
  }
  if (D.18564 == 0) goto <D.18690>; else goto <D.18691>;
  <D.18690>:
  config.enabled = 0;
  <D.18691>:
}


mono_attach_init ()
{
  InitializeCriticalSection (&agent_mutex);
  config.enabled = 1;
}


mono_attach_start ()
{
  int started.1;
  gboolean D.18696;
  int D.18697;
  int D.18700;
  char path[256];
  int fd;

  try
    {
      started.1 = started;
      if (started.1 != 0) goto <D.18694>; else goto <D.18695>;
      <D.18694>:
      D.18696 = 0;
      return D.18696;
      <D.18695>:
      D.18697 = getpid ();
      snprintf (&path, 256, "/tmp/.mono_attach_pid%d", D.18697);
      fd = open (&path, 0);
      if (fd == -1) goto <D.18698>; else goto <D.18699>;
      <D.18698>:
      D.18696 = 0;
      return D.18696;
      <D.18699>:
      close (fd);
      D.18700 = config.enabled;
      if (D.18700 == 0) goto <D.18701>; else goto <D.18702>;
      <D.18701>:
      D.18696 = 1;
      return D.18696;
      <D.18702>:
      started.1 = started;
      if (started.1 != 0) goto <D.18703>; else goto <D.18704>;
      <D.18703>:
      D.18696 = 0;
      return D.18696;
      <D.18704>:
      needs_to_start = 1;
      mono_gc_finalize_notify ();
      D.18696 = 1;
      return D.18696;
    }
  finally
    {
      path = {CLOBBER};
    }
}


snprintf (char * restrict __s, size_t __n, const char * restrict __fmt)
{
  int D.18707;
  long unsigned int D.18708;

  D.18708 = __builtin_object_size (__s, 1);
  D.18707 = __builtin___snprintf_chk (__s, __n, 1, D.18708, __fmt, __builtin_va_arg_pack ());
  return D.18707;
}


open (const char * __path, int __oflag)
{
  int D.18710;
  int D.18713;
  int D.18718;
  int D.18720;
  int D.18721;
  int D.18724;
  int D.18725;

  D.18710 = __builtin_va_arg_pack_len ();
  if (D.18710 > 1) goto <D.18711>; else goto <D.18712>;
  <D.18711>:
  __open_too_many_args ();
  <D.18712>:
  D.18713 = __builtin_constant_p (__oflag);
  if (D.18713 != 0) goto <D.18714>; else goto <D.18715>;
  <D.18714>:
  D.18718 = __oflag & 64;
  if (D.18718 != 0) goto <D.18716>; else goto <D.18719>;
  <D.18719>:
  D.18720 = __oflag & 4259840;
  if (D.18720 == 4259840) goto <D.18716>; else goto <D.18717>;
  <D.18716>:
  D.18721 = __builtin_va_arg_pack_len ();
  if (D.18721 <= 0) goto <D.18722>; else goto <D.18723>;
  <D.18722>:
  __open_missing_mode ();
  D.18724 = __open_2 (__path, __oflag);
  return D.18724;
  <D.18723>:
  <D.18717>:
  D.18724 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.18724;
  <D.18715>:
  D.18725 = __builtin_va_arg_pack_len ();
  if (D.18725 <= 0) goto <D.18726>; else goto <D.18727>;
  <D.18726>:
  D.18724 = __open_2 (__path, __oflag);
  return D.18724;
  <D.18727>:
  D.18724 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.18724;
}


mono_attach_maybe_start ()
{
  int needs_to_start.2;
  int started.3;

  needs_to_start.2 = needs_to_start;
  if (needs_to_start.2 == 0) goto <D.18730>; else goto <D.18731>;
  <D.18730>:
  return;
  <D.18731>:
  needs_to_start = 0;
  started.3 = started;
  if (started.3 == 0) goto <D.18733>; else goto <D.18734>;
  <D.18733>:
  transport_start_receive ();
  started = 1;
  <D.18734>:
}


transport_start_receive ()
{
  int listen_fd.4;
  void * receiver_thread_handle.5;
  void * receiver_thread_handle.6;
  _Bool D.18741;
  long int D.18742;
  long int D.18743;

  transport_connect ();
  listen_fd.4 = listen_fd;
  if (listen_fd.4 == 0) goto <D.18737>; else goto <D.18738>;
  <D.18737>:
  return;
  <D.18738>:
  receiver_thread_handle.5 = mono_threads_create_thread (receiver_thread, 0B, 0, 0, 0B);
  receiver_thread_handle = receiver_thread_handle.5;
  receiver_thread_handle.6 = receiver_thread_handle;
  D.18741 = receiver_thread_handle.6 == 0B;
  D.18742 = (long int) D.18741;
  D.18743 = __builtin_expect (D.18742, 0);
  if (D.18743 != 0) goto <D.18744>; else goto <D.18745>;
  <D.18744>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 482, "receiver_thread_handle");
  <D.18745>:
}


receiver_thread (void * arg)
{
  char * server_uri.7;
  int listen_fd.8;
  union 
{
  struct sockaddr * restrict __sockaddr__;
  struct sockaddr_at * restrict __sockaddr_at__;
  struct sockaddr_ax25 * restrict __sockaddr_ax25__;
  struct sockaddr_dl * restrict __sockaddr_dl__;
  struct sockaddr_eon * restrict __sockaddr_eon__;
  struct sockaddr_in * restrict __sockaddr_in__;
  struct sockaddr_in6 * restrict __sockaddr_in6__;
  struct sockaddr_inarp * restrict __sockaddr_inarp__;
  struct sockaddr_ipx * restrict __sockaddr_ipx__;
  struct sockaddr_iso * restrict __sockaddr_iso__;
  struct sockaddr_ns * restrict __sockaddr_ns__;
  struct sockaddr_un * restrict __sockaddr_un__;
  struct sockaddr_x25 * restrict __sockaddr_x25__;
} D.18749;
  int conn_fd.9;
  int conn_fd.10;
  guint32 D.18754;
  struct MonoDomain * D.18755;
  struct MonoInternalThread * D.18756;
  unsigned int D.18757;
  unsigned int D.18758;
  long int D.18759;
  int * D.18762;
  int D.18763;
  int stop_receiver_thread.11;
  int D.18772;
  unsigned char D.18774;
  unsigned char D.18776;
  struct _IO_FILE * stderr.12;
  long int D.18778;
  guint8 * p.13;
  long unsigned int D.18781;
  long unsigned int D.18782;
  long int D.18783;
  sizetype D.18784;
  int D.18644;
  int iftmp.14;
  int D.18643;
  const char[7] * D.18789;
  unsigned char D.18790;
  int D.18791;
  unsigned char D.18792;
  int D.18793;
  const unsigned char * D.18798;
  unsigned char D.18799;
  int D.18800;
  const unsigned char * D.18801;
  unsigned char D.18802;
  int D.18803;
  const unsigned char * D.18808;
  unsigned char D.18809;
  int D.18810;
  const unsigned char * D.18811;
  unsigned char D.18812;
  int D.18813;
  const unsigned char * D.18818;
  unsigned char D.18819;
  int D.18820;
  const unsigned char * D.18821;
  unsigned char D.18822;
  int D.18823;
  _Bool D.18825;
  long int D.18826;
  long int D.18827;
  struct MonoDomain * D.18830;
  int res;
  int content_len;
  guint8 buffer[256];
  guint8 * p;
  guint8 * p_end;
  struct MonoObject * exc;

  try
    {
      server_uri.7 = server_uri;
      printf ("attach: Listening on \'%s\'...\n", server_uri.7);
      <D.18647>:
      listen_fd.8 = listen_fd;
      D.18749.__sockaddr__ = 0B;
      conn_fd.9 = accept (listen_fd.8, D.18749, 0B);
      conn_fd = conn_fd.9;
      conn_fd.10 = conn_fd;
      if (conn_fd.10 == -1) goto <D.18752>; else goto <D.18753>;
      <D.18752>:
      D.18754 = 0;
      return D.18754;
      <D.18753>:
      printf ("attach: Connected.\n");
      D.18755 = mono_get_root_domain ();
      mono_thread_attach (D.18755);
      D.18756 = mono_thread_internal_current ();
      D.18757 = D.18756->state;
      D.18758 = D.18757 | 4;
      D.18756->state = D.18758;
      <D.18645>:
      {
        char * cmd;
        char * agent_name;
        char * agent_args;
        guint8 * body;

        conn_fd.10 = conn_fd;
        D.18759 = read (conn_fd.10, &buffer, 6);
        res = (int) D.18759;
        if (res == -1) goto <D.18760>; else goto <D.18761>;
        <D.18760>:
        D.18762 = __errno_location ();
        D.18763 = *D.18762;
        if (D.18763 == 4) goto <D.18764>; else goto <D.18765>;
        <D.18764>:
        // predicted unlikely by continue predictor.
        goto <D.18625>;
        <D.18765>:
        <D.18761>:
        if (res == -1) goto <D.18626>; else goto <D.18766>;
        <D.18766>:
        stop_receiver_thread.11 = stop_receiver_thread;
        if (stop_receiver_thread.11 != 0) goto <D.18626>; else goto <D.18768>;
        <D.18768>:
        if (res != 6) goto <D.18626>; else goto <D.18769>;
        <D.18769>:
        D.18772 = strncmp (&buffer, "MONO", 4);
        if (D.18772 != 0) goto <D.18770>; else goto <D.18773>;
        <D.18773>:
        D.18774 = buffer[4];
        if (D.18774 != 1) goto <D.18770>; else goto <D.18775>;
        <D.18775>:
        D.18776 = buffer[5];
        if (D.18776 != 0) goto <D.18770>; else goto <D.18771>;
        <D.18770>:
        stderr.12 = stderr;
        fprintf (stderr.12, "attach: message from server has unknown header.\n");
        goto <D.18626>;
        <D.18771>:
        conn_fd.10 = conn_fd;
        D.18778 = read (conn_fd.10, &buffer, 4);
        res = (int) D.18778;
        if (res != 4) goto <D.18626>; else goto <D.18779>;
        <D.18779>:
        p = &buffer;
        p.13 = p;
        p_end = p.13 + 8;
        p.13 = p;
        content_len = decode_int (p.13, &p, p_end);
        D.18781 = (long unsigned int) content_len;
        body = monoeg_malloc (D.18781);
        conn_fd.10 = conn_fd;
        D.18782 = (long unsigned int) content_len;
        D.18783 = read (conn_fd.10, body, D.18782);
        res = (int) D.18783;
        p = body;
        D.18784 = (sizetype) content_len;
        p_end = body + D.18784;
        p.13 = p;
        cmd = decode_string_value (p.13, &p, p_end);
        if (cmd == 0B) goto <D.18626>; else goto <D.18785>;
        <D.18785>:
        {
          size_t __s1_len;
          size_t __s2_len;

          __s2_len = 6;
          if (__s2_len <= 3) goto <D.18787>; else goto <D.18788>;
          <D.18787>:
          {
            const unsigned char * __s2;
            int __result;

            __s2 = cmd;
            D.18789 = "attach";
            D.18790 = MEM[(const unsigned char *)D.18789];
            D.18791 = (int) D.18790;
            D.18792 = *__s2;
            D.18793 = (int) D.18792;
            __result = D.18791 - D.18793;
            {
              if (__s2_len != 0) goto <D.18794>; else goto <D.18795>;
              <D.18794>:
              if (__result == 0) goto <D.18796>; else goto <D.18797>;
              <D.18796>:
              D.18798 = &MEM[(void *)"attach" + 1B];
              D.18799 = *D.18798;
              D.18800 = (int) D.18799;
              D.18801 = __s2 + 1;
              D.18802 = *D.18801;
              D.18803 = (int) D.18802;
              __result = D.18800 - D.18803;
              if (__s2_len > 1) goto <D.18804>; else goto <D.18805>;
              <D.18804>:
              if (__result == 0) goto <D.18806>; else goto <D.18807>;
              <D.18806>:
              D.18808 = &MEM[(void *)"attach" + 2B];
              D.18809 = *D.18808;
              D.18810 = (int) D.18809;
              D.18811 = __s2 + 2;
              D.18812 = *D.18811;
              D.18813 = (int) D.18812;
              __result = D.18810 - D.18813;
              if (__s2_len > 2) goto <D.18814>; else goto <D.18815>;
              <D.18814>:
              if (__result == 0) goto <D.18816>; else goto <D.18817>;
              <D.18816>:
              D.18818 = &MEM[(void *)"attach" + 3B];
              D.18819 = *D.18818;
              D.18820 = (int) D.18819;
              D.18821 = __s2 + 3;
              D.18822 = *D.18821;
              D.18823 = (int) D.18822;
              __result = D.18820 - D.18823;
              <D.18817>:
              <D.18815>:
              <D.18807>:
              <D.18805>:
              <D.18797>:
              <D.18795>:
            }
            D.18643 = __result;
          }
          iftmp.14 = -D.18643;
          goto <D.18824>;
          <D.18788>:
          iftmp.14 = __builtin_strcmp (cmd, "attach");
          <D.18824>:
          D.18644 = iftmp.14;
        }
        D.18825 = D.18644 != 0;
        D.18826 = (long int) D.18825;
        D.18827 = __builtin_expect (D.18826, 0);
        if (D.18827 != 0) goto <D.18828>; else goto <D.18829>;
        <D.18828>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 550, "!strcmp (cmd, \"attach\")");
        <D.18829>:
        p.13 = p;
        agent_name = decode_string_value (p.13, &p, p_end);
        p.13 = p;
        agent_args = decode_string_value (p.13, &p, p_end);
        printf ("attach: Loading agent \'%s\'.\n", agent_name);
        D.18830 = mono_domain_get ();
        mono_attach_load_agent (D.18830, agent_name, agent_args, &exc);
        monoeg_g_free (body);
      }
      <D.18625>:
      goto <D.18645>;
      <D.18626>:
      conn_fd.10 = conn_fd;
      close (conn_fd.10);
      conn_fd = 0;
      printf ("attach: Disconnected.\n");
      stop_receiver_thread.11 = stop_receiver_thread;
      if (stop_receiver_thread.11 != 0) goto <D.18646>; else goto <D.18831>;
      <D.18831>:
      goto <D.18647>;
      <D.18646>:
      D.18754 = 0;
      return D.18754;
    }
  finally
    {
      buffer = {CLOBBER};
      p = {CLOBBER};
      exc = {CLOBBER};
    }
}


fprintf (struct FILE * restrict __stream, const char * restrict __fmt)
{
  int D.18834;

  D.18834 = __fprintf_chk (__stream, 1, __fmt, __builtin_va_arg_pack ());
  return D.18834;
}


decode_int (guint8 * buf, guint8 * * endbuf, guint8 * limit)
{
  guint8 * D.18836;
  guint8 * D.18837;
  _Bool D.18838;
  long int D.18839;
  long int D.18840;
  int D.18843;
  unsigned char D.18844;
  int D.18845;
  guint8 * D.18846;
  unsigned char D.18847;
  int D.18848;
  int D.18849;
  int D.18850;
  guint8 * D.18851;
  unsigned char D.18852;
  int D.18853;
  int D.18854;
  int D.18855;
  guint8 * D.18856;
  unsigned char D.18857;
  int D.18858;
  int D.18859;

  D.18836 = buf + 4;
  *endbuf = D.18836;
  D.18837 = *endbuf;
  D.18838 = D.18837 > limit;
  D.18839 = (long int) D.18838;
  D.18840 = __builtin_expect (D.18839, 0);
  if (D.18840 != 0) goto <D.18841>; else goto <D.18842>;
  <D.18841>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 126, "*endbuf <= limit");
  <D.18842>:
  D.18844 = *buf;
  D.18845 = (int) D.18844;
  D.18846 = buf + 1;
  D.18847 = *D.18846;
  D.18848 = (int) D.18847;
  D.18849 = D.18848 << 8;
  D.18850 = D.18845 | D.18849;
  D.18851 = buf + 2;
  D.18852 = *D.18851;
  D.18853 = (int) D.18852;
  D.18854 = D.18853 << 16;
  D.18855 = D.18850 | D.18854;
  D.18856 = buf + 3;
  D.18857 = *D.18856;
  D.18858 = (int) D.18857;
  D.18859 = D.18858 << 24;
  D.18843 = D.18855 | D.18859;
  return D.18843;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.18861;
  int D.18864;
  ssize_t D.18867;
  long unsigned int D.18868;
  long unsigned int D.18869;
  long unsigned int D.18872;

  D.18861 = __builtin_object_size (__buf, 0);
  if (D.18861 != 18446744073709551615) goto <D.18862>; else goto <D.18863>;
  <D.18862>:
  D.18864 = __builtin_constant_p (__nbytes);
  if (D.18864 == 0) goto <D.18865>; else goto <D.18866>;
  <D.18865>:
  D.18868 = __builtin_object_size (__buf, 0);
  D.18867 = __read_chk (__fd, __buf, __nbytes, D.18868);
  return D.18867;
  <D.18866>:
  D.18869 = __builtin_object_size (__buf, 0);
  if (D.18869 < __nbytes) goto <D.18870>; else goto <D.18871>;
  <D.18870>:
  D.18872 = __builtin_object_size (__buf, 0);
  D.18867 = __read_chk_warn (__fd, __buf, __nbytes, D.18872);
  return D.18867;
  <D.18871>:
  <D.18863>:
  D.18867 = __read_alias (__fd, __buf, __nbytes);
  return D.18867;
}


decode_string_value (guint8 * buf, guint8 * * endbuf, guint8 * limit)
{
  guint8 * p.15;
  char * D.18877;
  _Bool D.18878;
  long int D.18879;
  long int D.18880;
  int D.18883;
  int D.18884;
  signed char b.16;
  _Bool D.18887;
  long int D.18888;
  long int D.18889;
  int D.18892;
  long unsigned int D.18893;
  sizetype D.18894;
  guint8 * p.17;
  _Bool D.18896;
  long int D.18897;
  long int D.18898;
  long unsigned int D.18901;
  char * D.18902;
  int type;
  gint32 length;
  guint8 * p;
  char * s;

  try
    {
      p = buf;
      p.15 = p;
      type = decode_byte (p.15, &p, limit);
      if (type == 17) goto <D.18875>; else goto <D.18876>;
      <D.18875>:
      p.15 = p;
      *endbuf = p.15;
      D.18877 = 0B;
      return D.18877;
      <D.18876>:
      D.18878 = type != 18;
      D.18879 = (long int) D.18878;
      D.18880 = __builtin_expect (D.18879, 0);
      if (D.18880 != 0) goto <D.18881>; else goto <D.18882>;
      <D.18881>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 153, "type == PRIM_TYPE_STRING");
      <D.18882>:
      length = 0;
      <D.18552>:
      {
        guint8 b;

        p.15 = p;
        D.18883 = decode_byte (p.15, &p, limit);
        b = (guint8) D.18883;
        length = length << 8;
        D.18884 = (int) b;
        length = D.18884 + length;
        b.16 = (signed char) b;
        if (b.16 >= 0) goto <D.18551>; else goto <D.18886>;
        <D.18886>:
      }
      goto <D.18552>;
      <D.18551>:
      D.18887 = length > 65535;
      D.18888 = (long int) D.18887;
      D.18889 = __builtin_expect (D.18888, 0);
      if (D.18889 != 0) goto <D.18890>; else goto <D.18891>;
      <D.18890>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 165, "length < (1 << 16)");
      <D.18891>:
      D.18892 = length + 1;
      D.18893 = (long unsigned int) D.18892;
      s = monoeg_malloc (D.18893);
      p.15 = p;
      D.18894 = (sizetype) length;
      p.17 = p.15 + D.18894;
      D.18896 = p.17 > limit;
      D.18897 = (long int) D.18896;
      D.18898 = __builtin_expect (D.18897, 0);
      if (D.18898 != 0) goto <D.18899>; else goto <D.18900>;
      <D.18899>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 169, "p + length <= limit");
      <D.18900>:
      p.15 = p;
      D.18901 = (long unsigned int) length;
      memcpy (s, p.15, D.18901);
      D.18894 = (sizetype) length;
      D.18902 = s + D.18894;
      *D.18902 = 0;
      p.15 = p;
      D.18894 = (sizetype) length;
      p.17 = p.15 + D.18894;
      p = p.17;
      p.15 = p;
      *endbuf = p.15;
      D.18877 = s;
      return D.18877;
    }
  finally
    {
      p = {CLOBBER};
    }
}


decode_byte (guint8 * buf, guint8 * * endbuf, guint8 * limit)
{
  guint8 * D.18905;
  guint8 * D.18906;
  _Bool D.18907;
  long int D.18908;
  long int D.18909;
  int D.18912;
  unsigned char D.18913;

  D.18905 = buf + 1;
  *endbuf = D.18905;
  D.18906 = *endbuf;
  D.18907 = D.18906 > limit;
  D.18908 = (long int) D.18907;
  D.18909 = __builtin_expect (D.18908, 0);
  if (D.18909 != 0) goto <D.18910>; else goto <D.18911>;
  <D.18910>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 118, "*endbuf <= limit");
  <D.18911>:
  D.18913 = *buf;
  D.18912 = (int) D.18913;
  return D.18912;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.18915;
  long unsigned int D.18916;

  D.18916 = __builtin_object_size (__dest, 0);
  D.18915 = __builtin___memcpy_chk (__dest, __src, __len, D.18916);
  return D.18915;
}


mono_attach_load_agent (struct MonoDomain * domain, char * agent, char * args, struct MonoObject * * exc)
{
  struct _IO_FILE * stderr.18;
  <unnamed type> open_status.19;
  const char * D.18922;
  int D.18923;
  const char * D.18926;
  struct MonoClass * D.18931;
  struct MonoString * D.18932;
  struct MonoAssembly * agent_assembly;
  struct MonoImage * image;
  struct MonoMethod * method;
  guint32 entry;
  struct MonoArray * main_args;
  void * pa[1];
  MonoImageOpenStatus open_status;

  try
    {
      agent_assembly = mono_assembly_open (agent, &open_status);
      if (agent_assembly == 0B) goto <D.18918>; else goto <D.18919>;
      <D.18918>:
      stderr.18 = stderr;
      open_status.19 = open_status;
      D.18922 = mono_image_strerror (open_status.19);
      fprintf (stderr.18, "Cannot open agent assembly \'%s\': %s.\n", agent, D.18922);
      monoeg_g_free (agent);
      D.18923 = 2;
      return D.18923;
      <D.18919>:
      image = mono_assembly_get_image (agent_assembly);
      entry = mono_image_get_entry_point (image);
      if (entry == 0) goto <D.18924>; else goto <D.18925>;
      <D.18924>:
      D.18926 = mono_image_get_filename (image);
      monoeg_g_print ("Assembly \'%s\' doesn\'t have an entry point.\n", D.18926);
      monoeg_g_free (agent);
      D.18923 = 1;
      return D.18923;
      <D.18925>:
      method = mono_get_method (image, entry, 0B);
      if (method == 0B) goto <D.18927>; else goto <D.18928>;
      <D.18927>:
      monoeg_g_print ("The entry point method of assembly \'%s\' could not be loaded\n", agent);
      monoeg_g_free (agent);
      D.18923 = 1;
      return D.18923;
      <D.18928>:
      if (args != 0B) goto <D.18929>; else goto <D.18930>;
      <D.18929>:
      D.18931 = mono_defaults.string_class;
      main_args = mono_array_new (domain, D.18931, 1);
      {
        struct MonoString * * __p;

        __p = mono_array_addr_with_size (main_args, 8, 0);
        D.18932 = mono_string_new (domain, args);
        *__p = D.18932;
      }
      goto <D.18933>;
      <D.18930>:
      D.18931 = mono_defaults.string_class;
      main_args = mono_array_new (domain, D.18931, 0);
      <D.18933>:
      monoeg_g_free (agent);
      pa[0] = main_args;
      mono_runtime_invoke (method, 0B, &pa, exc);
      D.18923 = 0;
      return D.18923;
    }
  finally
    {
      pa = {CLOBBER};
      open_status = {CLOBBER};
    }
}


printf (const char * restrict __fmt)
{
  int D.18936;

  D.18936 = __printf_chk (1, __fmt, __builtin_va_arg_pack ());
  return D.18936;
}


transport_connect ()
{
  ipc_connect ();
}


ipc_connect ()
{
  unsigned int D.18938;
  unsigned int D.18939;
  struct _IO_FILE * stderr.20;
  unsigned int D.18945;
  struct passwd * pw.21;
  _Bool D.18949;
  long int D.18950;
  long int D.18951;
  char * D.18954;
  int * D.18957;
  int D.18958;
  unsigned int D.18963;
  unsigned int D.18964;
  unsigned int D.18967;
  unsigned int D.18968;
  long unsigned int D.18971;
  long unsigned int D.18972;
  int D.18976;
  long unsigned int D.18977;
  union 
{
  const struct sockaddr * restrict __sockaddr__;
  const struct sockaddr_at * restrict __sockaddr_at__;
  const struct sockaddr_ax25 * restrict __sockaddr_ax25__;
  const struct sockaddr_dl * restrict __sockaddr_dl__;
  const struct sockaddr_eon * restrict __sockaddr_eon__;
  const struct sockaddr_in * restrict __sockaddr_in__;
  const struct sockaddr_in6 * restrict __sockaddr_in6__;
  const struct sockaddr_inarp * restrict __sockaddr_inarp__;
  const struct sockaddr_ipx * restrict __sockaddr_ipx__;
  const struct sockaddr_iso * restrict __sockaddr_iso__;
  const struct sockaddr_ns * restrict __sockaddr_ns__;
  const struct sockaddr_un * restrict __sockaddr_un__;
  const struct sockaddr_x25 * restrict __sockaddr_x25__;
} D.18978;
  unsigned int D.18979;
  int D.18980;
  char * D.18983;
  char * D.18988;
  gchar * ipc_filename.22;
  int D.18990;
  gchar * server_uri.23;
  struct sockaddr_un name;
  int sock;
  int res;
  size_t size;
  char * filename;
  char * directory;
  struct stat stat;
  struct passwd pwbuf;
  char buf[1024];
  struct passwd * pw;

  try
    {
      D.18938 = getuid ();
      D.18939 = geteuid ();
      if (D.18938 != D.18939) goto <D.18940>; else goto <D.18941>;
      <D.18940>:
      stderr.20 = stderr;
      fprintf (stderr.20, "attach: disabled listening on an IPC socket when running in setuid mode.\n");
      return;
      <D.18941>:
      sock = socket (1, 1, 0);
      if (sock < 0) goto <D.18943>; else goto <D.18944>;
      <D.18943>:
      perror ("attach: failed to create IPC socket");
      return;
      <D.18944>:
      pw = 0B;
      D.18945 = getuid ();
      res = getpwuid_r (D.18945, &pwbuf, &buf, 1024, &pw);
      if (res != 0) goto <D.18946>; else goto <D.18947>;
      <D.18946>:
      stderr.20 = stderr;
      fprintf (stderr.20, "attach: getpwuid_r () failed.\n");
      return;
      <D.18947>:
      pw.21 = pw;
      D.18949 = pw.21 == 0B;
      D.18950 = (long int) D.18949;
      D.18951 = __builtin_expect (D.18950, 0);
      if (D.18951 != 0) goto <D.18952>; else goto <D.18953>;
      <D.18952>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 379, "pw");
      <D.18953>:
      pw.21 = pw;
      D.18954 = pw.21->pw_name;
      directory = monoeg_g_strdup_printf ("/tmp/mono-%s", D.18954);
      res = mkdir (directory, 448);
      if (res != 0) goto <D.18955>; else goto <D.18956>;
      <D.18955>:
      D.18957 = __errno_location ();
      D.18958 = *D.18957;
      if (D.18958 == 17) goto <D.18959>; else goto <D.18960>;
      <D.18959>:
      res = lstat (directory, &stat);
      if (res != 0) goto <D.18961>; else goto <D.18962>;
      <D.18961>:
      perror ("attach: lstat () failed");
      return;
      <D.18962>:
      D.18963 = stat.st_mode;
      D.18964 = D.18963 & 61440;
      if (D.18964 != 16384) goto <D.18965>; else goto <D.18966>;
      <D.18965>:
      stderr.20 = stderr;
      fprintf (stderr.20, "attach: path \'%s\' is not a directory.\n", directory);
      return;
      <D.18966>:
      D.18967 = stat.st_uid;
      D.18968 = getuid ();
      if (D.18967 != D.18968) goto <D.18969>; else goto <D.18970>;
      <D.18969>:
      stderr.20 = stderr;
      fprintf (stderr.20, "attach: directory \'%s\' is not owned by the current user.\n", directory);
      return;
      <D.18970>:
      D.18971 = BIT_FIELD_REF <stat, 64, 192>;
      D.18972 = D.18971 & 511;
      if (D.18972 != 448) goto <D.18973>; else goto <D.18974>;
      <D.18973>:
      stderr.20 = stderr;
      fprintf (stderr.20, "attach: directory \'%s\' should have protection 0700.\n", directory);
      return;
      <D.18974>:
      goto <D.18975>;
      <D.18960>:
      perror ("attach: mkdir () failed");
      return;
      <D.18975>:
      <D.18956>:
      D.18976 = getpid ();
      filename = monoeg_g_strdup_printf ("%s/.mono-%d", directory, D.18976);
      unlink (filename);
      name.sun_family = 1;
      strcpy (&name.sun_path, filename);
      D.18977 = strlen (&name.sun_path);
      size = D.18977 + 3;
      D.18978.__sockaddr__ = &name;
      D.18979 = (unsigned int) size;
      D.18980 = bind (sock, D.18978, D.18979);
      if (D.18980 < 0) goto <D.18981>; else goto <D.18982>;
      <D.18981>:
      stderr.20 = stderr;
      D.18957 = __errno_location ();
      D.18958 = *D.18957;
      D.18983 = strerror (D.18958);
      fprintf (stderr.20, "attach: failed to bind IPC socket \'%s\': %s\n", filename, D.18983);
      close (sock);
      return;
      <D.18982>:
      res = chmod (filename, 384);
      if (res != 0) goto <D.18984>; else goto <D.18985>;
      <D.18984>:
      perror ("attach: failed to set permissions on IPC socket");
      close (sock);
      unlink (filename);
      return;
      <D.18985>:
      res = listen (sock, 16);
      if (res != 0) goto <D.18986>; else goto <D.18987>;
      <D.18986>:
      stderr.20 = stderr;
      D.18957 = __errno_location ();
      D.18958 = *D.18957;
      D.18988 = strerror (D.18958);
      fprintf (stderr.20, "attach: listen () failed: %s\n", D.18988);
      exit (1);
      <D.18987>:
      listen_fd = sock;
      ipc_filename.22 = monoeg_strdup (filename);
      ipc_filename = ipc_filename.22;
      D.18990 = getpid ();
      server_uri.23 = monoeg_g_strdup_printf ("unix://%s/.mono-%d?/vm", directory, D.18990);
      server_uri = server_uri.23;
      monoeg_g_free (filename);
      monoeg_g_free (directory);
    }
  finally
    {
      name = {CLOBBER};
      stat = {CLOBBER};
      pwbuf = {CLOBBER};
      buf = {CLOBBER};
      pw = {CLOBBER};
    }
}


lstat (const char * __path, struct stat * __statbuf)
{
  int D.18995;

  D.18995 = __lxstat (1, __path, __statbuf);
  return D.18995;
}


strcpy (char * restrict __dest, const char * restrict __src)
{
  char * D.18997;
  long unsigned int D.18998;

  D.18998 = __builtin_object_size (__dest, 1);
  D.18997 = __builtin___strcpy_chk (__dest, __src, D.18998);
  return D.18997;
}


monoeg_strdup (const gchar * str)
{
  gchar * D.19002;

  if (str != 0B) goto <D.19000>; else goto <D.19001>;
  <D.19000>:
  D.19002 = __strdup (str);
  return D.19002;
  <D.19001>:
  D.19002 = 0B;
  return D.19002;
}


mono_attach_cleanup ()
{
  int listen_fd.24;
  char * ipc_filename.25;
  int conn_fd.26;
  void * receiver_thread_handle.27;

  listen_fd.24 = listen_fd;
  if (listen_fd.24 != 0) goto <D.19005>; else goto <D.19006>;
  <D.19005>:
  listen_fd.24 = listen_fd;
  close (listen_fd.24);
  <D.19006>:
  ipc_filename.25 = ipc_filename;
  if (ipc_filename.25 != 0B) goto <D.19008>; else goto <D.19009>;
  <D.19008>:
  ipc_filename.25 = ipc_filename;
  unlink (ipc_filename.25);
  <D.19009>:
  stop_receiver_thread = 1;
  conn_fd.26 = conn_fd;
  if (conn_fd.26 != 0) goto <D.19011>; else goto <D.19012>;
  <D.19011>:
  conn_fd.26 = conn_fd;
  close (conn_fd.26);
  <D.19012>:
  receiver_thread_handle.27 = receiver_thread_handle;
  if (receiver_thread_handle.27 != 0B) goto <D.19014>; else goto <D.19015>;
  <D.19014>:
  receiver_thread_handle.27 = receiver_thread_handle;
  WaitForSingleObjectEx (receiver_thread_handle.27, 0, 0);
  <D.19015>:
}


