mono_attach_parse_options (char * options)
{
  int D.17637;
  int iftmp.0;
  int D.17636;
  const char[8] * D.17727;
  unsigned char D.17728;
  int D.17729;
  unsigned char D.17730;
  int D.17731;
  const unsigned char * D.17736;
  unsigned char D.17737;
  int D.17738;
  const unsigned char * D.17739;
  unsigned char D.17740;
  int D.17741;
  const unsigned char * D.17746;
  unsigned char D.17747;
  int D.17748;
  const unsigned char * D.17749;
  unsigned char D.17750;
  int D.17751;
  const unsigned char * D.17756;
  unsigned char D.17757;
  int D.17758;
  const unsigned char * D.17759;
  unsigned char D.17760;
  int D.17761;

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

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

      __s2 = options;
      D.17727 = "disable";
      D.17728 = MEM[(const unsigned char *)D.17727];
      D.17729 = (int) D.17728;
      D.17730 = *__s2;
      D.17731 = (int) D.17730;
      __result = D.17729 - D.17731;
      {
        if (__s2_len != 0) goto <D.17732>; else goto <D.17733>;
        <D.17732>:
        if (__result == 0) goto <D.17734>; else goto <D.17735>;
        <D.17734>:
        D.17736 = &MEM[(void *)"disable" + 1B];
        D.17737 = *D.17736;
        D.17738 = (int) D.17737;
        D.17739 = __s2 + 1;
        D.17740 = *D.17739;
        D.17741 = (int) D.17740;
        __result = D.17738 - D.17741;
        if (__s2_len > 1) goto <D.17742>; else goto <D.17743>;
        <D.17742>:
        if (__result == 0) goto <D.17744>; else goto <D.17745>;
        <D.17744>:
        D.17746 = &MEM[(void *)"disable" + 2B];
        D.17747 = *D.17746;
        D.17748 = (int) D.17747;
        D.17749 = __s2 + 2;
        D.17750 = *D.17749;
        D.17751 = (int) D.17750;
        __result = D.17748 - D.17751;
        if (__s2_len > 2) goto <D.17752>; else goto <D.17753>;
        <D.17752>:
        if (__result == 0) goto <D.17754>; else goto <D.17755>;
        <D.17754>:
        D.17756 = &MEM[(void *)"disable" + 3B];
        D.17757 = *D.17756;
        D.17758 = (int) D.17757;
        D.17759 = __s2 + 3;
        D.17760 = *D.17759;
        D.17761 = (int) D.17760;
        __result = D.17758 - D.17761;
        <D.17755>:
        <D.17753>:
        <D.17745>:
        <D.17743>:
        <D.17735>:
        <D.17733>:
      }
      D.17636 = __result;
    }
    iftmp.0 = -D.17636;
    goto <D.17762>;
    <D.17726>:
    iftmp.0 = __builtin_strcmp (options, "disable");
    <D.17762>:
    D.17637 = iftmp.0;
  }
  if (D.17637 == 0) goto <D.17763>; else goto <D.17764>;
  <D.17763>:
  config.enabled = 0;
  <D.17764>:
}


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


mono_attach_start ()
{
  int started.1;
  gboolean D.17769;
  int D.17770;
  int D.17773;
  char path[256];
  int fd;

  try
    {
      started.1 = started;
      if (started.1 != 0) goto <D.17767>; else goto <D.17768>;
      <D.17767>:
      D.17769 = 0;
      return D.17769;
      <D.17768>:
      D.17770 = getpid ();
      snprintf (&path, 256, "/tmp/.mono_attach_pid%d", D.17770);
      fd = open (&path, 0);
      if (fd == -1) goto <D.17771>; else goto <D.17772>;
      <D.17771>:
      D.17769 = 0;
      return D.17769;
      <D.17772>:
      close (fd);
      D.17773 = config.enabled;
      if (D.17773 == 0) goto <D.17774>; else goto <D.17775>;
      <D.17774>:
      D.17769 = 1;
      return D.17769;
      <D.17775>:
      started.1 = started;
      if (started.1 != 0) goto <D.17776>; else goto <D.17777>;
      <D.17776>:
      D.17769 = 0;
      return D.17769;
      <D.17777>:
      needs_to_start = 1;
      mono_gc_finalize_notify ();
      D.17769 = 1;
      return D.17769;
    }
  finally
    {
      path = {CLOBBER};
    }
}


