mono_file_map_open (const char * name)
{
  struct MonoFileMap * D.6319;

  D.6319 = fopen (name, "rb");
  return D.6319;
}


mono_file_map_size (struct MonoFileMap * fmap)
{
  int D.6321;
  int D.6322;
  guint64 D.6325;
  long int D.6326;
  struct stat stat_buf;

  try
    {
      D.6321 = fileno (fmap);
      D.6322 = fstat (D.6321, &stat_buf);
      if (D.6322 < 0) goto <D.6323>; else goto <D.6324>;
      <D.6323>:
      D.6325 = 0;
      return D.6325;
      <D.6324>:
      D.6326 = stat_buf.st_size;
      D.6325 = (guint64) D.6326;
      return D.6325;
    }
  finally
    {
      stat_buf = {CLOBBER};
    }
}


fstat (int __fd, struct stat * __statbuf)
{
  int D.6329;

  D.6329 = __fxstat (1, __fd, __statbuf);
  return D.6329;
}


mono_file_map_fd (struct MonoFileMap * fmap)
{
  int D.6331;

  D.6331 = fileno (fmap);
  return D.6331;
}


mono_file_map_close (struct MonoFileMap * fmap)
{
  int D.6333;

  D.6333 = fclose (fmap);
  return D.6333;
}


mono_file_map_set_allocator (void * (*mono_file_map_alloc_fn) (size_t) alloc, void (*mono_file_map_release_fn) (void *) release)
{
  void * (*<T1252>) (size_t) iftmp.0;
  void (*<Tc2>) (void *) iftmp.1;

  if (alloc != 0B) goto <D.6336>; else goto <D.6337>;
  <D.6336>:
  iftmp.0 = alloc;
  goto <D.6338>;
  <D.6337>:
  iftmp.0 = malloc;
  <D.6338>:
  alloc_fn = iftmp.0;
  if (release != 0B) goto <D.6340>; else goto <D.6341>;
  <D.6340>:
  iftmp.1 = release;
  goto <D.6342>;
  <D.6341>:
  iftmp.1 = free;
  <D.6342>:
  release_fn = iftmp.1;
}


mono_file_map_fileio (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  void * (*<T1252>) (size_t) alloc_fn.2;
  void * D.6346;
  long int D.6347;
  long int offset.3;
  long int D.6349;
  long unsigned int D.6350;
  void (*<Tc2>) (void *) release_fn.4;
  long int D.6354;
  long int cur_offset.5;
  guint64 cur_offset;
  size_t bytes_read;
  void * ptr;

  alloc_fn.2 = alloc_fn;
  ptr = alloc_fn.2 (length);
  if (ptr == 0B) goto <D.6344>; else goto <D.6345>;
  <D.6344>:
  D.6346 = 0B;
  return D.6346;
  <D.6345>:
  D.6347 = lseek (fd, 0, 1);
  cur_offset = (guint64) D.6347;
  offset.3 = (long int) offset;
  D.6349 = lseek (fd, offset.3, 0);
  D.6350 = (long unsigned int) D.6349;
  if (D.6350 != offset) goto <D.6351>; else goto <D.6352>;
  <D.6351>:
  release_fn.4 = release_fn;
  release_fn.4 (ptr);
  D.6346 = 0B;
  return D.6346;
  <D.6352>:
  D.6354 = read (fd, ptr, length);
  bytes_read = (size_t) D.6354;
  cur_offset.5 = (long int) cur_offset;
  lseek (fd, cur_offset.5, 0);
  *ret_handle = 0B;
  D.6346 = ptr;
  return D.6346;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.6357;
  int D.6360;
  ssize_t D.6363;
  long unsigned int D.6364;
  long unsigned int D.6365;
  long unsigned int D.6368;

  D.6357 = __builtin_object_size (__buf, 0);
  if (D.6357 != 18446744073709551615) goto <D.6358>; else goto <D.6359>;
  <D.6358>:
  D.6360 = __builtin_constant_p (__nbytes);
  if (D.6360 == 0) goto <D.6361>; else goto <D.6362>;
  <D.6361>:
  D.6364 = __builtin_object_size (__buf, 0);
  D.6363 = __read_chk (__fd, __buf, __nbytes, D.6364);
  return D.6363;
  <D.6362>:
  D.6365 = __builtin_object_size (__buf, 0);
  if (D.6365 < __nbytes) goto <D.6366>; else goto <D.6367>;
  <D.6366>:
  D.6368 = __builtin_object_size (__buf, 0);
  D.6363 = __read_chk_warn (__fd, __buf, __nbytes, D.6368);
  return D.6363;
  <D.6367>:
  <D.6359>:
  D.6363 = __read_alias (__fd, __buf, __nbytes);
  return D.6363;
}


mono_file_unmap_fileio (void * addr, void * handle)
{
  void (*<Tc2>) (void *) release_fn.6;
  int D.6371;

  release_fn.6 = release_fn;
  release_fn.6 (addr);
  D.6371 = 0;
  return D.6371;
}


