static void *rcu_q_updater(void *arg)

{

    int j, target_el;

    long long n_updates_local = 0;

    long long n_removed_local = 0;

    struct list_element *el, *prev_el;



    *(struct rcu_reader_data **)arg = &rcu_reader;

    atomic_inc(&nthreadsrunning);

    while (goflag == GOFLAG_INIT) {

        g_usleep(1000);

    }



    while (goflag == GOFLAG_RUN) {

        target_el = select_random_el(RCU_Q_LEN);

        j = 0;

        /* FOREACH_RCU could work here but let's use both macros */

        QLIST_FOREACH_SAFE_RCU(prev_el, &Q_list_head, entry, el) {

            j++;

            if (target_el == j) {

                QLIST_REMOVE_RCU(prev_el, entry);

                /* may be more than one updater in the future */

                call_rcu1(&prev_el->rcu, reclaim_list_el);

                n_removed_local++;

                break;

            }

        }

        if (goflag == GOFLAG_STOP) {

            break;

        }

        target_el = select_random_el(RCU_Q_LEN);

        j = 0;

        QLIST_FOREACH_RCU(el, &Q_list_head, entry) {

            j++;

            if (target_el == j) {

                prev_el = g_new(struct list_element, 1);

                atomic_add(&n_nodes, 1);

                prev_el->val = atomic_read(&n_nodes);

                QLIST_INSERT_BEFORE_RCU(el, prev_el, entry);

                break;

            }

        }



        n_updates_local += 2;

        synchronize_rcu();

    }

    synchronize_rcu();

    atomic_add(&n_updates, n_updates_local);

    atomic_add(&n_nodes_removed, n_removed_local);

    return NULL;

}

static void *rcu_q_updater(void *arg)

{

    int j, target_el;

    long long n_updates_local = 0;

    long long n_removed_local = 0;

    struct list_element *el, *prev_el;



    *(struct rcu_reader_data **)arg = &rcu_reader;

    atomic_inc(&nthreadsrunning);

    while (goflag == GOFLAG_INIT) {

        g_usleep(1000);

    }



    while (goflag == GOFLAG_RUN) {

        target_el = select_random_el(RCU_Q_LEN);

        j = 0;

        

        QLIST_FOREACH_SAFE_RCU(prev_el, &Q_list_head, entry, el) {

            j++;

            if (target_el == j) {

                QLIST_REMOVE_RCU(prev_el, entry);

                

                call_rcu1(&prev_el->rcu, reclaim_list_el);

                n_removed_local++;

                break;

            }

        }

        if (goflag == GOFLAG_STOP) {

            break;

        }

        target_el = select_random_el(RCU_Q_LEN);

        j = 0;

        QLIST_FOREACH_RCU(el, &Q_list_head, entry) {

            j++;

            if (target_el == j) {

                prev_el = g_new(struct list_element, 1);

                atomic_add(&n_nodes, 1);

                prev_el->val = atomic_read(&n_nodes);

                QLIST_INSERT_BEFORE_RCU(el, prev_el, entry);

                break;

            }

        }



        n_updates_local += 2;

        synchronize_rcu();

    }

    synchronize_rcu();

    atomic_add(&n_updates, n_updates_local);

    atomic_add(&n_nodes_removed, n_removed_local);

    return NULL;

}

static void *FUNC_0(void *VAR_0)

{

    int VAR_1, VAR_2;

    long long VAR_3 = 0;

    long long VAR_4 = 0;

    struct list_element *VAR_5, *VAR_6;



    *(struct rcu_reader_data **)VAR_0 = &rcu_reader;

    atomic_inc(&nthreadsrunning);

    while (goflag == GOFLAG_INIT) {

        g_usleep(1000);

    }



    while (goflag == GOFLAG_RUN) {

        VAR_2 = select_random_el(RCU_Q_LEN);

        VAR_1 = 0;

        

        QLIST_FOREACH_SAFE_RCU(VAR_6, &Q_list_head, entry, VAR_5) {

            VAR_1++;

            if (VAR_2 == VAR_1) {

                QLIST_REMOVE_RCU(VAR_6, entry);

                

                call_rcu1(&VAR_6->rcu, reclaim_list_el);

                VAR_4++;

                break;

            }

        }

        if (goflag == GOFLAG_STOP) {

            break;

        }

        VAR_2 = select_random_el(RCU_Q_LEN);

        VAR_1 = 0;

        QLIST_FOREACH_RCU(VAR_5, &Q_list_head, entry) {

            VAR_1++;

            if (VAR_2 == VAR_1) {

                VAR_6 = g_new(struct list_element, 1);

                atomic_add(&n_nodes, 1);

                VAR_6->val = atomic_read(&n_nodes);

                QLIST_INSERT_BEFORE_RCU(VAR_5, VAR_6, entry);

                break;

            }

        }



        VAR_3 += 2;

        synchronize_rcu();

    }

    synchronize_rcu();

    atomic_add(&n_updates, VAR_3);

    atomic_add(&n_nodes_removed, VAR_4);

    return NULL;

}

static void *FUNC_0(void *VAR_0)
{ int VAR_1, VAR_2; long long VAR_3 = 0; long long VAR_4 = 0; struct list_element *VAR_5, *VAR_6; *(struct rcu_reader_data **)VAR_0 = &rcu_reader; atomic_inc(&nthreadsrunning); while (goflag == GOFLAG_INIT) { g_usleep(1000); } while (goflag == GOFLAG_RUN) { VAR_2 = select_random_el(RCU_Q_LEN); VAR_1 = 0; QLIST_FOREACH_SAFE_RCU(VAR_6, &Q_list_head, entry, VAR_5) { VAR_1++; if (VAR_2 == VAR_1) { QLIST_REMOVE_RCU(VAR_6, entry); call_rcu1(&VAR_6->rcu, reclaim_list_el); VAR_4++; break; } } if (goflag == GOFLAG_STOP) { break; } VAR_2 = select_random_el(RCU_Q_LEN); VAR_1 = 0; QLIST_FOREACH_RCU(VAR_5, &Q_list_head, entry) { VAR_1++; if (VAR_2 == VAR_1) { VAR_6 = g_new(struct list_element, 1); atomic_add(&n_nodes, 1); VAR_6->val = atomic_read(&n_nodes); QLIST_INSERT_BEFORE_RCU(VAR_5, VAR_6, entry); break; } } VAR_3 += 2; synchronize_rcu(); } synchronize_rcu(); atomic_add(&n_updates, VAR_3); atomic_add(&n_nodes_removed, VAR_4); return NULL; }