ves_icall_System_IO_FSW_SupportsFSW ()
{
  gint D.16668;
  int (*<T2a8d>) (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.16666>; else goto <D.16667>;
  <D.16666>:
  close (inotify_instance);
  D.16668 = 5;
  return D.16668;
  <D.16667>:
  iter = 0B;
  fam_module = mono_dl_open ("libgamin-1.so", 1, 0B);
  if (fam_module == 0B) goto <D.16669>; else goto <D.16670>;
  <D.16669>:
  lib_used = 2;
  iter = 0B;
  fam_module = mono_dl_open ("libfam.so", 1, 0B);
  <D.16670>:
  if (fam_module == 0B) goto <D.16671>; else goto <D.16672>;
  <D.16671>:
  D.16668 = 0;
  return D.16668;
  <D.16672>:
  err = mono_dl_symbol (fam_module, "FAMNextEvent", &FAMNextEvent);
  monoeg_g_free (err);
  FAMNextEvent.0 = FAMNextEvent;
  if (FAMNextEvent.0 == 0B) goto <D.16674>; else goto <D.16675>;
  <D.16674>:
  D.16668 = 0;
  return D.16668;
  <D.16675>:
  D.16668 = lib_used;
  return D.16668;
}


ves_icall_System_IO_FAMW_InternalFAMNextEvent (void * conn, struct MonoString * * filename, gint * code, gint * reqnum)
{
  int (*<T2a8d>) (void *, void *) FAMNextEvent.1;
  int D.16678;
  struct MonoDomain * D.16681;
  struct MonoString * D.16682;
  int D.16683;
  int D.16684;
  gboolean D.16685;
  struct FAMEvent ev;

  try
    {
      FAMNextEvent.1 = FAMNextEvent;
      D.16678 = FAMNextEvent.1 (conn, &ev);
      if (D.16678 == 1) goto <D.16679>; else goto <D.16680>;
      <D.16679>:
      D.16681 = mono_domain_get ();
      D.16682 = mono_string_new (D.16681, &ev.filename);
      *filename = D.16682;
      D.16683 = ev.code;
      *code = D.16683;
      D.16684 = ev.fr.reqnum;
      *reqnum = D.16684;
      D.16685 = 1;
      return D.16685;
      <D.16680>:
      D.16685 = 0;
      return D.16685;
    }
  finally
    {
      ev = {CLOBBER};
    }
}


ves_icall_System_IO_InotifyWatcher_GetInotifyInstance ()
{
  int D.16688;

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


ves_icall_System_IO_InotifyWatcher_AddWatch (int fd, struct MonoString * name, gint32 mask)
{
  int D.16692;
  unsigned int mask.2;
  int * D.16698;
  int D.16699;
  char * str;
  char * path;
  int retval;

  if (name == 0B) goto <D.16690>; else goto <D.16691>;
  <D.16690>:
  D.16692 = -1;
  return D.16692;
  <D.16691>:
  str = mono_string_to_utf8 (name);
  path = mono_portability_find_file (str, 1);
  if (path == 0B) goto <D.16693>; else goto <D.16694>;
  <D.16693>:
  path = str;
  <D.16694>:
  mask.2 = (unsigned int) mask;
  retval = inotify_add_watch (fd, path, mask.2);
  if (retval < 0) goto <D.16696>; else goto <D.16697>;
  <D.16696>:
  D.16698 = __errno_location ();
  D.16699 = *D.16698;
  switch (D.16699) <default: <D.16660>, case 9: <D.16655>, case 12: <D.16658>, case 13: <D.16653>, case 14: <D.16656>, case 22: <D.16657>, case 28: <D.16659>>
  <D.16653>:
  D.16698 = __errno_location ();
  *D.16698 = 5;
  goto <D.16654>;
  <D.16655>:
  D.16698 = __errno_location ();
  *D.16698 = 6;
  goto <D.16654>;
  <D.16656>:
  D.16698 = __errno_location ();
  *D.16698 = 12;
  goto <D.16654>;
  <D.16657>:
  D.16698 = __errno_location ();
  *D.16698 = 13;
  goto <D.16654>;
  <D.16658>:
  D.16698 = __errno_location ();
  *D.16698 = 8;
  goto <D.16654>;
  <D.16659>:
  D.16698 = __errno_location ();
  *D.16698 = 4;
  goto <D.16654>;
  <D.16660>:
  D.16698 = __errno_location ();
  *D.16698 = 31;
  goto <D.16654>;
  <D.16654>:
  mono_marshal_set_last_error ();
  <D.16697>:
  if (path != str) goto <D.16700>; else goto <D.16701>;
  <D.16700>:
  monoeg_g_free (path);
  <D.16701>:
  monoeg_g_free (str);
  D.16692 = retval;
  return D.16692;
}


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

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


