sgen_hash_table_lookup (struct SgenHashTable * hash_table, void * key)
{
  void * D.17223;
  struct SgenHashTableEntry * entry;

  entry = lookup (hash_table, key, 0B);
  if (entry == 0B) goto <D.17221>; else goto <D.17222>;
  <D.17221>:
  D.17223 = 0B;
  return D.17223;
  <D.17222>:
  D.17223 = &entry->data;
  return D.17223;
}


lookup (struct SgenHashTable * hash_table, void * key, guint * _hash)
{
  unsigned int D.17225;
  struct SgenHashTableEntry * D.17228;
  guint (*<Tbde>) (const void *) D.17229;
  unsigned int D.17230;
  struct SgenHashTableEntry * * D.17233;
  unsigned int D.17234;
  struct SgenHashTableEntry * * D.17235;
  void * D.17240;
  int D.17241;
  struct SgenHashTableEntry * entry;
  guint hash;
  gboolean (*GEqualFunc) (const void *, const void *) equal;

  equal = hash_table->equal_func;
  D.17225 = hash_table->size;
  if (D.17225 == 0) goto <D.17226>; else goto <D.17227>;
  <D.17226>:
  D.17228 = 0B;
  return D.17228;
  <D.17227>:
  D.17229 = hash_table->hash_func;
  D.17230 = D.17229 (key);
  D.17225 = hash_table->size;
  hash = D.17230 % D.17225;
  if (_hash != 0B) goto <D.17231>; else goto <D.17232>;
  <D.17231>:
  *_hash = hash;
  <D.17232>:
  D.17233 = hash_table->table;
  D.17234 = hash * 4;
  D.17235 = D.17233 + D.17234;
  entry = *D.17235;
  goto <D.17166>;
  <D.17165>:
  if (equal != 0B) goto <D.17239>; else goto <D.17236>;
  <D.17239>:
  D.17240 = entry->key;
  D.17241 = equal (D.17240, key);
  if (D.17241 != 0) goto <D.17237>; else goto <D.17236>;
  <D.17236>:
  if (equal == 0B) goto <D.17242>; else goto <D.17238>;
  <D.17242>:
  D.17240 = entry->key;
  if (D.17240 == key) goto <D.17237>; else goto <D.17238>;
  <D.17237>:
  D.17228 = entry;
  return D.17228;
  <D.17238>:
  entry = entry->next;
  <D.17166>:
  if (entry != 0B) goto <D.17165>; else goto <D.17167>;
  <D.17167>:
  D.17228 = 0B;
  return D.17228;
}


sgen_hash_table_replace (struct SgenHashTable * hash_table, void * key, void * new_value, void * old_value)
{
  char[0:] * D.17248;
  unsigned int D.17249;
  gboolean D.17250;
  int D.17251;
  struct SgenHashTableEntry * * D.17252;
  unsigned int hash.0;
  unsigned int D.17254;
  struct SgenHashTableEntry * * D.17255;
  struct SgenHashTableEntry * D.17256;
  unsigned int D.17257;
  unsigned int D.17258;
  guint hash;
  struct SgenHashTableEntry * entry;

  try
    {
      rehash_if_necessary (hash_table);
      entry = lookup (hash_table, key, &hash);
      if (entry != 0B) goto <D.17244>; else goto <D.17245>;
      <D.17244>:
      if (old_value != 0B) goto <D.17246>; else goto <D.17247>;
      <D.17246>:
      D.17248 = &entry->data;
      D.17249 = hash_table->data_size;
      memcpy (old_value, D.17248, D.17249);
      <D.17247>:
      D.17248 = &entry->data;
      D.17249 = hash_table->data_size;
      memcpy (D.17248, new_value, D.17249);
      D.17250 = 0;
      return D.17250;
      <D.17245>:
      D.17251 = hash_table->entry_mem_type;
      entry = sgen_alloc_internal (D.17251);
      entry->key = key;
      D.17248 = &entry->data;
      D.17249 = hash_table->data_size;
      memcpy (D.17248, new_value, D.17249);
      D.17252 = hash_table->table;
      hash.0 = hash;
      D.17254 = hash.0 * 4;
      D.17255 = D.17252 + D.17254;
      D.17256 = *D.17255;
      entry->next = D.17256;
      D.17252 = hash_table->table;
      hash.0 = hash;
      D.17254 = hash.0 * 4;
      D.17255 = D.17252 + D.17254;
      *D.17255 = entry;
      D.17257 = hash_table->num_entries;
      D.17258 = D.17257 + 1;
      hash_table->num_entries = D.17258;
      D.17250 = 1;
      return D.17250;
    }
  finally
    {
      hash = {CLOBBER};
    }
}