snprintf (char * restrict __s, size_t __n, const char * restrict __fmt)
{
  int D.17780;
  unsigned int D.17781;

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


open (const char * __path, int __oflag)
{
  int D.17783;
  int D.17786;
  int D.17791;
  int D.17793;
  int D.17794;
  int D.17797;
  int D.17798;

  D.17783 = __builtin_va_arg_pack_len ();
  if (D.17783 > 1) goto <D.17784>; else goto <D.17785>;
  <D.17784>:
  __open_too_many_args ();
  <D.17785>:
  D.17786 = __builtin_constant_p (__oflag);
  if (D.17786 != 0) goto <D.17787>; else goto <D.17788>;
  <D.17787>:
  D.17791 = __oflag & 256;
  if (D.17791 != 0) goto <D.17789>; else goto <D.17792>;
  <D.17792>:
  D.17793 = __oflag & 4259840;
  if (D.17793 == 4259840) goto <D.17789>; else goto <D.17790>;
  <D.17789>:
  D.17794 = __builtin_va_arg_pack_len ();
  if (D.17794 <= 0) goto <D.17795>; else goto <D.17796>;
  <D.17795>:
  __open_missing_mode ();
  D.17797 = __open_2 (__path, __oflag);
  return D.17797;
  <D.17796>:
  <D.17790>:
  D.17797 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.17797;
  <D.17788>:
  D.17798 = __builtin_va_arg_pack_len ();
  if (D.17798 <= 0) goto <D.17799>; else goto <D.17800>;
  <D.17799>:
  D.17797 = __open_2 (__path, __oflag);
  return D.17797;
  <D.17800>:
  D.17797 = __open_alias (__path, __oflag, __builtin_va_arg_pack ());
  return D.17797;
}


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.17803>; else goto <D.17804>;
  <D.17803>:
  return;
  <D.17804>:
  needs_to_start = 0;
  started.3 = started;
  if (started.3 == 0) goto <D.17806>; else goto <D.17807>;
  <D.17806>:
  transport_start_receive ();
  started = 1;
  <D.17807>:
}


