void qbus_create_inplace(BusState *bus, BusInfo *info,

                         DeviceState *parent, const char *name)

{

    char *buf;

    int i,len;



    bus->info = info;

    bus->parent = parent;



    if (name) {

        /* use supplied name */

        bus->name = qemu_strdup(name);

    } else if (parent && parent->id) {

        /* parent device has id -> use it for bus name */

        len = strlen(parent->id) + 16;

        buf = qemu_malloc(len);

        snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);

        bus->name = buf;

    } else {

        /* no id -> use lowercase bus type for bus name */

        len = strlen(info->name) + 16;

        buf = qemu_malloc(len);

        len = snprintf(buf, len, "%s.%d", info->name,

                       parent ? parent->num_child_bus : 0);

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

            buf[i] = qemu_tolower(buf[i]);

        bus->name = buf;

    }



    QLIST_INIT(&bus->children);

    if (parent) {

        QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);

        parent->num_child_bus++;

    }



}

void qbus_create_inplace(BusState *bus, BusInfo *info,

                         DeviceState *parent, const char *name)

{

    char *buf;

    int i,len;



    bus->info = info;

    bus->parent = parent;



    if (name) {

        

        bus->name = qemu_strdup(name);

    } else if (parent && parent->id) {

        

        len = strlen(parent->id) + 16;

        buf = qemu_malloc(len);

        snprintf(buf, len, "%s.%d", parent->id, parent->num_child_bus);

        bus->name = buf;

    } else {

        

        len = strlen(info->name) + 16;

        buf = qemu_malloc(len);

        len = snprintf(buf, len, "%s.%d", info->name,

                       parent ? parent->num_child_bus : 0);

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

            buf[i] = qemu_tolower(buf[i]);

        bus->name = buf;

    }



    QLIST_INIT(&bus->children);

    if (parent) {

        QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);

        parent->num_child_bus++;

    }



}

void FUNC_0(BusState *VAR_0, BusInfo *VAR_1,

                         DeviceState *VAR_2, const char *VAR_3)

{

    char *VAR_4;

    int VAR_5,VAR_6;



    VAR_0->VAR_1 = VAR_1;

    VAR_0->VAR_2 = VAR_2;



    if (VAR_3) {

        

        VAR_0->VAR_3 = qemu_strdup(VAR_3);

    } else if (VAR_2 && VAR_2->id) {

        

        VAR_6 = strlen(VAR_2->id) + 16;

        VAR_4 = qemu_malloc(VAR_6);

        snprintf(VAR_4, VAR_6, "%s.%d", VAR_2->id, VAR_2->num_child_bus);

        VAR_0->VAR_3 = VAR_4;

    } else {

        

        VAR_6 = strlen(VAR_1->VAR_3) + 16;

        VAR_4 = qemu_malloc(VAR_6);

        VAR_6 = snprintf(VAR_4, VAR_6, "%s.%d", VAR_1->VAR_3,

                       VAR_2 ? VAR_2->num_child_bus : 0);

        for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++)

            VAR_4[VAR_5] = qemu_tolower(VAR_4[VAR_5]);

        VAR_0->VAR_3 = VAR_4;

    }



    QLIST_INIT(&VAR_0->children);

    if (VAR_2) {

        QLIST_INSERT_HEAD(&VAR_2->child_bus, VAR_0, sibling);

        VAR_2->num_child_bus++;

    }



}

void FUNC_0(BusState *VAR_0, BusInfo *VAR_1,
DeviceState *VAR_2, const char *VAR_3)
{ char *VAR_4; int VAR_5,VAR_6; VAR_0->VAR_1 = VAR_1; VAR_0->VAR_2 = VAR_2; if (VAR_3) { VAR_0->VAR_3 = qemu_strdup(VAR_3); } else if (VAR_2 && VAR_2->id) { VAR_6 = strlen(VAR_2->id) + 16; VAR_4 = qemu_malloc(VAR_6); snprintf(VAR_4, VAR_6, "%s.%d", VAR_2->id, VAR_2->num_child_bus); VAR_0->VAR_3 = VAR_4; } else { VAR_6 = strlen(VAR_1->VAR_3) + 16; VAR_4 = qemu_malloc(VAR_6); VAR_6 = snprintf(VAR_4, VAR_6, "%s.%d", VAR_1->VAR_3,
VAR_2 ? VAR_2->num_child_bus : 0); for (VAR_5 = 0; VAR_5 < VAR_6; VAR_5++) VAR_4[VAR_5] = qemu_tolower(VAR_4[VAR_5]); VAR_0->VAR_3 = VAR_4; } QLIST_INIT(&VAR_0->children); if (VAR_2) { QLIST_INSERT_HEAD(&VAR_2->child_bus, VAR_0, sibling); VAR_2->num_child_bus++; } }