rehash_if_necessary (struct SgenHashTable * hash_table)
{
  unsigned int D.17261;
  unsigned int D.17262;
  unsigned int D.17263;

  D.17261 = hash_table->num_entries;
  D.17262 = hash_table->size;
  D.17263 = D.17262 * 2;
  if (D.17261 >= D.17263) goto <D.17264>; else goto <D.17265>;
  <D.17264>:
  rehash (hash_table);
  <D.17265>:
}


rehash (struct SgenHashTable * hash_table)
{
  int D.17268;
  unsigned int D.17269;
  unsigned int D.17270;
  unsigned int D.17272;
  unsigned int D.17273;
  int D.17274;
  unsigned int D.17275;
  struct SgenHashTableEntry * * D.17276;
  guint (*<Tbde>) (const void *) D.17277;
  void * D.17278;
  unsigned int D.17279;
  unsigned int D.17280;
  struct SgenHashTableEntry * * D.17281;
  struct SgenHashTableEntry * D.17282;
  unsigned int D.17283;
  struct SgenHashTableEntry * * old_hash;
  guint old_hash_size;
  guint i;
  guint hash;
  guint new_size;
  struct SgenHashTableEntry * * new_hash;
  struct SgenHashTableEntry * entry;
  struct SgenHashTableEntry * next;

  old_hash = hash_table->table;
  old_hash_size = hash_table->size;
  if (old_hash == 0B) goto <D.17266>; else goto <D.17267>;
  <D.17266>:
  D.17268 = hash_table->entry_mem_type;
  D.17269 = hash_table->data_size;
  D.17270 = D.17269 + 8;
  sgen_register_fixed_internal_mem_type (D.17268, D.17270);
  new_size = 13;
  goto <D.17271>;
  <D.17267>:
  D.17272 = hash_table->num_entries;
  new_size = monoeg_g_spaced_primes_closest (D.17272);
  <D.17271>:
  D.17273 = new_size * 4;
  D.17274 = hash_table->table_mem_type;
  new_hash = sgen_alloc_internal_dynamic (D.17273, D.17274, 1);
  i = 0;
  goto <D.17152>;
  <D.17151>:
  D.17275 = i * 4;
  D.17276 = old_hash + D.17275;
  entry = *D.17276;
  goto <D.17149>;
  <D.17148>:
  D.17277 = hash_table->hash_func;
  D.17278 = entry->key;
  D.17279 = D.17277 (D.17278);
  hash = D.17279 % new_size;
  next = entry->next;
  D.17280 = hash * 4;
  D.17281 = new_hash + D.17280;
  D.17282 = *D.17281;
  entry->next = D.17282;
  D.17280 = hash * 4;
  D.17281 = new_hash + D.17280;
  *D.17281 = entry;
  entry = next;
  <D.17149>:
  if (entry != 0B) goto <D.17148>; else goto <D.17150>;
  <D.17150>:
  i = i + 1;
  <D.17152>:
  if (i < old_hash_size) goto <D.17151>; else goto <D.17153>;
  <D.17153>:
  D.17283 = old_hash_size * 4;
  D.17274 = hash_table->table_mem_type;
  sgen_free_internal_dynamic (old_hash, D.17283, D.17274);
  hash_table->table = new_hash;
  hash_table->size = new_size;
}


