CreateNLSocket ()
{
  int D.7544;
  int D.7547;
  unsigned int D.7548;
  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.7549;
  int D.7550;
  int sock;
  struct sockaddr_nl sa;
  int ret;

  try
    {
      sock = socket (16, 3, 0);
      ret = fcntl (sock, 3, 0);
      if (ret != -1) goto <D.7540>; else goto <D.7541>;
      <D.7540>:
      ret = ret | 2048;
      ret = fcntl (sock, 4, ret);
      if (ret < 0) goto <D.7542>; else goto <D.7543>;
      <D.7542>:
      D.7544 = -1;
      return D.7544;
      <D.7543>:
      <D.7541>:
      memset (&sa, 0, 12);
      if (sock < 0) goto <D.7545>; else goto <D.7546>;
      <D.7545>:
      D.7544 = -1;
      return D.7544;
      <D.7546>:
      sa.nl_family = 16;
      D.7547 = getpid ();
      D.7548 = (unsigned int) D.7547;
      sa.nl_pid = D.7548;
      sa.nl_groups = 1090;
      D.7549.__sockaddr__ = &sa;
      D.7550 = bind (sock, D.7549, 12);
      if (D.7550 < 0) goto <D.7551>; else goto <D.7552>;
      <D.7551>:
      D.7544 = -1;
      return D.7544;
      <D.7552>:
      D.7544 = sock;
      return D.7544;
    }
  finally
    {
      sa = {CLOBBER};
    }
}


memset (void * __dest, int __ch, size_t __len)
{
  int D.7557;
  int D.7562;
  void * D.7564;
  long unsigned int D.7565;

  D.7557 = __builtin_constant_p (__len);
  if (D.7557 != 0) goto <D.7558>; else goto <D.7559>;
  <D.7558>:
  if (__len == 0) goto <D.7560>; else goto <D.7561>;
  <D.7560>:
  D.7562 = __builtin_constant_p (__ch);
  if (D.7562 == 0) goto <D.7555>; else goto <D.7563>;
  <D.7563>:
  if (__ch != 0) goto <D.7555>; else goto <D.7556>;
  <D.7555>:
  __warn_memset_zero_len ();
  D.7564 = __dest;
  return D.7564;
  <D.7556>:
  <D.7561>:
  <D.7559>:
  D.7565 = __builtin_object_size (__dest, 0);
  D.7564 = __builtin___memset_chk (__dest, __ch, __len, D.7565);
  return D.7564;
}


