int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,

                       void *opaque, int version_id)

{

    VMStateField *field = vmsd->fields;



    if (version_id > vmsd->version_id) {

        return -EINVAL;

    }

    if (version_id < vmsd->minimum_version_id_old) {

        return -EINVAL;

    }

    if  (version_id < vmsd->minimum_version_id) {

        return vmsd->load_state_old(f, opaque, version_id);

    }

    while(field->name) {

        if (field->version_id <= version_id) {

            void *base_addr = opaque + field->offset;

            int ret, i, n_elems = 1;



            if (field->flags & VMS_ARRAY) {

                n_elems = field->num;

            } else if (field->flags & VMS_VARRAY) {

                n_elems = *(size_t *)(opaque+field->num_offset);

            }

            if (field->flags & VMS_POINTER) {

                base_addr = *(void **)base_addr;

            }

            for (i = 0; i < n_elems; i++) {

                void *addr = base_addr + field->size * i;



                if (field->flags & VMS_STRUCT) {

                    ret = vmstate_load_state(f, field->vmsd, addr, version_id);

                } else {

                    ret = field->info->get(f, addr, field->size);



                }

                if (ret < 0) {

                    return ret;

                }

            }

        }

        field++;

    }

    if (vmsd->run_after_load)

        return vmsd->run_after_load(opaque);

    return 0;

}

int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,

                       void *opaque, int version_id)

{

    VMStateField *field = vmsd->fields;



    if (version_id > vmsd->version_id) {

        return -EINVAL;

    }

    if (version_id < vmsd->minimum_version_id_old) {

        return -EINVAL;

    }

    if  (version_id < vmsd->minimum_version_id) {

        return vmsd->load_state_old(f, opaque, version_id);

    }

    while(field->name) {

        if (field->version_id <= version_id) {

            void *base_addr = opaque + field->offset;

            int ret, i, n_elems = 1;



            if (field->flags & VMS_ARRAY) {

                n_elems = field->num;

            } else if (field->flags & VMS_VARRAY) {

                n_elems = *(size_t *)(opaque+field->num_offset);

            }

            if (field->flags & VMS_POINTER) {

                base_addr = *(void **)base_addr;

            }

            for (i = 0; i < n_elems; i++) {

                void *addr = base_addr + field->size * i;



                if (field->flags & VMS_STRUCT) {

                    ret = vmstate_load_state(f, field->vmsd, addr, version_id);

                } else {

                    ret = field->info->get(f, addr, field->size);



                }

                if (ret < 0) {

                    return ret;

                }

            }

        }

        field++;

    }

    if (vmsd->run_after_load)

        return vmsd->run_after_load(opaque);

    return 0;

}

int FUNC_0(QEMUFile *VAR_0, const VMStateDescription *VAR_1,

                       void *VAR_2, int VAR_3)

{

    VMStateField *field = VAR_1->fields;



    if (VAR_3 > VAR_1->VAR_3) {

        return -EINVAL;

    }

    if (VAR_3 < VAR_1->minimum_version_id_old) {

        return -EINVAL;

    }

    if  (VAR_3 < VAR_1->minimum_version_id) {

        return VAR_1->load_state_old(VAR_0, VAR_2, VAR_3);

    }

    while(field->name) {

        if (field->VAR_3 <= VAR_3) {

            void *VAR_4 = VAR_2 + field->offset;

            int VAR_5, VAR_6, VAR_7 = 1;



            if (field->flags & VMS_ARRAY) {

                VAR_7 = field->num;

            } else if (field->flags & VMS_VARRAY) {

                VAR_7 = *(size_t *)(VAR_2+field->num_offset);

            }

            if (field->flags & VMS_POINTER) {

                VAR_4 = *(void **)VAR_4;

            }

            for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) {

                void *VAR_8 = VAR_4 + field->size * VAR_6;



                if (field->flags & VMS_STRUCT) {

                    VAR_5 = FUNC_0(VAR_0, field->VAR_1, VAR_8, VAR_3);

                } else {

                    VAR_5 = field->info->get(VAR_0, VAR_8, field->size);



                }

                if (VAR_5 < 0) {

                    return VAR_5;

                }

            }

        }

        field++;

    }

    if (VAR_1->run_after_load)

        return VAR_1->run_after_load(VAR_2);

    return 0;

}

int FUNC_0(QEMUFile *VAR_0, const VMStateDescription *VAR_1,
void *VAR_2, int VAR_3)
{ VMStateField *field = VAR_1->fields; if (VAR_3 > VAR_1->VAR_3) { return -EINVAL; } if (VAR_3 < VAR_1->minimum_version_id_old) { return -EINVAL; } if  (VAR_3 < VAR_1->minimum_version_id) { return VAR_1->load_state_old(VAR_0, VAR_2, VAR_3); } while(field->name) { if (field->VAR_3 <= VAR_3) { void *VAR_4 = VAR_2 + field->offset; int VAR_5, VAR_6, VAR_7 = 1; if (field->flags & VMS_ARRAY) { VAR_7 = field->num; } else if (field->flags & VMS_VARRAY) { VAR_7 = *(size_t *)(VAR_2+field->num_offset); } if (field->flags & VMS_POINTER) { VAR_4 = *(void **)VAR_4; } for (VAR_6 = 0; VAR_6 < VAR_7; VAR_6++) { void *VAR_8 = VAR_4 + field->size * VAR_6; if (field->flags & VMS_STRUCT) { VAR_5 = FUNC_0(VAR_0, field->VAR_1, VAR_8, VAR_3); } else { VAR_5 = field->info->get(VAR_0, VAR_8, field->size); } if (VAR_5 < 0) { return VAR_5; } } } field++; } if (VAR_1->run_after_load)
return VAR_1->run_after_load(VAR_2); return 0; }