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

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


mono_file_map_size (struct MonoFileMap * fmap)
{
  int D.5973;
  int D.5974;
  guint64 D.5977;
  long long int D.5978;
  struct stat stat_buf;

  try
    {
      D.5973 = fileno (fmap);
      D.5974 = fstat (D.5973, &stat_buf);
      if (D.5974 < 0) goto <D.5975>; else goto <D.5976>;
      <D.5975>:
      D.5977 = 0;
      return D.5977;
      <D.5976>:
      D.5978 = stat_buf.st_size;
      D.5977 = (guint64) D.5978;
      return D.5977;
    }
  finally
    {
      stat_buf = {CLOBBER};
    }
}


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

  D.5981 = __fxstat (3, __fd, __statbuf);
  return D.5981;
}


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

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


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

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


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

  if (alloc != 0B) goto <D.5988>; else goto <D.5989>;
  <D.5988>:
  iftmp.0 = alloc;
  goto <D.5990>;
  <D.5989>:
  iftmp.0 = malloc;
  <D.5990>:
  alloc_fn = iftmp.0;
  if (release != 0B) goto <D.5992>; else goto <D.5993>;
  <D.5992>:
  iftmp.1 = release;
  goto <D.5994>;
  <D.5993>:
  iftmp.1 = free;
  <D.5994>:
  release_fn = iftmp.1;
}


mono_file_map_fileio (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  void * (*<T11c8>) (size_t) alloc_fn.2;
  void * D.5998;
  long long int D.5999;
  long long int offset.3;
  long long int D.6001;
  long long unsigned int D.6002;
  void (*<Tbf>) (void *) release_fn.4;
  int D.6006;
  long 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.5996>; else goto <D.5997>;
  <D.5996>:
  D.5998 = 0B;
  return D.5998;
  <D.5997>:
  D.5999 = lseek (fd, 0, 1);
  cur_offset = (guint64) D.5999;
  offset.3 = (long long int) offset;
  D.6001 = lseek (fd, offset.3, 0);
  D.6002 = (long long unsigned int) D.6001;
  if (D.6002 != offset) goto <D.6003>; else goto <D.6004>;
  <D.6003>:
  release_fn.4 = release_fn;
  release_fn.4 (ptr);
  D.5998 = 0B;
  return D.5998;
  <D.6004>:
  D.6006 = read (fd, ptr, length);
  bytes_read = (size_t) D.6006;
  cur_offset.5 = (long long int) cur_offset;
  lseek (fd, cur_offset.5, 0);
  *ret_handle = 0B;
  D.5998 = ptr;
  return D.5998;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.6009;
  int D.6012;
  ssize_t D.6015;
  unsigned int D.6016;
  unsigned int D.6017;
  unsigned int D.6020;

  D.6009 = __builtin_object_size (__buf, 0);
  if (D.6009 != 4294967295) goto <D.6010>; else goto <D.6011>;
  <D.6010>:
  D.6012 = __builtin_constant_p (__nbytes);
  if (D.6012 == 0) goto <D.6013>; else goto <D.6014>;
  <D.6013>:
  D.6016 = __builtin_object_size (__buf, 0);
  D.6015 = __read_chk (__fd, __buf, __nbytes, D.6016);
  return D.6015;
  <D.6014>:
  D.6017 = __builtin_object_size (__buf, 0);
  if (D.6017 < __nbytes) goto <D.6018>; else goto <D.6019>;
  <D.6018>:
  D.6020 = __builtin_object_size (__buf, 0);
  D.6015 = __read_chk_warn (__fd, __buf, __nbytes, D.6020);
  return D.6015;
  <D.6019>:
  <D.6011>:
  D.6015 = __read_alias (__fd, __buf, __nbytes);
  return D.6015;
}


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

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


