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

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


mono_file_map_size (struct MonoFileMap * fmap)
{
  int D.6491;
  int D.6492;
  guint64 D.6495;
  long int D.6496;
  struct stat stat_buf;

  try
    {
      D.6491 = fileno (fmap);
      D.6492 = fstat (D.6491, &stat_buf);
      if (D.6492 < 0) goto <D.6493>; else goto <D.6494>;
      <D.6493>:
      D.6495 = 0;
      return D.6495;
      <D.6494>:
      D.6496 = stat_buf.st_size;
      D.6495 = (guint64) D.6496;
      return D.6495;
    }
  finally
    {
      stat_buf = {CLOBBER};
    }
}


__attribute__((__gnu_inline__, __leaf__, __nothrow__))
fstat (int __fd, struct stat * __statbuf)
{
  int D.6499;

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


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

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


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

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


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

  if (alloc != 0B) goto <D.6506>; else goto <D.6507>;
  <D.6506>:
  iftmp.0 = alloc;
  goto <D.6508>;
  <D.6507>:
  iftmp.0 = malloc;
  <D.6508>:
  alloc_fn = iftmp.0;
  if (release != 0B) goto <D.6510>; else goto <D.6511>;
  <D.6510>:
  iftmp.1 = release;
  goto <D.6512>;
  <D.6511>:
  iftmp.1 = free;
  <D.6512>:
  release_fn = iftmp.1;
}


mono_file_map_fileio (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  void * (*<T135c>) (size_t) alloc_fn.2;
  void * D.6516;
  long int D.6517;
  long int offset.3;
  long int D.6519;
  long unsigned int D.6520;
  void (*<Tc6>) (void *) release_fn.4;
  long int D.6524;
  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.6514>; else goto <D.6515>;
  <D.6514>:
  D.6516 = 0B;
  return D.6516;
  <D.6515>:
  D.6517 = lseek (fd, 0, 1);
  cur_offset = (guint64) D.6517;
  offset.3 = (long int) offset;
  D.6519 = lseek (fd, offset.3, 0);
  D.6520 = (long unsigned int) D.6519;
  if (D.6520 != offset) goto <D.6521>; else goto <D.6522>;
  <D.6521>:
  release_fn.4 = release_fn;
  release_fn.4 (ptr);
  D.6516 = 0B;
  return D.6516;
  <D.6522>:
  D.6524 = read (fd, ptr, length);
  bytes_read = (size_t) D.6524;
  cur_offset.5 = (long int) cur_offset;
  lseek (fd, cur_offset.5, 0);
  *ret_handle = 0B;
  D.6516 = ptr;
  return D.6516;
}


__attribute__((__artificial__, __gnu_inline__, __always_inline__))
read (int __fd, void * __buf, size_t __nbytes)
{
  long unsigned int D.6527;
  int D.6530;
  ssize_t D.6533;
  long unsigned int D.6534;
  long unsigned int D.6535;
  long unsigned int D.6538;

  D.6527 = __builtin_object_size (__buf, 0);
  if (D.6527 != 18446744073709551615) goto <D.6528>; else goto <D.6529>;
  <D.6528>:
  D.6530 = __builtin_constant_p (__nbytes);
  if (D.6530 == 0) goto <D.6531>; else goto <D.6532>;
  <D.6531>:
  D.6534 = __builtin_object_size (__buf, 0);
  D.6533 = __read_chk (__fd, __buf, __nbytes, D.6534);
  return D.6533;
  <D.6532>:
  D.6535 = __builtin_object_size (__buf, 0);
  if (D.6535 < __nbytes) goto <D.6536>; else goto <D.6537>;
  <D.6536>:
  D.6538 = __builtin_object_size (__buf, 0);
  D.6533 = __read_chk_warn (__fd, __buf, __nbytes, D.6538);
  return D.6533;
  <D.6537>:
  <D.6529>:
  D.6533 = __read_alias (__fd, __buf, __nbytes);
  return D.6533;
}


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

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


