ves_icall_System_IO_FSW_SupportsFSW ()
{
  gint D.17066;
  int (*<T2b3d>) (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.17064>; else goto <D.17065>;
  <D.17064>:
  close (inotify_instance);
  D.17066 = 5;
  return D.17066;
  <D.17065>:
  iter = 0B;
  fam_module = mono_dl_open ("libgamin-1.so", 1, 0B);
  if (fam_module == 0B) goto <D.17067>; else goto <D.17068>;
  <D.17067>:
  lib_used = 2;
  iter = 0B;
  fam_module = mono_dl_open ("libfam.so", 1, 0B);
  <D.17068>:
  if (fam_module == 0B) goto <D.17069>; else goto <D.17070>;
  <D.17069>:
  D.17066 = 0;
  return D.17066;
  <D.17070>:
  err = mono_dl_symbol (fam_module, "FAMNextEvent", &FAMNextEvent);
  monoeg_g_free (err);
  FAMNextEvent.0 = FAMNextEvent;
  if (FAMNextEvent.0 == 0B) goto <D.17072>; else goto <D.17073>;
  <D.17072>:
  D.17066 = 0;
  return D.17066;
  <D.17073>:
  D.17066 = lib_used;
  return D.17066;
}


ves_icall_System_IO_FAMW_InternalFAMNextEvent (void * conn, struct MonoString * * filename, gint * code, gint * reqnum)
{
  int (*<T2b3d>) (void *, void *) FAMNextEvent.1;
  int D.17076;
  struct MonoDomain * D.17079;
  struct MonoString * D.17080;
  int D.17081;
  int D.17082;
  gboolean D.17083;
  struct FAMEvent ev;

  try
    {
      FAMNextEvent.1 = FAMNextEvent;
      D.17076 = FAMNextEvent.1 (conn, &ev);
      if (D.17076 == 1) goto <D.17077>; else goto <D.17078>;
      <D.17077>:
      D.17079 = mono_domain_get ();
      D.17080 = mono_string_new (D.17079, &ev.filename);
      *filename = D.17080;
      D.17081 = ev.code;
      *code = D.17081;
      D.17082 = ev.fr.reqnum;
      *reqnum = D.17082;
      D.17083 = 1;
      return D.17083;
      <D.17078>:
      D.17083 = 0;
      return D.17083;
    }
  finally
    {
      ev = {CLOBBER};
    }
}


ves_icall_System_IO_InotifyWatcher_GetInotifyInstance ()
{
  int D.17086;

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


ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, struct MonoString * name, gint32 mask)
{
  int D.17090;
  unsigned int mask.2;
  int * D.17096;
  int D.17097;
  char * str;
  char * path;
  int retval;

  if (name == 0B) goto <D.17088>; else goto <D.17089>;
  <D.17088>:
  D.17090 = -1;
  return D.17090;
  <D.17089>:
  str = mono_string_to_utf8 (name);
  path = mono_portability_find_file (str, 1);
  if (path == 0B) goto <D.17091>; else goto <D.17092>;
  <D.17091>:
  path = str;
  <D.17092>:
  mask.2 = (unsigned int) mask;
  retval = inotify_add_watch (fd, path, mask.2);
  if (retval < 0) goto <D.17094>; else goto <D.17095>;
  <D.17094>:
  D.17096 = __errno_location ();
  D.17097 = *D.17096;
  switch (D.17097) <default: <D.17058>, case 9: <D.17053>, case 12: <D.17056>, case 13: <D.17051>, case 14: <D.17054>, case 22: <D.17055>, case 28: <D.17057>>
  <D.17051>:
  D.17096 = __errno_location ();
  *D.17096 = 5;
  goto <D.17052>;
  <D.17053>:
  D.17096 = __errno_location ();
  *D.17096 = 6;
  goto <D.17052>;
  <D.17054>:
  D.17096 = __errno_location ();
  *D.17096 = 12;
  goto <D.17052>;
  <D.17055>:
  D.17096 = __errno_location ();
  *D.17096 = 13;
  goto <D.17052>;
  <D.17056>:
  D.17096 = __errno_location ();
  *D.17096 = 8;
  goto <D.17052>;
  <D.17057>:
  D.17096 = __errno_location ();
  *D.17096 = 4;
  goto <D.17052>;
  <D.17058>:
  D.17096 = __errno_location ();
  *D.17096 = 31;
  goto <D.17052>;
  <D.17052>:
  mono_marshal_set_last_error ();
  <D.17095>:
  if (path != str) goto <D.17098>; else goto <D.17099>;
  <D.17098>:
  monoeg_g_free (path);
  <D.17099>:
  monoeg_g_free (str);
  D.17090 = retval;
  return D.17090;
}


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

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


