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

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


mono_file_map_size (struct MonoFileMap * fmap)
{
  int D.6839;
  int D.6840;
  guint64 D.6843;
  long int D.6844;
  struct stat stat_buf;

  try
    {
      D.6839 = fileno (fmap);
      D.6840 = fstat (D.6839, &stat_buf);
      if (D.6840 < 0) goto <D.6841>; else goto <D.6842>;
      <D.6841>:
      D.6843 = 0;
      return D.6843;
      <D.6842>:
      D.6844 = stat_buf.st_size;
      D.6843 = (guint64) D.6844;
      return D.6843;
    }
  finally
    {
      stat_buf = {CLOBBER};
    }
}


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

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


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

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


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

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


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

  if (alloc != 0B) goto <D.6854>; else goto <D.6855>;
  <D.6854>:
  iftmp.0 = alloc;
  goto <D.6856>;
  <D.6855>:
  iftmp.0 = malloc;
  <D.6856>:
  alloc_fn = iftmp.0;
  if (release != 0B) goto <D.6858>; else goto <D.6859>;
  <D.6858>:
  iftmp.1 = release;
  goto <D.6860>;
  <D.6859>:
  iftmp.1 = free;
  <D.6860>:
  release_fn = iftmp.1;
}


mono_file_map_fileio (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  void * (*<T1281>) (size_t) alloc_fn.2;
  void * D.6864;
  long int D.6865;
  long int offset.3;
  long int D.6867;
  long unsigned int D.6868;
  void (*<Tbf>) (void *) release_fn.4;
  long int D.6872;
  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.6862>; else goto <D.6863>;
  <D.6862>:
  D.6864 = 0B;
  return D.6864;
  <D.6863>:
  D.6865 = lseek (fd, 0, 1);
  cur_offset = (guint64) D.6865;
  offset.3 = (long int) offset;
  D.6867 = lseek (fd, offset.3, 0);
  D.6868 = (long unsigned int) D.6867;
  if (D.6868 != offset) goto <D.6869>; else goto <D.6870>;
  <D.6869>:
  release_fn.4 = release_fn;
  release_fn.4 (ptr);
  D.6864 = 0B;
  return D.6864;
  <D.6870>:
  D.6872 = read (fd, ptr, length);
  bytes_read = (size_t) D.6872;
  cur_offset.5 = (long int) cur_offset;
  lseek (fd, cur_offset.5, 0);
  *ret_handle = 0B;
  D.6864 = ptr;
  return D.6864;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.6875;
  int D.6878;
  ssize_t D.6881;
  long unsigned int D.6882;
  long unsigned int D.6883;
  long unsigned int D.6886;

  D.6875 = __builtin_object_size (__buf, 0);
  if (D.6875 != 18446744073709551615) goto <D.6876>; else goto <D.6877>;
  <D.6876>:
  D.6878 = __builtin_constant_p (__nbytes);
  if (D.6878 == 0) goto <D.6879>; else goto <D.6880>;
  <D.6879>:
  D.6882 = __builtin_object_size (__buf, 0);
  D.6881 = __read_chk (__fd, __buf, __nbytes, D.6882);
  return D.6881;
  <D.6880>:
  D.6883 = __builtin_object_size (__buf, 0);
  if (D.6883 < __nbytes) goto <D.6884>; else goto <D.6885>;
  <D.6884>:
  D.6886 = __builtin_object_size (__buf, 0);
  D.6881 = __read_chk_warn (__fd, __buf, __nbytes, D.6886);
  return D.6881;
  <D.6885>:
  <D.6877>:
  D.6881 = __read_alias (__fd, __buf, __nbytes);
  return D.6881;
}


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

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