transport_start_receive ()
{
  int listen_fd.4;
  void * receiver_thread_handle.5;
  void * receiver_thread_handle.6;
  _Bool D.17814;
  long int D.17815;
  long int D.17816;

  transport_connect ();
  listen_fd.4 = listen_fd;
  if (listen_fd.4 == 0) goto <D.17810>; else goto <D.17811>;
  <D.17810>:
  return;
  <D.17811>:
  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.17814 = receiver_thread_handle.6 == 0B;
  D.17815 = (long int) D.17814;
  D.17816 = __builtin_expect (D.17815, 0);
  if (D.17816 != 0) goto <D.17817>; else goto <D.17818>;
  <D.17817>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 482, "receiver_thread_handle");
  <D.17818>:
}


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.17822;
  int conn_fd.9;
  int conn_fd.10;
  guint32 D.17827;
  struct MonoDomain * D.17828;
  struct MonoInternalThread * D.17829;
  unsigned int D.17830;
  unsigned int D.17831;
  int * D.17834;
  int D.17835;
  int stop_receiver_thread.11;
  int D.17844;
  unsigned char D.17846;
  unsigned char D.17848;
  struct _IO_FILE * stderr.12;
  guint8 * p.13;
  unsigned int content_len.14;
  unsigned int content_len.15;
  sizetype content_len.16;
  int D.17717;
  int iftmp.17;
  int D.17716;
  const char[7] * D.17859;
  unsigned char D.17860;
  int D.17861;
  unsigned char D.17862;
  int D.17863;
  const unsigned char * D.17868;
  unsigned char D.17869;
  int D.17870;
  const unsigned char * D.17871;
  unsigned char D.17872;
  int D.17873;
  const unsigned char * D.17878;
  unsigned char D.17879;
  int D.17880;
  const unsigned char * D.17881;
  unsigned char D.17882;
  int D.17883;
  const unsigned char * D.17888;
  unsigned char D.17889;
  int D.17890;
  const unsigned char * D.17891;
  unsigned char D.17892;
  int D.17893;
  _Bool D.17895;
  long int D.17896;
  long int D.17897;
  struct MonoDomain * D.17900;
  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.17720>:
      listen_fd.8 = listen_fd;
      D.17822.__sockaddr__ = 0B;
      conn_fd.9 = accept (listen_fd.8, D.17822, 0B);
      conn_fd = conn_fd.9;
      conn_fd.10 = conn_fd;
      if (conn_fd.10 == -1) goto <D.17825>; else goto <D.17826>;
      <D.17825>:
      D.17827 = 0;
      return D.17827;
      <D.17826>:
      printf ("attach: Connected.\n");
      D.17828 = mono_get_root_domain ();
      mono_thread_attach (D.17828);
      D.17829 = mono_thread_internal_current ();
      D.17830 = D.17829->state;
      D.17831 = D.17830 | 4;
      D.17829->state = D.17831;
      <D.17718>:
      {
        char * cmd;
        char * agent_name;
        char * agent_args;
        guint8 * body;

        conn_fd.10 = conn_fd;
        res = read (conn_fd.10, &buffer, 6);
        if (res == -1) goto <D.17832>; else goto <D.17833>;
        <D.17832>:
        D.17834 = __errno_location ();
        D.17835 = *D.17834;
        if (D.17835 == 4) goto <D.17836>; else goto <D.17837>;
        <D.17836>:
        // predicted unlikely by continue predictor.
        goto <D.17698>;
        <D.17837>:
        <D.17833>:
        if (res == -1) goto <D.17699>; else goto <D.17838>;
        <D.17838>:
        stop_receiver_thread.11 = stop_receiver_thread;
        if (stop_receiver_thread.11 != 0) goto <D.17699>; else goto <D.17840>;
        <D.17840>:
        if (res != 6) goto <D.17699>; else goto <D.17841>;
        <D.17841>:
        D.17844 = strncmp (&buffer, "MONO", 4);
        if (D.17844 != 0) goto <D.17842>; else goto <D.17845>;
        <D.17845>:
        D.17846 = buffer[4];
        if (D.17846 != 1) goto <D.17842>; else goto <D.17847>;
        <D.17847>:
        D.17848 = buffer[5];
        if (D.17848 != 0) goto <D.17842>; else goto <D.17843>;
        <D.17842>:
        stderr.12 = stderr;
        fprintf (stderr.12, "attach: message from server has unknown header.\n");
        goto <D.17699>;
        <D.17843>:
        conn_fd.10 = conn_fd;
        res = read (conn_fd.10, &buffer, 4);
        if (res != 4) goto <D.17699>; else goto <D.17850>;
        <D.17850>:
        p = &buffer;
        p.13 = p;
        p_end = p.13 + 8;
        p.13 = p;
        content_len = decode_int (p.13, &p, p_end);
        content_len.14 = (unsigned int) content_len;
        body = monoeg_malloc (content_len.14);
        conn_fd.10 = conn_fd;
        content_len.15 = (unsigned int) content_len;
        res = read (conn_fd.10, body, content_len.15);
        p = body;
        content_len.16 = (sizetype) content_len;
        p_end = body + content_len.16;
        p.13 = p;
        cmd = decode_string_value (p.13, &p, p_end);
        if (cmd == 0B) goto <D.17699>; else goto <D.17855>;
        <D.17855>:
        {
          size_t __s1_len;
          size_t __s2_len;

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

            __s2 = cmd;
            D.17859 = "attach";
            D.17860 = MEM[(const unsigned char *)D.17859];
            D.17861 = (int) D.17860;
            D.17862 = *__s2;
            D.17863 = (int) D.17862;
            __result = D.17861 - D.17863;
            {
              if (__s2_len != 0) goto <D.17864>; else goto <D.17865>;
              <D.17864>:
              if (__result == 0) goto <D.17866>; else goto <D.17867>;
              <D.17866>:
              D.17868 = &MEM[(void *)"attach" + 1B];
              D.17869 = *D.17868;
              D.17870 = (int) D.17869;
              D.17871 = __s2 + 1;
              D.17872 = *D.17871;
              D.17873 = (int) D.17872;
              __result = D.17870 - D.17873;
              if (__s2_len > 1) goto <D.17874>; else goto <D.17875>;
              <D.17874>:
              if (__result == 0) goto <D.17876>; else goto <D.17877>;
              <D.17876>:
              D.17878 = &MEM[(void *)"attach" + 2B];
              D.17879 = *D.17878;
              D.17880 = (int) D.17879;
              D.17881 = __s2 + 2;
              D.17882 = *D.17881;
              D.17883 = (int) D.17882;
              __result = D.17880 - D.17883;
              if (__s2_len > 2) goto <D.17884>; else goto <D.17885>;
              <D.17884>:
              if (__result == 0) goto <D.17886>; else goto <D.17887>;
              <D.17886>:
              D.17888 = &MEM[(void *)"attach" + 3B];
              D.17889 = *D.17888;
              D.17890 = (int) D.17889;
              D.17891 = __s2 + 3;
              D.17892 = *D.17891;
              D.17893 = (int) D.17892;
              __result = D.17890 - D.17893;
              <D.17887>:
              <D.17885>:
              <D.17877>:
              <D.17875>:
              <D.17867>:
              <D.17865>:
            }
            D.17716 = __result;
          }
          iftmp.17 = -D.17716;
          goto <D.17894>;
          <D.17858>:
          iftmp.17 = __builtin_strcmp (cmd, "attach");
          <D.17894>:
          D.17717 = iftmp.17;
        }
        D.17895 = D.17717 != 0;
        D.17896 = (long int) D.17895;
        D.17897 = __builtin_expect (D.17896, 0);
        if (D.17897 != 0) goto <D.17898>; else goto <D.17899>;
        <D.17898>:
        monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 550, "!strcmp (cmd, \"attach\")");
        <D.17899>:
        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.17900 = mono_domain_get ();
        mono_attach_load_agent (D.17900, agent_name, agent_args, &exc);
        monoeg_g_free (body);
      }
      <D.17698>:
      goto <D.17718>;
      <D.17699>:
      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.17719>; else goto <D.17901>;
      <D.17901>:
      goto <D.17720>;
      <D.17719>:
      D.17827 = 0;
      return D.17827;
    }
  finally
    {
      buffer = {CLOBBER};
      p = {CLOBBER};
      exc = {CLOBBER};
    }
}


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

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


