ves_icall_System_IO_FSW_SupportsFSW ()
{
  gint D.17596;
  int (*<T2bc5>) (void *, void *) FAMNextEvent.0;
  struct MonoDl * fam_module;
  int lib_used;
  int inotify_instance;
  void * iter;
  char * err;

  lib_used = 4;
  inotify_instance = ves_icall_System_IO_InotifyWatcher_GetInotifyInstance ();
  if (inotify_instance != -1) goto <D.17594>; else goto <D.17595>;
  <D.17594>:
  close (inotify_instance);
  D.17596 = 5;
  return D.17596;
  <D.17595>:
  iter = 0B;
  fam_module = mono_dl_open ("libgamin-1.so", 1, 0B);
  if (fam_module == 0B) goto <D.17597>; else goto <D.17598>;
  <D.17597>:
  lib_used = 2;
  iter = 0B;
  fam_module = mono_dl_open ("libfam.so", 1, 0B);
  <D.17598>:
  if (fam_module == 0B) goto <D.17599>; else goto <D.17600>;
  <D.17599>:
  D.17596 = 0;
  return D.17596;
  <D.17600>:
  err = mono_dl_symbol (fam_module, "FAMNextEvent", &FAMNextEvent);
  monoeg_g_free (err);
  FAMNextEvent.0 = FAMNextEvent;
  if (FAMNextEvent.0 == 0B) goto <D.17602>; else goto <D.17603>;
  <D.17602>:
  D.17596 = 0;
  return D.17596;
  <D.17603>:
  D.17596 = lib_used;
  return D.17596;
}


ves_icall_System_IO_FAMW_InternalFAMNextEvent (void * conn, struct MonoString * * filename, gint * code, gint * reqnum)
{
  int (*<T2bc5>) (void *, void *) FAMNextEvent.1;
  int D.17606;
  struct MonoDomain * D.17609;
  struct MonoString * D.17610;
  int D.17611;
  int D.17612;
  gboolean D.17613;
  struct FAMEvent ev;

  try
    {
      FAMNextEvent.1 = FAMNextEvent;
      D.17606 = FAMNextEvent.1 (conn, &ev);
      if (D.17606 == 1) goto <D.17607>; else goto <D.17608>;
      <D.17607>:
      D.17609 = mono_domain_get ();
      D.17610 = mono_string_new (D.17609, &ev.filename);
      *filename = D.17610;
      D.17611 = ev.code;
      *code = D.17611;
      D.17612 = ev.fr.reqnum;
      *reqnum = D.17612;
      D.17613 = 1;
      return D.17613;
      <D.17608>:
      D.17613 = 0;
      return D.17613;
    }
  finally
    {
      ev = {CLOBBER};
    }
}


ves_icall_System_IO_InotifyWatcher_GetInotifyInstance ()
{
  int D.17616;

  D.17616 = inotify_init ();
  return D.17616;
}


ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, struct MonoString * name, gint32 mask)
{
  int D.17620;
  unsigned int mask.2;
  int * D.17626;
  int D.17627;
  char * str;
  char * path;
  int retval;

  if (name == 0B) goto <D.17618>; else goto <D.17619>;
  <D.17618>:
  D.17620 = -1;
  return D.17620;
  <D.17619>:
  str = mono_string_to_utf8 (name);
  path = mono_portability_find_file (str, 1);
  if (path == 0B) goto <D.17621>; else goto <D.17622>;
  <D.17621>:
  path = str;
  <D.17622>:
  mask.2 = (unsigned int) mask;
  retval = inotify_add_watch (fd, path, mask.2);
  if (retval < 0) goto <D.17624>; else goto <D.17625>;
  <D.17624>:
  D.17626 = __errno_location ();
  D.17627 = *D.17626;
  switch (D.17627) <default: <D.17588>, case 9: <D.17583>, case 12: <D.17586>, case 13: <D.17581>, case 14: <D.17584>, case 22: <D.17585>, case 28: <D.17587>>
  <D.17581>:
  D.17626 = __errno_location ();
  *D.17626 = 5;
  goto <D.17582>;
  <D.17583>:
  D.17626 = __errno_location ();
  *D.17626 = 6;
  goto <D.17582>;
  <D.17584>:
  D.17626 = __errno_location ();
  *D.17626 = 12;
  goto <D.17582>;
  <D.17585>:
  D.17626 = __errno_location ();
  *D.17626 = 13;
  goto <D.17582>;
  <D.17586>:
  D.17626 = __errno_location ();
  *D.17626 = 8;
  goto <D.17582>;
  <D.17587>:
  D.17626 = __errno_location ();
  *D.17626 = 4;
  goto <D.17582>;
  <D.17588>:
  D.17626 = __errno_location ();
  *D.17626 = 31;
  goto <D.17582>;
  <D.17582>:
  mono_marshal_set_last_error ();
  <D.17625>:
  if (path != str) goto <D.17628>; else goto <D.17629>;
  <D.17628>:
  monoeg_g_free (path);
  <D.17629>:
  monoeg_g_free (str);
  D.17620 = retval;
  return D.17620;
}


ves_icall_System_IO_InotifyWatcher_RemoveWatch (int fd, gint32 watch_descriptor)
{
  int D.17631;

  D.17631 = inotify_rm_watch (fd, watch_descriptor);
  return D.17631;
}


