mono_sem_timedwait (union MonoSemType * sem, guint32 timeout_ms, gboolean alertable)
{
  int D.9455;
  unsigned int D.9458;
  long int D.9459;
  long int D.9460;
  long int D.9461;
  unsigned int D.9462;
  unsigned int D.9463;
  long int D.9464;
  long int D.9465;
  long int D.9466;
  long int D.9467;
  long int D.9468;
  long int D.9469;
  long int D.9470;
  long int D.9471;
  long int D.9474;
  long int D.9475;
  long int D.9476;
  long int D.9477;
  long int D.9478;
  long int D.9479;
  long int D.9480;
  long int D.9486;
  long int D.9487;
  int * D.9491;
  int D.9492;
  struct timespec ts;
  struct timespec copy;
  struct timeval t;
  int res;

  try
    {
      res = 0;
      if (timeout_ms == 0) goto <D.9453>; else goto <D.9454>;
      <D.9453>:
      D.9455 = sem_trywait (sem);
      return D.9455;
      <D.9454>:
      if (timeout_ms == 4294967295) goto <D.9456>; else goto <D.9457>;
      <D.9456>:
      D.9455 = mono_sem_wait (sem, alertable);
      return D.9455;
      <D.9457>:
      gettimeofday (&t, 0B);
      D.9458 = timeout_ms / 1000;
      D.9459 = (long int) D.9458;
      D.9460 = t.tv_sec;
      D.9461 = D.9459 + D.9460;
      ts.tv_sec = D.9461;
      D.9462 = timeout_ms % 1000;
      D.9463 = D.9462 * 1000000;
      D.9464 = (long int) D.9463;
      D.9465 = t.tv_usec;
      D.9466 = D.9465 * 1000;
      D.9467 = D.9464 + D.9466;
      ts.tv_nsec = D.9467;
      goto <D.9431>;
      <D.9430>:
      D.9468 = ts.tv_nsec;
      D.9469 = D.9468 + -1000000000;
      ts.tv_nsec = D.9469;
      D.9470 = ts.tv_sec;
      D.9471 = D.9470 + 1;
      ts.tv_sec = D.9471;
      <D.9431>:
      D.9468 = ts.tv_nsec;
      if (D.9468 > 1000000000) goto <D.9430>; else goto <D.9432>;
      <D.9432>:
      copy = ts;
      goto <D.9435>;
      <D.9434>:
      {
        struct timeval current;

        try
          {
            if (alertable != 0) goto <D.9472>; else goto <D.9473>;
            <D.9472>:
            D.9455 = -1;
            return D.9455;
            <D.9473>:
            gettimeofday (&current, 0B);
            ts = copy;
            D.9470 = ts.tv_sec;
            D.9460 = t.tv_sec;
            D.9474 = current.tv_sec;
            D.9475 = D.9460 - D.9474;
            D.9476 = D.9470 + D.9475;
            ts.tv_sec = D.9476;
            D.9468 = ts.tv_nsec;
            D.9465 = t.tv_usec;
            D.9477 = current.tv_usec;
            D.9478 = D.9465 - D.9477;
            D.9479 = D.9478 * 1000;
            D.9480 = D.9468 + D.9479;
            ts.tv_nsec = D.9480;
            D.9468 = ts.tv_nsec;
            if (D.9468 < 0) goto <D.9481>; else goto <D.9482>;
            <D.9481>:
            D.9470 = ts.tv_sec;
            if (D.9470 <= 0) goto <D.9483>; else goto <D.9484>;
            <D.9483>:
            ts.tv_nsec = 0;
            goto <D.9485>;
            <D.9484>:
            D.9470 = ts.tv_sec;
            D.9486 = D.9470 + -1;
            ts.tv_sec = D.9486;
            D.9468 = ts.tv_nsec;
            D.9487 = D.9468 + 1000000000;
            ts.tv_nsec = D.9487;
            <D.9485>:
            <D.9482>:
            D.9470 = ts.tv_sec;
            if (D.9470 < 0) goto <D.9488>; else goto <D.9489>;
            <D.9488>:
            ts.tv_sec = 0;
            ts.tv_nsec = 0;
            <D.9489>:
          }
        finally
          {
            current = {CLOBBER};
          }
      }
      <D.9435>:
      res = sem_timedwait (sem, &ts);
      if (res == -1) goto <D.9490>; else goto <D.9436>;
      <D.9490>:
      D.9491 = __errno_location ();
      D.9492 = *D.9491;
      if (D.9492 == 4) goto <D.9434>; else goto <D.9436>;
      <D.9436>:
      if (res != 0) goto <D.9493>; else goto <D.9494>;
      <D.9493>:
      res = -1;
      <D.9494>:
      D.9455 = res;
      return D.9455;
    }
  finally
    {
      ts = {CLOBBER};
      copy = {CLOBBER};
      t = {CLOBBER};
    }
}


mono_sem_wait (union MonoSemType * sem, gboolean alertable)
{
  int D.9501;
  int * D.9503;
  int D.9504;
  int res;

  goto <D.9443>;
  <D.9442>:
  if (alertable != 0) goto <D.9499>; else goto <D.9500>;
  <D.9499>:
  D.9501 = -1;
  return D.9501;
  <D.9500>:
  <D.9443>:
  res = sem_wait (sem);
  if (res == -1) goto <D.9502>; else goto <D.9444>;
  <D.9502>:
  D.9503 = __errno_location ();
  D.9504 = *D.9503;
  if (D.9504 == 4) goto <D.9442>; else goto <D.9444>;
  <D.9444>:
  if (res != 0) goto <D.9505>; else goto <D.9506>;
  <D.9505>:
  res = -1;
  <D.9506>:
  D.9501 = res;
  return D.9501;
}


mono_sem_post (union MonoSemType * sem)
{
  int * D.9509;
  int D.9510;
  int D.9511;
  int res;

  goto <D.9450>;
  <D.9449>:
  <D.9450>:
  res = sem_post (sem);
  if (res == -1) goto <D.9508>; else goto <D.9451>;
  <D.9508>:
  D.9509 = __errno_location ();
  D.9510 = *D.9509;
  if (D.9510 == 4) goto <D.9449>; else goto <D.9451>;
  <D.9451>:
  D.9511 = res;
  return D.9511;
}