decode_int (guint8 * buf, guint8 * * endbuf, guint8 * limit)
{
  guint8 * D.17906;
  guint8 * D.17907;
  _Bool D.17908;
  long int D.17909;
  long int D.17910;
  int D.17913;
  unsigned char D.17914;
  int D.17915;
  guint8 * D.17916;
  unsigned char D.17917;
  int D.17918;
  int D.17919;
  int D.17920;
  guint8 * D.17921;
  unsigned char D.17922;
  int D.17923;
  int D.17924;
  int D.17925;
  guint8 * D.17926;
  unsigned char D.17927;
  int D.17928;
  int D.17929;

  D.17906 = buf + 4;
  *endbuf = D.17906;
  D.17907 = *endbuf;
  D.17908 = D.17907 > limit;
  D.17909 = (long int) D.17908;
  D.17910 = __builtin_expect (D.17909, 0);
  if (D.17910 != 0) goto <D.17911>; else goto <D.17912>;
  <D.17911>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 126, "*endbuf <= limit");
  <D.17912>:
  D.17914 = *buf;
  D.17915 = (int) D.17914;
  D.17916 = buf + 1;
  D.17917 = *D.17916;
  D.17918 = (int) D.17917;
  D.17919 = D.17918 << 8;
  D.17920 = D.17915 | D.17919;
  D.17921 = buf + 2;
  D.17922 = *D.17921;
  D.17923 = (int) D.17922;
  D.17924 = D.17923 << 16;
  D.17925 = D.17920 | D.17924;
  D.17926 = buf + 3;
  D.17927 = *D.17926;
  D.17928 = (int) D.17927;
  D.17929 = D.17928 << 24;
  D.17913 = D.17925 | D.17929;
  return D.17913;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.17931;
  int D.17934;
  ssize_t D.17937;
  unsigned int D.17938;
  unsigned int D.17939;
  unsigned int D.17942;

  D.17931 = __builtin_object_size (__buf, 0);
  if (D.17931 != 4294967295) goto <D.17932>; else goto <D.17933>;
  <D.17932>:
  D.17934 = __builtin_constant_p (__nbytes);
  if (D.17934 == 0) goto <D.17935>; else goto <D.17936>;
  <D.17935>:
  D.17938 = __builtin_object_size (__buf, 0);
  D.17937 = __read_chk (__fd, __buf, __nbytes, D.17938);
  return D.17937;
  <D.17936>:
  D.17939 = __builtin_object_size (__buf, 0);
  if (D.17939 < __nbytes) goto <D.17940>; else goto <D.17941>;
  <D.17940>:
  D.17942 = __builtin_object_size (__buf, 0);
  D.17937 = __read_chk_warn (__fd, __buf, __nbytes, D.17942);
  return D.17937;
  <D.17941>:
  <D.17933>:
  D.17937 = __read_alias (__fd, __buf, __nbytes);
  return D.17937;
}


