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

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


mono_file_map_size (struct MonoFileMap * fmap)
{
  int D.5996;
  int D.5997;
  guint64 D.6000;
  long long int D.6001;
  struct stat stat_buf;

  try
    {
      D.5996 = fileno (fmap);
      D.5997 = fstat (D.5996, &stat_buf);
      if (D.5997 < 0) goto <D.5998>; else goto <D.5999>;
      <D.5998>:
      D.6000 = 0;
      return D.6000;
      <D.5999>:
      D.6001 = stat_buf.st_size;
      D.6000 = (guint64) D.6001;
      return D.6000;
    }
  finally
    {
      stat_buf = {CLOBBER};
    }
}


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

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


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

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


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

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


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

  if (alloc != 0B) goto <D.6011>; else goto <D.6012>;
  <D.6011>:
  iftmp.0 = alloc;
  goto <D.6013>;
  <D.6012>:
  iftmp.0 = malloc;
  <D.6013>:
  alloc_fn = iftmp.0;
  if (release != 0B) goto <D.6015>; else goto <D.6016>;
  <D.6015>:
  iftmp.1 = release;
  goto <D.6017>;
  <D.6016>:
  iftmp.1 = free;
  <D.6017>:
  release_fn = iftmp.1;
}


mono_file_map_fileio (size_t length, int flags, int fd, guint64 offset, void * * ret_handle)
{
  void * (*<T11de>) (size_t) alloc_fn.2;
  void * D.6021;
  long long int D.6022;
  long long int offset.3;
  long long int D.6024;
  long long unsigned int D.6025;
  void (*<Tc3>) (void *) release_fn.4;
  int D.6029;
  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.6019>; else goto <D.6020>;
  <D.6019>:
  D.6021 = 0B;
  return D.6021;
  <D.6020>:
  D.6022 = lseek (fd, 0, 1);
  cur_offset = (guint64) D.6022;
  offset.3 = (long long int) offset;
  D.6024 = lseek (fd, offset.3, 0);
  D.6025 = (long long unsigned int) D.6024;
  if (D.6025 != offset) goto <D.6026>; else goto <D.6027>;
  <D.6026>:
  release_fn.4 = release_fn;
  release_fn.4 (ptr);
  D.6021 = 0B;
  return D.6021;
  <D.6027>:
  D.6029 = read (fd, ptr, length);
  bytes_read = (size_t) D.6029;
  cur_offset.5 = (long long int) cur_offset;
  lseek (fd, cur_offset.5, 0);
  *ret_handle = 0B;
  D.6021 = ptr;
  return D.6021;
}


read (int __fd, void * __buf, size_t __nbytes)
{
  unsigned int D.6032;
  int D.6035;
  ssize_t D.6038;
  unsigned int D.6039;
  unsigned int D.6040;
  unsigned int D.6043;

  D.6032 = __builtin_object_size (__buf, 0);
  if (D.6032 != 4294967295) goto <D.6033>; else goto <D.6034>;
  <D.6033>:
  D.6035 = __builtin_constant_p (__nbytes);
  if (D.6035 == 0) goto <D.6036>; else goto <D.6037>;
  <D.6036>:
  D.6039 = __builtin_object_size (__buf, 0);
  D.6038 = __read_chk (__fd, __buf, __nbytes, D.6039);
  return D.6038;
  <D.6037>:
  D.6040 = __builtin_object_size (__buf, 0);
  if (D.6040 < __nbytes) goto <D.6041>; else goto <D.6042>;
  <D.6041>:
  D.6043 = __builtin_object_size (__buf, 0);
  D.6038 = __read_chk_warn (__fd, __buf, __nbytes, D.6043);
  return D.6038;
  <D.6042>:
  <D.6034>:
  D.6038 = __read_alias (__fd, __buf, __nbytes);
  return D.6038;
}


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

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


