HeapCreate (gint32 flags, gint32 initial_size, gint32 max_size)
{
  struct GHashTable * heaps.0;
  struct GHashTable * heaps.1;
  struct GHashTable * D.5946;
  void * D.5947;
  struct HeapInfo * hi;

  heaps.0 = heaps;
  if (heaps.0 == 0B) goto <D.5941>; else goto <D.5942>;
  <D.5941>:
  heaps.1 = monoeg_g_hash_table_new (monoeg_g_direct_hash, monoeg_g_direct_equal);
  heaps = heaps.1;
  <D.5942>:
  if (flags != 0) goto <D.5944>; else goto <D.5945>;
  <D.5944>:
  monoeg_g_log (0B, 16, "Flags for HeapCreate are the unsupported value non-zero");
  <D.5945>:
  hi = monoeg_malloc (24);
  hi->flags = flags;
  hi->initial_size = initial_size;
  hi->max_size = max_size;
  D.5946 = monoeg_g_hash_table_new (monoeg_g_direct_hash, monoeg_g_direct_equal);
  hi->hash = D.5946;
  heaps.0 = heaps;
  monoeg_g_hash_table_insert_replace (heaps.0, hi, hi, 0);
  D.5947 = hi;
  return D.5947;
}


HeapSetInformation (void * handle, void * heap_info_class, void * heap_info, gint32 head_info_length)
{
  gboolean D.5949;

  D.5949 = 1;
  return D.5949;
}


HeapQueryInformation (void * handle, void * heap_info_class, void * heap_info, gint32 head_info_length, gint32 * ret_length)
{
  gboolean D.5951;

  *ret_length = 0;
  D.5951 = 1;
  return D.5951;
}


HeapAlloc (void * handle, gint32 flags, gint32 nbytes)
{
  long unsigned int D.5953;
  long int D.5954;
  void * D.5955;
  struct GHashTable * D.5956;
  void * D.5957;
  struct HeapInfo * heap;
  void * ptr;

  heap = handle;
  D.5953 = (long unsigned int) nbytes;
  ptr = monoeg_malloc0 (D.5953);
  D.5954 = (long int) nbytes;
  D.5955 = (void *) D.5954;
  D.5956 = heap->hash;
  monoeg_g_hash_table_insert_replace (D.5956, ptr, D.5955, 0);
  D.5957 = ptr;
  return D.5957;
}


HeapReAlloc (void * handle, gint32 flags, void * mem, gint32 nbytes)
{
  struct GHashTable * D.5959;
  long unsigned int D.5960;
  long int D.5961;
  void * D.5962;
  void * D.5963;
  struct HeapInfo * heap;
  void * ptr;

  heap = handle;
  D.5959 = heap->hash;
  monoeg_g_hash_table_remove (D.5959, mem);
  D.5960 = (long unsigned int) nbytes;
  ptr = monoeg_realloc (mem, D.5960);
  D.5961 = (long int) nbytes;
  D.5962 = (void *) D.5961;
  D.5959 = heap->hash;
  monoeg_g_hash_table_insert_replace (D.5959, ptr, D.5962, 0);
  D.5963 = ptr;
  return D.5963;
}


HeapSize (void * handle, gint32 flags, void * mem)
{
  struct GHashTable * D.5965;
  void * D.5966;
  long int D.5967;
  gint32 D.5968;
  struct HeapInfo * heap;
  gint32 size;

  heap = handle;
  D.5965 = heap->hash;
  D.5966 = monoeg_g_hash_table_lookup (D.5965, mem);
  D.5967 = (long int) D.5966;
  size = (gint32) D.5967;
  D.5968 = size;
  return D.5968;
}


HeapFree (void * handle, gint32 flags, void * mem)
{
  struct GHashTable * D.5970;
  gboolean D.5971;
  struct HeapInfo * heap;

  heap = handle;
  D.5970 = heap->hash;
  monoeg_g_hash_table_remove (D.5970, mem);
  monoeg_g_free (mem);
  D.5971 = 1;
  return D.5971;
}


HeapValidate (void * handle, void * mem)
{
  gboolean D.5973;

  D.5973 = 1;
  return D.5973;
}


HeapDestroy (void * handle)
{
  struct HeapInfo * process_heap.2;
  gboolean D.5978;
  struct GHashTable * D.5979;
  struct GHashTable * heaps.3;
  struct HeapInfo * heap;

  heap = handle;
  process_heap.2 = process_heap;
  if (handle == process_heap.2) goto <D.5976>; else goto <D.5977>;
  <D.5976>:
  D.5978 = 0;
  return D.5978;
  <D.5977>:
  D.5979 = heap->hash;
  monoeg_g_hash_table_foreach (D.5979, free_handles, 0B);
  D.5979 = heap->hash;
  monoeg_g_hash_table_destroy (D.5979);
  heaps.3 = heaps;
  monoeg_g_hash_table_remove (heaps.3, handle);
  monoeg_g_free (heap);
  D.5978 = 1;
  return D.5978;
}


free_handles (void * key, void * value, void * user_data)
{
  monoeg_g_free (key);
}


GetProcessHeap ()
{
  struct HeapInfo * process_heap.4;
  void * process_heap.5;
  void * D.5986;

  process_heap.4 = process_heap;
  if (process_heap.4 == 0B) goto <D.5983>; else goto <D.5984>;
  <D.5983>:
  process_heap.5 = monoeg_malloc (24);
  process_heap = process_heap.5;
  process_heap.4 = process_heap;
  process_heap.4->flags = 0;
  process_heap.4 = process_heap;
  process_heap.4->initial_size = 1024;
  process_heap.4 = process_heap;
  process_heap.4->max_size = 1073741824;
  <D.5984>:
  D.5986 = process_heap;
  return D.5986;
}