decode_string_value (guint8 * buf, guint8 * * endbuf, guint8 * limit)
{
  guint8 * p.18;
  char * D.17947;
  _Bool D.17948;
  long int D.17949;
  long int D.17950;
  int D.17953;
  int D.17954;
  signed char b.19;
  _Bool D.17957;
  long int D.17958;
  long int D.17959;
  int D.17962;
  unsigned int D.17963;
  sizetype length.20;
  guint8 * p.22;
  _Bool D.17966;
  long int D.17967;
  long int D.17968;
  unsigned int length.21;
  char * D.17972;
  int type;
  gint32 length;
  guint8 * p;
  char * s;

  try
    {
      p = buf;
      p.18 = p;
      type = decode_byte (p.18, &p, limit);
      if (type == 17) goto <D.17945>; else goto <D.17946>;
      <D.17945>:
      p.18 = p;
      *endbuf = p.18;
      D.17947 = 0B;
      return D.17947;
      <D.17946>:
      D.17948 = type != 18;
      D.17949 = (long int) D.17948;
      D.17950 = __builtin_expect (D.17949, 0);
      if (D.17950 != 0) goto <D.17951>; else goto <D.17952>;
      <D.17951>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 153, "type == PRIM_TYPE_STRING");
      <D.17952>:
      length = 0;
      <D.17625>:
      {
        guint8 b;

        p.18 = p;
        D.17953 = decode_byte (p.18, &p, limit);
        b = (guint8) D.17953;
        length = length << 8;
        D.17954 = (int) b;
        length = D.17954 + length;
        b.19 = (signed char) b;
        if (b.19 >= 0) goto <D.17624>; else goto <D.17956>;
        <D.17956>:
      }
      goto <D.17625>;
      <D.17624>:
      D.17957 = length > 65535;
      D.17958 = (long int) D.17957;
      D.17959 = __builtin_expect (D.17958, 0);
      if (D.17959 != 0) goto <D.17960>; else goto <D.17961>;
      <D.17960>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 165, "length < (1 << 16)");
      <D.17961>:
      D.17962 = length + 1;
      D.17963 = (unsigned int) D.17962;
      s = monoeg_malloc (D.17963);
      p.18 = p;
      length.20 = (sizetype) length;
      p.22 = p.18 + length.20;
      D.17966 = p.22 > limit;
      D.17967 = (long int) D.17966;
      D.17968 = __builtin_expect (D.17967, 0);
      if (D.17968 != 0) goto <D.17969>; else goto <D.17970>;
      <D.17969>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 169, "p + length <= limit");
      <D.17970>:
      p.18 = p;
      length.21 = (unsigned int) length;
      memcpy (s, p.18, length.21);
      length.20 = (sizetype) length;
      D.17972 = s + length.20;
      *D.17972 = 0;
      p.18 = p;
      length.20 = (sizetype) length;
      p.22 = p.18 + length.20;
      p = p.22;
      p.18 = p;
      *endbuf = p.18;
      D.17947 = s;
      return D.17947;
    }
  finally
    {
      p = {CLOBBER};
    }
}


