<commit_before>
#include "clique_naude.h"

intset_t* clique_enum_naude_pivot_extra(clique_context_t* ctx, intset_t* p, intset_t* x, intset_t* r, intset_t** extra)
{
    size_t v, q, least;
    intset_walk_t it;
    intset_t *nv, *nw, *Q, *ex = NULL;
    size_t domain = ctx->n;

search:
    q = domain; // an initial value which is not a valid vertex
    least = domain + 1; // not infinity, but large enough

    intset_walk(&it, x);
    while (intset_walk_next(&it, &v))
    {
        size_t w = 0, count;
        nv = adjacency_row(ctx->matrix, v);
        count = intset_count_common_inverse_until(p, nv, least, &w);
        if (count < least)
        {
            if (count <= 2)
            {
                if (count != 1) // count in { 0, 2 }
                {
                    q = v;
                    goto conclude;
                }
                else
                {
                    /// Process w in place
                    nw = adjacency_row(ctx->matrix, w);
                    if (ex == NULL)
                    {
                        ex = intset(domain, false, &ctx->manager);
                    }
                    ctx->numInPivot++;
                    intset_add(ex, w);
                    intset_add(r, w);
                    intset_intersect(p, nw, false);
                    intset_intersect(x, nw, false);

                    if ((q < domain) && !intset_contains(nw, q)) goto search;
                }
            }
            else
            {
                q = v;
                least = count;
            }
        }
    }

    intset_walk(&it, p);
    while (intset_walk_next(&it, &v))
    {
        size_t w = 0, count;
        nv = adjacency_row(ctx->matrix, v);
        count = intset_count_common_inverse_until(p, nv, least, &w);
        if (count < least)
        {
            if (count <= 2)
            {
                if (count != 1) // count in { 0, 2 }
                {
                    q = v;
                    goto conclude;
                }
                else
                {
                    /// Process v in place
                    if (ex == NULL)
                    {
                        ex = intset(domain, false, &ctx->manager);
                    }
                    ctx->numInPivot++;
                    intset_add(ex, v);
                    intset_add(r, v);
                    intset_intersect(p, nv, false);
                    intset_intersect(x, nv, false);

                    if ((q < domain) && !intset_contains(nv, q)) goto search;
                }
            }
            else
            {
                q = v;
                least = count;
            }
        }
    }

conclude:
    *extra = ex;
    if (q < domain)
    {
        nv = adjacency_row(ctx->matrix, q);
        Q = intset_copy_remove(p, nv);
        return Q;
    }
    else
    {
        return NULL;
    }<commit_msg>Reduced runtime cost of instrumentation<commit_after>
#include "clique_naude.h"

intset_t* clique_enum_naude_pivot_extra(clique_context_t* ctx, intset_t* p, intset_t* x, intset_t* r, intset_t** extra)
{
    size_t v, q, least;
    intset_walk_t it;
    intset_t *nv, *nw, *Q, *ex = NULL;
    uint64_t numInPivot = ctx->numInPivot;
    size_t domain = ctx->n;

search:
    q = domain; // an initial value which is not a valid vertex
    least = domain + 1; // not infinity, but large enough

    intset_walk(&it, x);
    while (intset_walk_next(&it, &v))
    {
        size_t w = 0, count;
        nv = adjacency_row(ctx->matrix, v);
        count = intset_count_common_inverse_until(p, nv, least, &w);
        if (count < least)
        {
            if (count <= 2)
            {
                if (count != 1) // count in { 0, 2 }
                {
                    q = v;
                    goto conclude;
                }
                else
                {
                    /// Process w in place
                    nw = adjacency_row(ctx->matrix, w);
                    if (ex == NULL)
                    {
                        ex = intset(domain, false, &ctx->manager);
                    }
                    numInPivot++;
                    intset_add(ex, w);
                    intset_add(r, w);
                    intset_intersect(p, nw, false);
                    intset_intersect(x, nw, false);

                    if ((q < domain) && !intset_contains(nw, q)) goto search;
                }
            }
            else
            {
                q = v;
                least = count;
            }
        }
    }

    intset_walk(&it, p);
    while (intset_walk_next(&it, &v))
    {
        size_t w = 0, count;
        nv = adjacency_row(ctx->matrix, v);
        count = intset_count_common_inverse_until(p, nv, least, &w);
        if (count < least)
        {
            if (count <= 2)
            {
                if (count != 1) // count in { 0, 2 }
                {
                    q = v;
                    goto conclude;
                }
                else
                {
                    /// Process v in place
                    if (ex == NULL)
                    {
                        ex = intset(domain, false, &ctx->manager);
                    }
                    numInPivot++;
                    intset_add(ex, v);
                    intset_add(r, v);
                    intset_intersect(p, nv, false);
                    intset_intersect(x, nv, false);

                    if ((q < domain) && !intset_contains(nv, q)) goto search;
                }
            }
            else
            {
                q = v;
                least = count;
            }
        }
    }

conclude:
    ctx->numInPivot = numInPivot;
    *extra = ex;
    if (q < domain)
    {
        nv = adjacency_row(ctx->matrix, q);
        Q = intset_copy_remove(p, nv);
        return Q;
    }
    else
    {
        return NULL;
    }
{'fraction_non_alphanumeric': 0.10778847778340936, 'fraction_numerical': 0.0040547389761784085, 'mean_word_length': 0.9919246298788694, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2205913', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1716, 'n_words': 423}