_wapi_lock_file_region (int fd, off_t offset, off_t length)
{
  _Bool D.9261;
  _Bool D.9262;
  _Bool D.9263;
  gboolean D.9266;
  int * D.9268;
  int D.9269;
  int D.9274;
  _Bool D.9275;
  _Bool D.9276;
  _Bool D.9277;
  struct flock lock_data;
  int ret;

  try
    {
      D.9261 = offset < 0;
      D.9262 = length < 0;
      D.9263 = D.9261 | D.9262;
      if (D.9263 != 0) goto <D.9264>; else goto <D.9265>;
      <D.9264>:
      SetLastError (87);
      D.9266 = 0;
      return D.9266;
      <D.9265>:
      lock_data.l_type = 1;
      lock_data.l_whence = 0;
      lock_data.l_start = offset;
      lock_data.l_len = length;
      <D.9223>:
      ret = fcntl (fd, 13, &lock_data);
      if (ret == -1) goto <D.9267>; else goto <D.9224>;
      <D.9267>:
      D.9268 = __errno_location ();
      D.9269 = *D.9268;
      if (D.9269 == 4) goto <D.9223>; else goto <D.9224>;
      <D.9224>:
      if (ret == -1) goto <D.9270>; else goto <D.9271>;
      <D.9270>:
      D.9268 = __errno_location ();
      D.9274 = *D.9268;
      D.9275 = D.9274 == 37;
      D.9276 = D.9274 == 95;
      D.9277 = D.9275 | D.9276;
      if (D.9277 != 0) goto <D.9272>; else goto <D.9278>;
      <D.9278>:
      D.9268 = __errno_location ();
      D.9269 = *D.9268;
      if (D.9269 == 95) goto <D.9272>; else goto <D.9273>;
      <D.9272>:
      D.9266 = 1;
      return D.9266;
      <D.9273>:
      SetLastError (33);
      D.9266 = 0;
      return D.9266;
      <D.9271>:
      D.9266 = 1;
      return D.9266;
    }
  finally
    {
      lock_data = {CLOBBER};
    }
}


_wapi_unlock_file_region (int fd, off_t offset, off_t length)
{
  int * D.9282;
  int D.9283;
  int D.9288;
  _Bool D.9289;
  _Bool D.9290;
  _Bool D.9291;
  gboolean D.9293;
  struct flock lock_data;
  int ret;

  try
    {
      lock_data.l_type = 2;
      lock_data.l_whence = 0;
      lock_data.l_start = offset;
      lock_data.l_len = length;
      <D.9232>:
      ret = fcntl (fd, 13, &lock_data);
      if (ret == -1) goto <D.9281>; else goto <D.9233>;
      <D.9281>:
      D.9282 = __errno_location ();
      D.9283 = *D.9282;
      if (D.9283 == 4) goto <D.9232>; else goto <D.9233>;
      <D.9233>:
      if (ret == -1) goto <D.9284>; else goto <D.9285>;
      <D.9284>:
      D.9282 = __errno_location ();
      D.9288 = *D.9282;
      D.9289 = D.9288 == 37;
      D.9290 = D.9288 == 95;
      D.9291 = D.9289 | D.9290;
      if (D.9291 != 0) goto <D.9286>; else goto <D.9292>;
      <D.9292>:
      D.9282 = __errno_location ();
      D.9283 = *D.9282;
      if (D.9283 == 95) goto <D.9286>; else goto <D.9287>;
      <D.9286>:
      D.9293 = 1;
      return D.9293;
      <D.9287>:
      SetLastError (33);
      D.9293 = 0;
      return D.9293;
      <D.9285>:
      D.9293 = 1;
      return D.9293;
    }
  finally
    {
      lock_data = {CLOBBER};
    }
}