decode_byte (guint8 * buf, guint8 * * endbuf, guint8 * limit)
{
  guint8 * D.17975;
  guint8 * D.17976;
  _Bool D.17977;
  long int D.17978;
  long int D.17979;
  int D.17982;
  unsigned char D.17983;

  D.17975 = buf + 1;
  *endbuf = D.17975;
  D.17976 = *endbuf;
  D.17977 = D.17976 > limit;
  D.17978 = (long int) D.17977;
  D.17979 = __builtin_expect (D.17978, 0);
  if (D.17979 != 0) goto <D.17980>; else goto <D.17981>;
  <D.17980>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 118, "*endbuf <= limit");
  <D.17981>:
  D.17983 = *buf;
  D.17982 = (int) D.17983;
  return D.17982;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.17985;
  unsigned int D.17986;

  D.17986 = __builtin_object_size (__dest, 0);
  D.17985 = __builtin___memcpy_chk (__dest, __src, __len, D.17986);
  return D.17985;
}


mono_attach_load_agent (struct MonoDomain * domain, char * agent, char * args, struct MonoObject * * exc)
{
  struct _IO_FILE * stderr.23;
  <unnamed type> open_status.24;
  const char * D.17992;
  int D.17993;
  const char * D.17996;
  struct MonoClass * D.18001;
  struct MonoString * D.18002;
  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.17988>; else goto <D.17989>;
      <D.17988>:
      stderr.23 = stderr;
      open_status.24 = open_status;
      D.17992 = mono_image_strerror (open_status.24);
      fprintf (stderr.23, "Cannot open agent assembly \'%s\': %s.\n", agent, D.17992);
      monoeg_g_free (agent);
      D.17993 = 2;
      return D.17993;
      <D.17989>:
      image = mono_assembly_get_image (agent_assembly);
      entry = mono_image_get_entry_point (image);
      if (entry == 0) goto <D.17994>; else goto <D.17995>;
      <D.17994>:
      D.17996 = mono_image_get_filename (image);
      monoeg_g_print ("Assembly \'%s\' doesn\'t have an entry point.\n", D.17996);
      monoeg_g_free (agent);
      D.17993 = 1;
      return D.17993;
      <D.17995>:
      method = mono_get_method (image, entry, 0B);
      if (method == 0B) goto <D.17997>; else goto <D.17998>;
      <D.17997>:
      monoeg_g_print ("The entry point method of assembly \'%s\' could not be loaded\n", agent);
      monoeg_g_free (agent);
      D.17993 = 1;
      return D.17993;
      <D.17998>:
      if (args != 0B) goto <D.17999>; else goto <D.18000>;
      <D.17999>:
      D.18001 = mono_defaults.string_class;
      main_args = mono_array_new (domain, D.18001, 1);
      {
        struct MonoString * * __p;

        __p = mono_array_addr_with_size (main_args, 4, 0);
        D.18002 = mono_string_new (domain, args);
        *__p = D.18002;
      }
      goto <D.18003>;
      <D.18000>:
      D.18001 = mono_defaults.string_class;
      main_args = mono_array_new (domain, D.18001, 0);
      <D.18003>:
      monoeg_g_free (agent);
      pa[0] = main_args;
      mono_runtime_invoke (method, 0B, &pa, exc);
      D.17993 = 0;
      return D.17993;
    }
  finally
    {
      pa = {CLOBBER};
      open_status = {CLOBBER};
    }
}


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

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