memcpy (void * restrict __dest, const void * restrict __src, size_t __len)
{
  void * D.17284;
  unsigned int D.17285;

  D.17285 = __builtin_object_size (__dest, 0);
  D.17284 = __builtin___memcpy_chk (__dest, __src, __len, D.17285);
  return D.17284;
}


sgen_hash_table_set_value (struct SgenHashTable * hash_table, void * key, void * new_value, void * old_value)
{
  char[0:] * D.17291;
  unsigned int D.17292;
  gboolean D.17293;
  guint hash;
  struct SgenHashTableEntry * entry;

  try
    {
      entry = lookup (hash_table, key, &hash);
      if (entry != 0B) goto <D.17287>; else goto <D.17288>;
      <D.17287>:
      if (old_value != 0B) goto <D.17289>; else goto <D.17290>;
      <D.17289>:
      D.17291 = &entry->data;
      D.17292 = hash_table->data_size;
      memcpy (old_value, D.17291, D.17292);
      <D.17290>:
      D.17291 = &entry->data;
      D.17292 = hash_table->data_size;
      memcpy (D.17291, new_value, D.17292);
      D.17293 = 1;
      return D.17293;
      <D.17288>:
      D.17293 = 0;
      return D.17293;
    }
  finally
    {
      hash = {CLOBBER};
    }
}


sgen_hash_table_set_key (struct SgenHashTable * hash_table, void * old_key, void * new_key)
{
  gboolean D.17298;
  guint hash;
  struct SgenHashTableEntry * entry;

  try
    {
      entry = lookup (hash_table, old_key, &hash);
      if (entry != 0B) goto <D.17296>; else goto <D.17297>;
      <D.17296>:
      entry->key = new_key;
      D.17298 = 1;
      return D.17298;
      <D.17297>:
      D.17298 = 0;
      return D.17298;
    }
  finally
    {
      hash = {CLOBBER};
    }
}


sgen_hash_table_remove (struct SgenHashTable * hash_table, void * key, void * data_return)
{
  guint (*<Tbde>) (const void *) D.17301;
  unsigned int D.17302;
  unsigned int D.17303;
  struct SgenHashTableEntry * * D.17304;
  unsigned int D.17305;
  struct SgenHashTableEntry * * D.17306;
  void * D.17311;
  int D.17312;
  struct SgenHashTableEntry * D.17316;
  unsigned int D.17318;
  unsigned int D.17319;
  char[0:] * D.17322;
  unsigned int D.17323;
  int D.17324;
  gboolean D.17325;
  struct SgenHashTableEntry * entry;
  struct SgenHashTableEntry * prev;
  guint hash;
  gboolean (*GEqualFunc) (const void *, const void *) equal;

  equal = hash_table->equal_func;
  rehash_if_necessary (hash_table);
  D.17301 = hash_table->hash_func;
  D.17302 = D.17301 (key);
  D.17303 = hash_table->size;
  hash = D.17302 % D.17303;
  prev = 0B;
  D.17304 = hash_table->table;
  D.17305 = hash * 4;
  D.17306 = D.17304 + D.17305;
  entry = *D.17306;
  goto <D.17206>;
  <D.17205>:
  if (equal != 0B) goto <D.17310>; else goto <D.17307>;
  <D.17310>:
  D.17311 = entry->key;
  D.17312 = equal (D.17311, key);
  if (D.17312 != 0) goto <D.17308>; else goto <D.17307>;
  <D.17307>:
  if (equal == 0B) goto <D.17313>; else goto <D.17309>;
  <D.17313>:
  D.17311 = entry->key;
  if (D.17311 == key) goto <D.17308>; else goto <D.17309>;
  <D.17308>:
  if (prev != 0B) goto <D.17314>; else goto <D.17315>;
  <D.17314>:
  D.17316 = entry->next;
  prev->next = D.17316;
  goto <D.17317>;
  <D.17315>:
  D.17304 = hash_table->table;
  D.17305 = hash * 4;
  D.17306 = D.17304 + D.17305;
  D.17316 = entry->next;
  *D.17306 = D.17316;
  <D.17317>:
  D.17318 = hash_table->num_entries;
  D.17319 = D.17318 + 4294967295;
  hash_table->num_entries = D.17319;
  if (data_return != 0B) goto <D.17320>; else goto <D.17321>;
  <D.17320>:
  D.17322 = &entry->data;
  D.17323 = hash_table->data_size;
  memcpy (data_return, D.17322, D.17323);
  <D.17321>:
  D.17324 = hash_table->entry_mem_type;
  sgen_free_internal (entry, D.17324);
  D.17325 = 1;
  return D.17325;
  <D.17309>:
  prev = entry;
  entry = entry->next;
  <D.17206>:
  if (entry != 0B) goto <D.17205>; else goto <D.17207>;
  <D.17207>:
  D.17325 = 0;
  return D.17325;
}


