int pci_device_load(PCIDevice *s, QEMUFile *f)

{

    uint8_t config[PCI_CONFIG_SPACE_SIZE];

    uint32_t version_id;

    int i;



    version_id = qemu_get_be32(f);

    if (version_id > 2)

        return -EINVAL;

    qemu_get_buffer(f, config, sizeof config);

    for (i = 0; i < sizeof config; ++i)

        if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i])

            return -EINVAL;

    memcpy(s->config, config, sizeof config);



    pci_update_mappings(s);



    if (version_id >= 2)

        for (i = 0; i < 4; i ++)

            s->irq_state[i] = qemu_get_be32(f);

    return 0;

}

int pci_device_load(PCIDevice *s, QEMUFile *f)

{

    uint8_t config[PCI_CONFIG_SPACE_SIZE];

    uint32_t version_id;

    int i;



    version_id = qemu_get_be32(f);

    if (version_id > 2)

        return -EINVAL;

    qemu_get_buffer(f, config, sizeof config);

    for (i = 0; i < sizeof config; ++i)

        if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i])

            return -EINVAL;

    memcpy(s->config, config, sizeof config);



    pci_update_mappings(s);



    if (version_id >= 2)

        for (i = 0; i < 4; i ++)

            s->irq_state[i] = qemu_get_be32(f);

    return 0;

}

int FUNC_0(PCIDevice *VAR_0, QEMUFile *VAR_1)

{

    uint8_t config[PCI_CONFIG_SPACE_SIZE];

    uint32_t version_id;

    int VAR_2;



    version_id = qemu_get_be32(VAR_1);

    if (version_id > 2)

        return -EINVAL;

    qemu_get_buffer(VAR_1, config, sizeof config);

    for (VAR_2 = 0; VAR_2 < sizeof config; ++VAR_2)

        if ((config[VAR_2] ^ VAR_0->config[VAR_2]) & VAR_0->cmask[VAR_2] & ~VAR_0->wmask[VAR_2])

            return -EINVAL;

    memcpy(VAR_0->config, config, sizeof config);



    pci_update_mappings(VAR_0);



    if (version_id >= 2)

        for (VAR_2 = 0; VAR_2 < 4; VAR_2 ++)

            VAR_0->irq_state[VAR_2] = qemu_get_be32(VAR_1);

    return 0;

}

int FUNC_0(PCIDevice *VAR_0, QEMUFile *VAR_1)
{ uint8_t config[PCI_CONFIG_SPACE_SIZE]; uint32_t version_id; int VAR_2; version_id = qemu_get_be32(VAR_1); if (version_id > 2)
return -EINVAL; qemu_get_buffer(VAR_1, config, sizeof config); for (VAR_2 = 0; VAR_2 < sizeof config; ++VAR_2) if ((config[VAR_2] ^ VAR_0->config[VAR_2]) & VAR_0->cmask[VAR_2] & ~VAR_0->wmask[VAR_2])
return -EINVAL; memcpy(VAR_0->config, config, sizeof config); pci_update_mappings(VAR_0); if (version_id >= 2)
for (VAR_2 = 0; VAR_2 < 4; VAR_2 ++) VAR_0->irq_state[VAR_2] = qemu_get_be32(VAR_1); return 0; }