transport_connect ()
{
  ipc_connect ();
}


ipc_connect ()
{
  unsigned int D.18008;
  unsigned int D.18009;
  struct _IO_FILE * stderr.25;
  unsigned int D.18015;
  struct passwd * pw.26;
  _Bool D.18019;
  long int D.18020;
  long int D.18021;
  char * D.18024;
  int * D.18027;
  int D.18028;
  unsigned int D.18033;
  unsigned int D.18034;
  unsigned int D.18037;
  unsigned int D.18038;
  unsigned int D.18041;
  unsigned int D.18042;
  int D.18046;
  unsigned int D.18047;
  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.18048;
  int D.18049;
  char * D.18052;
  char * D.18057;
  gchar * ipc_filename.27;
  int D.18059;
  gchar * server_uri.28;
  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.18008 = getuid ();
      D.18009 = geteuid ();
      if (D.18008 != D.18009) goto <D.18010>; else goto <D.18011>;
      <D.18010>:
      stderr.25 = stderr;
      fprintf (stderr.25, "attach: disabled listening on an IPC socket when running in setuid mode.\n");
      return;
      <D.18011>:
      sock = socket (1, 2, 0);
      if (sock < 0) goto <D.18013>; else goto <D.18014>;
      <D.18013>:
      perror ("attach: failed to create IPC socket");
      return;
      <D.18014>:
      pw = 0B;
      D.18015 = getuid ();
      res = getpwuid_r (D.18015, &pwbuf, &buf, 1024, &pw);
      if (res != 0) goto <D.18016>; else goto <D.18017>;
      <D.18016>:
      stderr.25 = stderr;
      fprintf (stderr.25, "attach: getpwuid_r () failed.\n");
      return;
      <D.18017>:
      pw.26 = pw;
      D.18019 = pw.26 == 0B;
      D.18020 = (long int) D.18019;
      D.18021 = __builtin_expect (D.18020, 0);
      if (D.18021 != 0) goto <D.18022>; else goto <D.18023>;
      <D.18022>:
      monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "attach.c", 379, "pw");
      <D.18023>:
      pw.26 = pw;
      D.18024 = pw.26->pw_name;
      directory = monoeg_g_strdup_printf ("/tmp/mono-%s", D.18024);
      res = mkdir (directory, 448);
      if (res != 0) goto <D.18025>; else goto <D.18026>;
      <D.18025>:
      D.18027 = __errno_location ();
      D.18028 = *D.18027;
      if (D.18028 == 17) goto <D.18029>; else goto <D.18030>;
      <D.18029>:
      res = lstat (directory, &stat);
      if (res != 0) goto <D.18031>; else goto <D.18032>;
      <D.18031>:
      perror ("attach: lstat () failed");
      return;
      <D.18032>:
      D.18033 = stat.st_mode;
      D.18034 = D.18033 & 61440;
      if (D.18034 != 16384) goto <D.18035>; else goto <D.18036>;
      <D.18035>:
      stderr.25 = stderr;
      fprintf (stderr.25, "attach: path \'%s\' is not a directory.\n", directory);
      return;
      <D.18036>:
      D.18037 = stat.st_uid;
      D.18038 = getuid ();
      if (D.18037 != D.18038) goto <D.18039>; else goto <D.18040>;
      <D.18039>:
      stderr.25 = stderr;
      fprintf (stderr.25, "attach: directory \'%s\' is not owned by the current user.\n", directory);
      return;
      <D.18040>:
      D.18041 = BIT_FIELD_REF <stat, 32, 192>;
      D.18042 = D.18041 & 511;
      if (D.18042 != 448) goto <D.18043>; else goto <D.18044>;
      <D.18043>:
      stderr.25 = stderr;
      fprintf (stderr.25, "attach: directory \'%s\' should have protection 0700.\n", directory);
      return;
      <D.18044>:
      goto <D.18045>;
      <D.18030>:
      perror ("attach: mkdir () failed");
      return;
      <D.18045>:
      <D.18026>:
      D.18046 = getpid ();
      filename = monoeg_g_strdup_printf ("%s/.mono-%d", directory, D.18046);
      unlink (filename);
      name.sun_family = 1;
      strcpy (&name.sun_path, filename);
      D.18047 = strlen (&name.sun_path);
      size = D.18047 + 3;
      D.18048.__sockaddr__ = &name;
      D.18049 = bind (sock, D.18048, size);
      if (D.18049 < 0) goto <D.18050>; else goto <D.18051>;
      <D.18050>:
      stderr.25 = stderr;
      D.18027 = __errno_location ();
      D.18028 = *D.18027;
      D.18052 = strerror (D.18028);
      fprintf (stderr.25, "attach: failed to bind IPC socket \'%s\': %s\n", filename, D.18052);
      close (sock);
      return;
      <D.18051>:
      res = chmod (filename, 384);
      if (res != 0) goto <D.18053>; else goto <D.18054>;
      <D.18053>:
      perror ("attach: failed to set permissions on IPC socket");
      close (sock);
      unlink (filename);
      return;
      <D.18054>:
      res = listen (sock, 16);
      if (res != 0) goto <D.18055>; else goto <D.18056>;
      <D.18055>:
      stderr.25 = stderr;
      D.18027 = __errno_location ();
      D.18028 = *D.18027;
      D.18057 = strerror (D.18028);
      fprintf (stderr.25, "attach: listen () failed: %s\n", D.18057);
      exit (1);
      <D.18056>:
      listen_fd = sock;
      ipc_filename.27 = monoeg_strdup (filename);
      ipc_filename = ipc_filename.27;
      D.18059 = getpid ();
      server_uri.28 = monoeg_g_strdup_printf ("unix://%s/.mono-%d?/vm", directory, D.18059);
      server_uri = server_uri.28;
      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.18064;

  D.18064 = __lxstat (3, __path, __statbuf);
  return D.18064;
}