LockFile (void * handle, guint32 offset_low, guint32 offset_high, guint32 length_low, guint32 length_high)
{
  gboolean D.9298;
  struct _WapiHandle_file * file_handle.0;
  unsigned int D.9300;
  signed int D.9301;
  unsigned int D.9304;
  unsigned int D.9305;
  long long int D.9308;
  long long int D.9309;
  long long int D.9310;
  long long int D.9311;
  long long int D.9312;
  long long int D.9313;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  off_t offset;
  off_t length;
  int fd;
  static const char __func__[9] = "LockFile";

  try
    {
      fd = (int) handle;
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.9296>; else goto <D.9297>;
      <D.9296>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.9298 = 0;
      return D.9298;
      <D.9297>:
      file_handle.0 = file_handle;
      D.9300 = file_handle.0->fileaccess;
      D.9301 = (signed int) D.9300;
      if (D.9301 >= 0) goto <D.9302>; else goto <D.9303>;
      <D.9302>:
      file_handle.0 = file_handle;
      D.9304 = BIT_FIELD_REF <*file_handle.0, 32, 128>;
      D.9305 = D.9304 & 1342177280;
      if (D.9305 == 0) goto <D.9306>; else goto <D.9307>;
      <D.9306>:
      SetLastError (5);
      D.9298 = 0;
      return D.9298;
      <D.9307>:
      <D.9303>:
      D.9308 = (long long int) offset_high;
      D.9309 = D.9308 << 32;
      D.9310 = (long long int) offset_low;
      offset = D.9309 | D.9310;
      D.9311 = (long long int) length_high;
      D.9312 = D.9311 << 32;
      D.9313 = (long long int) length_low;
      length = D.9312 | D.9313;
      D.9298 = _wapi_lock_file_region (fd, offset, length);
      return D.9298;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


UnlockFile (void * handle, guint32 offset_low, guint32 offset_high, guint32 length_low, guint32 length_high)
{
  gboolean D.9318;
  struct _WapiHandle_file * file_handle.1;
  unsigned int D.9320;
  signed int D.9321;
  unsigned int D.9324;
  unsigned int D.9325;
  long long int D.9328;
  long long int D.9329;
  long long int D.9330;
  long long int D.9331;
  long long int D.9332;
  long long int D.9333;
  struct _WapiHandle_file * file_handle;
  gboolean ok;
  off_t offset;
  off_t length;
  int fd;
  static const char __func__[11] = "UnlockFile";

  try
    {
      fd = (int) handle;
      ok = _wapi_lookup_handle (handle, 1, &file_handle);
      if (ok == 0) goto <D.9316>; else goto <D.9317>;
      <D.9316>:
      monoeg_g_log (0B, 16, "%s: error looking up file handle %p", &__func__, handle);
      SetLastError (6);
      D.9318 = 0;
      return D.9318;
      <D.9317>:
      file_handle.1 = file_handle;
      D.9320 = file_handle.1->fileaccess;
      D.9321 = (signed int) D.9320;
      if (D.9321 >= 0) goto <D.9322>; else goto <D.9323>;
      <D.9322>:
      file_handle.1 = file_handle;
      D.9324 = BIT_FIELD_REF <*file_handle.1, 32, 128>;
      D.9325 = D.9324 & 1342177280;
      if (D.9325 == 0) goto <D.9326>; else goto <D.9327>;
      <D.9326>:
      SetLastError (5);
      D.9318 = 0;
      return D.9318;
      <D.9327>:
      <D.9323>:
      D.9328 = (long long int) offset_high;
      D.9329 = D.9328 << 32;
      D.9330 = (long long int) offset_low;
      offset = D.9329 | D.9330;
      D.9331 = (long long int) length_high;
      D.9332 = D.9331 << 32;
      D.9333 = (long long int) length_low;
      length = D.9332 | D.9333;
      D.9318 = _wapi_unlock_file_region (fd, offset, length);
      return D.9318;
    }
  finally
    {
      file_handle = {CLOBBER};
    }
}


