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

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


lookup (struct SgenHashTable * hash_table, void * key, guint * _hash)
{
  unsigned int D.17245;
  struct SgenHashTableEntry * D.17248;
  guint (*<Tbd5>) (const void *) D.17249;
  unsigned int D.17250;
  struct SgenHashTableEntry * * D.17253;
  unsigned int D.17254;
  struct SgenHashTableEntry * * D.17255;
  void * D.17260;
  int D.17261;
  struct SgenHashTableEntry * entry;
  guint hash;
  gboolean (*GEqualFunc) (const void *, const void *) equal;

  equal = hash_table->equal_func;
  D.17245 = hash_table->size;
  if (D.17245 == 0) goto <D.17246>; else goto <D.17247>;
  <D.17246>:
  D.17248 = 0B;
  return D.17248;
  <D.17247>:
  D.17249 = hash_table->hash_func;
  D.17250 = D.17249 (key);
  D.17245 = hash_table->size;
  hash = D.17250 % D.17245;
  if (_hash != 0B) goto <D.17251>; else goto <D.17252>;
  <D.17251>:
  *_hash = hash;
  <D.17252>:
  D.17253 = hash_table->table;
  D.17254 = hash * 4;
  D.17255 = D.17253 + D.17254;
  entry = *D.17255;
  goto <D.17186>;
  <D.17185>:
  if (equal != 0B) goto <D.17259>; else goto <D.17256>;
  <D.17259>:
  D.17260 = entry->key;
  D.17261 = equal (D.17260, key);
  if (D.17261 != 0) goto <D.17257>; else goto <D.17256>;
  <D.17256>:
  if (equal == 0B) goto <D.17262>; else goto <D.17258>;
  <D.17262>:
  D.17260 = entry->key;
  if (D.17260 == key) goto <D.17257>; else goto <D.17258>;
  <D.17257>:
  D.17248 = entry;
  return D.17248;
  <D.17258>:
  entry = entry->next;
  <D.17186>:
  if (entry != 0B) goto <D.17185>; else goto <D.17187>;
  <D.17187>:
  D.17248 = 0B;
  return D.17248;
}


sgen_hash_table_replace (struct SgenHashTable * hash_table, void * key, void * new_value, void * old_value)
{
  unsigned int D.17268;
  char[0:] * D.17269;
  gboolean D.17270;
  int D.17271;
  struct SgenHashTableEntry * * D.17272;
  unsigned int hash.0;
  unsigned int D.17274;
  struct SgenHashTableEntry * * D.17275;
  struct SgenHashTableEntry * D.17276;
  unsigned int D.17277;
  unsigned int D.17278;
  guint hash;
  struct SgenHashTableEntry * entry;

  try
    {
      rehash_if_necessary (hash_table);
      entry = lookup (hash_table, key, &hash);
      if (entry != 0B) goto <D.17264>; else goto <D.17265>;
      <D.17264>:
      if (old_value != 0B) goto <D.17266>; else goto <D.17267>;
      <D.17266>:
      D.17268 = hash_table->data_size;
      D.17269 = &entry->data;
      memcpy (old_value, D.17269, D.17268);
      <D.17267>:
      D.17268 = hash_table->data_size;
      D.17269 = &entry->data;
      memcpy (D.17269, new_value, D.17268);
      D.17270 = 0;
      return D.17270;
      <D.17265>:
      D.17271 = hash_table->entry_mem_type;
      entry = sgen_alloc_internal (D.17271);
      entry->key = key;
      D.17268 = hash_table->data_size;
      D.17269 = &entry->data;
      memcpy (D.17269, new_value, D.17268);
      D.17272 = hash_table->table;
      hash.0 = hash;
      D.17274 = hash.0 * 4;
      D.17275 = D.17272 + D.17274;
      D.17276 = *D.17275;
      entry->next = D.17276;
      D.17272 = hash_table->table;
      hash.0 = hash;
      D.17274 = hash.0 * 4;
      D.17275 = D.17272 + D.17274;
      *D.17275 = entry;
      D.17277 = hash_table->num_entries;
      D.17278 = D.17277 + 1;
      hash_table->num_entries = D.17278;
      D.17270 = 1;
      return D.17270;
    }
  finally
    {
      hash = {CLOBBER};
    }
}


rehash_if_necessary (struct SgenHashTable * hash_table)
{
  unsigned int D.17281;
  unsigned int D.17282;
  unsigned int D.17283;

  D.17281 = hash_table->num_entries;
  D.17282 = hash_table->size;
  D.17283 = D.17282 * 2;
  if (D.17281 >= D.17283) goto <D.17284>; else goto <D.17285>;
  <D.17284>:
  rehash (hash_table);
  <D.17285>:
}