ReadEvents (void * sock, void * buffer, gint32 count, gint32 size)
{
  long int sock.0;
  long unsigned int D.7570;
  long int D.7571;
  int * D.7573;
  int D.7574;
  int D.7577;
  short unsigned int D.7578;
  unsigned int msg_type.1;
  unsigned int D.7580;
  unsigned char D.7583;
  _Bool D.7584;
  _Bool D.7585;
  _Bool D.7586;
  int iftmp.2;
  unsigned char D.7593;
  unsigned char D.7594;
  unsigned char D.7595;
  unsigned char D.7596;
  unsigned int table.3;
  unsigned int D.7598;
  unsigned int D.7601;
  unsigned int D.7602;
  short unsigned int D.7603;
  int D.7604;
  long unsigned int D.7605;
  short unsigned int D.7606;
  int D.7607;
  int D.7608;
  int D.7609;
  sizetype D.7610;
  _Bool D.7620;
  _Bool D.7621;
  _Bool D.7622;
  int D.7625;
  int D.7635;
  int D.7643;
  long int D.7646;
  unsigned int count.4;
  unsigned int D.7651;
  unsigned int D.7652;
  unsigned int D.7653;
  sizetype D.7654;
  sizetype D.7655;
  struct nlmsghdr * nlp;
  struct rtmsg * rtp;
  int rtl;
  struct rtattr * rtap;
  int result;
  int s;

  result = 0;
  sock.0 = (long int) sock;
  s = (int) sock.0;
  if (count == 0) goto <D.7568>; else goto <D.7569>;
  <D.7568>:
  goto <D.7502>;
  <D.7501>:
  <D.7502>:
  D.7570 = (long unsigned int) size;
  D.7571 = recv (s, buffer, D.7570, 0);
  count = (gint32) D.7571;
  if (count == -1) goto <D.7572>; else goto <D.7503>;
  <D.7572>:
  D.7573 = __errno_location ();
  D.7574 = *D.7573;
  if (D.7574 == 4) goto <D.7501>; else goto <D.7503>;
  <D.7503>:
  if (count <= 0) goto <D.7575>; else goto <D.7576>;
  <D.7575>:
  D.7577 = result;
  return D.7577;
  <D.7576>:
  <D.7569>:
  nlp = buffer;
  goto <D.7534>;
  <D.7533>:
  {
    int family;
    int addr_length;
    int msg_type;
    int table;
    int protocol;
    int scope;
    int rtm_type;
    gboolean have_dst;
    gboolean have_src;
    gboolean have_pref_src;
    gboolean have_gw;
    char dst[16];
    char src[16];
    char pref_src[16];
    char gw[16];

    try
      {
        D.7578 = nlp->nlmsg_type;
        msg_type = (int) D.7578;
        msg_type.1 = (unsigned int) msg_type;
        D.7580 = msg_type.1 + 4294967272;
        if (D.7580 > 1) goto <D.7581>; else goto <D.7582>;
        <D.7581>:
        // predicted unlikely by continue predictor.
        goto <D.7519>;
        <D.7582>:
        rtp = nlp + 16;
        D.7583 = rtp->rtm_family;
        family = (int) D.7583;
        D.7584 = family != 2;
        D.7585 = family != 10;
        D.7586 = D.7584 & D.7585;
        if (D.7586 != 0) goto <D.7587>; else goto <D.7588>;
        <D.7587>:
        // predicted unlikely by continue predictor.
        goto <D.7519>;
        <D.7588>:
        if (family == 2) goto <D.7590>; else goto <D.7591>;
        <D.7590>:
        iftmp.2 = 4;
        goto <D.7592>;
        <D.7591>:
        iftmp.2 = 16;
        <D.7592>:
        addr_length = iftmp.2;
        D.7593 = rtp->rtm_table;
        table = (int) D.7593;
        D.7594 = rtp->rtm_protocol;
        protocol = (int) D.7594;
        D.7595 = rtp->rtm_scope;
        scope = (int) D.7595;
        D.7596 = rtp->rtm_type;
        rtm_type = (int) D.7596;
        table.3 = (unsigned int) table;
        D.7598 = table.3 + 4294967042;
        if (D.7598 > 1) goto <D.7599>; else goto <D.7600>;
        <D.7599>:
        // predicted unlikely by continue predictor.
        goto <D.7519>;
        <D.7600>:
        rtap = rtp + 12;
        D.7601 = nlp->nlmsg_len;
        D.7602 = D.7601 + 4294967268;
        rtl = (int) D.7602;
        have_gw = 0;
        have_pref_src = have_gw;
        have_src = have_pref_src;
        have_dst = have_src;
        goto <D.7528>;
        <D.7527>:
        {
          char * data;

          data = rtap + 4;
          D.7603 = rtap->rta_type;
          D.7604 = (int) D.7603;
          switch (D.7604) <default: <D.7526>, case 1: <D.7521>, case 2: <D.7524>, case 5: <D.7525>, case 7: <D.7523>>
          <D.7521>:
          have_dst = 1;
          D.7605 = (long unsigned int) addr_length;
          memcpy (&dst, data, D.7605);
          goto <D.7522>;
          <D.7523>:
          have_pref_src = 1;
          D.7605 = (long unsigned int) addr_length;
          memcpy (&pref_src, data, D.7605);
          goto <D.7522>;
          <D.7524>:
          have_src = 1;
          D.7605 = (long unsigned int) addr_length;
          memcpy (&src, data, D.7605);
          goto <D.7522>;
          <D.7525>:
          have_gw = 1;
          D.7605 = (long unsigned int) addr_length;
          memcpy (&gw, data, D.7605);
          goto <D.7522>;
          <D.7526>:
          goto <D.7522>;
          <D.7522>:
        }
        D.7606 = rtap->rta_len;
        D.7607 = (int) D.7606;
        D.7608 = D.7607 + 3;
        D.7609 = D.7608 & -4;
        rtl = rtl - D.7609;
        D.7606 = rtap->rta_len;
        D.7607 = (int) D.7606;
        D.7608 = D.7607 + 3;
        D.7609 = D.7608 & -4;
        D.7610 = (sizetype) D.7609;
        rtap = rtap + D.7610;
        <D.7528>:
        if (rtl > 3) goto <D.7611>; else goto <D.7529>;
        <D.7611>:
        D.7606 = rtap->rta_len;
        if (D.7606 > 3) goto <D.7612>; else goto <D.7529>;
        <D.7612>:
        D.7606 = rtap->rta_len;
        D.7607 = (int) D.7606;
        if (D.7607 <= rtl) goto <D.7527>; else goto <D.7529>;
        <D.7529>:
        if (msg_type == 24) goto <D.7613>; else goto <D.7614>;
        <D.7613>:
        if (table == 254) goto <D.7615>; else goto <D.7616>;
        <D.7615>:
        result = result | 1;
        goto <D.7617>;
        <D.7616>:
        if (table == 255) goto <D.7618>; else goto <D.7619>;
        <D.7618>:
        D.7620 = have_dst != 0;
        D.7621 = have_pref_src != 0;
        D.7622 = D.7620 & D.7621;
        if (D.7622 != 0) goto <D.7623>; else goto <D.7624>;
        <D.7623>:
        D.7605 = (long unsigned int) addr_length;
        D.7625 = memcmp (&dst, &pref_src, D.7605);
        if (D.7625 == 0) goto <D.7626>; else goto <D.7627>;
        <D.7626>:
        result = result | 2;
        <D.7627>:
        <D.7624>:
        <D.7619>:
        <D.7617>:
        goto <D.7628>;
        <D.7614>:
        if (msg_type == 25) goto <D.7629>; else goto <D.7630>;
        <D.7629>:
        if (table == 254) goto <D.7631>; else goto <D.7632>;
        <D.7631>:
        if (rtm_type == 1) goto <D.7633>; else goto <D.7634>;
        <D.7633>:
        D.7635 = have_dst | have_pref_src;
        if (D.7635 != 0) goto <D.7636>; else goto <D.7637>;
        <D.7636>:
        result = result | 1;
        <D.7637>:
        <D.7634>:
        goto <D.7638>;
        <D.7632>:
        if (table == 255) goto <D.7639>; else goto <D.7640>;
        <D.7639>:
        D.7620 = have_dst != 0;
        D.7621 = have_pref_src != 0;
        D.7622 = D.7620 & D.7621;
        if (D.7622 != 0) goto <D.7641>; else goto <D.7642>;
        <D.7641>:
        D.7605 = (long unsigned int) addr_length;
        D.7643 = memcmp (&dst, &pref_src, D.7605);
        if (D.7643 == 0) goto <D.7644>; else goto <D.7645>;
        <D.7644>:
        result = result | 2;
        <D.7645>:
        <D.7642>:
        <D.7640>:
        <D.7638>:
        <D.7630>:
        <D.7628>:
        goto <D.7531>;
        <D.7530>:
        <D.7531>:
        D.7570 = (long unsigned int) size;
        D.7646 = recv (s, buffer, D.7570, 0);
        count = (gint32) D.7646;
        if (count == -1) goto <D.7647>; else goto <D.7532>;
        <D.7647>:
        D.7573 = __errno_location ();
        D.7574 = *D.7573;
        if (D.7574 == 4) goto <D.7530>; else goto <D.7532>;
        <D.7532>:
        if (count <= 0) goto <D.7648>; else goto <D.7649>;
        <D.7648>:
        D.7577 = result;
        return D.7577;
        <D.7649>:
        nlp = buffer;
      }
    finally
      {
        dst = {CLOBBER};
        src = {CLOBBER};
        pref_src = {CLOBBER};
        gw = {CLOBBER};
      }
  }
  <D.7519>:
  count.4 = (unsigned int) count;
  D.7601 = nlp->nlmsg_len;
  D.7651 = D.7601 + 3;
  D.7652 = D.7651 & 4294967292;
  D.7653 = count.4 - D.7652;
  count = (gint32) D.7653;
  D.7601 = nlp->nlmsg_len;
  D.7651 = D.7601 + 3;
  D.7654 = (sizetype) D.7651;
  D.7655 = D.7654 & 4294967292;
  nlp = nlp + D.7655;
  <D.7534>:
  if (count > 15) goto <D.7656>; else goto <D.7535>;
  <D.7656>:
  D.7601 = nlp->nlmsg_len;
  if (D.7601 > 15) goto <D.7657>; else goto <D.7535>;
  <D.7657>:
  D.7601 = nlp->nlmsg_len;
  count.4 = (unsigned int) count;
  if (D.7601 <= count.4) goto <D.7533>; else goto <D.7535>;
  <D.7535>:
  D.7577 = result;
  return D.7577;
}


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

  D.7664 = __builtin_object_size (__dest, 0);
  D.7663 = __builtin___memcpy_chk (__dest, __src, __len, D.7664);
  return D.7663;
}


