mono_sem_timedwait (union MonoSemType * sem, guint32 timeout_ms, gboolean alertable)
{
  int D.9969;
  unsigned int D.9972;
  long int D.9973;
  long int D.9974;
  long int D.9975;
  unsigned int D.9976;
  unsigned int D.9977;
  long int D.9978;
  long int D.9979;
  long int D.9980;
  long int D.9981;
  long int D.9982;
  long int D.9983;
  long int D.9984;
  long int D.9985;
  long int D.9988;
  long int D.9989;
  long int D.9990;
  long int D.9991;
  long int D.9992;
  long int D.9993;
  long int D.9994;
  long int D.10000;
  long int D.10001;
  int * D.10005;
  int D.10006;
  struct timespec ts;
  struct timespec copy;
  struct timeval t;
  int res;

  try
    {
      res = 0;
      if (timeout_ms == 0) goto <D.9967>; else goto <D.9968>;
      <D.9967>:
      D.9969 = sem_trywait (sem);
      return D.9969;
      <D.9968>:
      if (timeout_ms == 4294967295) goto <D.9970>; else goto <D.9971>;
      <D.9970>:
      D.9969 = mono_sem_wait (sem, alertable);
      return D.9969;
      <D.9971>:
      gettimeofday (&t, 0B);
      D.9972 = timeout_ms / 1000;
      D.9973 = (long int) D.9972;
      D.9974 = t.tv_sec;
      D.9975 = D.9973 + D.9974;
      ts.tv_sec = D.9975;
      D.9976 = timeout_ms % 1000;
      D.9977 = D.9976 * 1000000;
      D.9978 = (long int) D.9977;
      D.9979 = t.tv_usec;
      D.9980 = D.9979 * 1000;
      D.9981 = D.9978 + D.9980;
      ts.tv_nsec = D.9981;
      goto <D.9945>;
      <D.9944>:
      D.9982 = ts.tv_nsec;
      D.9983 = D.9982 + -1000000000;
      ts.tv_nsec = D.9983;
      D.9984 = ts.tv_sec;
      D.9985 = D.9984 + 1;
      ts.tv_sec = D.9985;
      <D.9945>:
      D.9982 = ts.tv_nsec;
      if (D.9982 > 1000000000) goto <D.9944>; else goto <D.9946>;
      <D.9946>:
      copy = ts;
      goto <D.9949>;
      <D.9948>:
      {
        struct timeval current;

        try
          {
            if (alertable != 0) goto <D.9986>; else goto <D.9987>;
            <D.9986>:
            D.9969 = -1;
            return D.9969;
            <D.9987>:
            gettimeofday (&current, 0B);
            ts = copy;
            D.9984 = ts.tv_sec;
            D.9974 = t.tv_sec;
            D.9988 = current.tv_sec;
            D.9989 = D.9974 - D.9988;
            D.9990 = D.9984 + D.9989;
            ts.tv_sec = D.9990;
            D.9982 = ts.tv_nsec;
            D.9979 = t.tv_usec;
            D.9991 = current.tv_usec;
            D.9992 = D.9979 - D.9991;
            D.9993 = D.9992 * 1000;
            D.9994 = D.9982 + D.9993;
            ts.tv_nsec = D.9994;
            D.9982 = ts.tv_nsec;
            if (D.9982 < 0) goto <D.9995>; else goto <D.9996>;
            <D.9995>:
            D.9984 = ts.tv_sec;
            if (D.9984 <= 0) goto <D.9997>; else goto <D.9998>;
            <D.9997>:
            ts.tv_nsec = 0;
            goto <D.9999>;
            <D.9998>:
            D.9984 = ts.tv_sec;
            D.10000 = D.9984 + -1;
            ts.tv_sec = D.10000;
            D.9982 = ts.tv_nsec;
            D.10001 = D.9982 + 1000000000;
            ts.tv_nsec = D.10001;
            <D.9999>:
            <D.9996>:
            D.9984 = ts.tv_sec;
            if (D.9984 < 0) goto <D.10002>; else goto <D.10003>;
            <D.10002>:
            ts.tv_sec = 0;
            ts.tv_nsec = 0;
            <D.10003>:
          }
        finally
          {
            current = {CLOBBER};
          }
      }
      <D.9949>:
      res = sem_timedwait (sem, &ts);
      if (res == -1) goto <D.10004>; else goto <D.9950>;
      <D.10004>:
      D.10005 = __errno_location ();
      D.10006 = *D.10005;
      if (D.10006 == 4) goto <D.9948>; else goto <D.9950>;
      <D.9950>:
      if (res != 0) goto <D.10007>; else goto <D.10008>;
      <D.10007>:
      res = -1;
      <D.10008>:
      D.9969 = res;
      return D.9969;
    }
  finally
    {
      ts = {CLOBBER};
      copy = {CLOBBER};
      t = {CLOBBER};
    }
}


mono_sem_wait (union MonoSemType * sem, gboolean alertable)
{
  int D.10015;
  int * D.10017;
  int D.10018;
  int res;

  goto <D.9957>;
  <D.9956>:
  if (alertable != 0) goto <D.10013>; else goto <D.10014>;
  <D.10013>:
  D.10015 = -1;
  return D.10015;
  <D.10014>:
  <D.9957>:
  res = sem_wait (sem);
  if (res == -1) goto <D.10016>; else goto <D.9958>;
  <D.10016>:
  D.10017 = __errno_location ();
  D.10018 = *D.10017;
  if (D.10018 == 4) goto <D.9956>; else goto <D.9958>;
  <D.9958>:
  if (res != 0) goto <D.10019>; else goto <D.10020>;
  <D.10019>:
  res = -1;
  <D.10020>:
  D.10015 = res;
  return D.10015;
}


mono_sem_post (union MonoSemType * sem)
{
  int * D.10023;
  int D.10024;
  int D.10025;
  int res;

  goto <D.9964>;
  <D.9963>:
  <D.9964>:
  res = sem_post (sem);
  if (res == -1) goto <D.10022>; else goto <D.9965>;
  <D.10022>:
  D.10023 = __errno_location ();
  D.10024 = *D.10023;
  if (D.10024 == 4) goto <D.9963>; else goto <D.9965>;
  <D.9965>:
  D.10025 = res;
  return D.10025;
}


