ecma_find_or_create_literal_bigint (ecma_value_t bigint) /**< bigint to be searched */
{
  JERRY_ASSERT (ecma_is_value_bigint (bigint));

  if (bigint == ECMA_BIGINT_ZERO)
  {
    return bigint;
  }

  jmem_cpointer_t bigint_list_cp = JERRY_CONTEXT (bigint_list_first_cp);
  jmem_cpointer_t *empty_cpointer_p = NULL;

  while (bigint_list_cp != JMEM_CP_NULL)
  {
    ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
                                                                           bigint_list_cp);

    for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
    {
      if (bigint_list_p->values[i] == JMEM_CP_NULL)
      {
        if (empty_cpointer_p == NULL)
        {
          empty_cpointer_p = bigint_list_p->values + i;
        }
      }
      else
      {
        ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
                                                                                  bigint_list_p->values[i]);
        ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);

        if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
        {
          ecma_free_value (bigint);
          return other_bigint;
        }
      }
    }

    bigint_list_cp = bigint_list_p->next_cp;
  }

  jmem_cpointer_t result;
  JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_extended_primitive_from_value (bigint));

  if (empty_cpointer_p != NULL)
  {
    *empty_cpointer_p = result;
    return bigint;
  }

  ecma_lit_storage_item_t *new_item_p;
  new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));

  new_item_p->values[0] = result;
  for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
  {
    new_item_p->values[i] = JMEM_CP_NULL;
  }

  new_item_p->next_cp = JERRY_CONTEXT (bigint_list_first_cp);
  JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (bigint_list_first_cp), new_item_p);

  return bigint;
} /* ecma_find_or_create_literal_bigint */
ecma_find_or_create_literal_bigint (ecma_value_t bigint)  
{
  JERRY_ASSERT (ecma_is_value_bigint (bigint));

  if (bigint == ECMA_BIGINT_ZERO)
  {
    return bigint;
  }

  jmem_cpointer_t bigint_list_cp = JERRY_CONTEXT (bigint_list_first_cp);
  jmem_cpointer_t *empty_cpointer_p = NULL;

  while (bigint_list_cp != JMEM_CP_NULL)
  {
    ecma_lit_storage_item_t *bigint_list_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_lit_storage_item_t,
                                                                           bigint_list_cp);

    for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
    {
      if (bigint_list_p->values[i] == JMEM_CP_NULL)
      {
        if (empty_cpointer_p == NULL)
        {
          empty_cpointer_p = bigint_list_p->values + i;
        }
      }
      else
      {
        ecma_extended_primitive_t *other_bigint_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_extended_primitive_t,
                                                                                  bigint_list_p->values[i]);
        ecma_value_t other_bigint = ecma_make_extended_primitive_value (other_bigint_p, ECMA_TYPE_BIGINT);

        if (ecma_bigint_is_equal_to_bigint (bigint, other_bigint))
        {
          ecma_free_value (bigint);
          return other_bigint;
        }
      }
    }

    bigint_list_cp = bigint_list_p->next_cp;
  }

  jmem_cpointer_t result;
  JMEM_CP_SET_NON_NULL_POINTER (result, ecma_get_extended_primitive_from_value (bigint));

  if (empty_cpointer_p != NULL)
  {
    *empty_cpointer_p = result;
    return bigint;
  }

  ecma_lit_storage_item_t *new_item_p;
  new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));

  new_item_p->values[0] = result;
  for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
  {
    new_item_p->values[i] = JMEM_CP_NULL;
  }

  new_item_p->next_cp = JERRY_CONTEXT (bigint_list_first_cp);
  JMEM_CP_SET_NON_NULL_POINTER (JERRY_CONTEXT (bigint_list_first_cp), new_item_p);

  return bigint;
}  