rehash (struct SgenHashTable * hash_table)
{
  unsigned int D.17288;
  unsigned int D.17289;
  int D.17290;
  unsigned int D.17292;
  int D.17293;
  unsigned int D.17294;
  unsigned int D.17295;
  struct SgenHashTableEntry * * D.17296;
  guint (*<Tbd5>) (const void *) D.17297;
  void * D.17298;
  unsigned int D.17299;
  unsigned int D.17300;
  struct SgenHashTableEntry * * D.17301;
  struct SgenHashTableEntry * D.17302;
  unsigned int D.17303;
  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.17286>; else goto <D.17287>;
  <D.17286>:
  D.17288 = hash_table->data_size;
  D.17289 = D.17288 + 8;
  D.17290 = hash_table->entry_mem_type;
  sgen_register_fixed_internal_mem_type (D.17290, D.17289);
  new_size = 13;
  goto <D.17291>;
  <D.17287>:
  D.17292 = hash_table->num_entries;
  new_size = monoeg_g_spaced_primes_closest (D.17292);
  <D.17291>:
  D.17293 = hash_table->table_mem_type;
  D.17294 = new_size * 4;
  new_hash = sgen_alloc_internal_dynamic (D.17294, D.17293, 1);
  i = 0;
  goto <D.17172>;
  <D.17171>:
  D.17295 = i * 4;
  D.17296 = old_hash + D.17295;
  entry = *D.17296;
  goto <D.17169>;
  <D.17168>:
  D.17297 = hash_table->hash_func;
  D.17298 = entry->key;
  D.17299 = D.17297 (D.17298);
  hash = D.17299 % new_size;
  next = entry->next;
  D.17300 = hash * 4;
  D.17301 = new_hash + D.17300;
  D.17302 = *D.17301;
  entry->next = D.17302;
  D.17300 = hash * 4;
  D.17301 = new_hash + D.17300;
  *D.17301 = entry;
  entry = next;
  <D.17169>:
  if (entry != 0B) goto <D.17168>; else goto <D.17170>;
  <D.17170>:
  i = i + 1;
  <D.17172>:
  if (i < old_hash_size) goto <D.17171>; else goto <D.17173>;
  <D.17173>:
  D.17293 = hash_table->table_mem_type;
  D.17303 = old_hash_size * 4;
  sgen_free_internal_dynamic (old_hash, D.17303, D.17293);
  hash_table->table = new_hash;
  hash_table->size = new_size;
}


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

  D.17305 = __builtin_object_size (__dest, 0);
  D.17304 = __builtin___memcpy_chk (__dest, __src, __len, D.17305);
  return D.17304;
}


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

  try
    {
      entry = lookup (hash_table, key, &hash);
      if (entry != 0B) goto <D.17307>; else goto <D.17308>;
      <D.17307>:
      if (old_value != 0B) goto <D.17309>; else goto <D.17310>;
      <D.17309>:
      D.17311 = hash_table->data_size;
      D.17312 = &entry->data;
      memcpy (old_value, D.17312, D.17311);
      <D.17310>:
      D.17311 = hash_table->data_size;
      D.17312 = &entry->data;
      memcpy (D.17312, new_value, D.17311);
      D.17313 = 1;
      return D.17313;
      <D.17308>:
      D.17313 = 0;
      return D.17313;
    }
  finally
    {
      hash = {CLOBBER};
    }
}


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

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