sgen_hash_table_clean (struct SgenHashTable * hash_table)
{
  unsigned int D.17327;
  struct SgenHashTableEntry * * D.17330;
  _Bool D.17331;
  long int D.17332;
  long int D.17333;
  unsigned int D.17336;
  _Bool D.17337;
  long int D.17338;
  long int D.17339;
  unsigned int D.17342;
  struct SgenHashTableEntry * * D.17343;
  int D.17344;
  unsigned int D.17345;
  int D.17346;
  guint i;

  D.17327 = hash_table->size;
  if (D.17327 == 0) goto <D.17328>; else goto <D.17329>;
  <D.17328>:
  D.17330 = hash_table->table;
  D.17331 = D.17330 != 0B;
  D.17332 = (long int) D.17331;
  D.17333 = __builtin_expect (D.17332, 0);
  if (D.17333 != 0) goto <D.17334>; else goto <D.17335>;
  <D.17334>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "sgen-hash-table.c", 200, "!hash_table->table");
  <D.17335>:
  D.17336 = hash_table->num_entries;
  D.17337 = D.17336 != 0;
  D.17338 = (long int) D.17337;
  D.17339 = __builtin_expect (D.17338, 0);
  if (D.17339 != 0) goto <D.17340>; else goto <D.17341>;
  <D.17340>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "sgen-hash-table.c", 201, "!hash_table->num_entries");
  <D.17341>:
  return;
  <D.17329>:
  i = 0;
  goto <D.17218>;
  <D.17217>:
  {
    struct SgenHashTableEntry * entry;

    D.17330 = hash_table->table;
    D.17342 = i * 4;
    D.17343 = D.17330 + D.17342;
    entry = *D.17343;
    goto <D.17215>;
    <D.17214>:
    {
      struct SgenHashTableEntry * next;

      next = entry->next;
      D.17344 = hash_table->entry_mem_type;
      sgen_free_internal (entry, D.17344);
      entry = next;
    }
    <D.17215>:
    if (entry != 0B) goto <D.17214>; else goto <D.17216>;
    <D.17216>:
  }
  i = i + 1;
  <D.17218>:
  D.17327 = hash_table->size;
  if (D.17327 > i) goto <D.17217>; else goto <D.17219>;
  <D.17219>:
  D.17330 = hash_table->table;
  D.17327 = hash_table->size;
  D.17345 = D.17327 * 4;
  D.17346 = hash_table->table_mem_type;
  sgen_free_internal_dynamic (D.17330, D.17345, D.17346);
  hash_table->table = 0B;
  hash_table->size = 0;
  hash_table->num_entries = 0;
}


