static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,

                                 int64_t max_ns)

{

    bool has_timeout = max_ns != -1;

    int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;

    int index = spapr->htab_save_index;

    int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);



    assert(spapr->htab_first_pass);



    do {

        int chunkstart;



        /* Consume invalid HPTEs */

        while ((index < htabslots)

               && !HPTE_VALID(HPTE(spapr->htab, index))) {

            index++;

            CLEAN_HPTE(HPTE(spapr->htab, index));

        }



        /* Consume valid HPTEs */

        chunkstart = index;

        while ((index < htabslots) && (index - chunkstart < USHRT_MAX)

               && HPTE_VALID(HPTE(spapr->htab, index))) {

            index++;

            CLEAN_HPTE(HPTE(spapr->htab, index));

        }



        if (index > chunkstart) {

            int n_valid = index - chunkstart;



            qemu_put_be32(f, chunkstart);

            qemu_put_be16(f, n_valid);

            qemu_put_be16(f, 0);

            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),

                            HASH_PTE_SIZE_64 * n_valid);



            if (has_timeout &&

                (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {

                break;

            }

        }

    } while ((index < htabslots) && !qemu_file_rate_limit(f));



    if (index >= htabslots) {

        assert(index == htabslots);

        index = 0;

        spapr->htab_first_pass = false;

    }

    spapr->htab_save_index = index;

}

static void htab_save_first_pass(QEMUFile *f, sPAPRMachineState *spapr,

                                 int64_t max_ns)

{

    bool has_timeout = max_ns != -1;

    int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;

    int index = spapr->htab_save_index;

    int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);



    assert(spapr->htab_first_pass);



    do {

        int chunkstart;



        

        while ((index < htabslots)

               && !HPTE_VALID(HPTE(spapr->htab, index))) {

            index++;

            CLEAN_HPTE(HPTE(spapr->htab, index));

        }



        

        chunkstart = index;

        while ((index < htabslots) && (index - chunkstart < USHRT_MAX)

               && HPTE_VALID(HPTE(spapr->htab, index))) {

            index++;

            CLEAN_HPTE(HPTE(spapr->htab, index));

        }



        if (index > chunkstart) {

            int n_valid = index - chunkstart;



            qemu_put_be32(f, chunkstart);

            qemu_put_be16(f, n_valid);

            qemu_put_be16(f, 0);

            qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),

                            HASH_PTE_SIZE_64 * n_valid);



            if (has_timeout &&

                (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {

                break;

            }

        }

    } while ((index < htabslots) && !qemu_file_rate_limit(f));



    if (index >= htabslots) {

        assert(index == htabslots);

        index = 0;

        spapr->htab_first_pass = false;

    }

    spapr->htab_save_index = index;

}

            index++;             index++;
static void FUNC_0(QEMUFile *VAR_0, sPAPRMachineState *VAR_1,

                                 int64_t VAR_2)

{

    bool has_timeout = VAR_2 != -1;

    int VAR_3 = HTAB_SIZE(VAR_1) / HASH_PTE_SIZE_64;

    int VAR_4 = VAR_1->htab_save_index;

    int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);



    assert(VAR_1->htab_first_pass);



    do {

        int VAR_5;



        

        while ((VAR_4 < VAR_3)

               && !HPTE_VALID(HPTE(VAR_1->htab, VAR_4))) {

            VAR_4++;

            CLEAN_HPTE(HPTE(VAR_1->htab, VAR_4));

        }



        

        VAR_5 = VAR_4;

        while ((VAR_4 < VAR_3) && (VAR_4 - VAR_5 < USHRT_MAX)

               && HPTE_VALID(HPTE(VAR_1->htab, VAR_4))) {

            VAR_4++;

            CLEAN_HPTE(HPTE(VAR_1->htab, VAR_4));

        }



        if (VAR_4 > VAR_5) {

            int VAR_6 = VAR_4 - VAR_5;



            qemu_put_be32(VAR_0, VAR_5);

            qemu_put_be16(VAR_0, VAR_6);

            qemu_put_be16(VAR_0, 0);

            qemu_put_buffer(VAR_0, HPTE(VAR_1->htab, VAR_5),

                            HASH_PTE_SIZE_64 * VAR_6);



            if (has_timeout &&

                (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > VAR_2) {

                break;

            }

        }

    } while ((VAR_4 < VAR_3) && !qemu_file_rate_limit(VAR_0));



    if (VAR_4 >= VAR_3) {

        assert(VAR_4 == VAR_3);

        VAR_4 = 0;

        VAR_1->htab_first_pass = false;

    }

    VAR_1->htab_save_index = VAR_4;

}

static void FUNC_0(QEMUFile *VAR_0, sPAPRMachineState *VAR_1,
int64_t VAR_2)
{ bool has_timeout = VAR_2 != -1; int VAR_3 = HTAB_SIZE(VAR_1) / HASH_PTE_SIZE_64; int VAR_4 = VAR_1->htab_save_index; int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); assert(VAR_1->htab_first_pass); do { int VAR_5; while ((VAR_4 < VAR_3)
&& !HPTE_VALID(HPTE(VAR_1->htab, VAR_4))) { VAR_4++; CLEAN_HPTE(HPTE(VAR_1->htab, VAR_4)); } VAR_5 = VAR_4; while ((VAR_4 < VAR_3) && (VAR_4 - VAR_5 < USHRT_MAX)
&& HPTE_VALID(HPTE(VAR_1->htab, VAR_4))) { VAR_4++; CLEAN_HPTE(HPTE(VAR_1->htab, VAR_4)); } if (VAR_4 > VAR_5) { int VAR_6 = VAR_4 - VAR_5; qemu_put_be32(VAR_0, VAR_5); qemu_put_be16(VAR_0, VAR_6); qemu_put_be16(VAR_0, 0); qemu_put_buffer(VAR_0, HPTE(VAR_1->htab, VAR_5),
HASH_PTE_SIZE_64 * VAR_6); if (has_timeout &&
(qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > VAR_2) { break; } } } while ((VAR_4 < VAR_3) && !qemu_file_rate_limit(VAR_0)); if (VAR_4 >= VAR_3) { assert(VAR_4 == VAR_3); VAR_4 = 0; VAR_1->htab_first_pass = false; } VAR_1->htab_save_index = VAR_4; }