sgen_hash_table_remove (struct SgenHashTable * hash_table, void * key, void * data_return)
{
  guint (*<Tbd5>) (const void *) D.17321;
  unsigned int D.17322;
  unsigned int D.17323;
  struct SgenHashTableEntry * * D.17324;
  unsigned int D.17325;
  struct SgenHashTableEntry * * D.17326;
  void * D.17331;
  int D.17332;
  struct SgenHashTableEntry * D.17336;
  unsigned int D.17338;
  unsigned int D.17339;
  unsigned int D.17342;
  char[0:] * D.17343;
  int D.17344;
  gboolean D.17345;
  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.17321 = hash_table->hash_func;
  D.17322 = D.17321 (key);
  D.17323 = hash_table->size;
  hash = D.17322 % D.17323;
  prev = 0B;
  D.17324 = hash_table->table;
  D.17325 = hash * 4;
  D.17326 = D.17324 + D.17325;
  entry = *D.17326;
  goto <D.17226>;
  <D.17225>:
  if (equal != 0B) goto <D.17330>; else goto <D.17327>;
  <D.17330>:
  D.17331 = entry->key;
  D.17332 = equal (D.17331, key);
  if (D.17332 != 0) goto <D.17328>; else goto <D.17327>;
  <D.17327>:
  if (equal == 0B) goto <D.17333>; else goto <D.17329>;
  <D.17333>:
  D.17331 = entry->key;
  if (D.17331 == key) goto <D.17328>; else goto <D.17329>;
  <D.17328>:
  if (prev != 0B) goto <D.17334>; else goto <D.17335>;
  <D.17334>:
  D.17336 = entry->next;
  prev->next = D.17336;
  goto <D.17337>;
  <D.17335>:
  D.17324 = hash_table->table;
  D.17325 = hash * 4;
  D.17326 = D.17324 + D.17325;
  D.17336 = entry->next;
  *D.17326 = D.17336;
  <D.17337>:
  D.17338 = hash_table->num_entries;
  D.17339 = D.17338 + 4294967295;
  hash_table->num_entries = D.17339;
  if (data_return != 0B) goto <D.17340>; else goto <D.17341>;
  <D.17340>:
  D.17342 = hash_table->data_size;
  D.17343 = &entry->data;
  memcpy (data_return, D.17343, D.17342);
  <D.17341>:
  D.17344 = hash_table->entry_mem_type;
  sgen_free_internal (entry, D.17344);
  D.17345 = 1;
  return D.17345;
  <D.17329>:
  prev = entry;
  entry = entry->next;
  <D.17226>:
  if (entry != 0B) goto <D.17225>; else goto <D.17227>;
  <D.17227>:
  D.17345 = 0;
  return D.17345;
}


sgen_hash_table_clean (struct SgenHashTable * hash_table)
{
  unsigned int D.17347;
  struct SgenHashTableEntry * * D.17350;
  _Bool D.17351;
  long int D.17352;
  long int D.17353;
  unsigned int D.17356;
  _Bool D.17357;
  long int D.17358;
  long int D.17359;
  unsigned int D.17362;
  struct SgenHashTableEntry * * D.17363;
  int D.17364;
  int D.17365;
  unsigned int D.17366;
  guint i;

  D.17347 = hash_table->size;
  if (D.17347 == 0) goto <D.17348>; else goto <D.17349>;
  <D.17348>:
  D.17350 = hash_table->table;
  D.17351 = D.17350 != 0B;
  D.17352 = (long int) D.17351;
  D.17353 = __builtin_expect (D.17352, 0);
  if (D.17353 != 0) goto <D.17354>; else goto <D.17355>;
  <D.17354>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "sgen-hash-table.c", 200, "!hash_table->table");
  <D.17355>:
  D.17356 = hash_table->num_entries;
  D.17357 = D.17356 != 0;
  D.17358 = (long int) D.17357;
  D.17359 = __builtin_expect (D.17358, 0);
  if (D.17359 != 0) goto <D.17360>; else goto <D.17361>;
  <D.17360>:
  monoeg_assertion_message ("* Assertion at %s:%d, condition `%s\' not met\n", "sgen-hash-table.c", 201, "!hash_table->num_entries");
  <D.17361>:
  return;
  <D.17349>:
  i = 0;
  goto <D.17238>;
  <D.17237>:
  {
    struct SgenHashTableEntry * entry;

    D.17350 = hash_table->table;
    D.17362 = i * 4;
    D.17363 = D.17350 + D.17362;
    entry = *D.17363;
    goto <D.17235>;
    <D.17234>:
    {
      struct SgenHashTableEntry * next;

      next = entry->next;
      D.17364 = hash_table->entry_mem_type;
      sgen_free_internal (entry, D.17364);
      entry = next;
    }
    <D.17235>:
    if (entry != 0B) goto <D.17234>; else goto <D.17236>;
    <D.17236>:
  }
  i = i + 1;
  <D.17238>:
  D.17347 = hash_table->size;
  if (D.17347 > i) goto <D.17237>; else goto <D.17239>;
  <D.17239>:
  D.17365 = hash_table->table_mem_type;
  D.17347 = hash_table->size;
  D.17366 = D.17347 * 4;
  D.17350 = hash_table->table;
  sgen_free_internal_dynamic (D.17350, D.17366, D.17365);
  hash_table->table = 0B;
  hash_table->size = 0;
  hash_table->num_entries = 0;
}