strcpy (char * restrict __dest, const char * restrict __src)
{
  char * D.18066;
  unsigned int D.18067;

  D.18067 = __builtin_object_size (__dest, 1);
  D.18066 = __builtin___strcpy_chk (__dest, __src, D.18067);
  return D.18066;
}


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

  if (str != 0B) goto <D.18069>; else goto <D.18070>;
  <D.18069>:
  D.18071 = __strdup (str);
  return D.18071;
  <D.18070>:
  D.18071 = 0B;
  return D.18071;
}


mono_attach_cleanup ()
{
  int listen_fd.29;
  char * ipc_filename.30;
  int conn_fd.31;
  void * receiver_thread_handle.32;

  listen_fd.29 = listen_fd;
  if (listen_fd.29 != 0) goto <D.18074>; else goto <D.18075>;
  <D.18074>:
  listen_fd.29 = listen_fd;
  close (listen_fd.29);
  <D.18075>:
  ipc_filename.30 = ipc_filename;
  if (ipc_filename.30 != 0B) goto <D.18077>; else goto <D.18078>;
  <D.18077>:
  ipc_filename.30 = ipc_filename;
  unlink (ipc_filename.30);
  <D.18078>:
  stop_receiver_thread = 1;
  conn_fd.31 = conn_fd;
  if (conn_fd.31 != 0) goto <D.18080>; else goto <D.18081>;
  <D.18080>:
  conn_fd.31 = conn_fd;
  close (conn_fd.31);
  <D.18081>:
  receiver_thread_handle.32 = receiver_thread_handle;
  if (receiver_thread_handle.32 != 0B) goto <D.18083>; else goto <D.18084>;
  <D.18083>:
  receiver_thread_handle.32 = receiver_thread_handle;
  WaitForSingleObjectEx (receiver_thread_handle.32, 0, 0);
  <D.18084>:
}