recv (int __fd, void * __buf, size_t __n, int __flags)
{
  long unsigned int D.7666;
  int D.7669;
  ssize_t D.7672;
  long unsigned int D.7673;
  long unsigned int D.7674;
  long unsigned int D.7677;

  D.7666 = __builtin_object_size (__buf, 0);
  if (D.7666 != 18446744073709551615) goto <D.7667>; else goto <D.7668>;
  <D.7667>:
  D.7669 = __builtin_constant_p (__n);
  if (D.7669 == 0) goto <D.7670>; else goto <D.7671>;
  <D.7670>:
  D.7673 = __builtin_object_size (__buf, 0);
  D.7672 = __recv_chk (__fd, __buf, __n, D.7673, __flags);
  return D.7672;
  <D.7671>:
  D.7674 = __builtin_object_size (__buf, 0);
  if (D.7674 < __n) goto <D.7675>; else goto <D.7676>;
  <D.7675>:
  D.7677 = __builtin_object_size (__buf, 0);
  D.7672 = __recv_chk_warn (__fd, __buf, __n, D.7677, __flags);
  return D.7672;
  <D.7676>:
  <D.7668>:
  D.7672 = __recv_alias (__fd, __buf, __n, __flags);
  return D.7672;
}


CloseNLSocket (void * sock)
{
  int D.7679;
  long int sock.5;
  int D.7681;

  sock.5 = (long int) sock;
  D.7681 = (int) sock.5;
  D.7679 = close (D.7681);
  return D.7679;
}


